Merge 2.4 patch. 20/54420/3
authorMyungki Lee <mk5004.lee@samsung.com>
Tue, 15 Dec 2015 11:10:53 +0000 (20:10 +0900)
committerMyungki Lee <mk5004.lee@samsung.com>
Tue, 15 Dec 2015 11:10:53 +0000 (20:10 +0900)
- deprecate app_manager_get_exterenal_shared_data_path
- Doxygen tag modified for the deprecated func
- update doxygen
- removed app_manager_open_app API
- Fix prevent issue
- Fix bug that foreach callback is not stopped

Change-Id: I6c5c74b9d80fc49d320877cddbf03fd46955c9b0
Signed-off-by: Myungki Lee <mk5004.lee@samsung.com>
include/app_context.h
include/app_info.h
include/app_manager.h
src/app_context.c
src/app_info.c
src/app_manager.c

index 5f0e90e..2ed320b 100644 (file)
@@ -44,7 +44,7 @@ typedef struct app_context_s *app_context_h;
 
 /**
  * @brief  Enumeration for Application Context Event.
- * @since_tizen  @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @since_tizen 2.4
  */
 typedef enum
 {
@@ -68,10 +68,10 @@ int app_context_destroy(app_context_h app_context);
 
 
 /**
+ * @deprecated Deprecated since 2.3.1. Use app_context_get_app_id() instead.
  * @brief    Gets the package with the given application context.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @remarks  This function is @b deprecated. Use app_context_get_app_id() instead. \n
- *           You must release @a package using free().
+ * @remarks You must release @a package using free().
  * @param[in]   app_context  The application context
  * @param[out]  package      The package of the given application context
  * @return      @c 0 on success,
index eac0cba..234054a 100644 (file)
@@ -33,13 +33,34 @@ extern "C" {
 * @{
 */
 
-/** @brief  Definition for string property for filtering based on app info. */
+/**
+ * @brief  Definition for string property for filtering based on app info: String property for filtering packages with app id
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
 #define  PACKAGE_INFO_PROP_APP_ID            "PACKAGE_INFO_PROP_APP_ID"
+
+/**
+ * @brief  Definition for string property for filtering based on app info: String property for filtering packages with app type
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
 #define  PACKAGE_INFO_PROP_APP_TYPE          "PACKAGE_INFO_PROP_APP_TYPE"
+
+/**
+ * @brief  Definition for string property for filtering based on app info: String property for filtering packages with app category
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
 #define  PACKAGE_INFO_PROP_APP_CATEGORY      "PACKAGE_INFO_PROP_APP_CATEGORY"
 
-/** @brief Definition for boolean property for filtering based on app info. */
+/**
+ * @brief Definition for boolean property for filtering based on app info: Boolean property for filtering whether the package is nodisplay or not based on package info
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
 #define        PACKAGE_INFO_PROP_APP_NODISPLAY     "PACKAGE_INFO_PROP_APP_NODISPLAY"
+
+/**
+ * @brief Definition for boolean property for filtering based on app info: Boolean property for filtering whether the package has the authority to manage task or not based on package info
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
 #define        PACKAGE_INFO_PROP_APP_TASKMANAGE    "PACKAGE_INFO_PROP_APP_TASKMANAGE"
 
 /**
index a9a44f9..f312237 100644 (file)
@@ -55,9 +55,8 @@ typedef enum
 } app_manager_error_e;
 
 /**
- * @internal
  * @brief  Called when an application is launched or terminated.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @since_tizen 2.4
  * @param[in]   app_context  The application context of the application launched or terminated
  * @param[in]   event        The application context event
  * @param[in]   user_data    The user data passed from the foreach function
@@ -219,23 +218,6 @@ int app_manager_resume_app(app_context_h app_context);
  */
 int app_manager_request_terminate_bg_app(app_context_h app_context);
 
-/* FIXME: should be separated */
-/**
- * @brief  Opens the application.
- * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @privlevel public
- * @privilege %http://tizen.org/privilege/appmanager.launch
- * @param[in]   app_id  The ID of the application
- * @return      @c 0 on success,
- *              otherwise a negative error value
- * @retval  #APP_MANAGER_ERROR_NONE               Successful
- * @retval  #APP_MANAGER_ERROR_INVALID_PARAMETER  Invalid parameter
- * @retval  #APP_MANAGER_ERROR_NO_SUCH_APP        No such application
- * @retval  #APP_MANAGER_ERROR_REQUEST_FAILED     Internal open error
- * @retval  #APP_MANAGER_ERROR_PERMISSION_DENIED  Permission denied
- */
-int app_manager_open_app(const char *app_id);
-
 /**
  * @brief  Retrieves all installed applications information.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
@@ -330,11 +312,13 @@ int app_manager_get_shared_resource_path(const char *app_id, char **path);
 int app_manager_get_shared_trusted_path(const char *app_id, char **path);
 
 /**
+ * @deprecated Deprecated since 2.4.
  * @brief  Gets the absolute path to the shared data directory of the application specified
  *         with an application ID.
  * @details     An application can only read the files of other application's shared data directory.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @remarks     The specified @a path should be released.
+ * @remarks     To access the path returned by this function may not work as intended in certain devices due to some implementation issues.
  *
  * @param[in]      app_id  The ID of the application
  * @param[in,out]  path    The absolute path to the shared data directory of the application
index b6fba3d..efd27a6 100644 (file)
@@ -287,22 +287,17 @@ static void app_context_pid_table_entry_destroyed_cb(void * data)
 {
        app_context_h app_context = data;
 
-       if (app_context != NULL) {
-               char *app_id;
-               int pid;
-               app_context_get_app_id(app_context, &app_id);
-               app_context_get_pid(app_context, &pid);
-               SECURE_LOGI("[%s] app_id(%s), pid(%d)", __FUNCTION__, app_context->app_id, app_context->pid);
-               free(app_id);
-
+       if (app_context != NULL)
                app_context_destroy(app_context);
-       }
 }
 
 static int app_context_launched_event_cb(pid_t pid, const char *app_id, void *data)
 {
        app_context_h app_context = NULL;
 
+       if (pid < 0 || app_id == NULL)
+               return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+
        app_context_lock_event_cb_context();
 
        if (app_context_create(app_id, pid, &app_context) == APP_MANAGER_ERROR_NONE) {
index e59c747..41f492d 100644 (file)
@@ -99,6 +99,7 @@ static int app_info_foreach_app_filter_cb(pkgmgrinfo_appinfo_h handle, void *use
        int retval = 0;
        char *appid = NULL;
        app_info_h info = NULL;
+       bool iteration_next = true;
 
        info = calloc(1, sizeof(struct app_info_s));
        if (info == NULL)
@@ -117,23 +118,46 @@ static int app_info_foreach_app_filter_cb(pkgmgrinfo_appinfo_h handle, void *use
        }
 
        info->app_id = strdup(appid);
+       if (info->app_id == NULL) {
+               if (info) {
+                       free(info);
+                       info = NULL;
+               }
+               return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+       }
        info->pkg_app_info = handle;
 
-       foreach_context->callback(info, foreach_context->user_data);
+       iteration_next = foreach_context->callback(info, foreach_context->user_data);
 
-       return APP_MANAGER_ERROR_NONE;
+       if (info->app_id) {
+               free(info->app_id);
+               info->app_id = NULL;
+       }
+
+       if (info) {
+               free(info);
+               info = NULL;
+       }
+
+       if (iteration_next == true)
+               return PMINFO_R_OK;
+       else
+               return PMINFO_R_ERROR;
 }
 
 static int app_info_foreach_app_metadata_cb(const char *metadata_key, const char *metadata_value, void *user_data)
 {
        foreach_metadata_context_s *foreach_context = user_data;
+       bool iteration_next = true;
 
        if (metadata_value == NULL || foreach_context == NULL)
                return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL);
 
-       foreach_context->callback(metadata_key, metadata_value, foreach_context->user_data);
-
-       return APP_MANAGER_ERROR_NONE;
+       iteration_next = foreach_context->callback(metadata_key, metadata_value, foreach_context->user_data);
+       if (iteration_next == true)
+               return PMINFO_R_OK;
+       else
+               return PMINFO_R_ERROR;
 }
 
 static int app_info_foreach_app_info_cb(pkgmgrinfo_appinfo_h handle, void *cb_data)
@@ -244,11 +268,14 @@ API int app_info_destroy(app_info_h app_info)
 
 API int app_info_get_app_id(app_info_h app_info, char **app_id)
 {
-       char *app_id_dup;
+       char *app_id_dup = NULL;
 
        if (app_info == NULL || app_id == NULL)
                return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
+       if (app_info->app_id == NULL)
+               return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+
        app_id_dup = strdup(app_info->app_id);
        if (app_id_dup == NULL)
                return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
@@ -260,14 +287,15 @@ API int app_info_get_app_id(app_info_h app_info, char **app_id)
 
 API int app_info_get_exec(app_info_h app_info, char **exec)
 {
-       char *val;
-       char *app_exec_dup;
+       char *val = NULL;
+       char *app_exec_dup = NULL;
+       int ret = -1;
 
        if (app_info == NULL || exec == NULL)
                return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
-       pkgmgrinfo_appinfo_get_exec(app_info->pkg_app_info, &val);
-       if (val == NULL)
+       ret = pkgmgrinfo_appinfo_get_exec(app_info->pkg_app_info, &val);
+       if (ret != PMINFO_R_OK || val == NULL)
                return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
        app_exec_dup = strdup(val);
@@ -281,14 +309,15 @@ API int app_info_get_exec(app_info_h app_info, char **exec)
 
 API int app_info_get_label(app_info_h app_info, char **label)
 {
-       char *val;
-       char *app_label_dup;
+       char *val = NULL;
+       char *app_label_dup = NULL;
+       int ret = 0;
 
        if (app_info == NULL || label == NULL)
                return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
-       pkgmgrinfo_appinfo_get_label(app_info->pkg_app_info, &val);
-       if (val == NULL)
+       ret = pkgmgrinfo_appinfo_get_label(app_info->pkg_app_info, &val);
+       if (ret < 0 || val == NULL)
                return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
        app_label_dup = strdup(val);
@@ -302,8 +331,8 @@ API int app_info_get_label(app_info_h app_info, char **label)
 
 API int app_info_get_localed_label(const char *app_id, const char *locale, char **label)
 {
-       char *val;
-       char *app_label_dup;
+       char *val = NULL;
+       char *app_label_dup = NULL;
 
        if (app_id == NULL || locale == NULL || label == NULL)
                return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
@@ -312,8 +341,13 @@ API int app_info_get_localed_label(const char *app_id, const char *locale, char
                return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
        app_label_dup = strdup(val);
-       if (app_label_dup == NULL)
+       if (app_label_dup == NULL) {
+               if (val) {
+                       free(val);
+                       val = NULL;
+               }
                return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+       }
 
        *label = app_label_dup;
        free(val);
@@ -323,14 +357,15 @@ API int app_info_get_localed_label(const char *app_id, const char *locale, char
 
 API int app_info_get_icon(app_info_h app_info, char **path)
 {
-       char *val;
-       char *app_icon_dup;
+       char *val = NULL;
+       char *app_icon_dup = NULL;
+       int ret = -1;
 
        if (app_info == NULL || path == NULL)
                return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
-       pkgmgrinfo_appinfo_get_icon(app_info->pkg_app_info, &val);
-       if (val == NULL)
+       ret = pkgmgrinfo_appinfo_get_icon(app_info->pkg_app_info, &val);
+       if (ret != PMINFO_R_OK || val == NULL)
                return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
        app_icon_dup = strdup(val);
@@ -344,13 +379,18 @@ API int app_info_get_icon(app_info_h app_info, char **path)
 
 API int app_info_get_package(app_info_h app_info, char **package)
 {
-       char *val;
-       char *app_package_dup;
+       char *val = NULL;
+       char *app_package_dup = NULL;
+       int ret = 0;
 
        if (app_info == NULL || package == NULL)
                return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
-       pkgmgrinfo_appinfo_get_pkgname(app_info->pkg_app_info, &val);
+       ret = pkgmgrinfo_appinfo_get_pkgname(app_info->pkg_app_info, &val);
+       if (ret < 0)
+               return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+       if (val == NULL)
+               return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
        app_package_dup = strdup(val);
        if (app_package_dup == NULL)
@@ -363,13 +403,18 @@ API int app_info_get_package(app_info_h app_info, char **package)
 
 API int app_info_get_type(app_info_h app_info, char **type)
 {
-       char *val;
-       char *app_type_dup;
+       char *val = NULL;
+       char *app_type_dup = NULL;
+       int ret = 0;
 
        if (app_info == NULL || type == NULL)
                return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
-       pkgmgrinfo_appinfo_get_apptype(app_info->pkg_app_info, &val);
+       ret = pkgmgrinfo_appinfo_get_apptype(app_info->pkg_app_info, &val);
+       if (ret < 0)
+               return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+       if (val == NULL)
+               return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
        app_type_dup = strdup(val);
        if (app_type_dup == NULL)
index 0b32489..8f04329 100644 (file)
@@ -103,7 +103,7 @@ API int app_manager_get_app_context(const char *app_id, app_context_h *app_conte
 API int app_manager_resume_app(app_context_h app_context)
 {
        char *app_id;
-       int retval;
+       int retval = APP_MANAGER_ERROR_NONE;
 
        if (app_context == NULL)
                return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
@@ -112,13 +112,17 @@ API int app_manager_resume_app(app_context_h app_context)
                return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, "failed to get the application ID");
 
        if (aul_app_is_running(app_id) == 0) {
-               free(app_id);
+               if (app_id) {
+                       free(app_id);
+                       app_id = NULL;
+               }
                return app_manager_error(APP_MANAGER_ERROR_APP_NO_RUNNING, __FUNCTION__, NULL);
        }
 
        retval = aul_resume_app(app_id);
 
-       free(app_id);
+       if (app_id)
+               free(app_id);
 
        if (retval == AUL_R_EINVAL)
                return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
@@ -241,27 +245,6 @@ API int app_manager_is_running(const char *app_id, bool *running)
        return APP_MANAGER_ERROR_NONE;
 }
 
-API int app_manager_open_app(const char *app_id)
-{
-       int retval;
-
-       retval = aul_open_app(app_id);
-       if (retval == AUL_R_ERROR) {
-               LOGE("[%s] APP_MANAGER_ERROR_NO_SUCH_APP(0x%08x) : No such application", __FUNCTION__, APP_MANAGER_ERROR_NO_SUCH_APP);
-               return APP_MANAGER_ERROR_NO_SUCH_APP;
-       } else if (retval == AUL_R_EINVAL) {
-               LOGE("[%s] APP_MANAGER_ERROR_INVALID_PARAMETER(0x%08x) : Invalid param", __FUNCTION__, APP_MANAGER_ERROR_INVALID_PARAMETER);
-               return APP_MANAGER_ERROR_INVALID_PARAMETER;
-       } else if (retval == AUL_R_EILLACC) {
-               LOGE("[%s] APP_MANAGER_ERROR_PERMISSION_DENIED(0x%08x) : Permission denied", __FUNCTION__, APP_MANAGER_ERROR_PERMISSION_DENIED);
-               return APP_MANAGER_ERROR_PERMISSION_DENIED;
-       } else if (retval < 0) {
-               return APP_MANAGER_ERROR_REQUEST_FAILED;
-       }
-
-       return APP_MANAGER_ERROR_NONE;
-}
-
 API int app_manager_get_shared_data_path(const char *app_id, char **path)
 {
        int r;