Fix the wrong implementation 91/210691/2
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 24 Jul 2019 03:06:58 +0000 (12:06 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 24 Jul 2019 03:14:50 +0000 (12:14 +0900)
To use component_manager_is_running(), the packagemanager.info privilege
is needed. And, if the component context in the function cannot be created
with COMPONENT_MANAGER_ERROR_NO_SUCH_COMPONENT, the running flag should be
"false".

Change-Id: Ide782a88809daefcb739b51aaa63b982735a49cd
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/component_manager.h
src/component_manager.c

index 2412420..d42a8a9 100644 (file)
@@ -171,6 +171,8 @@ int component_manager_get_component_info(const char *comp_id, component_info_h *
 /**
  * @brief Checks whether the component is running or not.
  * @since_tizen 5.5
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/packagemanager.info
  *
  * @param[in]   comp_id         The component ID
  * @param[out]  running         @c true if the component is running, \n
@@ -178,6 +180,7 @@ int component_manager_get_component_info(const char *comp_id, component_info_h *
  * @return      @c 0 on success,
  *              otherwise a negative error value
  * @retval #COMPONENT_MANAGER_ERROR_NONE Successful
+ * @retval #COMPONENT_MANAGER_ERROR_PERMISSION_DENIED Permission denied
  * @retval #COMPONENT_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #COMPONENT_MANAGER_ERROR_IO_ERROR I/O error
  * @retval #COMPONENT_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
index 871d4ed..8a6a82c 100644 (file)
@@ -105,8 +105,14 @@ EXPORT_API int component_manager_is_running(const char *comp_id, bool *running)
        }
 
        ret = component_context_create(comp_id, &handle);
-       if (ret != COMPONENT_MANAGER_ERROR_NONE)
+       if (ret != COMPONENT_MANAGER_ERROR_NONE) {
+               if (ret == COMPONENT_MANAGER_ERROR_NO_SUCH_COMPONENT) {
+                       *running = false;
+                       return COMPONENT_MANAGER_ERROR_NONE;
+               }
+
                return ret;
+       }
 
        ret = component_context_is_running(handle, running);
        component_context_destroy(handle);