Reload plugin on voice assistant related pkgmgr events 27/230227/3
authorJi-hoon Lee <dalton.lee@samsung.com>
Mon, 23 Mar 2020 03:25:52 +0000 (12:25 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Fri, 10 Apr 2020 00:13:49 +0000 (00:13 +0000)
Change-Id: I1c00665a138d4a55d2d2517675fada5ef5ea963e

src/multi_assistant_service.c

index d81520038bb22b100eee8d8dda2a3bc3ccbb5d0d..bc84cc181de3a2b071b6aadf8486fda517968da3 100644 (file)
@@ -732,6 +732,7 @@ static void mas_active_state_changed_cb(keynode_t* key, void* data)
 
 static int init_plugin(void)
 {
+       MAS_LOGI("[ENTER]");
        if (0 != multi_assistant_service_plugin_initialize()) {
                MAS_LOGE("Fail to ws intialize");
                return -1;
@@ -1382,28 +1383,52 @@ ma_service_state_e mas_get_current_service_state()
        return g_current_service_state;
 }
 
-static int pkg_app_list_cb(const pkgmgrinfo_appinfo_h handle, void *user_data)
+static bool is_wakeup_engine(const pkgmgrinfo_appinfo_h handle)
 {
+       bool is_wakeup_engine = false;
        char *appid = NULL;
 
        int ret = pkgmgrinfo_appinfo_get_appid (handle, &appid);
        if (PMINFO_R_OK == ret && NULL != appid) {
-               int *result = (int*)user_data;
-               if (result) {
-                       for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM;loop++) {
-                               if (g_maclient_info[loop].used) {
-                                       LOGD("comparing appid : %s %s", g_maclient_info[loop].wakeup_engine, appid);
-                                       if (0 == strncmp(g_maclient_info[loop].wakeup_engine, appid, MAX_APPID_LEN)) {
-                                               *result = 1;
-                                       }
+               for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM;loop++) {
+                       if (g_maclient_info[loop].used) {
+                               LOGD("comparing appid : %s %s", g_maclient_info[loop].wakeup_engine, appid);
+                               if (0 == strncmp(g_maclient_info[loop].wakeup_engine, appid, MAX_APPID_LEN)) {
+                                       is_wakeup_engine = true;
                                }
                        }
                }
        } else {
                LOGE("pkgmgrinfo_appinfo_get_appid failed! error code=%d", ret);
-               return 0;
        }
 
+       return is_wakeup_engine;
+}
+
+static bool is_voice_assistant(const pkgmgrinfo_appinfo_h handle)
+{
+       bool is_voice_assistant = false;
+       char* metadata_value = NULL;
+       const char* voice_assistant_metadata = "http://tizen.org/metadata/multi-assistant/name";
+       int ret = pkgmgrinfo_appinfo_get_metadata_value(handle, voice_assistant_metadata, &metadata_value);
+       if (PMINFO_R_OK == ret && NULL != metadata_value) {
+               is_voice_assistant = true;
+       } else {
+               LOGE("pkgmgrinfo_appinfo_get_metadata_value failed! error code=%d", ret);
+       }
+       return is_voice_assistant;
+}
+
+static int pkg_app_list_cb(const pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+       int *result = (int*)user_data;
+       if (result) {
+               if (is_voice_assistant(handle)) {
+                       *result = 1;
+               } else if (is_wakeup_engine(handle)) {
+                       *result = 1;
+               }
+       }
        return 0;
 }