Adds new internal apis 83/318583/2
authorChanggyu Choi <changyu.choi@samsung.com>
Tue, 21 Jan 2025 01:43:44 +0000 (10:43 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Tue, 21 Jan 2025 02:12:00 +0000 (11:12 +0900)
This is for omitting resinfo feature from fast launch.

Adds:
 - aul_launch_app_fast_without_resinfo()
 - aul_launch_app_fast_without_resinfo_for_uid()

Change-Id: Ie74f193b8367d7d0e65c6138b503f244b172030d
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
src/aul/include/aul.h
src/aul/launch.cc
src/tool/app_launcher/app_launcher.c

index 8c93f5fbac4a83d2ea1f08f02370d4f42d20e528..e91aa6f4807065590355a8f1836681d9d5aeebd9 100644 (file)
@@ -3416,7 +3416,7 @@ int aul_terminate_pid_for_oom(pid_t pid);
 
 /**
  * @brief Sends an application launch request before amd ready.
- * @since_tizen 10.0
+ * @since_tizen 9.0
  * @details This is fast version of aul_launch_app().
  *          This is functionally similar to the app_launcher -f option.
  * @param[in]  appid application name to be run as callee
@@ -3432,6 +3432,25 @@ int aul_launch_app_fast(const char *appid, bundle *bundle);
 
 int aul_launch_app_fast_for_uid(const char *appid, bundle *bundle, uid_t uid);
 
+
+/**
+ * @brief Sends an application launch request without resinfo before amd ready.
+ * @since_tizen 9.0
+ * @details This is fast version of aul_launch_app().
+ *          This is functionally similar to the app_launcher -f option.
+ * @param[in]  appid application name to be run as callee
+ * @param[in]  kb    bundle to be passed to callee
+ * @return     callee's pid if success, negative value(<0) if fail
+ * @retval     AUL_R_OK        - success
+ * @retval     AUL_R_EINVAL    - invaild application name
+ * @retval     AUL_R_ECOM      - internal AUL IPC error
+ * @retval     AUL_R_ERROR     - general error
+ * @remarks This function is only for App Framework internally.
+ */
+int aul_launch_app_fast_without_resinfo(const char *appid, bundle *bundle);
+
+int aul_launch_app_fast_without_resinfo_for_uid(const char *appid, bundle *bundle, uid_t uid);
+
 #ifdef __cplusplus
         }
 #endif
index 9e19ad490ed15e148a8338e14bfc2db3a4694b52..7dbcb33b4d0fd0641cace22987fd233036864a21 100644 (file)
@@ -233,7 +233,7 @@ static int GetGles(void)
   return gles;
 }
 
