Add aul_package_pre_event_send() 92/280292/8
authorChanggyu Choi <changyu.choi@samsung.com>
Fri, 26 Aug 2022 08:18:39 +0000 (17:18 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Tue, 6 Sep 2022 03:59:27 +0000 (12:59 +0900)
This api send signal to amd before sending pkg event to listeners.
amd should reload appinfo before some apps that is listening pkg event.

Change-Id: I82b4d8f8a8e5d1a93ee8d1e7aa13f81df34a077d
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.cc

index df7c0b9..b3bf3fb 100644 (file)
@@ -3099,6 +3099,11 @@ int aul_set_auto_restart(bundle *b);
  */
 int aul_unset_auto_restart();
 
+/**
+ * @remarks This function is only for App Framework internally.
+ */
+int aul_package_pre_event_send(uid_t uid, bundle *b);
+
 #ifdef __cplusplus
         }
 #endif
index 40562e0..4f180b9 100644 (file)
@@ -218,6 +218,9 @@ enum app_cmd {
        BOOT_SEQUENCE_START_APP = 173,
        BOOT_SEQUENCE_GET_APPINFO_LIST = 174,
        BOOT_SEQUENCE_RELOAD = 175,
+
+       PKG_PRE_EVENT_SEND = 176,
+
        APP_CMD_MAX
 };
 
index dfff008..31911b8 100644 (file)
  * @since_tizen 5.0
  */
 #define AUL_K_COMPLICATION_MODE         "__AUL_COMPLICATION_MODE__"
+
+/**
+ * @brief Definition for AUL: The package event name.
+ * @since_tizen 7.0
+ */
+#define AUL_K_PKG_EVENT_NAME "__AUL_K_PKG_EVENT_NAME__"
+
+/**
+ * @brief Definition for AUL: The package event
+ * @since_tizen 7.0
+ */
+#define AUL_K_PKG_EVENT_RESULT "__AUL_K_PKG_EVENT_RESULT__"
index f244c8e..cabc4ab 100644 (file)
@@ -221,6 +221,8 @@ API const char *aul_cmd_convert_to_string(int cmd)
                "BOOT_SEQUENCE_GET_APPINFO_LIST",
                "BOOT_SEQUENCE_RELOAD",
 
+               "PKG_PRE_EVENT_SEND",
+
                "CUSTOM_COMMAND"
        };
 
index 76c9c6a..d70cf6b 100644 (file)
@@ -21,6 +21,7 @@
 #include <bundle_cpp.h>
 #include <bundle_internal.h>
 
+#include <atomic>
 #include <string>
 #include <memory>
 
@@ -46,6 +47,21 @@ constexpr const char* kAppInfoKeys[] = {
   AUL_K_IS_SUBAPP,
 };
 
+constexpr const char kPathAmdReady[] = "/run/.amd_ready";
+
+bool IsAmdReady() {
+  static std::atomic<bool> amd_ready = false;
+  if (amd_ready)
+    return amd_ready;
+
+  if (access(kPathAmdReady, F_OK) == 0) {
+    amd_ready.exchange(true);
+    return amd_ready;
+  }
+
+  return false;
+}
+
 class Context {
  public:
   Context() = default;
@@ -602,3 +618,17 @@ extern "C" API int aul_get_default_app(bundle* b, char** appid) {
 
   return AUL_R_OK;
 }
+
+extern "C" API int aul_package_pre_event_send(uid_t uid, bundle* b) {
+  if (b == nullptr) {
+    _E("Invalid paremeter");
+    return AUL_R_EINVAL;
+  }
+
+  if (!IsAmdReady())
+    return AUL_R_OK;
+
+  return AppRequest(PKG_PRE_EVENT_SEND, uid)
+      .With(b)
+      .SendSimply();
+}