From: Changgyu Choi Date: Fri, 26 Aug 2022 08:18:39 +0000 (+0900) Subject: Add aul_package_pre_event_send() X-Git-Tag: accepted/tizen/unified/20220908.013408~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3d86a7a57fd5791a54dac2138e1429c34085be5f;p=platform%2Fcore%2Fappfw%2Faul-1.git Add aul_package_pre_event_send() 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 --- diff --git a/include/aul.h b/include/aul.h index df7c0b9..b3bf3fb 100644 --- a/include/aul.h +++ b/include/aul.h @@ -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 diff --git a/include/aul_cmd.h b/include/aul_cmd.h index 40562e0..4f180b9 100644 --- a/include/aul_cmd.h +++ b/include/aul_cmd.h @@ -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 }; diff --git a/include/aul_key.h b/include/aul_key.h index dfff008..31911b8 100644 --- a/include/aul_key.h +++ b/include/aul_key.h @@ -951,3 +951,15 @@ * @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__" diff --git a/src/aul_cmd.c b/src/aul_cmd.c index f244c8e..cabc4ab 100644 --- a/src/aul_cmd.c +++ b/src/aul_cmd.c @@ -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" }; diff --git a/src/pkginfo.cc b/src/pkginfo.cc index 76c9c6a..d70cf6b 100644 --- a/src/pkginfo.cc +++ b/src/pkginfo.cc @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -46,6 +47,21 @@ constexpr const char* kAppInfoKeys[] = { AUL_K_IS_SUBAPP, }; +constexpr const char kPathAmdReady[] = "/run/.amd_ready"; + +bool IsAmdReady() { + static std::atomic 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(); +}