Add suspend timer after calling pause callback 83/170083/1
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 13 Feb 2018 08:07:56 +0000 (17:07 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 13 Feb 2018 08:08:43 +0000 (17:08 +0900)
After calling pause callback, appcore_ui_base adds
the suspend timer to flush memory.

Change-Id: I1f98725e8ba70fbf146b11226a9f16157a522704
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/appcore_base.h
include/appcore_efl_base.h
include/appcore_ui_base.h
src/base/appcore_base.c
src/efl_base/appcore_efl_base.c
src/legacy/appcore-efl.c
src/ui_base/appcore_ui_base.c

index 795b18a..3fb216e 100644 (file)
@@ -89,6 +89,8 @@ bool appcore_base_is_suspended(void);
 void appcore_base_toggle_suspended_state(void);
 int appcore_base_set_i18n(const char *domain_name, const char *dir_name);
 void appcore_base_exit(void);
+void appcore_base_add_suspend_timer(void);
+void appcore_base_remove_suspend_timer(void);
 
 #ifdef __cplusplus
 }
index 90903d2..d902130 100644 (file)
@@ -63,6 +63,7 @@ unsigned int appcore_efl_base_get_main_surface(void);
 int appcore_efl_base_get_hint(void);
 bool appcore_efl_base_get_bg_state(void);
 void appcore_efl_base_set_bg_state(bool bg_state);
+void appcore_efl_base_set_system_resource_reclaiming(bool enable);
 
 #ifdef __cplusplus
 }
index 83f648d..f85f727 100644 (file)
@@ -75,6 +75,7 @@ unsigned int appcore_ui_base_get_main_surface(void);
 int appcore_ui_base_get_hint(void);
 bool appcore_ui_base_get_bg_state(void);
 void appcore_ui_base_set_bg_state(bool bg_state);
+void appcore_ui_base_set_system_resource_reclaiming(bool enable);
 
 #ifdef __cplusplus
 }
index c815922..a792d8f 100644 (file)
@@ -1321,6 +1321,16 @@ EXPORT_API void appcore_base_exit(void)
                __context.ops.exit(__context.data);
 }
 
+EXPORT_API void appcore_base_add_suspend_timer(void)
+{
+       __add_suspend_timer();
+}
+
+EXPORT_API void appcore_base_remove_suspend_timer(void)
+{
+       __remove_suspend_timer();
+}
+
 static int __on_receive(aul_type type, bundle *b, void *data)
 {
        return appcore_base_on_receive(type, b);
index e2fd7c3..d193f38 100644 (file)
@@ -323,3 +323,8 @@ EXPORT_API void appcore_efl_base_set_bg_state(bool bg_state)
 {
        appcore_ui_base_set_bg_state(bg_state);
 }
+
+EXPORT_API void appcore_efl_base_set_system_resource_reclaiming(bool enable)
+{
+       appcore_ui_base_set_system_resource_reclaiming(enable);
+}
index b171a27..0ec077f 100644 (file)
@@ -146,5 +146,6 @@ EXPORT_API unsigned int appcore_get_main_surface(void)
 
 EXPORT_API int appcore_set_system_resource_reclaiming(bool enable)
 {
+       appcore_efl_base_set_system_resource_reclaiming(enable);
        return 0;
 }
index 56817dc..f641ce0 100644 (file)
@@ -70,6 +70,7 @@ typedef struct _appcore_ui_base_context {
        char *below_app;
        char *appid;
        bool bg_state;
+       bool resource_reclaiming;
 
        int state;
        Ecore_Event_Handler *hshow;
@@ -284,14 +285,19 @@ static void __exit_from_suspend(void)
 
 static void __do_pause(void)
 {
+       int r = -1;
+
        if (__context.state == AS_RUNNING) {
                if (__context.ops.pause) {
                        traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:PAUSE");
                        _DBG("Call pause callback");
-                       __context.ops.pause(__context.data);
+                       r = __context.ops.pause(__context.data);
                        traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
                }
 
+               if (r >= 0 && __context.resource_reclaiming)
+                       appcore_base_add_suspend_timer();
+
                __context.state = AS_PAUSED;
                __prepare_to_suspend();
        }
@@ -922,6 +928,7 @@ EXPORT_API int appcore_ui_base_init(appcore_ui_base_ops ops, int argc, char **ar
        __context.hint = hint;
        __context.state = AS_NONE;
        __context.appid = strdup(appid);
+       __context.resource_reclaiming = true;
 
        LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:main:done]", appid);
        if (__context.hint & APPCORE_UI_BASE_HINT_BG_LAUNCH_CONTROL) {
@@ -997,6 +1004,11 @@ EXPORT_API void appcore_ui_base_set_bg_state(bool bg_state)
        __context.bg_state = bg_state;
 }
 
+EXPORT_API void appcore_ui_base_set_system_resource_reclaiming(bool enable)
+{
+       __context.resource_reclaiming = enable;
+}
+
 static int __on_receive(aul_type type, bundle *b, void *data)
 {
        return appcore_ui_base_on_receive(type, b);