Add new APIs 26/267126/10
authorChanggyu Choi <changyu.choi@samsung.com>
Fri, 26 Nov 2021 02:54:45 +0000 (11:54 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Wed, 22 Dec 2021 07:55:59 +0000 (16:55 +0900)
This patch adds apis for runtime restart app setting.

Adds:
 - aul_set_auto_restart()
 - aul_unset_auto_restart()

Change-Id: I302f64b97203817c1d4abe26f22613464566bb60
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
include/aul.h
include/aul_cmd.h
include/aul_key.h
src/aul_cmd.c
src/pkginfo.c

index 41464ba..8eff785 100644 (file)
@@ -3013,6 +3013,16 @@ int aul_status_update_v2(int status);
  */
 int aul_get_default_app(bundle *b, char **appid);
 
+/**
+ * @remarks This function is only for App Framework internally.
+ */
+int aul_set_auto_restart(bundle *b);
+
+/**
+ * @remarks This function is only for App Framework internally.
+ */
+int aul_unset_auto_restart();
+
 #ifdef __cplusplus
        }
 #endif
index 793db1c..1ce5923 100644 (file)
@@ -214,6 +214,7 @@ enum app_cmd {
        PROC_GROUP_REMOVE = 170,
 
        APP_CONNECT = 171,
+       APP_SET_AUTO_RESTART = 172,
 
        APP_CMD_MAX
 };
index b7f5ad0..771901b 100644 (file)
  * @since_tizen 6.5
  */
 #define AUL_K_PROC_EXTRA                "__AUL_PROC_EXTRA__"
+
+/**
+ * @brief Definition for AUL: The flag of the auto restart.
+ * @since_tizen 7.0
+ */
+#define AUL_K_AUTO_RESTART              "__AUL_AUTO_RESTART__"
+
+/**
+ * @brief Definition for AUL: The bundle data for auto restart.
+ * @since_tizen 7.0
+ */
+#define AUL_K_RESTART_EXTRA             "__AUL_RESTART_EXTRA__"
index daf62ec..b747792 100644 (file)
@@ -216,6 +216,7 @@ API const char *aul_cmd_convert_to_string(int cmd)
                "PROC_GROUP_REMOVE",
 
                "APP_CONNECT",
+               "APP_SET_AUTO_RESTART",
 
                "CUSTOM_COMMAND"
        };
index 54e3f73..8fb6c82 100644 (file)
@@ -613,6 +613,61 @@ API int aul_unset_alias_appid(const char *alias_appid)
        return AUL_R_OK;
 }
 
+API int aul_set_auto_restart(bundle *b)
+{
+       int ret;
+       bundle *kb;
+       bundle_raw *raw;
+       int len;
+
+       kb = bundle_create();
+       if (!kb) {
+               _E("Out of memory");
+               return AUL_R_ENOMEM;
+       }
+
+       bundle_add(kb, AUL_K_AUTO_RESTART, "true");
+       if (b) {
+               ret = bundle_encode(b, &raw, &len);
+               if (ret != BUNDLE_ERROR_NONE) {
+                       bundle_free(kb);
+                       return AUL_R_EINVAL;
+               }
+
+               bundle_add(b, AUL_K_RESTART_EXTRA, (const char *)raw);
+               bundle_free_encoded_rawdata(&raw);
+       }
+       ret = aul_sock_send_bundle(AUL_UTIL_PID, getuid(),
+                       APP_SET_AUTO_RESTART, kb, AUL_SOCK_NONE);
+       bundle_free(kb);
+       if (ret != AUL_R_OK)
+               return aul_error_convert(ret);
+
+       return AUL_R_OK;
+}
+
+API int aul_unset_auto_restart()
+{
+       int ret;
+       bundle *kb;
+
+       kb = bundle_create();
+       if (kb == NULL) {
+               _E("out of memory");
+               return AUL_R_ERROR;
+       }
+
+       bundle_add(kb, AUL_K_AUTO_RESTART, "false");
+
+       ret = aul_sock_send_bundle(AUL_UTIL_PID, getuid(),
+                                  APP_SET_AUTO_RESTART, kb, AUL_SOCK_NONE);
+       bundle_free(kb);
+       if (ret != AUL_R_OK)
+               return aul_error_convert(ret);
+
+       return AUL_R_OK;
+}
+
 API int aul_enable_alias_info(const char *appid)
 {
        int ret;