Apply to insert backgroud_category value in db. 95/54095/8 accepted/tizen/mobile/20151215.230723 accepted/tizen/tv/20151215.230744 accepted/tizen/wearable/20151215.230757 submit/tizen/20151215.105605
authorjongmyeongko <jongmyeong.ko@samsung.com>
Fri, 11 Dec 2015 09:04:46 +0000 (18:04 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Tue, 15 Dec 2015 04:59:01 +0000 (13:59 +0900)
Change-Id: Iac15397b294093877ba0996ae2e6a6af27cedfd4
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
include/pkgmgrinfo_type.h
parser/pkgmgr_parser.c
parser/pkgmgr_parser_db.c
src/pkgmgrinfo_appinfo.c

index 9e23ba3..654fca0 100644 (file)
 
 #include <sys/types.h>
 
+/* app background category value */
+#define APP_BG_CATEGORY_USER_DISABLE_FALSE_VAL         0x00000
+#define APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL          0x00001
+#define APP_BG_CATEGORY_MEDIA_VAL                      0x00002
+#define APP_BG_CATEGORY_DOWNLOAD_VAL                   0x00004
+#define APP_BG_CATEGORY_BGNETWORK_VAL                  0x00008
+#define APP_BG_CATEGORY_LOCATION_VAL                   0x00010
+#define APP_BG_CATEGORY_SENSOR_VAL                     0x00020
+#define APP_BG_CATEGORY_IOTCOMM_VAL                    0x00040
+#define APP_BG_CATEGORY_SYSTEM_VAL                     0x00080
+
+#define APP_BG_CATEGORY_USER_DISABLE_FALSE_STR         "enable"
+#define APP_BG_CATEGORY_USER_DISABLE_TRUE_STR          "disable"
+#define APP_BG_CATEGORY_MEDIA_STR                      "media"
+#define APP_BG_CATEGORY_DOWNLOAD_STR                   "download"
+#define APP_BG_CATEGORY_BGNETWORK_STR                  "background-network"
+#define APP_BG_CATEGORY_LOCATION_STR                   "location"
+#define APP_BG_CATEGORY_SENSOR_STR                     "sensor"
+#define APP_BG_CATEGORY_IOTCOMM_STR                    "iot-communication"
+#define APP_BG_CATEGORY_SYSTEM                         "system"
+
 /**
  * @brief A type to retrieve uid information from the manifest handle
  */
index 35a8450..64c0e84 100644 (file)
@@ -2700,7 +2700,7 @@ API int pkgmgr_parser_check_manifest_validation(const char *manifest)
                _LOGE("xmlSchemaValidateFile() failed\n");
                return PMINFO_R_ERROR;
        } else if (ret == 0) {
-               _LOGE("Manifest is Valid\n");
+               _LOGD("Manifest is Valid\n");
                return PMINFO_R_OK;
        } else {
                _LOGE("Manifest Validation Failed with error code %d\n", ret);
index 2be532c..ab6a533 100644 (file)
@@ -145,6 +145,7 @@ sqlite3 *pkgmgr_cert_db;
                                                "component_type text, " \
                                                "package text not null, " \
                                                "app_tep_name text, " \
+                                               "app_background_category INTEGER DEFAULT 0, " \
                                                "FOREIGN KEY(package) " \
                                                "REFERENCES package_info(package) " \
                                                "ON DELETE CASCADE)"
@@ -399,7 +400,7 @@ static int __exec_query(char *query)
        char *error_message = NULL;
        if (SQLITE_OK !=
            sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &error_message)) {
-               _LOGD("Don't execute query = %s error message = %s\n", query,
+               _LOGE("Don't execute query = %s error message = %s\n", query,
                       error_message);
                sqlite3_free(error_message);
                return -1;
@@ -827,6 +828,41 @@ static int __insert_mainapp_info(manifest_x *mfx)
 
        return 0;
 }
+
+static int __convert_background_category(GList *category_list)
+{
+       int ret = 0;
+       GList *tmp_list = category_list;
+       char *category_data = NULL;
+
+       if (category_list == NULL)
+               return 0;
+
+       while (tmp_list != NULL) {
+               category_data = (char *)tmp_list->data;
+               if (strcmp(category_data, APP_BG_CATEGORY_MEDIA_STR) == 0) {
+                       ret = ret | APP_BG_CATEGORY_MEDIA_VAL;
+               } else if (strcmp(category_data, APP_BG_CATEGORY_DOWNLOAD_STR) == 0) {
+                       ret = ret | APP_BG_CATEGORY_DOWNLOAD_VAL;
+               } else if (strcmp(category_data, APP_BG_CATEGORY_BGNETWORK_STR) == 0) {
+                       ret = ret | APP_BG_CATEGORY_BGNETWORK_VAL;
+               } else if (strcmp(category_data, APP_BG_CATEGORY_LOCATION_STR) == 0) {
+                       ret = ret | APP_BG_CATEGORY_LOCATION_VAL;
+               } else if (strcmp(category_data, APP_BG_CATEGORY_SENSOR_STR) == 0) {
+                       ret = ret | APP_BG_CATEGORY_SENSOR_VAL;
+               } else if (strcmp(category_data, APP_BG_CATEGORY_IOTCOMM_STR) == 0) {
+                       ret = ret | APP_BG_CATEGORY_IOTCOMM_VAL;
+               } else if (strcmp(category_data, APP_BG_CATEGORY_SYSTEM) == 0) {
+                       ret = ret | APP_BG_CATEGORY_SYSTEM_VAL;
+               } else {
+                       _LOGE("Unidentified category [%s]", category_data);
+               }
+               tmp_list = g_list_next(tmp_list);
+       }
+
+       return ret;
+}
+
 /* _PRODUCT_LAUNCHING_ENHANCED_
 *  app->indicatordisplay, app->portraitimg, app->landscapeimg, app->guestmode_appstatus
 */
@@ -835,49 +871,45 @@ static int __insert_application_info(manifest_x *mfx)
        GList *tmp;
        application_x *app;
        int ret = -1;
+       int background_value = 0;
        char query[MAX_QUERY_LEN] = {'\0'};
+
        for (tmp = mfx->application; tmp; tmp = tmp->next) {
                app = (application_x *)tmp->data;
                if (app == NULL)
                        continue;
 
+               background_value = __convert_background_category(app->background_category);
+               if (background_value < 0) {
+                       _LOGE("Failed to retrieve background value[%d]", background_value);
+                       background_value = 0;
+               }
+
                snprintf(query, MAX_QUERY_LEN,
-                        "insert into package_app_info(app_id, app_component, app_exec, app_nodisplay, app_type, app_onboot, " \
-                       "app_multiple, app_autorestart, app_taskmanage, app_enabled, app_hwacceleration, app_screenreader, app_mainapp , app_recentimage, " \
-                       "app_launchcondition, app_indicatordisplay, app_portraitimg, app_landscapeimg, app_guestmodevisibility, app_permissiontype, "\
-                       "app_preload, app_submode, app_submode_mainid, app_installed_storage, app_process_pool, app_launch_mode, app_ui_gadget, app_support_disable, component_type, package, app_tep_name) " \
-                       "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
-                        app->appid,
-                        app->component_type,
-                        app->exec,
-                        app->nodisplay,
-                        app->type,
-                        app->onboot,
-                        app->multiple,
-                        app->autorestart,
-                        app->taskmanage,
-                        app->enabled,
-                        app->hwacceleration,
-                        app->screenreader,
-                        app->mainapp,
-                        __get_str(app->recentimage),
-                        app->launchcondition,
-                        app->indicatordisplay,
-                        __get_str(app->portraitimg),
-                        __get_str(app->landscapeimg),
-                        app->guestmode_visibility,
-                        app->permission_type,
-                        mfx->preload,
-                        app->submode,
-                        __get_str(app->submode_mainid),
-                        mfx->installed_storage,
-                        app->process_pool,
-                        app->launch_mode,
-                        app->ui_gadget,
-                        mfx->support_disable,
-                        app->component_type,
-                        mfx->package,
-                        __get_str(mfx->tep_name));
+                       "insert into package_app_info(" \
+                       "app_id, app_component, app_exec, app_nodisplay, app_type, " \
+                       "app_onboot, app_multiple, app_autorestart, app_taskmanage, app_enabled, " \
+                       "app_hwacceleration, app_screenreader, app_mainapp, app_recentimage, app_launchcondition, " \
+                       "app_indicatordisplay, app_portraitimg, app_landscapeimg, app_guestmodevisibility, app_permissiontype, " \
+                       "app_preload, app_submode, app_submode_mainid, app_installed_storage, app_process_pool, " \
+                       "app_launch_mode, app_ui_gadget, app_support_disable, component_type, package, " \
+                       "app_tep_name, app_background_category) " \
+                       "values(" \
+                       "'%s', '%s', '%s', '%s', '%s', " \
+                       "'%s', '%s', '%s', '%s', '%s', " \
+                       "'%s', '%s', '%s', '%s', '%s', " \
+                       "'%s', '%s', '%s', '%s', '%s', " \
+                       "'%s', '%s', '%s', '%s', '%s', " \
+                       "'%s', '%s', '%s', '%s', '%s', " \
+                       "'%s', '%d')", \
+                       app->appid, app->component_type, app->exec, app->nodisplay, app->type,
+                       app->onboot, app->multiple, app->autorestart, app->taskmanage, app->enabled,
+                       app->hwacceleration, app->screenreader, app->mainapp, __get_str(app->recentimage), app->launchcondition,
+                       app->indicatordisplay, __get_str(app->portraitimg), __get_str(app->landscapeimg),
+                       app->guestmode_visibility, app->permission_type,
+                       mfx->preload, app->submode, __get_str(app->submode_mainid), mfx->installed_storage, app->process_pool,
+                       app->launch_mode, app->ui_gadget, mfx->support_disable, app->component_type, mfx->package,
+                       __get_str(mfx->tep_name), background_value);
 
                ret = __exec_query(query);
                if (ret == -1) {
@@ -1182,35 +1214,24 @@ static int __insert_manifest_info_in_db(manifest_x *mfx, uid_t uid)
 
        /*Insert in the package_info DB*/
        snprintf(query, MAX_QUERY_LEN,
-                "insert into package_info(package, package_type, package_version, package_api_version, package_tep_name, install_location, package_size, " \
-               "package_removable, package_preload, package_readonly, package_update, package_appsetting, package_nodisplay, package_system," \
-               "author_name, author_email, author_href, installed_time, installed_storage, storeclient_id, mainapp_id, package_url, root_path, csc_path, package_support_disable) " \
-               "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
-                mfx->package,
-                mfx->type,
-                mfx->version,
-                __get_str(mfx->api_version),
-                __get_str(mfx->tep_name),
-                __get_str(mfx->installlocation),
-                __get_str(mfx->package_size),
-                mfx->removable,
-                mfx->preload,
-                mfx->readonly,
-                mfx->update,
-                mfx->appsetting,
-                mfx->nodisplay_setting,
-                mfx->system,
-                __get_str(auth_name),
-                __get_str(auth_email),
-                __get_str(auth_href),
-                mfx->installed_time,
-                mfx->installed_storage,
-                __get_str(mfx->storeclient_id),
-                mfx->mainapp_id,
-                __get_str(mfx->package_url),
-                mfx->root_path,
-                __get_str(mfx->csc_path),
-                mfx->support_disable);
+               "insert into package_info(" \
+               "package, package_type, package_version, package_api_version, package_tep_name, " \
+               "install_location, package_size, package_removable, package_preload, package_readonly, " \
+               "package_update, package_appsetting, package_nodisplay, package_system, author_name, " \
+               "author_email, author_href, installed_time, installed_storage, storeclient_id, " \
+               "mainapp_id, package_url, root_path, csc_path, package_support_disable) " \
+               "values(" \
+               "'%s', '%s', '%s', '%s', '%s', " \
+               "'%s', '%s', '%s', '%s', '%s', " \
+               "'%s', '%s', '%s', '%s', '%s', " \
+               "'%s', '%s', '%s', '%s', '%s', " \
+               "'%s', '%s', '%s', '%s', '%s')", \
+               mfx->package, mfx->type, mfx->version, __get_str(mfx->api_version), __get_str(mfx->tep_name),
+               __get_str(mfx->installlocation), __get_str(mfx->package_size), mfx->removable, mfx->preload, mfx->readonly,
+               mfx->update, mfx->appsetting, mfx->nodisplay_setting, mfx->system, __get_str(auth_name),
+               __get_str(auth_email), __get_str(auth_href), mfx->installed_time, mfx->installed_storage,
+               __get_str(mfx->storeclient_id),
+               mfx->mainapp_id, __get_str(mfx->package_url), mfx->root_path, __get_str(mfx->csc_path), mfx->support_disable);
 
        ret = __exec_query(query);
        if (ret == -1) {
index 04e2548..d74cd60 100644 (file)
@@ -490,6 +490,47 @@ static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
 
 }
 
+static GList *__get_background_category(char *value)
+{
+       GList *category_list = NULL;
+       int convert_value = 0;
+       if (!value || strlen(value) == 0)
+               return NULL;
+
+       convert_value = atoi(value);
+       if (convert_value < 0)
+               return NULL;
+
+       if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
+               category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
+       else
+               category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
+
+       if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
+               category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
+
+       if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
+               category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
+
+       if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
+               category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
+
+       if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
+               category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
+
+       if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
+               category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
+
+       if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
+               category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
+
+       if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
+               category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
+
+       return category_list;
+
+}
+
 static int _appinfo_get_application(sqlite3 *db, const char *appid,
                const char *locale, application_x **application)
 {
@@ -503,13 +544,15 @@ static int _appinfo_get_application(sqlite3 *db, const char *appid,
                "app_permissiontype, app_preload, app_submode, "
                "app_submode_mainid, app_launch_mode, app_ui_gadget, "
                "app_support_disable, "
-               "component_type, package, app_process_pool, app_installed_storage "
+               "component_type, package, app_process_pool, app_installed_storage, "
+               "app_background_category "
                "FROM package_app_info WHERE app_id=%Q";
        int ret;
        char *query;
        sqlite3_stmt *stmt;
        int idx;
        application_x *info;
+       char *bg_category_str = NULL;
 
        query = sqlite3_mprintf(query_raw, appid);
        if (query == NULL) {
@@ -571,6 +614,9 @@ static int _appinfo_get_application(sqlite3 *db, const char *appid,
        _save_column_str(stmt, idx++, &info->package);
        _save_column_str(stmt, idx++, &info->process_pool);
        _save_column_str(stmt, idx++, &info->installed_storage);
+       _save_column_str(stmt, idx++, &bg_category_str);
+
+       info->background_category = __get_background_category(bg_category_str);
 
        if (_appinfo_get_label(db, info->appid, locale, &info->label)) {
                pkgmgrinfo_basic_free_application(info);