Fix wrong implementation of pkginfo API 85/279985/5
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 22 Aug 2022 04:07:25 +0000 (04:07 +0000)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 22 Aug 2022 10:38:37 +0000 (10:38 +0000)
The socket option of some requests have to be AUL_SOCK_NONE and AUL_SOCK_BUNDLE.
The application ID that is set to the bundle will be removed while creating
the AppRequest instance. To set the application ID to the bundle properly, we
should use the AppRequest::SetAppId() method.

Change-Id: I43cadc2aa633b8afa55375d2461e69c98467c525
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/pkginfo.cc
test/unit_tests/test_pkginfo.cc

index c3ac0dd..76c9c6a 100644 (file)
@@ -365,7 +365,7 @@ extern "C" API int aul_update_rua_stat_for_uid(bundle* b, uid_t uid) {
 
   return AppRequest(APP_UPDATE_RUA_STAT, uid)
       .With(b)
-      .Send();
+      .SendSimply();
 }
 
 extern "C" API int aul_add_rua_history_for_uid(bundle* b, uid_t uid) {
@@ -376,7 +376,7 @@ extern "C" API int aul_add_rua_history_for_uid(bundle* b, uid_t uid) {
 
   return AppRequest(APP_ADD_HISTORY, uid)
       .With(b)
-      .Send();
+      .SendSimply();
 }
 
 extern "C" API int aul_delete_rua_history_for_uid(bundle* b, uid_t uid) {
@@ -386,7 +386,7 @@ extern "C" API int aul_delete_rua_history_for_uid(bundle* b, uid_t uid) {
 
   return AppRequest(APP_REMOVE_HISTORY, uid)
       .With(std::move(kb))
-      .Send();
+      .SendSimply();
 }
 
 extern "C" API int aul_set_default_app_by_operation(bundle* b) {
@@ -395,7 +395,7 @@ extern "C" API int aul_set_default_app_by_operation(bundle* b) {
 
   return AppRequest(APP_SET_APP_CONTROL_DEFAULT_APP, getuid())
       .With(b)
-      .Send();
+      .SendSimply();
 }
 
 extern "C" API int aul_unset_default_app_by_operation(const char* appid) {
@@ -424,7 +424,7 @@ extern "C" API int aul_app_get_last_caller_pid_for_uid(int pid, uid_t uid) {
 
   return AppRequest(APP_GET_LAST_CALLER_PID, uid)
       .SetPid(pid)
-      .Send();
+      .SendSimply();
 }
 
 extern "C" API int aul_set_alias_appid(const char* alias_appid,
@@ -434,14 +434,12 @@ extern "C" API int aul_set_alias_appid(const char* alias_appid,
     return AUL_R_EINVAL;
   }
 
-  tizen_base::Bundle b {
-    { AUL_K_ALIAS_APPID, alias_appid },
-    { AUL_K_APPID, appid }
-  };
+  tizen_base::Bundle b { { AUL_K_ALIAS_APPID, alias_appid } };
 
   return AppRequest(APP_SET_ALIAS_APPID, getuid())
       .With(std::move(b))
-      .Send();
+      .SetAppId(appid)
+      .SendSimply();
 }
 
 extern "C" API int aul_unset_alias_appid(const char* alias_appid) {
@@ -453,7 +451,7 @@ extern "C" API int aul_unset_alias_appid(const char* alias_appid) {
   tizen_base::Bundle b { { AUL_K_ALIAS_APPID, alias_appid } };
   return AppRequest(APP_UNSET_ALIAS_APPID, getuid())
       .With(std::move(b))
-      .Send();
+      .SendSimply();
 }
 
 extern "C" API int aul_enable_alias_info(const char* appid) {
@@ -464,7 +462,7 @@ extern "C" API int aul_enable_alias_info(const char* appid) {
 
   return AppRequest(APP_ENABLE_ALIAS_INFO, getuid())
       .SetAppId(appid)
-      .Send();
+      .SendSimply();
 }
 
 extern "C" API int aul_disable_alias_info(const char* appid) {
@@ -475,7 +473,7 @@ extern "C" API int aul_disable_alias_info(const char* appid) {
 
   return AppRequest(APP_DISABLE_ALIAS_INFO, getuid())
       .SetAppId(appid)
-      .Send();
+      .SendSimply();
 }
 
 extern "C" API int aul_set_auto_restart(bundle* b) {
@@ -492,14 +490,14 @@ extern "C" API int aul_set_auto_restart(bundle* b) {
 
   return AppRequest(APP_SET_AUTO_RESTART, getuid())
       .With(std::move(kb))
-      .Send();
+      .SendSimply();
 }
 
 extern "C" API int aul_unset_auto_restart(void) {
   tizen_base::Bundle kb { { AUL_K_AUTO_RESTART, "false" } };
   return AppRequest(APP_SET_AUTO_RESTART, getuid())
       .With(std::move(kb))
-      .Send();
+      .SendSimply();
 }
 
 extern "C" API int aul_app_get_instance_id_bypid(int pid, char* instance_id,
@@ -544,7 +542,7 @@ extern "C" API int aul_app_is_running_with_instance_id(const char* appid,
   int ret = AppRequest(APP_IS_RUNNING, getuid())
       .SetAppId(appid)
       .SetInstId(instance_id)
-      .Send();
+      .SendSimply();
   if (ret < 0)
     return ret;
 
index b7e974b..e58ecf7 100644 (file)
@@ -39,6 +39,17 @@ using ::testing::SaveArg;
 
 namespace {
 
+constexpr const char kAppId[] = "org.tizen.helloworld";
+constexpr const char kInstanceId[] = "hello@org.tizen.helloworld";
+constexpr const char kAliasAppId[] = "org.tizen.hello";
+constexpr const char kPkgId[] = "org.tizen.helloworld";
+constexpr const pid_t kPid = 100;
+constexpr const int kStatus = 3;
+constexpr const bool kIsSubapp = false;
+constexpr const char kExec[] =
+    "/home/owner/apps_rw/org.tizen.helloworld/bin/helloworld";
+constexpr const char kRootPath[] = "/home/owner/apps_rw/org.tizen.helloworld";
+
 class Mocks : virtual public ::testing::NiceMock<SocketMock> {};
 
 }  // namespace
@@ -61,14 +72,13 @@ class PkgInfoTest : public TestFixture {
 
   tizen_base::Bundle MakeAppInfoBundle() {
     return {
-          { AUL_K_APPID, "org.tizen.helloworld" },
-          { AUL_K_PID, "100" },
-          { AUL_K_EXEC,
-            "/home/owner/apps_rw/org.tizen.helloworld/bin/helloworld" },
-          { AUL_K_PKGID, "org.tizen.helloworld" },
-          { AUL_K_INSTANCE_ID, "hello@org.tizen.helloworld" },
-          { AUL_K_STATUS, "3" },
-          { AUL_K_IS_SUBAPP, "0" }
+          { AUL_K_APPID, kAppId },
+          { AUL_K_PID, std::to_string(kPid) },
+          { AUL_K_EXEC, kExec },
+          { AUL_K_PKGID, kPkgId },
+          { AUL_K_INSTANCE_ID, kInstanceId },
+          { AUL_K_STATUS, std::to_string(kStatus) },
+          { AUL_K_IS_SUBAPP, std::to_string(kIsSubapp) }
         };
   }
 
@@ -106,13 +116,17 @@ class PkgInfoTest : public TestFixture {
 
 TEST_F(PkgInfoTest, aul_app_get_pid_P) {
   int cmd = -1;
+  int opt = 0;
+  bundle* kb = nullptr;
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
       .WillOnce(Invoke([&](int fd, const void* buf, size_t n, int flags)
           -> ssize_t {
-        const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
-        cmd = header->cmd;
+        const app_pkt_t* pkt = reinterpret_cast<const app_pkt_t*>(buf);
+        cmd = pkt->cmd;
+        opt = pkt->opt;
+        kb = bundle_decode(pkt->data, pkt->len);
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -123,9 +137,14 @@ TEST_F(PkgInfoTest, aul_app_get_pid_P) {
         return sizeof(int);
       }));
 
-  int ret = aul_app_get_pid("org.tizen.helloworld");
+  int ret = aul_app_get_pid(kAppId);
+  EXPECT_NE(kb, nullptr);
+  tizen_base::Bundle b(kb, false, true);
+
   EXPECT_EQ(ret, 100);
   EXPECT_EQ(cmd, APP_GET_PID);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_NONE));
+  EXPECT_EQ(b.GetString(AUL_K_APPID), kAppId);
 }
 
 TEST_F(PkgInfoTest, aul_app_get_pid_N) {
@@ -135,13 +154,17 @@ TEST_F(PkgInfoTest, aul_app_get_pid_N) {
 
 TEST_F(PkgInfoTest, aul_app_is_running_P) {
   int cmd = -1;
+  int opt = 0;
+  bundle* kb = nullptr;
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
       .WillOnce(Invoke([&](int fd, const void* buf, size_t n, int flags)
           -> ssize_t {
-        const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
-        cmd = header->cmd;
+        const app_pkt_t* pkt = reinterpret_cast<const app_pkt_t*>(buf);
+        cmd = pkt->cmd;
+        opt = pkt->opt;
+        kb = bundle_decode(pkt->data, pkt->len);
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -152,9 +175,14 @@ TEST_F(PkgInfoTest, aul_app_is_running_P) {
         return sizeof(int);
       }));
 
-  int ret = aul_app_is_running("org.tizen.helloworld");
+  int ret = aul_app_is_running(kAppId);
+  EXPECT_NE(kb, nullptr);
+  tizen_base::Bundle b(kb, false, true);
+
   EXPECT_EQ(ret, 1);
   EXPECT_EQ(cmd, APP_IS_RUNNING);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_NONE));
+  EXPECT_EQ(b.GetString(AUL_K_APPID), kAppId);
 }
 
 TEST_F(PkgInfoTest, aul_app_is_running_N) {
@@ -164,6 +192,7 @@ TEST_F(PkgInfoTest, aul_app_is_running_N) {
 
 TEST_F(PkgInfoTest, aul_app_get_running_app_info_P) {
   int cmd = -1;
+  int opt = 0;
   auto pkt = MakePacket(std::move(MakeAppInfoBundle()));
   EXPECT_NE(pkt, nullptr);
 
@@ -173,6 +202,7 @@ TEST_F(PkgInfoTest, aul_app_get_running_app_info_P) {
           -> ssize_t {
         const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
         cmd = header->cmd;
+        opt = header->opt;
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -193,9 +223,8 @@ TEST_F(PkgInfoTest, aul_app_get_running_app_info_P) {
 
   int ret = aul_app_get_running_app_info(
       [](const aul_app_info* app_info, void* user_data) {
-        printf("callback. appid: %s\n", app_info->appid);
         auto* test = static_cast<PkgInfoTest*>(user_data);
-        if (app_info->appid && !strcmp(app_info->appid, "org.tizen.helloworld"))
+        if (app_info->appid && !strcmp(app_info->appid, kAppId))
           test->touched_ = true;
 
         return 0;
@@ -203,6 +232,7 @@ TEST_F(PkgInfoTest, aul_app_get_running_app_info_P) {
   EXPECT_EQ(ret, AUL_R_OK);
   EXPECT_EQ(touched_, true);
   EXPECT_EQ(cmd, APP_RUNNING_INFO);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_ASYNC));
 }
 
 TEST_F(PkgInfoTest, aul_app_get_running_app_info_N) {
@@ -212,6 +242,7 @@ TEST_F(PkgInfoTest, aul_app_get_running_app_info_N) {
 
 TEST_F(PkgInfoTest, aul_app_get_all_running_app_info_P) {
   int cmd = -1;
+  int opt = 0;
   auto pkt = MakePacket(std::move(MakeAppInfoBundle()));
   EXPECT_NE(pkt, nullptr);
 
@@ -221,6 +252,7 @@ TEST_F(PkgInfoTest, aul_app_get_all_running_app_info_P) {
           -> ssize_t {
         const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
         cmd = header->cmd;
+        opt = header->opt;
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -241,9 +273,8 @@ TEST_F(PkgInfoTest, aul_app_get_all_running_app_info_P) {
 
   int ret = aul_app_get_all_running_app_info(
       [](const aul_app_info* app_info, void* user_data) {
-        printf("callback. appid: %s\n", app_info->appid);
         auto* test = static_cast<PkgInfoTest*>(user_data);
-        if (app_info->appid && !strcmp(app_info->appid, "org.tizen.helloworld"))
+        if (app_info->appid && !strcmp(app_info->appid, kAppId))
           test->touched_ = true;
 
         return 0;
@@ -251,6 +282,7 @@ TEST_F(PkgInfoTest, aul_app_get_all_running_app_info_P) {
   EXPECT_EQ(ret, AUL_R_OK);
   EXPECT_EQ(touched_, true);
   EXPECT_EQ(cmd, APP_ALL_RUNNING_INFO);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_ASYNC));
 }
 
 TEST_F(PkgInfoTest, aul_app_get_all_running_app_info_N) {
@@ -260,6 +292,7 @@ TEST_F(PkgInfoTest, aul_app_get_all_running_app_info_N) {
 
 TEST_F(PkgInfoTest, aul_app_get_running_app_instance_info_P) {
   int cmd = -1;
+  int opt = 0;
   auto pkt = MakePacket(std::move(MakeAppInfoBundle()));
   EXPECT_NE(pkt, nullptr);
 
@@ -269,6 +302,7 @@ TEST_F(PkgInfoTest, aul_app_get_running_app_instance_info_P) {
           -> ssize_t {
         const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
         cmd = header->cmd;
+        opt = header->opt;
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -289,10 +323,9 @@ TEST_F(PkgInfoTest, aul_app_get_running_app_instance_info_P) {
 
   int ret = aul_app_get_running_app_instance_info(
       [](const aul_app_info* app_info, void* user_data) {
-        printf("callback. appid: %s\n", app_info->appid);
         auto* test = static_cast<PkgInfoTest*>(user_data);
         if (app_info->instance_id &&
-            !strcmp(app_info->instance_id, "hello@org.tizen.helloworld"))
+            !strcmp(app_info->instance_id, kInstanceId))
           test->touched_ = true;
 
         return 0;
@@ -300,6 +333,7 @@ TEST_F(PkgInfoTest, aul_app_get_running_app_instance_info_P) {
   EXPECT_EQ(ret, AUL_R_OK);
   EXPECT_EQ(touched_, true);
   EXPECT_EQ(cmd, APP_RUNNING_INSTANCE_INFO);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_ASYNC));
 }
 
 TEST_F(PkgInfoTest, aul_app_get_running_app_instance_info_N) {
@@ -308,52 +342,54 @@ TEST_F(PkgInfoTest, aul_app_get_running_app_instance_info_N) {
 }
 
 TEST_F(PkgInfoTest, aul_set_preinit_appid_P) {
-  aul_set_preinit_appid("org.tizen.helloworld");
+  aul_set_preinit_appid(kAppId);
 
   char buf[256] = { 0, };
   int ret = aul_app_get_appid_bypid(getpid(), buf, sizeof(buf));
   EXPECT_EQ(ret, AUL_R_OK);
-  EXPECT_EQ(std::string(buf), "org.tizen.helloworld");
+  EXPECT_EQ(std::string(buf), kAppId);
 }
 
 TEST_F(PkgInfoTest, aul_set_preinit_pkgid_P) {
-  aul_set_preinit_pkgid("org.tizen.helloworld");
+  aul_set_preinit_pkgid(kPkgId);
 
   char buf[256] = { 0, };
   int ret = aul_app_get_pkgid_bypid(getpid(), buf, sizeof(buf));
   EXPECT_EQ(ret, AUL_R_OK);
-  EXPECT_EQ(std::string(buf), "org.tizen.helloworld");
+  EXPECT_EQ(std::string(buf), kPkgId);
 }
 
 TEST_F(PkgInfoTest, aul_set_preinit_root_path_P) {
-  std::string path("/home/owner/apps_rw/org.tizen.helloworld");
-  aul_set_preinit_root_path(path.c_str());
+  aul_set_preinit_root_path(kRootPath);
 
   auto* root_path = aul_get_preinit_root_path();
   EXPECT_NE(root_path, nullptr);
-  EXPECT_EQ(std::string(root_path), path);
+  EXPECT_EQ(std::string(root_path), kRootPath);
 }
 
 TEST_F(PkgInfoTest, aul_get_preinit_root_path_P) {
-  std::string path("/home/owner/apps_rw/org.tizen.helloworld2");
-  aul_set_preinit_root_path(path.c_str());
+  aul_set_preinit_root_path(kRootPath);
 
   auto* root_path = aul_get_preinit_root_path();
   EXPECT_NE(root_path, nullptr);
-  EXPECT_EQ(std::string(root_path), path);
+  EXPECT_EQ(std::string(root_path), kRootPath);
 }
 
 TEST_F(PkgInfoTest, aul_app_get_pkgname_bypid_P) {
   int cmd = -1;
-  auto pkt = MakePacket("org.tizen.helloworld");
+  int opt = 0;
+  bundle* kb = nullptr;
+  auto pkt = MakePacket(kAppId);
   EXPECT_NE(pkt, nullptr);
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
       .WillOnce(Invoke([&](int fd, const void* buf, size_t n, int flags)
           -> ssize_t {
-        const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
-        cmd = header->cmd;
+        const app_pkt_t* app_pkt = reinterpret_cast<const app_pkt_t*>(buf);
+        cmd = app_pkt->cmd;
+        opt = app_pkt->opt;
+        kb = bundle_decode(app_pkt->data, app_pkt->len);
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -369,8 +405,14 @@ TEST_F(PkgInfoTest, aul_app_get_pkgname_bypid_P) {
 
   char buf[256] = { 0, };
   int ret = aul_app_get_pkgname_bypid(100, buf, sizeof(buf));
+  EXPECT_NE(kb, nullptr);
+  tizen_base::Bundle b(kb, false, true);
+
   EXPECT_EQ(ret, AUL_R_OK);
-  EXPECT_EQ(std::string(buf), "org.tizen.helloworld");
+  EXPECT_EQ(cmd, APP_GET_APPID_BYPID);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_ASYNC));
+  EXPECT_EQ(b.GetString(AUL_K_PID), std::to_string(100));
+  EXPECT_EQ(std::string(buf), kAppId);
 }
 
 TEST_F(PkgInfoTest, aul_app_get_pkgname_bypid_N) {
@@ -384,15 +426,19 @@ TEST_F(PkgInfoTest, aul_app_get_pkgname_bypid_N) {
 
 TEST_F(PkgInfoTest, aul_app_get_appid_bypid_P) {
   int cmd = -1;
-  auto pkt = MakePacket("org.tizen.helloworld");
+  int opt = 0;
+  bundle* kb = nullptr;
+  auto pkt = MakePacket(kAppId);
   EXPECT_NE(pkt, nullptr);
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
       .WillOnce(Invoke([&](int fd, const void* buf, size_t n, int flags)
           -> ssize_t {
-        const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
-        cmd = header->cmd;
+        const app_pkt_t* app_pkt = reinterpret_cast<const app_pkt_t*>(buf);
+        cmd = app_pkt->cmd;
+        opt = app_pkt->opt;
+        kb = bundle_decode(app_pkt->data, app_pkt->len);
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -408,9 +454,14 @@ TEST_F(PkgInfoTest, aul_app_get_appid_bypid_P) {
 
   char buf[256] = { 0, };
   int ret = aul_app_get_appid_bypid(100, buf, sizeof(buf));
+  EXPECT_NE(kb, nullptr);
+  tizen_base::Bundle b(kb, false, true);
+
   EXPECT_EQ(ret, AUL_R_OK);
-  EXPECT_EQ(std::string(buf), "org.tizen.helloworld");
+  EXPECT_EQ(std::string(buf), kAppId);
   EXPECT_EQ(cmd, APP_GET_APPID_BYPID);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_ASYNC));
+  EXPECT_EQ(b.GetString(AUL_K_PID), std::to_string(100));
 }
 
 TEST_F(PkgInfoTest, aul_app_get_appid_bypid_N) {
@@ -424,15 +475,19 @@ TEST_F(PkgInfoTest, aul_app_get_appid_bypid_N) {
 
 TEST_F(PkgInfoTest, aul_app_get_pkgid_bypid_P) {
   int cmd = -1;
-  auto pkt = MakePacket("org.tizen.helloworld");
+  int opt = 0;
+  bundle* kb = nullptr;
+  auto pkt = MakePacket(kPkgId);
   EXPECT_NE(pkt, nullptr);
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
       .WillOnce(Invoke([&](int fd, const void* buf, size_t n, int flags)
           -> ssize_t {
-        const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
-        cmd = header->cmd;
+        const app_pkt_t* app_pkt = reinterpret_cast<const app_pkt_t*>(buf);
+        cmd = app_pkt->cmd;
+        opt = app_pkt->opt;
+        kb = bundle_decode(app_pkt->data, app_pkt->len);
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -448,9 +503,14 @@ TEST_F(PkgInfoTest, aul_app_get_pkgid_bypid_P) {
 
   char buf[256] = { 0, };
   int ret = aul_app_get_pkgid_bypid(100, buf, sizeof(buf));
+  EXPECT_NE(kb, nullptr);
+  tizen_base::Bundle b(kb, false, true);
+
   EXPECT_EQ(ret, AUL_R_OK);
-  EXPECT_EQ(std::string(buf), "org.tizen.helloworld");
+  EXPECT_EQ(std::string(buf), kPkgId);
   EXPECT_EQ(cmd, APP_GET_PKGID_BYPID);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_ASYNC));
+  EXPECT_EQ(b.GetString(AUL_K_PID), std::to_string(100));
 }
 
 TEST_F(PkgInfoTest, aul_app_get_pkgid_bypid_N) {
@@ -464,6 +524,7 @@ TEST_F(PkgInfoTest, aul_app_get_pkgid_bypid_N) {
 
 TEST_F(PkgInfoTest, aul_update_rua_stat_for_uid_P) {
   int cmd = -1;
+  int opt = 0;
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
@@ -471,6 +532,7 @@ TEST_F(PkgInfoTest, aul_update_rua_stat_for_uid_P) {
           -> ssize_t {
         const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
         cmd = header->cmd;
+        opt = header->opt;
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -485,6 +547,7 @@ TEST_F(PkgInfoTest, aul_update_rua_stat_for_uid_P) {
   int ret = aul_update_rua_stat_for_uid(b.GetHandle(), getuid());
   EXPECT_EQ(ret, AUL_R_OK);
   EXPECT_EQ(cmd, APP_UPDATE_RUA_STAT);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_NONE));
 }
 
 TEST_F(PkgInfoTest, aul_update_rua_stat_for_uid_N) {
@@ -494,6 +557,7 @@ TEST_F(PkgInfoTest, aul_update_rua_stat_for_uid_N) {
 
 TEST_F(PkgInfoTest, aul_add_history_for_uid_P) {
   int cmd = -1;
+  int opt = 0;
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
@@ -501,6 +565,7 @@ TEST_F(PkgInfoTest, aul_add_history_for_uid_P) {
           -> ssize_t {
         const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
         cmd = header->cmd;
+        opt = header->opt;
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -515,6 +580,7 @@ TEST_F(PkgInfoTest, aul_add_history_for_uid_P) {
   int ret = aul_add_rua_history_for_uid(b.GetHandle(), getuid());
   EXPECT_EQ(ret, AUL_R_OK);
   EXPECT_EQ(cmd, APP_ADD_HISTORY);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_NONE));
 }
 
 TEST_F(PkgInfoTest, aul_add_history_for_uid_N) {
@@ -524,6 +590,7 @@ TEST_F(PkgInfoTest, aul_add_history_for_uid_N) {
 
 TEST_F(PkgInfoTest, aul_delete_history_for_uid_P) {
   int cmd = -1;
+  int opt = 0;
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
@@ -531,6 +598,7 @@ TEST_F(PkgInfoTest, aul_delete_history_for_uid_P) {
           -> ssize_t {
         const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
         cmd = header->cmd;
+        opt = header->opt;
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -545,10 +613,12 @@ TEST_F(PkgInfoTest, aul_delete_history_for_uid_P) {
   int ret = aul_delete_rua_history_for_uid(b.GetHandle(), getuid());
   EXPECT_EQ(ret, AUL_R_OK);
   EXPECT_EQ(cmd, APP_REMOVE_HISTORY);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_NONE));
 }
 
 TEST_F(PkgInfoTest, aul_set_default_app_by_operation_P) {
   int cmd = -1;
+  int opt = 0;
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
@@ -556,6 +626,7 @@ TEST_F(PkgInfoTest, aul_set_default_app_by_operation_P) {
           -> ssize_t {
         const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
         cmd = header->cmd;
+        opt = header->opt;
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -570,6 +641,7 @@ TEST_F(PkgInfoTest, aul_set_default_app_by_operation_P) {
   int ret = aul_set_default_app_by_operation(b.GetHandle());
   EXPECT_EQ(ret, AUL_R_OK);
   EXPECT_EQ(cmd, APP_SET_APP_CONTROL_DEFAULT_APP);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_NONE));
 }
 
 TEST_F(PkgInfoTest, aul_set_default_app_by_operation_N) {
@@ -579,6 +651,7 @@ TEST_F(PkgInfoTest, aul_set_default_app_by_operation_N) {
 
 TEST_F(PkgInfoTest, aul_unset_default_app_by_operation_P) {
   int cmd = -1;
+  int opt = 0;
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
@@ -586,6 +659,7 @@ TEST_F(PkgInfoTest, aul_unset_default_app_by_operation_P) {
           -> ssize_t {
         const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
         cmd = header->cmd;
+        opt = header->opt;
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -596,9 +670,10 @@ TEST_F(PkgInfoTest, aul_unset_default_app_by_operation_P) {
         return sizeof(int);
       }));
 
-  int ret = aul_unset_default_app_by_operation("org.tizen.helloworld");
+  int ret = aul_unset_default_app_by_operation(kAppId);
   EXPECT_EQ(ret, AUL_R_OK);
   EXPECT_EQ(cmd, APP_UNSET_APP_CONTROL_DEFAULT_APP);
+  EXPECT_EQ(opt, AUL_SOCK_NONE);
 }
 
 TEST_F(PkgInfoTest, aul_unset_default_app_by_operation_N) {
@@ -608,13 +683,17 @@ TEST_F(PkgInfoTest, aul_unset_default_app_by_operation_N) {
 
 TEST_F(PkgInfoTest, aul_app_get_last_caller_pid_P) {
   int cmd = -1;
+  int opt = 0;
+  bundle* kb = nullptr;
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
       .WillOnce(Invoke([&](int fd, const void* buf, size_t n, int flags)
           -> ssize_t {
-        const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
-        cmd = header->cmd;
+        const app_pkt_t* pkt = reinterpret_cast<const app_pkt_t*>(buf);
+        cmd = pkt->cmd;
+        opt = pkt->opt;
+        kb = bundle_decode(pkt->data, pkt->len);
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -626,8 +705,13 @@ TEST_F(PkgInfoTest, aul_app_get_last_caller_pid_P) {
       }));
 
   int ret = aul_app_get_last_caller_pid(100);
+  EXPECT_NE(kb, nullptr);
+  tizen_base::Bundle b(kb, false, true);
+
   EXPECT_EQ(ret, getpid());
   EXPECT_EQ(cmd, APP_GET_LAST_CALLER_PID);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_NONE));
+  EXPECT_EQ(b.GetString(AUL_K_PID), std::to_string(100));
 }
 
 TEST_F(PkgInfoTest, aul_app_get_last_caller_pid_N) {
@@ -637,13 +721,17 @@ TEST_F(PkgInfoTest, aul_app_get_last_caller_pid_N) {
 
 TEST_F(PkgInfoTest, aul_set_alias_appid_P) {
   int cmd = -1;
+  int opt = 0;
+  bundle* kb = nullptr;
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
       .WillOnce(Invoke([&](int fd, const void* buf, size_t n, int flags)
           -> ssize_t {
-        const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
-        cmd = header->cmd;
+        const app_pkt_t* pkt = reinterpret_cast<const app_pkt_t*>(buf);
+        cmd = pkt->cmd;
+        opt = pkt->opt;
+        kb = bundle_decode(pkt->data, pkt->len);
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -654,16 +742,22 @@ TEST_F(PkgInfoTest, aul_set_alias_appid_P) {
         return sizeof(int);
       }));
 
-  int ret = aul_set_alias_appid("org.tizen.hello", "org.tizen.helloworld");
+  int ret = aul_set_alias_appid(kAliasAppId, kAppId);
+  EXPECT_NE(kb, nullptr);
+  tizen_base::Bundle b(kb, false, true);
+
   EXPECT_EQ(ret, AUL_R_OK);
   EXPECT_EQ(cmd, APP_SET_ALIAS_APPID);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_NONE));
+  EXPECT_EQ(b.GetString(AUL_K_ALIAS_APPID), kAliasAppId);
+  EXPECT_EQ(b.GetString(AUL_K_APPID), kAppId);
 }
 
 TEST_F(PkgInfoTest, aul_set_alias_appid_N) {
-  int ret = aul_set_alias_appid(nullptr, "org.tizen.helloworld");
+  int ret = aul_set_alias_appid(nullptr, kAppId);
   EXPECT_EQ(ret, AUL_R_EINVAL);
 
-  ret = aul_set_alias_appid("org.tizen.hello", nullptr);
+  ret = aul_set_alias_appid(kAliasAppId, nullptr);
   EXPECT_EQ(ret, AUL_R_EINVAL);
 
   ret = aul_set_alias_appid(nullptr, nullptr);
@@ -672,13 +766,17 @@ TEST_F(PkgInfoTest, aul_set_alias_appid_N) {
 
 TEST_F(PkgInfoTest, aul_unset_alias_appid_P) {
   int cmd = -1;
+  int opt = 0;
+  bundle* kb = nullptr;
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
       .WillOnce(Invoke([&](int fd, const void* buf, size_t n, int flags)
           -> ssize_t {
-        const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
-        cmd = header->cmd;
+        const app_pkt_t* pkt = reinterpret_cast<const app_pkt_t*>(buf);
+        cmd = pkt->cmd;
+        opt = pkt->opt;
+        kb = bundle_decode(pkt->data, pkt->len);
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -689,9 +787,14 @@ TEST_F(PkgInfoTest, aul_unset_alias_appid_P) {
         return sizeof(int);
       }));
 
-  int ret = aul_unset_alias_appid("org.tizen.hello");
+  int ret = aul_unset_alias_appid(kAliasAppId);
+  EXPECT_NE(kb, nullptr);
+  tizen_base::Bundle b(kb, false, true);
+
   EXPECT_EQ(ret, AUL_R_OK);
   EXPECT_EQ(cmd, APP_UNSET_ALIAS_APPID);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_BUNDLE));
+  EXPECT_EQ(b.GetString(AUL_K_ALIAS_APPID), kAliasAppId);
 }
 
 TEST_F(PkgInfoTest, aul_unset_alias_appid_N) {
@@ -701,13 +804,17 @@ TEST_F(PkgInfoTest, aul_unset_alias_appid_N) {
 
 TEST_F(PkgInfoTest, aul_enable_alias_info_P) {
   int cmd = -1;
+  int opt = 0;
+  bundle* kb = nullptr;
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
       .WillOnce(Invoke([&](int fd, const void* buf, size_t n, int flags)
           -> ssize_t {
-        const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
-        cmd = header->cmd;
+        const app_pkt_t* pkt = reinterpret_cast<const app_pkt_t*>(buf);
+        cmd = pkt->cmd;
+        opt = pkt->opt;
+        kb = bundle_decode(pkt->data, pkt->len);
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -718,9 +825,14 @@ TEST_F(PkgInfoTest, aul_enable_alias_info_P) {
         return sizeof(int);
       }));
 
-  int ret = aul_enable_alias_info("org.tizen.helloworld");
+  int ret = aul_enable_alias_info(kAppId);
+  EXPECT_NE(kb, nullptr);
+  tizen_base::Bundle b(kb, false, true);
+
   EXPECT_EQ(ret, AUL_R_OK);
   EXPECT_EQ(cmd, APP_ENABLE_ALIAS_INFO);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_NONE));
+  EXPECT_EQ(b.GetString(AUL_K_APPID), kAppId);
 }
 
 TEST_F(PkgInfoTest, aul_enable_alias_info_N) {
@@ -730,13 +842,17 @@ TEST_F(PkgInfoTest, aul_enable_alias_info_N) {
 
 TEST_F(PkgInfoTest, aul_disable_alias_info_P) {
   int cmd = -1;
+  int opt = 0;
+  bundle* kb = nullptr;
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
       .WillOnce(Invoke([&](int fd, const void* buf, size_t n, int flags)
           -> ssize_t {
-        const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
-        cmd = header->cmd;
+        const app_pkt_t* pkt = reinterpret_cast<const app_pkt_t*>(buf);
+        cmd = pkt->cmd;
+        opt = pkt->opt;
+        kb = bundle_decode(pkt->data, pkt->len);
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -747,9 +863,14 @@ TEST_F(PkgInfoTest, aul_disable_alias_info_P) {
         return sizeof(int);
       }));
 
-  int ret = aul_disable_alias_info("org.tizen.helloworld");
+  int ret = aul_disable_alias_info(kAppId);
+  EXPECT_NE(kb, nullptr);
+  tizen_base::Bundle b(kb, false, true);
+
   EXPECT_EQ(ret, AUL_R_OK);
   EXPECT_EQ(cmd, APP_DISABLE_ALIAS_INFO);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_NONE));
+  EXPECT_EQ(b.GetString(AUL_K_APPID), kAppId);
 }
 
 TEST_F(PkgInfoTest, aul_disable_alias_info_N) {
@@ -759,6 +880,7 @@ TEST_F(PkgInfoTest, aul_disable_alias_info_N) {
 
 TEST_F(PkgInfoTest, aul_set_auto_restart_P) {
   int cmd = -1;
+  int opt = 0;
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
@@ -766,6 +888,7 @@ TEST_F(PkgInfoTest, aul_set_auto_restart_P) {
           -> ssize_t {
         const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
         cmd = header->cmd;
+        opt = header->opt;
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -779,10 +902,12 @@ TEST_F(PkgInfoTest, aul_set_auto_restart_P) {
   int ret = aul_set_auto_restart(nullptr);
   EXPECT_EQ(ret, AUL_R_OK);
   EXPECT_EQ(cmd, APP_SET_AUTO_RESTART);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_NONE));
 }
 
 TEST_F(PkgInfoTest, aul_unset_auto_restart_P) {
   int cmd = -1;
+  int opt = 0;
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
@@ -790,6 +915,7 @@ TEST_F(PkgInfoTest, aul_unset_auto_restart_P) {
           -> ssize_t {
         const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
         cmd = header->cmd;
+        opt = header->opt;
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -803,19 +929,24 @@ TEST_F(PkgInfoTest, aul_unset_auto_restart_P) {
   int ret = aul_unset_auto_restart();
   EXPECT_EQ(ret, AUL_R_OK);
   EXPECT_EQ(cmd, APP_SET_AUTO_RESTART);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_NONE));
 }
 
 TEST_F(PkgInfoTest, aul_app_get_instance_id_bypid_P) {
   int cmd = -1;
-  auto pkt = MakePacket("hello@org.tizen.helloworld");
+  int opt = 0;
+  bundle* kb = nullptr;
+  auto pkt = MakePacket(kInstanceId);
   EXPECT_NE(pkt, nullptr);
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
       .WillOnce(Invoke([&](int fd, const void* buf, size_t n, int flags)
           -> ssize_t {
-        const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
-        cmd = header->cmd;
+        const app_pkt_t* app_pkt = reinterpret_cast<const app_pkt_t*>(buf);
+        cmd = app_pkt->cmd;
+        opt = app_pkt->opt;
+        kb = bundle_decode(app_pkt->data, app_pkt->len);
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -831,9 +962,14 @@ TEST_F(PkgInfoTest, aul_app_get_instance_id_bypid_P) {
 
   char buf[512] = { 0, };
   int ret = aul_app_get_instance_id_bypid(getpid(), buf, sizeof(buf));
+  EXPECT_NE(kb, nullptr);
+  tizen_base::Bundle b(kb, false, true);
+
   EXPECT_EQ(ret, AUL_R_OK);
   EXPECT_EQ(cmd, APP_GET_INSTANCE_ID_BYPID);
-  EXPECT_EQ(std::string(buf), "hello@org.tizen.helloworld");
+  EXPECT_EQ(std::string(buf), kInstanceId);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_ASYNC));
+  EXPECT_EQ(b.GetString(AUL_K_PID), std::to_string(getpid()));
 }
 
 TEST_F(PkgInfoTest, aul_app_get_instance_id_bypid_N) {
@@ -847,13 +983,17 @@ TEST_F(PkgInfoTest, aul_app_get_instance_id_bypid_N) {
 
 TEST_F(PkgInfoTest, aul_app_is_running_with_instance_id_P) {
   int cmd = -1;
+  int opt = 0;
+  bundle* kb = nullptr;
 
   EXPECT_CALL(GetMock<SocketMock>(), send(_, _, _, _))
       .Times(1)
       .WillOnce(Invoke([&](int fd, const void* buf, size_t n, int flags)
           -> ssize_t {
-        const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
-        cmd = header->cmd;
+        const app_pkt_t* pkt = reinterpret_cast<const app_pkt_t*>(buf);
+        cmd = pkt->cmd;
+        opt = pkt->opt;
+        kb = bundle_decode(pkt->data, pkt->len);
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -865,26 +1005,31 @@ TEST_F(PkgInfoTest, aul_app_is_running_with_instance_id_P) {
       }));
 
   bool running = false;
-  int ret = aul_app_is_running_with_instance_id("org.tizen.helloworld",
-      "hello@org.tizen.helloworld", &running);
+  int ret = aul_app_is_running_with_instance_id(kAppId, kInstanceId, &running);
+  EXPECT_NE(kb, nullptr);
+  tizen_base::Bundle b(kb, false, true);
+
   EXPECT_EQ(ret, AUL_R_OK);
   EXPECT_EQ(cmd, APP_IS_RUNNING);
   EXPECT_EQ(running, true);
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_NONE));
+  EXPECT_EQ(b.GetString(AUL_K_APPID), kAppId);
+  EXPECT_EQ(b.GetString(AUL_K_INSTANCE_ID), kInstanceId);
 }
 
 TEST_F(PkgInfoTest, aul_app_is_running_with_instance_id_N) {
-  int ret = aul_app_is_running_with_instance_id(nullptr,
-      "hello@org.tizen.helloworld", nullptr);
+  int ret = aul_app_is_running_with_instance_id(nullptr, kInstanceId, nullptr);
   EXPECT_EQ(ret, AUL_R_EINVAL);
 
-  ret = aul_app_is_running_with_instance_id("org.tizen.helloworld", nullptr,
+  ret = aul_app_is_running_with_instance_id(kAppId, nullptr,
       nullptr);
   EXPECT_EQ(ret, AUL_R_EINVAL);
 }
 
 TEST_F(PkgInfoTest, aul_get_default_app_P) {
   int cmd = -1;
-  tizen_base::Bundle b { { AUL_K_APPID, "org.tizen.helloworld" } };
+  int opt = 0;
+  tizen_base::Bundle b { { AUL_K_APPID, kAppId } };
   auto pkt = MakePacket(b);
   EXPECT_NE(pkt, nullptr);
 
@@ -894,6 +1039,7 @@ TEST_F(PkgInfoTest, aul_get_default_app_P) {
           -> ssize_t {
         const app_pkt_t* header = reinterpret_cast<const app_pkt_t*>(buf);
         cmd = header->cmd;
+        opt = header->opt;
         return n;
       }));
   EXPECT_CALL(GetMock<SocketMock>(), recv(_, _, _, _))
@@ -913,7 +1059,8 @@ TEST_F(PkgInfoTest, aul_get_default_app_P) {
   std::unique_ptr<char, decltype(std::free)*> appid_auto(appid, std::free);
   EXPECT_EQ(ret, AUL_R_OK);
   EXPECT_EQ(cmd, APP_GET_APP_CONTROL_DEFAULT_APP);
-  EXPECT_EQ(std::string(appid), "org.tizen.helloworld");
+  EXPECT_EQ(opt, (AUL_SOCK_BUNDLE | AUL_SOCK_ASYNC));
+  EXPECT_EQ(std::string(appid), kAppId);
 }
 
 TEST_F(PkgInfoTest, aul_get_default_app_N) {