Check ISE alive even if ISE launch was not successful 61/168961/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Thu, 1 Feb 2018 11:26:15 +0000 (20:26 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Thu, 1 Feb 2018 11:27:23 +0000 (20:27 +0900)
Change-Id: I7805a0b21d016c25f2260ba1010613cb979c1a54

ism/extras/efl_panel/isf_panel_efl.cpp

index 184f9b1..b3b30a9 100644 (file)
@@ -518,7 +518,7 @@ static String ime_selector_app = "";
 static String ime_list_app = "";
 
 static Ecore_Timer       *_ise_check_pid_alive_timer            = NULL;
-static const double      _ise_check_pid_alive_time              = 1.0f;
+static const double      _ise_check_pid_alive_time              = 3.0f;
 static String            _ise_check_pid_alive_uuid;
 
 enum {
@@ -6146,23 +6146,33 @@ static void delete_ise_check_pid_alive_timer(void)
 static Eina_Bool ise_check_pid_alive_timer(void *data)
 {
     Eina_Bool ret = ECORE_CALLBACK_RENEW;
-    long int ime_pid = (long int)data;
+    Eina_Bool retry = EINA_FALSE;
 
-    int status = aul_app_get_status_bypid(ime_pid);
-    LOGD("STATUS : %d %d", status, (int)ime_pid);
+    int status = aul_app_get_status (_ise_check_pid_alive_uuid.c_str ());
+    LOGD ("STATUS : %d", status);
+    if (status >= STATUS_LAUNCHING) {
+        /* If the status is not one of STATUS_LAUNCHING, STATUS_VISIBLE, STATUS_BG */
+        if (status >= STATUS_DYING) {
+            LOGE ("aul_app_get_status reports %d", status);
+            retry = EINA_TRUE;
+        }
+    }
+    else {
+        /* Status query not successful, the ISE could have failed launching */
+        LOGE ("aul_app_get_status failed. %d", status);
+        retry = EINA_TRUE;
+    }
 
-    /* If the status is not one of STATUS_LAUNCHING, STATUS_VISIBLE, STATUS_BG */
-    if (status >= STATUS_DYING || status == -1) {
+    if (retry) {
         _soft_keyboard_launched = false;
-
-        String uuid = _config->read(SCIM_CONFIG_DEFAULT_HELPER_ISE, String(""));
+        String uuid = _config->read (SCIM_CONFIG_DEFAULT_HELPER_ISE, String(""));
         /* The start_helper() function below will going to call slot_run_helper,
            which will going to assign a new timer handle to the _ise_check_pid_alive_timer variable.
         */
-        LOGW("The previous attempt to launch %s seems to be failed, restarting", uuid.c_str());
-        if (_info_manager->start_helper(uuid))
+        LOGW ("The previous attempt to launch %s seems to be failed, restarting",
+            _ise_check_pid_alive_uuid.c_str ());
+        if (_info_manager->start_helper (uuid))
             _soft_keyboard_launched = true;
-
         ret = ECORE_CALLBACK_CANCEL;
     }
 
@@ -6504,6 +6514,14 @@ static bool app_control_launch (const char *app_id)
     return (ret == APP_CONTROL_ERROR_NONE);
 }
 
+static void add_ise_check_pid_alive_timer(const String &uuid) {
+    delete_ise_check_pid_alive_timer ();
+    LOGD ("Register check_alive timer for uuid : %s", uuid.c_str ());
+    _ise_check_pid_alive_uuid = uuid;
+    _ise_check_pid_alive_timer = ecore_timer_add (_ise_check_pid_alive_time,
+        ise_check_pid_alive_timer, NULL);
+}
+
 static void slot_run_helper (const String &uuid, const String &config, const String &display)
 {
     ISF_SAVE_LOG ("time:%ld  pid:%d  %s  %s  uuid(%s)",
@@ -6511,7 +6529,7 @@ static void slot_run_helper (const String &uuid, const String &config, const Str
 
     String scim_helper_path;
 
-    delete_ise_check_pid_alive_timer();
+    delete_ise_check_pid_alive_timer ();
 
 #ifdef HAVE_PKGMGR_INFO
     char *execpath = NULL;
@@ -6522,14 +6540,17 @@ static void slot_run_helper (const String &uuid, const String &config, const Str
     /* Try to get in global packages */
     ret = pkgmgr_get_appinfo (uuid.c_str (), &appinfo_handle);
     if (ret != PMINFO_R_OK) {
-        LOGW ("pkgmgrinfo_appinfo_get_appinfo () & get_usr_appinfo () failed. appid : %s, ret : %d ", uuid.c_str (), ret);
+        LOGE ("pkgmgr_get_appinfo failed. appid : %s, ret : %d ", uuid.c_str (), ret);
+        add_ise_check_pid_alive_timer (uuid);
         return;
     }
 
     /* Get exec path */
     ret = pkgmgrinfo_appinfo_get_exec (appinfo_handle, &execpath);
     if (ret != PMINFO_R_OK) {
+        LOGE ("pkgmgrinfo_appinfo_get_exec failed. appid : %s, ret : %d ", uuid.c_str (), ret);
         pkgmgrinfo_appinfo_destroy_appinfo (appinfo_handle);
+        add_ise_check_pid_alive_timer (uuid);
         return;
     }
 
@@ -6563,17 +6584,10 @@ static void slot_run_helper (const String &uuid, const String &config, const Str
                 }
                 /* execute type IME */
                 LOGD ("Try to launch IME (%s)", uuid.c_str ());
-                bool launched = app_control_launch (uuid.c_str ());
-
-                if (launched) {
-                    long int ime_pid = aul_app_get_pid(uuid.c_str());
-                    if (ime_pid > 0) {
-                        LOGD ("Register check_alive timer for pid : %d", (int)ime_pid);
-                        _ise_check_pid_alive_uuid = uuid;
-                        _ise_check_pid_alive_timer = ecore_timer_add (_ise_check_pid_alive_time,
-                            ise_check_pid_alive_timer, (void*)ime_pid);
-                    }
-                }
+                app_control_launch (uuid.c_str ());
+
+                /* ISE check alive only works for AUL based IMEs */
+                add_ise_check_pid_alive_timer (uuid);
             }
             else {
                 /* shared object (so) type IME */