-bool SetAppinfoForLaunchpad(bundle* kb, std::string_view appid, uid_t uid) {
+bool SetAppinfoForLaunchpad(bundle* kb, std::string_view appid, uid_t uid, bool res_info = true) {
   char *pkgid = nullptr;
   char *exec = nullptr;
   char *apptype = nullptr;
@@ -319,7 +319,9 @@ bool SetAppinfoForLaunchpad(bundle* kb, std::string_view appid, uid_t uid) {
   bundle_add(kb, AUL_K_FAST_LAUNCH, "true");
 
   aul_svc_set_loader_id(kb, PAD_LOADER_ID_DIRECT);
-  SetResInfo(handle, uid, kb);
+  if (res_info)
+    SetResInfo(handle, uid, kb);
+
   return true;
 }
 
@@ -1158,3 +1160,55 @@ extern "C" int aul_launch_app_fast_for_uid(const char *appid,
 
   return pid;
 }
+
+
+extern "C" int aul_launch_app_fast_without_resinfo(const char* appid, bundle* bundle) {
+  return aul_launch_app_fast_without_resinfo_for_uid(appid, bundle, getuid());
+}
+
+extern "C" int aul_launch_app_fast_without_resinfo_for_uid(const char *appid,
+    bundle* bundle, uid_t uid) {
+  if (appid == nullptr) {
+    _E("Invalid parameter");
+    return AUL_R_EINVAL;
+  }
+
+  if (access(kAmdReadyPath, F_OK) == 0) {
+    bundle_del(bundle, AUL_K_FAST_LAUNCH);
+    return aul_launch_app_for_uid(appid, bundle, uid);
+  }
+
+  _W("without resinfo");
+  if (!SetAppinfoForLaunchpad(bundle, appid, uid, false)) {
+    _E("Failed to set appinfo. appid: %s, uid: %u", appid, uid);
+    return AUL_R_ERROR;
+  }
+
+  std::string socket_path = "/run/aul/daemons/" + std::to_string(uid) + "/" +
+      kLaunchpadProcessPoolSock;
+
+  int retry_count = 0;
+  while (access(socket_path.c_str(), F_OK) != 0) {
+    usleep(100 * 1000);
+    if (++retry_count > 100) {
+      _E("%s is not created. appid: %s, uid: %u", socket_path.c_str(), appid,
+          uid);
+      break;
+    }
+  }
+
+  int fd = aul_sock_create_launchpad_client_without_timeout(
+      kLaunchpadProcessPoolSock, uid);
+  if (fd < 0) {
+    _E("Failed to create client socket. appid: %s, error: %d", appid, fd);
+    return AUL_R_ERROR;
+  }
+
+  pid_t pid = aul_sock_send_bundle_with_fd(fd, 0, bundle, AUL_SOCK_NONE);
+  if (pid <= 0) {
+    _E("Failed to send request. appid: %s, error: %d", appid, pid);
+    return AUL_R_ERROR;
+  }
+
+  return pid;
+}
index 96c3f96fc1583e67d362f907537624d544be4849..780c85d2c9ee752e62662d4a355bc8001a2b88b8 100644 (file)
@@ -47,6 +47,7 @@ struct launch_arg {
        bool web_debug;
        bool sync;
        bool amd_ready;
+       bool resinfo;
 };
 
 enum command_e {
@@ -65,6 +66,7 @@ enum option_e {
        OPT_DEBUG,
        OPT_WEB_DEBUG,
        OPT_USER,
+       OPT_RESINFO,
        OPT_MAX,
 };
 
@@ -185,6 +187,15 @@ static GOptionEntry opt_entries[] = {
                .description = "Specify the user ID",
                .arg_description = "USER ID"
        },
+       {
+               .long_name = "resinfo",
+               .short_name = 'R',
+               .flags = 0,
+               .arg = G_OPTION_ARG_NONE,
+               .arg_data = &opt[OPT_RESINFO],
+               .description = "Enable resinfo feature, Use only for fast launch",
+               .arg_description = NULL
+       },
        {
                NULL
        }
@@ -488,7 +499,10 @@ static int __cmd_fast_start_init(struct launch_arg *arg)
 
 static int __cmd_fast_start_run(struct launch_arg *arg)
 {
-       arg->pid = aul_launch_app_fast_for_uid(arg->appid, arg->b, arg->uid);
+       if (arg->resinfo)
+               arg->pid = aul_launch_app_fast_for_uid(arg->appid, arg->b, arg->uid);
+       else
+               arg->pid = aul_launch_app_fast_without_resinfo_for_uid(arg->appid, arg->b, arg->uid);
        if (arg->pid <= 0) {
                fprintf(stderr, "... launch failed\n");
                return -1;
@@ -571,6 +585,7 @@ static struct launch_arg *__create_launch_arg(int argc, char **argv)
 
        launch_arg->debug = GPOINTER_TO_INT(opt[OPT_DEBUG]);
        launch_arg->web_debug = GPOINTER_TO_INT(opt[OPT_WEB_DEBUG]);
+       launch_arg->resinfo = GPOINTER_TO_INT(opt[OPT_RESINFO]);
        launch_arg->b = __create_bundle(argc, argv);
        if (launch_arg->b) {
                val = bundle_get_val(launch_arg->b, "__LAUNCH_APP_MODE__");