From: Ji-hoon Lee Date: Thu, 29 Sep 2022 11:33:06 +0000 (+0900) Subject: Register package manager event handler before loading wakeup engines X-Git-Tag: accepted/tizen/unified/20230208.112442~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7d3cff07f22746654f0f7e080190ae89150ced33;p=platform%2Fcore%2Fuifw%2Fmulti-assistant-service.git Register package manager event handler before loading wakeup engines If the wakeup engine app gets installed while multi-assistant-service is being launched and also is trying to load wakeup engines, the newly installed wakeup engine will not be loaded since at the time of launching the installation was not completed, and the installation completion event would not be received also, since the package manager event handler might not be registered yet. So if we register package manager event handler first and then load wakeup engines, even if the wakeup engine currently being installed fails to be loaded, the installation completion event is guaranteed to be received by the package manager event handler, making sure that the multi-assistant-service would restart for re-loading. Change-Id: I1e8f57d6a08c9290a0ae11422d1404188c97c3df --- diff --git a/src/package_update_monitor.cpp b/src/package_update_monitor.cpp index 112fff8..c2c74ff 100644 --- a/src/package_update_monitor.cpp +++ b/src/package_update_monitor.cpp @@ -42,7 +42,7 @@ void CPackageUpdateMonitor::initialize() ret = package_manager_set_event_cb(mHandle, CPackageUpdateMonitor::package_manager_event_cb, this); if (ret == PACKAGE_MANAGER_ERROR_NONE) { - LOGD("package_manager_set_event_cb succeeded."); + LOGE("package_manager_set_event_cb succeeded : %p", mHandle); } else { LOGE("package_manager_set_event_cb failed(%d)", ret); } @@ -74,7 +74,7 @@ static bool is_wakeup_engine(const pkgmgrinfo_appinfo_h handle, CPackageUpdateMo for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM;loop++) { if (clientInfo.getItems()[loop].used) { for (int inner_loop = 0;inner_loop < MAX_WAKEUP_ENGINES_NUM;inner_loop++) { - LOGD("comparing appid : %s %s", clientInfo.getItems()[loop].wakeup_engine[inner_loop], appid); + LOGI("comparing appid : %s %s", clientInfo.getItems()[loop].wakeup_engine[inner_loop], appid); if (0 == strncmp(clientInfo.getItems()[loop].wakeup_engine[inner_loop], appid, MAX_APPID_LEN)) { is_wakeup_engine = true; } @@ -85,6 +85,7 @@ static bool is_wakeup_engine(const pkgmgrinfo_appinfo_h handle, CPackageUpdateMo LOGE("pkgmgrinfo_appinfo_get_appid failed! error code=%d", ret); } + LOGI("Returning : %d", is_wakeup_engine); return is_wakeup_engine; } @@ -99,6 +100,7 @@ static bool is_voice_assistant(const pkgmgrinfo_appinfo_h handle, CPackageUpdate } else { LOGE("pkgmgrinfo_appinfo_get_metadata_value failed! error code=%d", ret); } + LOGI("Returning : %d", is_voice_assistant); return is_voice_assistant; } @@ -152,21 +154,26 @@ void CPackageUpdateMonitor::package_manager_event_cb(const char *type, const cha bool should_exit = false; bool pkginfo_found = true; - if (!package || !type) + if (!package || !type){ + LOGE("Package name or type info is NULL"); return; + } if (PACKAGE_MANAGER_EVENT_TYPE_UPDATE != event_type && PACKAGE_MANAGER_EVENT_TYPE_INSTALL != event_type && - PACKAGE_MANAGER_EVENT_TYPE_UNINSTALL != event_type) + PACKAGE_MANAGER_EVENT_TYPE_UNINSTALL != event_type) { + LOGE("Unexpected event type : %d", event_type); return; + } if (PACKAGE_MANAGER_EVENT_STATE_STARTED != event_state && PACKAGE_MANAGER_EVENT_STATE_COMPLETED != event_state && - PACKAGE_MANAGER_EVENT_STATE_FAILED != event_state) + PACKAGE_MANAGER_EVENT_STATE_FAILED != event_state) { return; + } bool user = false; - LOGD("type=%s package=%s event_type=%d event_state=%d progress=%d error=%d", + LOGI("type=%s package=%s event_type=%d event_state=%d progress=%d error=%d", type, package, event_type, event_state, progress, error); ret = pkgmgrinfo_pkginfo_get_pkginfo(package, &handle); if (ret != PMINFO_R_OK || NULL == handle) { @@ -199,6 +206,7 @@ void CPackageUpdateMonitor::package_manager_event_cb(const char *type, const cha LOGW("Failed to get pkg list from pkginfo, returned %d", ret); } } + LOGI("filter_result : %d", filter_result); } else { /* Even if we failed acquiring the pkginfo, proceed if we're uninstalling since at the time of uninstall completion, pkginfo would not exist */ diff --git a/src/service_main.cpp b/src/service_main.cpp index 48eb142..14cb54b 100644 --- a/src/service_main.cpp +++ b/src/service_main.cpp @@ -1384,6 +1384,8 @@ bool CServiceMain::app_create(void *data) return false; } + mPackageUpdateMonitor.initialize(); + initialize_service_plugin(); process_activated_setting(); @@ -1400,8 +1402,6 @@ bool CServiceMain::app_create(void *data) nullptr, 0, nullptr, CLIENT_LAUNCH_MODE_PRELAUNCH); } - mPackageUpdateMonitor.initialize(); - MAS_LOGE("[END] Service app create"); return true; }