Fix background management feature 49/83149/5 accepted/tizen/common/20161212.185615 accepted/tizen/ivi/20161213.003140 accepted/tizen/mobile/20161213.002954 accepted/tizen/tv/20161213.003038 accepted/tizen/wearable/20161213.003103 submit/tizen/20161212.091026
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 9 Aug 2016 09:27:08 +0000 (18:27 +0900)
committerHwanKyu Jhun <h.jhun@samsung.com>
Mon, 12 Dec 2016 08:10:49 +0000 (00:10 -0800)
While an application receives the AUL_SUSPEND event,
the allowed_bg value is changed to "false". AMD always
sends the AUL_SUSPEND event when the application is not
allowed to run in the background. And, the allowed_bg value
can be changed when the application receives the AUL_WAKE event.

- Requires
[aul] https://review.tizen.org/gerrit/#/c/83134/
[amd] https://review.tizen.org/gerrit/#/c/83044/

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

index a33301f..df898ea 100644 (file)
@@ -752,10 +752,9 @@ static int __aul_handler(aul_type type, bundle *b, void *data)
                ret = __agent_terminate(data);
                break;
        case AUL_SUSPEND:
-               if (!ac->allowed_bg) {
-                       _DBG("[__SUSPEND__] suspend");
-                       __add_suspend_timer(data);
-               }
+               ac->allowed_bg = false;
+               _DBG("[__SUSPEND__] suspend");
+               __add_suspend_timer(data);
                break;
        case AUL_WAKE:
                if (!ac->allowed_bg) {
@@ -763,6 +762,14 @@ static int __aul_handler(aul_type type, bundle *b, void *data)
                        __remove_suspend_timer(data);
                        __exit_from_suspend(data);
                }
+
+               if (b) {
+                       bundle_get_str(b, AUL_K_ALLOWED_BG, &bg);
+                       if (bg && strcmp(bg, "ALLOWED_BG") == 0) {
+                               _DBG("[__SUSPEND__] allowed background");
+                               ac->allowed_bg = true;
+                       }
+               }
                break;
        default:
                /* do nothing */