Support legacy lifecycle 03/135603/3
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 23 Jun 2017 09:22:22 +0000 (18:22 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 26 Jun 2017 05:03:03 +0000 (14:03 +0900)
This patch is for Tizen 2.3 applications. In Tizen 2.3, the resume
callback is invoked when getting the reset event.

Change-Id: I9d09ae79570e3dbc0552a695918b4baa8c30b752
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/appcore-efl.c

index 0091c3df3efb65c8aeaabca70be8d684f0cf6051..d7f0db83c66c41340b0c07436234194c18964a91 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#define _GNU_SOURCE
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
@@ -361,6 +362,59 @@ static void wl_pause_win(void)
 
 #endif
 
+static void __on_resume(struct ui_priv *ui, bundle *b)
+{
+       LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:start]", ui->name);
+#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
+       if (ui->exit_from_suspend) {
+               _DBG("[__SUSPEND__] resume case");
+               ui->exit_from_suspend(ui);
+       }
+       if (ui->app_core->allowed_bg)
+               __appcore_timer_del(ui);
+#endif
+
+       if (ui->state == AS_PAUSED || ui->state == AS_CREATED) {
+               _DBG("[APP %d] RESUME", _pid);
+               if (ui->ops->resume) {
+                       traceBegin(TTRACE_TAG_APPLICATION_MANAGER,
+                                       "APPCORE:RESUME");
+                       ui->ops->resume(ui->ops->data);
+                       traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
+               }
+               ui->state = AS_RUNNING;
+
+               if (ui->below_app) {
+                       aul_app_group_activate_below(ui->below_app);
+                       free(ui->below_app);
+                       ui->below_app = NULL;
+               }
+       }
+       LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:done]", ui->name);
+       aul_status_update(STATUS_VISIBLE);
+}
+
+static int __is_legacy_lifecycle(void)
+{
+       static int legacy = -1;
+       const char *api_version;
+
+       if (legacy != -1)
+               return legacy;
+
+       api_version = getenv("TIZEN_API_VERSION");
+       if (api_version) {
+               if (strverscmp("2.4", api_version) <= 0)
+                       legacy = 0;
+               else
+                       legacy = 1;
+       } else {
+               legacy = 0;
+       }
+
+       return legacy;
+}
+
 static void __do_app(enum app_event event, void *data, bundle * b)
 {
        int r = -1;
@@ -475,6 +529,10 @@ static void __do_app(enum app_event event, void *data, bundle * b)
                }
                LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]",
                    ui->name);
+               if (!bg_state && __is_legacy_lifecycle()) {
+                       _DBG("Legacy lifecycle");
+                       __on_resume(ui, b);
+               }
                break;
        case AE_PAUSE:
                if (ui->state == AS_RUNNING) {
@@ -501,39 +559,7 @@ static void __do_app(enum app_event event, void *data, bundle * b)
                aul_status_update(STATUS_BG);
                break;
        case AE_RESUME:
-               LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:start]",
-                               ui->name);
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
-               if (ui->exit_from_suspend) {
-                       _DBG("[__SUSPEND__] resume case");
-                       ui->exit_from_suspend(ui);
-               }
-               if (ui->app_core->allowed_bg)
-                       __appcore_timer_del(ui);
-#endif
-
-               if (ui->state == AS_PAUSED || ui->state == AS_CREATED) {
-                       _DBG("[APP %d] RESUME", _pid);
-
-                       if (ui->ops->resume) {
-                               traceBegin(TTRACE_TAG_APPLICATION_MANAGER,
-                                       "APPCORE:RESUME");
-                               ui->ops->resume(ui->ops->data);
-                               traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
-                       }
-                       ui->state = AS_RUNNING;
-
-                       if (ui->below_app) {
-                               aul_app_group_activate_below(ui->below_app);
-                               free(ui->below_app);
-                               ui->below_app = NULL;
-                       }
-               }
-               /*TODO : rotation start*/
-               /* r = appcore_resume_rotation_cb(); */
-               LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:done]",
-                   ui->name);
-               aul_status_update(STATUS_VISIBLE);
+               __on_resume(ui, b);
                break;
        case AE_TERMINATE_BGAPP:
                if (ui->state == AS_PAUSED) {