Add a new internal function 52/273252/2
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 1 Apr 2022 08:21:29 +0000 (17:21 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 4 Apr 2022 00:05:14 +0000 (09:05 +0900)
To support setting auto-restart,the function is added.
This function is only available for platform level signed applications.

Adds:
 - app_control_set_auto_restart()

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

index 646574b..55cc00e 100644 (file)
@@ -326,6 +326,26 @@ 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.
+ * @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.
+ *
+ * @since_tizen 7.0
+ * @param[in]   app_control     The app_control handle
+ * @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.
+ */
+int app_control_set_auto_restart(app_control_h app_control);
+
+/**
  * @}
  */
 
index d7b3ecf..f80157f 100644 (file)
@@ -1220,3 +1220,33 @@ EXPORT int app_control_request_transient_app(app_control_h app_control,
   return APP_CONTROL_ERROR_NONE;
 }
 
+EXPORT int app_control_set_auto_restart(app_control_h app_control) {
+  if (app_control == nullptr) {
+    _E("Invalid parameter");
+    return APP_CONTROL_ERROR_INVALID_PARAMETER;
+  }
+
+  auto* handle = reinterpret_cast<AppControl*>(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 ret;
+  }
+
+  return APP_CONTROL_ERROR_NONE;
+}