Add an internal API 07/291507/1
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 18 Apr 2023 00:11:49 +0000 (00:11 +0000)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 18 Apr 2023 00:11:49 +0000 (00:11 +0000)
The added function is to disable the auto restart setting.
It's related to the app_control_set_auto_restart() function.

Adds:
 - app_control_unset_auto_restart()

Change-Id: I4d14c6934bc50f9e27a168e950d4fd334436a79d
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/app_control_internal.h
src/app-control/stub.cc

index 2e69dea8a19ffc4f9a476ecc02a7464aa849b13a..7ec91a4c3b99b757746ec9e4a7ca7fe3306f8ca9 100644 (file)
@@ -326,7 +326,7 @@ int app_control_send_resume_request(app_control_h app_control, app_control_resul
 int app_control_prepare_app_defined_loader(app_control_h app_control, const char *loader_id);
 
 /**
- * @brief Sets the auto restart.
+ * @brief Enables the auto restart setting.
  * @details The functionality of this function only applies to the caller application.
  *          The auto restart cannot be applied to other applications.
  *          The application ID set in the app_control handle is ignored.
@@ -342,9 +342,28 @@ int app_control_prepare_app_defined_loader(app_control_h app_control, const char
  * @retval      #APP_CONTROL_ERROR_IO_ERROR             I/O error
  *
  * @remarks This function is only available for platform level signed applications.
+ * @see app_control_unset_auto_restart()
  */
 int app_control_set_auto_restart(app_control_h app_control);
 
+/**
+ * @brief Disables the auto restart setting.
+ * @details The functionality of this function only applies to the caller application.
+ *
+ * @since_tizen 7.0
+ * @return      @c 0 on success,
+ *              otherwise a negative error value
+ * @retval      #APP_CONTROL_ERROR_NONE                 Successful
+ * @retval      #APP_CONTROL_ERROR_PERMISSION_DENIED    Permission denied
+ * @retval      #APP_CONTROL_ERROR_INVALID_PARAMETER    Invalid parameter
+ * @retval      #APP_CONTROL_ERROR_OUT_OF_MEMORY        Out of memory
+ * @retval      #APP_CONTROL_ERROR_IO_ERROR             I/O error
+ *
+ * @remarks This function is only available for platform level signed applications.
+ * @see app_control_set_auto_restart()
+ */
+int app_control_unset_auto_restart(void);
+
 /**
  * @brief Sends the launch request with setting timeout
  *
index 577a6c6d7fddf87f9d4c3368d22b758d482a3484..d3bfb2ac1dfc6b6a918e3a0072f340b57e922f05 100644 (file)
@@ -59,11 +59,8 @@ namespace {
 class ActionExt : public AppControlAction,
                   public AppControlAction::IEvent {
  public:
-  ActionExt(std::string action) : AppControlAction(action, this) {
-  }
-
-  virtual ~ActionExt() {
-  }
+  explicit ActionExt(std::string action) : AppControlAction(action, this) {}
+  virtual ~ActionExt() {}
 
   void SetActionCb(app_control_action_cb cb, void* user_data) {
     cb_ = cb;
@@ -96,6 +93,27 @@ unsigned int GetAppControlTimeout(unsigned int timeout) {
       APP_CONTROL_TIMEOUT_MAX);
 }
 
+int ConvertAulError(int error) {
+  int ret;
+
+  switch (error) {
+    case AUL_R_ENOMEM:
+      ret = APP_CONTROL_ERROR_OUT_OF_MEMORY;
+      break;
+    case AUL_R_EILLACC:
+      ret = APP_CONTROL_ERROR_PERMISSION_DENIED;
+      break;
+    case AUL_R_EINVAL:
+      ret = APP_CONTROL_ERROR_INVALID_PARAMETER;
+      break;
+    default:
+      ret = APP_CONTROL_ERROR_IO_ERROR;
+      break;
+  }
+
+  return ret;
+}
+
 }  // namespace
 
 EXPORT int app_control_create_request(bundle* data,
@@ -1240,22 +1258,17 @@ EXPORT int app_control_set_auto_restart(app_control_h app_control) {
   int ret = aul_set_auto_restart(handle->ToBundle());
   if (ret != AUL_R_OK) {
     _E("aul_set_auto_restart() is failed. error(%d)", ret);
-    switch (ret) {
-      case AUL_R_ENOMEM:
-        ret = APP_CONTROL_ERROR_OUT_OF_MEMORY;
-        break;
-      case AUL_R_EILLACC:
-        ret = APP_CONTROL_ERROR_PERMISSION_DENIED;
-        break;
-      case AUL_R_EINVAL:
-        ret = APP_CONTROL_ERROR_INVALID_PARAMETER;
-        break;
-      default:
-        ret = APP_CONTROL_ERROR_IO_ERROR;
-        break;
-    }
+    return ConvertAulError(ret);
+  }
 
-    return ret;
+  return APP_CONTROL_ERROR_NONE;
+}
+
+EXPORT int app_control_unset_auto_restart(void) {
+  int ret = aul_unset_auto_restart();
+  if (ret != AUL_R_OK) {
+    _E("aul_unset_auto_restart() is failed. error(%d)", ret);
+    return ConvertAulError(ret);
   }
 
   return APP_CONTROL_ERROR_NONE;