Recover the visible state for watch app.
authorSung-jae Park <nicesj.park@samsung.com>
Tue, 26 May 2015 05:32:26 +0000 (14:32 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 26 May 2015 05:32:26 +0000 (14:32 +0900)
After processing the helo_sync request,
if it is recovered from faulted state, send the visible state change event to the slave again.

[model] Redwood,Kiran,B3(Wearable)
[binary_type] AP
[customer] Open
[issue#] N/A
[problem] Recovered Watch doesn't get its visible state information.
[cause] After recover from the fault, the watch should be handled diferrently with widget.
[solution] Send the visible state change event to the watch again after recover it from fault state.
[team] HomeTF
[request]
[horizontal_expansion]

Change-Id: Ie551c01d1f3c75f3cdc598167d80f1fe4adb5468

include/instance.h
src/instance.c
src/package.c
src/server.c

index 81a111e..8e61d24 100644 (file)
@@ -273,4 +273,8 @@ extern struct packet *instance_duplicate_packet_create(const struct packet *pack
 extern void instance_set_orientation(struct inst_info *inst, int orientation);
 extern int instance_orientation(struct inst_info *inst);
 
+extern void instance_watch_set_need_to_recover(struct inst_info *inst, int recover);
+extern int instance_watch_need_to_recover(struct inst_info *inst);
+extern int instance_watch_recover_visible_state(struct inst_info *inst);
+
 /* End of a file */
index ed84b6c..2a0d27e 100644 (file)
@@ -120,6 +120,10 @@ struct inst_info {
        enum widget_visible_state visible;
 
        struct {
+               int need_to_recover;
+       } watch;
+
+       struct {
                int width;
                int height;
                double priority;
@@ -2611,6 +2615,33 @@ HAPI int instance_set_visible_state(struct inst_info *inst, enum widget_visible_
        return WIDGET_ERROR_NONE;
 }
 
+/**
+ * @note
+ * Just touch the visible state again.
+ */
+HAPI int instance_watch_recover_visible_state(struct inst_info *inst)
+{
+       switch (inst->visible) {
+       case WIDGET_SHOW:
+       case WIDGET_HIDE:
+               (void)resume_widget(inst);
+               instance_thaw_updator(inst);
+               /**
+                * @note
+                * We don't need to send the monitor event.
+                */
+               break;
+       case WIDGET_HIDE_WITH_PAUSE:
+               (void)pause_widget(inst);
+               instance_freeze_updator(inst);
+               break;
+       default:
+               return WIDGET_ERROR_INVALID_PARAMETER;
+       }
+
+       return WIDGET_ERROR_NONE;
+}
+
 static void resize_cb(struct slave_node *slave, const struct packet *packet, void *data)
 {
        struct resize_cbdata *cbdata = data;
@@ -3849,4 +3880,14 @@ HAPI int instance_orientation(struct inst_info *inst)
        return inst->orientation;
 }
 
+HAPI void instance_watch_set_need_to_recover(struct inst_info *inst, int recover)
+{
+       inst->watch.need_to_recover = !!recover;
+}
+
+HAPI int instance_watch_need_to_recover(struct inst_info *inst)
+{
+       return inst->watch.need_to_recover;
+}
+
 /* End of a file */
index 86df474..8f89c6f 100644 (file)
@@ -150,6 +150,7 @@ static int slave_activated_cb(struct slave_node *slave, void *data)
        int cnt;
        int ret;
        const char *category;
+       int is_watch;
 
        if (!slave_need_to_reactivate_instances(slave)) {
                DbgPrint("Do not need to reactivate instances\n");
@@ -157,19 +158,25 @@ static int slave_activated_cb(struct slave_node *slave, void *data)
        }
 
        category = package_category(info);
-       if (category && strcmp(CATEGORY_WATCH_CLOCK, category) == 0) {
-               DbgPrint("[%s] is a watch application, don't recover its state\n", package_name(info));
-               return 0;
-       }
+       is_watch = (category && strcmp(CATEGORY_WATCH_CLOCK, category) == 0);
 
        cnt = 0;
        EINA_LIST_FOREACH_SAFE(info->inst_list, l, n, inst) {
-               ret = instance_recover_state(inst);
-               if (!ret) {
-                       continue;
-               }
+               if (is_watch) {
+                       /**
+                        * @note
+                        * Watch will be recovered by SLAVE_SYNC_HELLO command.
+                        * Not from here.
+                        */
+                       instance_watch_set_need_to_recover(inst, EINA_TRUE);
+               } else {
+                       ret = instance_recover_state(inst);
+                       if (!ret) {
+                               continue;
+                       }
 
-               instance_thaw_updator(inst);
+                       instance_thaw_updator(inst);
+               }
                cnt++;
        }
 
index 7f60a96..6f39e27 100644 (file)
@@ -8293,6 +8293,23 @@ static struct packet *slave_hello_sync(pid_t pid, int handle, const struct packe
 
                result = instance_duplicate_packet_create(packet, inst, info, width, height);
 
+               if (instance_watch_need_to_recover(inst)) {
+                       /**
+                        * @note
+                        * Reset the state recover flag.
+                        */
+                       (void)instance_watch_set_need_to_recover(inst, EINA_FALSE);
+
+                       /**
+                        * @note
+                        * Re-send the visible state change request in this case.
+                        * But, this will be sent after return from this function.
+                        * Request will be sent from command comsumer which are running by timer callback.
+                        * (slave_rpc_request_only, slave_rpc_async_request, ...)
+                        */
+                       (void)instance_watch_recover_visible_state(inst);
+               }
+
                DbgFree(widget_id);
        }