Fix for Web/C# TCT fail 32/264532/1
authorJihoon Jung <jh8801.jung@samsung.com>
Fri, 24 Sep 2021 03:20:57 +0000 (12:20 +0900)
committerJihoon Jung <jh8801.jung@samsung.com>
Fri, 24 Sep 2021 03:24:56 +0000 (12:24 +0900)
- Change logic to get focused app pid

Change-Id: Ic8a176bfdf2d662a324130754ec15f844e8fd86a
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
include/nfc_common.h
src/nfc_common.c

index fc49bbd..0639d68 100644 (file)
@@ -26,6 +26,7 @@
 #include <system_info.h>
 #include <systemd/sd-login.h>
 #include <aul.h>
+#include <aul_window.h>
 
 #include "net_nfc.h"
 #include "nfc.h"
index 87413d5..6040e0b 100755 (executable)
 _nfc_context_s gdbus_nfc_context;
 
 /* LCOV_EXCL_START */
-bool nfc_common_get_login_user(uid_t *uid)
-{
-       int i, ret;
-       uid_t *uids;
-       int uid_count;
-
-       uid_count = sd_get_uids(&uids);
-
-       if (uid_count <= 0) {
-               LOGD("sd_get_uids failed [%d]", uid_count);
-               return false;
-       }
-
-       for (i = 0; i < uid_count ; i++) {
-               char *state = NULL;
-
-               ret = sd_uid_get_state(uids[i], &state);
-
-               if (ret < 0) {
-                       LOGD("sd_uid_get_state failed [%d]", ret);
-               } else {
-                       if (!strncmp(state, "online", 6)) {
-                               *uid = uids[i];
-                               free(state);
-                               free(uids);
-                               return true;
-                       }
-               }
-
-               free(state);
-       }
-
-       LOGD("not exist login user");
-
-       free(uids);
-       return false;
-}
-
-int _iter_func(const aul_app_info *info, void *data)
-{
-       uid_t uid = 0;
-       int *pid = (int *)data;
-       int status;
-
-       if (nfc_common_get_login_user(&uid) == false) {
-               LOGD("net_nfc_util_get_login_user is failed");
-               return 0;
-       }
-
-       status = aul_app_get_status_bypid_for_uid(info->pid, uid);
-
-       LOGD("login user is %d, pid is %d, status is %d", (int)uid, info->pid, status);
-
-       if (status == STATUS_VISIBLE || status == STATUS_FOCUS) {
-               *pid = info->pid;
-               return -1;
-       }
-       return 0;
-}
-
 pid_t nfc_common_get_focus_app_pid()
 {
        int ret;
-       uid_t uid = 0;
        pid_t pid = 0;
 
-       if (nfc_common_get_login_user(&uid) == false) {
-               LOGD("nfc_common_get_login_user is failed");
-               return -1;
-       }
-
-       ret = aul_app_get_all_running_app_info_for_uid(_iter_func, &pid, uid);
+       ret = aul_window_get_focused_pid(&pid);
 
        if (ret == AUL_R_OK) {
                return pid;
        } else {
-               LOGD("aul_app_get_all_running_app_info_for_uid is failed");
+               LOGD("aul_window_get_focused_pid is failed");
                return -1;
        }
 }