Merge branch 'tizen_3.0' into tizen
[platform/core/appfw/app-core.git] / src / appcore.c
index f3a10fa..20fb3c4 100644 (file)
@@ -511,6 +511,7 @@ static int __aul_handler(aul_type type, bundle *b, void *data)
 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
        const char *bg = NULL;
        struct appcore *ac = data;
+       int suspend = APPCORE_SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND;
 #endif
 
        switch (type) {
@@ -583,15 +584,23 @@ static int __aul_handler(aul_type type, bundle *b, void *data)
        case AUL_WAKE:
                _DBG("[APP %d]     AUL event: AUL_WAKE", _pid);
                if (!ac->allowed_bg && ac->suspended_state) {
-                       int suspend = APPCORE_SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND;
                        __remove_suspend_timer(data);
                        __sys_do(ac, &suspend, SE_SUSPENDED_STATE);
                        ac->suspended_state = false;
                }
+
+               if (b) {
+                       bg = bundle_get_val(b, AUL_K_ALLOWED_BG);
+                       if (bg && strcmp(bg, "ALLOWED_BG") == 0) {
+                               _DBG("[__SUSPEND__] allowed background");
+                               ac->allowed_bg = true;
+                       }
+               }
                break;
        case AUL_SUSPEND:
                _DBG("[APP %d]     AUL event: AUL_SUSPEND", _pid);
-               if (!ac->allowed_bg && !ac->suspended_state) {
+               ac->allowed_bg = false;
+               if (!ac->suspended_state) {
                        __remove_suspend_timer(data);
                        __flush_memory((gpointer)ac);
                }