_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;
}
}