Add app_manager_set_app_icon API 90/152190/9
authorJunghyun Yeon <jungh.yeon@samsung.com>
Mon, 25 Sep 2017 08:08:36 +0000 (17:08 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Mon, 4 Dec 2017 10:32:19 +0000 (19:32 +0900)
- Add app_manager_set_app_icon API to allow change app icon dynamically.
- Please note that icon file to be changed should be included in pkg and
  icon will not change dynamically.

Change-Id: I9975e2907442240e162da7c5bdf265f96996635a
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
include/app_manager.h
src/app_manager.c

index a9214ad..b15514b 100644 (file)
@@ -490,6 +490,28 @@ int app_manager_unset_event_cb(app_manager_event_h handle);
  */
 int app_manager_event_destroy(app_manager_event_h handle);
 
+/**
+ * @platform
+ * @brief Sets the application's icon path into given path.
+ * @since_tizen 5.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/packagemanager.admin
+ * @remarks   The icon file should be included in package which the applications belongs to.
+ * @param[in] app_id    The ID of the application
+ * @param[in] icon_path The path of icon file
+ *
+ * @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_OUT_OF_MEMORY        Out of memory
+ * @retval #APP_MANAGER_ERROR_IO_ERROR             Internal error
+ * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED    Permission denied
+ *
+ * @see app_manager_event_create()
+ */
+int app_manager_set_app_icon(const char *app_id, const char *icon_path);
 
 /**
  * @}
index 88a3895..f6cdb7c 100644 (file)
@@ -430,6 +430,45 @@ API int app_manager_set_splash_screen_display(const char *app_id, bool display)
        return r;
 }
 
+API int app_manager_set_app_icon(const char *app_id, const char *icon_path)
+{
+       int r;
+       pkgmgr_client *pc;
+
+       if (app_id == NULL)
+               return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER,
+                               __FUNCTION__, NULL);
+
+       pc = pkgmgr_client_new(PC_REQUEST);
+       if (pc == NULL)
+               return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY,
+                               __FUNCTION__, NULL);
+
+       r = pkgmgr_client_set_app_icon(pc, (char *)app_id, (char *)icon_path);
+       pkgmgr_client_free(pc);
+
+       switch (r) {
+       case PKGMGR_R_OK:
+               r = APP_MANAGER_ERROR_NONE;
+               break;
+       case PKGMGR_R_EINVAL:
+               r = app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER,
+                               __FUNCTION__, NULL);
+               break;
+       case PKGMGR_R_EPRIV:
+               r = app_manager_error(APP_MANAGER_ERROR_PERMISSION_DENIED,
+                               __FUNCTION__, NULL);
+               break;
+       default:
+               r = app_manager_error(APP_MANAGER_ERROR_IO_ERROR,
+                               __FUNCTION__, NULL);
+               break;
+       }
+
+       return r;
+}
+
+
 API int app_manager_event_create(app_manager_event_h *handle)
 {
        pkgmgr_client *pc = NULL;