Implement support_mode related feature 08/97508/3 accepted/tizen/3.0/common/20161116.143515 accepted/tizen/3.0/ivi/20161116.022242 accepted/tizen/3.0/mobile/20161116.022021 accepted/tizen/3.0/tv/20161116.022125 accepted/tizen/3.0/wearable/20161116.022204 submit/tizen_3.0/20161115.024443
authorJunghyun Yeon <jungh.yeon@samsung.com>
Mon, 14 Nov 2016 10:14:41 +0000 (19:14 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 15 Nov 2016 10:38:06 +0000 (02:38 -0800)
Related changes:
[app-installers] : https://review.tizen.org/gerrit/97702
[tpk-manifest-handlers] : https://review.tizen.org/gerrit/97699

Change-Id: Iff9193028a773161c3a09a63dd8508c3ca5fdaff
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
include/pkgmgr-info.h
include/pkgmgrinfo_basic.h
include/pkgmgrinfo_private.h
include/pkgmgrinfo_type.h
parser/src/pkgmgr_parser_db.c
src/pkgmgrinfo_appinfo.c
src/pkgmgrinfo_basic.c
src/pkgmgrinfo_pkginfo.c
src/pkgmgrinfo_private.c

index e789b15..80a8ead 100644 (file)
@@ -146,6 +146,8 @@ extern "C" {
 
  /** Integer property for filtering app disabled by user*/
 #define        PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER        "PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER_VALUE"
+/** Integer property for filtering app support mode */
+#define        PMINFO_APPINFO_PROP_APP_SUPPORT_MODE            "PMINFO_APPINFO_PROP_APP_SUPPORT_MODE"
 
  /** Boolean property for filtering based on app info*/
 #define        PMINFO_APPINFO_PROP_APP_NODISPLAY               "PMINFO_APPINFO_PROP_APP_NODISPLAY"
@@ -1158,6 +1160,42 @@ static int get_csc_path(const char *pkgid)
 int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path);
 
 /**
+ * @fn int pkgmgrinfo_pkginfo_get_support_mode(pkgmgrinfo_pkginfo_h handle, int *support_mode)
+ * @brief      This API gets the support_mode of package
+ *
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle           pointer to package info handle
+ * @param[out] support_mode            pointer to hold support_mode of package
+ * @return     0 if success, error code(<0) if fail
+ * @retval     PMINFO_R_OK     success
+ * @retval     PMINFO_R_EINVAL invalid argument
+ * @retval     PMINFO_R_ERROR  internal error
+ * @code
+static int get_support_mode(const char *pkgid)
+{
+       int ret = 0;
+       int support_mode = 0;
+       pkgmgrinfo_pkginfo_h handle = NULL;
+       ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+
+       ret = pkgmgrinfo_pkginfo_get_support_mode(handle, &support_mode);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+               return -1;
+       }
+       printf("support_mode : %s\n", support_mode);
+       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_pkginfo_get_support_mode(pkgmgrinfo_pkginfo_h handle, int *support_mode);
+
+/**
  * @fn int pkgmgrinfo_pkginfo_compare_pkg_cert_info(const char *lhs_package_id, const char *rhs_package_id, pkgmgrinfo_cert_compare_result_type_e *compare_result)
  * @brief      This API compare the cert information from given package id
  *
@@ -3608,6 +3646,44 @@ static int get_app_installed_time(const char *appid)
 int pkgmgrinfo_appinfo_get_installed_time(pkgmgrinfo_appinfo_h handle, int *installed_time);
 
 /**
+ * @fn int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h  handle, int *support_mode)
+ * @brief      This API gets the support_mode of the application
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle           pointer to the application info handle.
+ * @param[out] support_mode            pointer to hold app support_mode
+ * @return     0 if success, error code(<0) if fail
+ * @retval     PMINFO_R_OK     success
+ * @retval     PMINFO_R_EINVAL invalid argument
+ * @retval     PMINFO_R_ERROR  internal error
+ * @pre                pkgmgrinfo_appinfo_get_appinfo()
+ * @post               pkgmgrinfo_appinfo_destroy_appinfo()
+ * @see                pkgmgrinfo_appinfo_get_appid()
+ * @code
+static int get_app_support_mode(const char *appid)
+{
+       int ret = 0;
+       int support_mode = 0;
+       pkgmgrinfo_appinfo_h handle = NULL;
+       ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_appinfo_get_support_mode(handle, &support_mode);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_appinfo_destroy_appinfo(handle);
+               return -1;
+       }
+       printf("support_mode: %s\n", support_mode);
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *support_mode);
+
+/**
  * @fn int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
                        pkgmgrinfo_app_permission_list_cb permission_func, void *user_data);
  * @brief      This API gets the list of permission for a particular application
index 0886c5c..cd4023c 100644 (file)
@@ -160,6 +160,7 @@ typedef struct application_x {
        char *package_system; /*set from package_x*/
        char *removable; /*set from package_x*/
        char *package_installed_time; /*installed time after finishing of installation*/
+       char *support_mode; /*attr*/
        GList *label;   /*element*/
        GList *icon;    /*element*/
        GList *image;   /*element*/
@@ -198,6 +199,7 @@ typedef struct package_x {
        char *root_path;                /**< package root path, attr*/
        char *csc_path;         /**< package csc path, attr*/
        char *nodisplay_setting;                /**< package no display setting menu, attr, default: "false"*/
+       char *support_mode; /**< package support mode, attr*/
        char *support_disable;          /**< package support disable flag, attr, default: "false"*/
        char *api_version;              /**< minimum version of API package using, attr, default: patch_version trimmed version from tizen_full_version*/
        char *tep_name; /*no xml part*/
index ab1189d..776cd89 100644 (file)
@@ -152,7 +152,8 @@ typedef enum _pkgmgrinfo_appinfo_filter_prop_int {
        /*Currently No Fields*/
        E_PMINFO_APPINFO_PROP_APP_MIN_INT = 601,
        E_PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER = E_PMINFO_APPINFO_PROP_APP_MIN_INT,
-       E_PMINFO_APPINFO_PROP_APP_MAX_INT = E_PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER
+       E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE,
+       E_PMINFO_APPINFO_PROP_APP_MAX_INT = E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE
 } pkgmgrinfo_appinfo_filter_prop_int;
 
 /*Integer properties for filtering based on app info*/
index ba7e3c1..8d81738 100644 (file)
 #define APP_BG_CATEGORY_IOTCOMM_STR                    "iot-communication"
 #define APP_BG_CATEGORY_SYSTEM                         "system"
 
+/* Integer property for mode */
+#define        APP_SUPPORT_MODE_ULTRA_POWER_SAVING             0x00001
+#define        APP_SUPPORT_MODE_COOL_DOWN                              0x00002
+#define        APP_SUPPORT_MODE_SCREEN_READER                  0x00004
+
 /**
  * @brief A type to retrieve uid information from the manifest handle
  */
index 8955a8b..7331af1 100644 (file)
@@ -113,6 +113,7 @@ sqlite3 *pkgmgr_cert_db;
                                                "root_path TEXT, " \
                                                "external_path TEXT, " \
                                                "csc_path TEXT, " \
+                                               "package_support_mode TEXT, " \
                                                "package_support_disable TEXT NOT NULL DEFAULT 'false', " \
                                                "package_disable TEXT NOT NULL DEFAULT 'false')"
 
@@ -166,6 +167,7 @@ sqlite3 *pkgmgr_cert_db;
                                                "app_process_pool TEXT NOT NULL DEFAULT 'false', " \
                                                "app_launch_mode TEXT NOT NULL DEFAULT 'caller', " \
                                                "app_ui_gadget TEXT NOT NULL DEFAULT 'false', " \
+                                               "app_support_mode TEXT, " \
                                                "app_support_disable TEXT NOT NULL DEFAULT 'false', " \
                                                "app_disable TEXT NOT NULL DEFAULT 'false', " \
                                                "app_package_type TEXT DEFAULT 'tpk', " \
@@ -1263,29 +1265,29 @@ static int __insert_application_info(manifest_x *mfx)
                        "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_launch_mode, app_ui_gadget, app_support_mode, app_support_disable, component_type, package, " \
                        "app_tep_name, app_zip_mount_file, app_background_category, app_package_type, app_root_path, " \
                        "app_api_version, app_effective_appid, app_splash_screen_display, app_package_system, app_removable, " \
-                       "app_package_installed_time) " \
+                       "app_package_installed_time, app_support_mode) " \
                        "VALUES(" \
                        "%Q, %Q, %Q, LOWER(%Q), %Q, " \
                        "LOWER(%Q), LOWER(%Q), LOWER(%Q), LOWER(%Q), LOWER(%Q), " \
                        "%Q, %Q, %Q, %Q, %Q, " \
                        "LOWER(%Q), %Q, %Q, LOWER(%Q), %Q, " \
                        "LOWER(%Q), LOWER(%Q), %Q, %Q, LOWER(%Q), " \
-                       "COALESCE(%Q, 'caller'), LOWER(%Q), LOWER(%Q), %Q, %Q, " \
+                       "COALESCE(%Q, 'caller'), LOWER(%Q), %Q, LOWER(%Q), %Q, %Q, " \
                        "%Q, %Q, %d, %Q, %Q, " \
                        "%Q, %Q, LOWER(%Q), LOWER(%Q), LOWER(%Q), " \
-                       "%Q)", \
+                       "%Q, %Q)", \
                        app->appid, app->component_type, app->exec, __get_bool(app->nodisplay, false), app->type,
                        __get_bool(app->onboot, false), __get_bool(app->multiple, false), __get_bool(app->autorestart, false), __get_bool(app->taskmanage, false), __get_bool(app->enabled, true),
                        app->hwacceleration, app->screenreader, app->mainapp, app->recentimage, app->launchcondition,
                        __get_bool(app->indicatordisplay, true), app->portraitimg, app->landscapeimg,
                        __get_bool(app->guestmode_visibility, true), app->permission_type,
                        __get_bool(mfx->preload, false), __get_bool(app->submode, false), app->submode_mainid, mfx->installed_storage, __get_bool(app->process_pool, false),
-                       app->launch_mode, __get_bool(app->ui_gadget, false), __get_bool(mfx->support_disable, false), app->component_type, mfx->package,
+                       app->launch_mode, __get_bool(app->ui_gadget, false), mfx->support_mode, __get_bool(mfx->support_disable, false), app->component_type, mfx->package,
                        mfx->tep_name, mfx->zip_mount_file, background_value, type, mfx->root_path, mfx->api_version,
-                       effective_appid, __get_bool(app->splash_screen_display, false), __get_bool(mfx->system, false), __get_bool(mfx->removable, true), mfx->installed_time);
+                       effective_appid, __get_bool(app->splash_screen_display, false), __get_bool(mfx->system, false), __get_bool(mfx->removable, true), mfx->installed_time, mfx->support_mode);
 
                ret = __exec_query(query);
                if (ret == -1) {
@@ -1898,6 +1900,12 @@ static int __insert_manifest_info_in_db(manifest_x *mfx, uid_t uid)
        GList *appicon = NULL;
        GList *appimage = NULL;
 
+       int temp_pkg_mode = 0;
+       int temp_app_mode = 0;
+       char pkg_mode[10] = {'\0'};
+       application_x *up_support_mode = NULL;
+       GList *list_up = NULL;
+
        if (mfx->author && mfx->author->data) {
                author = (author_x *)mfx->author->data;
                if (author->text)
@@ -1908,6 +1916,24 @@ static int __insert_manifest_info_in_db(manifest_x *mfx, uid_t uid)
                        auth_href = author->href;
        }
 
+       if (mfx->support_mode)
+               temp_pkg_mode = atoi(mfx->support_mode);
+
+       list_up = mfx->application;
+       while (list_up != NULL) {
+               up_support_mode = (application_x *)list_up->data;
+               if (up_support_mode->support_mode) {
+                       temp_app_mode = atoi(up_support_mode->support_mode);
+                       temp_pkg_mode |= temp_app_mode;
+               }
+               list_up = list_up->next;
+       }
+       sprintf(pkg_mode, "%d", temp_pkg_mode);
+
+       if(mfx->support_mode)
+               free((void *)mfx->support_mode);
+       mfx->support_mode = strdup(pkg_mode);
+
        /*Insert in the package_info DB*/
        sqlite3_snprintf(MAX_QUERY_LEN, query,
                "INSERT INTO package_info(" \
@@ -1915,19 +1941,19 @@ static int __insert_manifest_info_in_db(manifest_x *mfx, uid_t uid)
                "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) " \
+               "mainapp_id, package_url, root_path, csc_path, package_support_mode, package_support_disable, package_support_mode) " \
                "VALUES(" \
                "%Q, %Q, %Q, %Q, %Q, %Q, " \
                "%Q, %Q, LOWER(%Q), LOWER(%Q), LOWER(%Q), " \
                "LOWER(%Q), LOWER(%Q), LOWER(%Q), LOWER(%Q), %Q, " \
                "%Q, %Q, %Q, %Q, %Q, " \
-               "%Q, %Q, %Q, %Q, LOWER(%Q))",
+               "%Q, %Q, %Q, %Q, %Q, LOWER(%Q), %Q)",
                mfx->package, mfx->type, mfx->version, mfx->api_version, mfx->tep_name, mfx->zip_mount_file,
                mfx->installlocation, mfx->package_size, __get_bool(mfx->removable, true), __get_bool(mfx->preload, false), __get_bool(mfx->readonly, false),
                __get_bool(mfx->update, false), __get_bool(mfx->appsetting, false), __get_bool(mfx->nodisplay_setting, false), __get_bool(mfx->system, false), auth_name,
                auth_email, auth_href, mfx->installed_time, mfx->installed_storage,
                mfx->storeclient_id,
-               mfx->mainapp_id, mfx->package_url, mfx->root_path, mfx->csc_path, __get_bool(mfx->support_disable, false));
+               mfx->mainapp_id, mfx->package_url, mfx->root_path, mfx->csc_path, mfx->support_mode, __get_bool(mfx->support_disable, false), mfx->support_mode);
 
        ret = __exec_query(query);
        if (ret == -1) {
index c243192..f1c3665 100644 (file)
@@ -474,7 +474,7 @@ static int _appinfo_get_applications(uid_t db_uid, uid_t uid,
                "ai.app_splash_screen_display, ai.app_tep_name, "
                "ai.app_zip_mount_file, ai.component_type, ai.package, "
                "ai.app_external_path, ai.app_package_system, ai.app_removable, "
-               "ai.app_package_installed_time";
+               "ai.app_package_installed_time, ai.app_support_mode";
        static const char query_label[] =
                ", COALESCE("
                "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
@@ -605,6 +605,7 @@ static int _appinfo_get_applications(uid_t db_uid, uid_t uid,
                _save_column_str(stmt, idx++, &info->package_system);
                _save_column_str(stmt, idx++, &info->removable);
                _save_column_str(stmt, idx++, &info->package_installed_time);
+               _save_column_str(stmt, idx++, &info->support_mode);
 
                info->for_all_users =
                        strdup((uid != GLOBAL_USER) ? "false" : "true");
@@ -2245,6 +2246,20 @@ API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **
        return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
 }
 
+API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h  handle, int *support_mode)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+       if (info->app_info->support_mode)
+               *support_mode = atoi(info->app_info->support_mode);
+       else
+               *support_mode = 0;
+
+       return PMINFO_R_OK;
+}
+
 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
                        pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
 {
index 5c083e8..924cc2c 100644 (file)
@@ -346,6 +346,8 @@ static void __ps_free_application(gpointer data)
                free((void *)application->removable);
        if (application->package_installed_time)
                free((void *)application->package_installed_time);
+       if (application->support_mode)
+               free((void *)application->support_mode);
 
        /*Free Label*/
        g_list_free_full(application->label, __ps_free_label);
@@ -440,6 +442,8 @@ API void pkgmgrinfo_basic_free_package(package_x *package)
                free((void *)package->zip_mount_file);
        if (package->external_path)
                free((void *)package->external_path);
+       if (package->support_mode)
+               free((void *)package->support_mode);
 
        /*Free Icon*/
        g_list_free_full(package->icon, __ps_free_icon);
index ca0d464..2b22e92 100644 (file)
@@ -297,7 +297,8 @@ static int _pkginfo_get_packages(uid_t uid, const char *locale,
                "pi.storeclient_id, pi.mainapp_id, pi.package_url, "
                "pi.root_path, pi.csc_path, pi.package_nodisplay, "
                "pi.package_api_version, pi.package_support_disable, "
-               "pi.package_tep_name, pi.package_zip_mount_file, pi.external_path";
+               "pi.package_tep_name, pi.package_zip_mount_file, pi.external_path, "
+               "pi.package_support_mode";
        static const char query_author[] =
                ", pi.author_name, pi.author_email, pi.author_href";
        static const char query_label[] =
@@ -438,6 +439,7 @@ static int _pkginfo_get_packages(uid_t uid, const char *locale,
                _save_column_str(stmt, idx++, &info->tep_name);
                _save_column_str(stmt, idx++, &info->zip_mount_file);
                _save_column_str(stmt, idx++, &info->external_path);
+               _save_column_str(stmt, idx++, &info->support_mode);
                info->for_all_users =
                        strdup((uid != GLOBAL_USER) ? "false" : "true");
 
@@ -1129,6 +1131,19 @@ API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path
        return PMINFO_R_OK;
 }
 
+API int pkgmgrinfo_pkginfo_get_support_mode(pkgmgrinfo_pkginfo_h handle, int *support_mode)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+       retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+       if (info->pkg_info->support_mode)
+               *support_mode = atoi(info->pkg_info->support_mode);
+       else
+               *support_mode = 0;
+
+       return PMINFO_R_OK;
+}
 
 API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *accessible)
 {
index 2889ce5..c1699fd 100644 (file)
@@ -105,7 +105,8 @@ struct _appinfo_int_map_t {
 };
 
 static struct _appinfo_int_map_t appinfo_int_prop_map[] = {
-       {E_PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER,    PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER}
+       {E_PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER,    PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER},
+       {E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE,        PMINFO_APPINFO_PROP_APP_SUPPORT_MODE}
 };
 
 struct _appinfo_bool_map_t {
@@ -394,6 +395,9 @@ int __get_filter_condition(gpointer data, char **condition, GList **params)
                                "(SELECT app_id from package_app_info_for_uid WHERE uid=? " \
                                "AND is_disabled='true' COLLATE NOCASE)");
                break;
+       case E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE:
+               snprintf(buf, sizeof(buf), "ai.app_support_mode=?");
+               break;
        default:
                _LOGE("Invalid Property Type\n");
                *condition = NULL;