Add feature definition about background management 52/162652/1
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 4 Dec 2017 23:34:36 +0000 (08:34 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 4 Dec 2017 23:35:37 +0000 (08:35 +0900)
In tv profile, the feature isn't supported.

Change-Id: I1e429397ffaba53876d8bda6e7d6be5a116ff32c
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/base/appcore_base.c
src/base/appcore_base_private.h

index 0706ba3..37e1840 100644 (file)
@@ -37,6 +37,7 @@
 #include <bundle_internal.h>
 #include <sensor_internal.h>
 #include <ttrace.h>
 #include <bundle_internal.h>
 #include <sensor_internal.h>
 #include <ttrace.h>
+#include <system_info.h>
 #include "appcore_base.h"
 #include "appcore_base_private.h"
 
 #include "appcore_base.h"
 #include "appcore_base_private.h"
 
@@ -81,6 +82,46 @@ static guint __suspend_dbus_handler_initialized;
 static char *__locale_dir;
 static appcore_base_rotation __rotation;
 
 static char *__locale_dir;
 static appcore_base_rotation __rotation;
 
+appcore_base_tizen_profile_t appcore_base_get_tizen_profile(void)
+{
+       static appcore_base_tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
+       char *profile_name = NULL;
+
+       if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
+               return profile;
+
+       system_info_get_platform_string("http://tizen.org/feature/profile",
+                       &profile_name);
+       if (profile_name == NULL)
+               return profile;
+
+       switch (*profile_name) {
+       case 'm':
+       case 'M':
+               profile = TIZEN_PROFILE_MOBILE;
+               break;
+       case 'w':
+       case 'W':
+               profile = TIZEN_PROFILE_WEARABLE;
+               break;
+       case 't':
+       case 'T':
+               profile = TIZEN_PROFILE_TV;
+               break;
+       case 'i':
+       case 'I':
+               profile = TIZEN_PROFILE_IVI;
+               break;
+       default:
+               profile = TIZEN_PROFILE_COMMON;
+               break;
+       }
+       free(profile_name);
+
+       return profile;
+}
+
+
 static void __invoke_callback(void *event, int type)
 {
        GList *iter = __events;
 static void __invoke_callback(void *event, int type)
 {
        GList *iter = __events;
@@ -880,7 +921,8 @@ EXPORT_API int appcore_base_init(appcore_base_ops ops, int argc, char **argv, vo
        if (__context.ops.set_i18n)
                __context.ops.set_i18n(__context.data);
 
        if (__context.ops.set_i18n)
                __context.ops.set_i18n(__context.data);
 
-       __init_suspend_dbus_handler();
+       if (TIZEN_FEATURE_BACKGROUND_MANAGEMENT)
+               __init_suspend_dbus_handler();
 
        if (!__context.dirty) {
                __context.dirty = true;
 
        if (!__context.dirty) {
                __context.dirty = true;
@@ -929,7 +971,9 @@ EXPORT_API void appcore_base_fini(void)
 
        g_list_free_full(__events, free);
        __events = NULL;
 
        g_list_free_full(__events, free);
        __events = NULL;
-       __fini_suspend_dbus_handler();
+
+       if (TIZEN_FEATURE_BACKGROUND_MANAGEMENT)
+               __fini_suspend_dbus_handler();
 
        if (__locale_dir) {
                free(__locale_dir);
 
        if (__locale_dir) {
                free(__locale_dir);
@@ -971,11 +1015,13 @@ EXPORT_API int appcore_base_on_receive(aul_type type, bundle *b)
                        }
                }
 
                        }
                }
 
-               bg = bundle_get_val(b, AUL_K_ALLOWED_BG);
-               if (bg && strncmp(bg, "ALLOWED_BG", strlen("ALLOWED_BG")) == 0) {
-                       _DBG("[__SUSPEND__] allowed background");
-                       __context.allowed_bg = true;
-                       __remove_suspend_timer();
+               if (TIZEN_FEATURE_BACKGROUND_MANAGEMENT) {
+                       bg = bundle_get_val(b, AUL_K_ALLOWED_BG);
+                       if (bg && !strcmp(bg, "ALLOWED_BG")) {
+                               _DBG("[__SUSPEND__] allowed background");
+                               __context.allowed_bg = true;
+                               __remove_suspend_timer();
+                       }
                }
 
                if (__context.ops.control) {
                }
 
                if (__context.ops.control) {
@@ -986,11 +1032,13 @@ EXPORT_API int appcore_base_on_receive(aul_type type, bundle *b)
                break;
        case AUL_RESUME:
                _DBG("[APP %d]     AUL event: AUL_RESUME", getpid());
                break;
        case AUL_RESUME:
                _DBG("[APP %d]     AUL event: AUL_RESUME", getpid());
-               bg = bundle_get_val(b, AUL_K_ALLOWED_BG);
-               if (bg && strncmp(bg, "ALLOWED_BG", strlen("ALLOWED_BG")) == 0) {
-                       _DBG("[__SUSPEND__] allowed background");
-                       __context.allowed_bg = true;
-                       __remove_suspend_timer();
+               if (TIZEN_FEATURE_BACKGROUND_MANAGEMENT) {
+                       bg = bundle_get_val(b, AUL_K_ALLOWED_BG);
+                       if (bg && !strcmp(bg, "ALLOWED_BG")) {
+                               _DBG("[__SUSPEND__] allowed background");
+                               __context.allowed_bg = true;
+                               __remove_suspend_timer();
+                       }
                }
                break;
        case AUL_TERMINATE:
                }
                break;
        case AUL_TERMINATE:
@@ -1009,18 +1057,24 @@ EXPORT_API int appcore_base_on_receive(aul_type type, bundle *b)
                break;
        case AUL_WAKE:
                _DBG("[APP %d]     AUL event: AUL_WAKE", getpid());
                break;
        case AUL_WAKE:
                _DBG("[APP %d]     AUL event: AUL_WAKE", getpid());
-               if (!__context.allowed_bg && __context.suspended_state) {
-                       int suspend = APPCORE_BASE_SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND;
-                       __remove_suspend_timer();
-                       __invoke_callback((void *)&suspend, APPCORE_BASE_EVENT_SUSPENDED_STATE_CHANGE);
-                       __context.suspended_state = false;
+               if (TIZEN_FEATURE_BACKGROUND_MANAGEMENT) {
+                       if (!__context.allowed_bg &&
+                                       __context.suspended_state) {
+                               int suspend = APPCORE_BASE_SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND;
+                               __remove_suspend_timer();
+                               __invoke_callback((void *)&suspend, APPCORE_BASE_EVENT_SUSPENDED_STATE_CHANGE);
+                               __context.suspended_state = false;
+                       }
                }
                break;
        case AUL_SUSPEND:
                _DBG("[APP %d]     AUL event: AUL_SUSPEND", getpid());
                }
                break;
        case AUL_SUSPEND:
                _DBG("[APP %d]     AUL event: AUL_SUSPEND", getpid());
-               if (!__context.allowed_bg && !__context.suspended_state) {
-                       __remove_suspend_timer();
-                       __flush_memory(NULL);
+               if (TIZEN_FEATURE_BACKGROUND_MANAGEMENT) {
+                       if (!__context.allowed_bg &&
+                                       !__context.suspended_state) {
+                               __remove_suspend_timer();
+                               __flush_memory(NULL);
+                       }
                }
                break;
        case AUL_UPDATE_REQUESTED:
                }
                break;
        case AUL_UPDATE_REQUESTED:
@@ -1263,5 +1317,3 @@ EXPORT_API appcore_base_ops appcore_base_get_default_ops(void)
 
        return ops;
 }
 
        return ops;
 }
-
-
index 9e596fe..6c4b95d 100644 (file)
 #include <stdbool.h>
 #include <dlog.h>
 
 #include <stdbool.h>
 #include <dlog.h>
 
+typedef enum {
+       TIZEN_PROFILE_UNKNOWN = 0,
+       TIZEN_PROFILE_MOBILE = 0x1,
+       TIZEN_PROFILE_WEARABLE = 0x2,
+       TIZEN_PROFILE_TV = 0x4,
+       TIZEN_PROFILE_IVI = 0x8,
+       TIZEN_PROFILE_COMMON = 0x10,
+} appcore_base_tizen_profile_t;
+
 #ifndef EXPORT_API
 #  define EXPORT_API __attribute__ ((visibility("default")))
 #endif
 #ifndef EXPORT_API
 #  define EXPORT_API __attribute__ ((visibility("default")))
 #endif
                } \
        } while (0)
 
                } \
        } while (0)
 
+appcore_base_tizen_profile_t appcore_base_get_tizen_profile(void);
+
+#define TIZEN_FEATURE_BACKGROUND_MANAGEMENT \
+       (!(appcore_base_get_tizen_profile() & TIZEN_PROFILE_TV))
 
 extern void aul_finalize();
 
 
 extern void aul_finalize();