bool net_nfc_util_aid_is_matched(const char *aid_criteria,
const char *aid_target);
+bool net_nfc_util_get_login_user(uid_t *uid);
bool net_nfc_util_get_pkgid_by_pid(pid_t pid, char *pkgid, size_t len);
bool net_nfc_util_hex_string_to_binary(const char *str, data_s *result);
#include <fcntl.h>
#include <glib.h>
#include <systemd/sd-daemon.h>
+#include <systemd/sd-login.h>
// platform header
#include "aul.h"
return result;
}
+bool net_nfc_util_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) {
+ DEBUG_ERR_MSG("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) {
+ DEBUG_ERR_MSG("sd_uid_get_state failed [%d]", ret);
+ } else {
+ if (!strncmp(state, "online", 6)) {
+ *uid = uids[i];
+ free(state);
+ free(uids);
+ return true;
+ }
+ }
+
+ free(state);
+ }
+
+ DEBUG_ERR_MSG("not exist login user");
+
+ free(uids);
+ return false;
+}
+
bool net_nfc_util_get_pkgid_by_pid(pid_t pid, char *pkgid, size_t len)
{
pkgmgrinfo_appinfo_h appinfo = NULL;
char package[1024];
int ret;
bool result = false;
+ uid_t uid = 0;
+
+ if (net_nfc_util_get_login_user(&uid) == false) {
+ DEBUG_ERR_MSG("net_nfc_util_get_login_user is failed");
+
+ goto END;
+ }
/* get pkgid id from pid */
- ret = aul_app_get_pkgname_bypid(pid, package, sizeof(package));
+ ret = aul_app_get_appid_bypid_for_uid(pid, package, sizeof(package), uid);
if (ret < 0) {
DEBUG_ERR_MSG("aul_app_get_pkgname_bypid failed [%d]", ret);
#include <openssl/evp.h>
#include <openssl/bio.h>
#include <openssl/buffer.h>
-#include <systemd/sd-login.h>
#include <bundle_internal.h>
#include "appsvc.h"
void net_nfc_app_util_aul_launch_app(char* package_name, bundle* kb)
{
int result = 0;
- if((result = aul_launch_app(package_name, kb)) < 0)
+ uid_t uid = 0;
+
+ if (net_nfc_util_get_login_user(&uid) == false) {
+ DEBUG_ERR_MSG("net_nfc_util_get_login_user is failed");
+ return;
+ }
+
+ if((result = aul_launch_app_for_uid(package_name, kb, uid)) < 0)
{
switch(result)
{
return ret;
}
-static int __find_login_user(uid_t *uid)
-{
- uid_t *uids;
- int ret, i;
- char *state;
-
- ret = sd_get_uids(&uids);
- if (ret <= 0)
- return -1;
-
- for (i = 0; i < ret ; i++) {
- if (sd_uid_get_state(uids[i], &state) < 0) {
- free(uids);
- return -1;
- } else {
- if (!strncmp(state, "online", 6)) {
- *uid = uids[i];
- free(uids);
- free(state);
- return 0;
- }
- }
- }
-
- free(uids);
- free(state);
- return -1;
-}
-
int _iter_func(const aul_app_info *info, void *data)
{
uid_t uid = 0;
int *pid = (int *)data;
int status;
- if(__find_login_user(&uid) < 0) {
- DEBUG_ERR_MSG("__find_login_user is failed");
+ if (net_nfc_util_get_login_user(&uid) == false) {
+ DEBUG_ERR_MSG("net_nfc_util_get_login_user is failed");
return 0;
}
status = aul_app_get_status_bypid_for_uid(info->pid, uid);
+ DEBUG_SERVER_MSG("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;
uid_t uid = 0;
int pid = 0;
- if(__find_login_user(&uid) < 0) {
- DEBUG_ERR_MSG("__find_login_user is failed");
+ if (net_nfc_util_get_login_user(&uid) == false) {
+ DEBUG_ERR_MSG("net_nfc_util_get_login_user is failed");
return -1;
}
bundle *bd;
char aid[1024];
int ret;
+ uid_t uid = 0;
data_s temp_aid = { aid_data, lc };
bd = bundle_create();
net_nfc_util_binary_to_hex_string(&temp_aid, aid, sizeof(aid));
appsvc_set_operation(bd, "http://tizen.org/appcontrol/operation/nfc/card_emulation/host_apdu_service");
appsvc_add_data(bd, "data", aid);
- ret = aul_launch_app(handler->package, bd);
- if (ret < 0) {
- DEBUG_ERR_MSG("aul_launch_app failed, [%d]", ret);
+
+ if (net_nfc_util_get_login_user(&uid) == true) {
+ ret = aul_launch_app_for_uid(handler->package, bd, uid);
+ if (ret < 0)
+ DEBUG_ERR_MSG("aul_launch_app_for_uid failed, uid [%d] ret [%d]", uid, ret);
+ } else {
+ DEBUG_ERR_MSG("net_nfc_util_get_login_user is failed");
}
bundle_free(bd);
//check match prefered and foreground app
pid = net_nfc_app_util_get_focus_app_pid();
+
+ if (pid <= 0) {
+ DEBUG_ERR_MSG("focus app is not exist. pid is %d", (int)pid);
+ return;
+ }
+
net_nfc_util_get_pkgid_by_pid(pid, foreground, sizeof(foreground));
DEBUG_SERVER_MSG("------------------------------");
char package[1024];
if (__get_package_name(id, package, sizeof(package)) == true) {
+ DEBUG_SERVER_MSG("caller package_name is %s", package);
result = net_nfc_server_route_table_find_handler(package);
} else {
result = NULL;