Use AUL launcher instead of app_control 07/62307/1 accepted/tizen/common/20160316.160333 accepted/tizen/ivi/20160316.040515 accepted/tizen/mobile/20160316.040423 accepted/tizen/tv/20160316.040438 accepted/tizen/wearable/20160316.040501 submit/tizen/20160316.022156
authorYu Jiung <jiung.yu@samsung.com>
Tue, 15 Mar 2016 09:28:07 +0000 (18:28 +0900)
committerYu Jiung <jiung.yu@samsung.com>
Tue, 15 Mar 2016 09:28:20 +0000 (18:28 +0900)
Description :
app_control functions can't be used by root user daemon.
So, We should use AUL launcher function.

Change-Id: Ia59a95cb4e25ec606d7b9af2546a671f567d2d5b
Signed-off-by: Yu jiung <jiung.yu@samsung.com>
CMakeLists.txt
packaging/wifi-direct-manager.spec
src/wifi-direct-util.c

index 12be6f0..2b86d6d 100755 (executable)
@@ -2,7 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(wfd-manager C)
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED capi-network-wifi-direct glib-2.0 gio-2.0 gobject-2.0 dlog libnl-2.0 capi-appfw-application vconf cynara-client cynara-creds-socket cynara-session aul${MDM_REQUIRED_PKGS})
+pkg_check_modules(pkgs REQUIRED capi-network-wifi-direct glib-2.0 gio-2.0 gobject-2.0 dlog libnl-2.0 capi-appfw-application vconf cynara-client cynara-creds-socket cynara-session aul libsystemd-login ${MDM_REQUIRED_PKGS})
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
index 0f972aa..7f39141 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          wifi-direct-manager
 Summary:       Wi-Fi Direct manger
-Version:       1.2.146
+Version:       1.2.147
 Release:       1
 Group:      Network & Connectivity/Wireless
 License:    Apache-2.0
@@ -19,6 +19,7 @@ BuildRequires:        pkgconfig(cynara-creds-socket)
 BuildRequires: pkgconfig(cynara-session)
 
 BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires:  pkgconfig(libsystemd-login)
 
 BuildRequires: pkgconfig(libtzplatform-config)
 
index e04a72a..3023e7a 100755 (executable)
@@ -45,7 +45,7 @@
 #include <vconf.h>
 #include <tzplatform_config.h>
 #if defined(TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT)
-#include <app_control.h>
+#include <systemd/sd-login.h>
 #include <aul.h>
 #endif
 #include <wifi-direct.h>
@@ -154,6 +154,37 @@ int wfd_util_get_current_time(unsigned long *cur_time)
 }
 #endif
 
+#if defined(TIZEN_FEATURE_DEFAULT_CONNECTION_AGENT)
+static int __wfd_util_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;
+ }
+
+#endif
+
 gboolean wfd_util_execute_file(const char *file_path,
        char *const args[], char *const envs[])
 {
@@ -589,33 +620,20 @@ int wfd_util_start_wifi_direct_popup()
 {
        __WDS_LOG_FUNC_ENTER__;
 
-       app_control_h popup_control = NULL;
-       if (APP_CONTROL_ERROR_NONE != app_control_create(&popup_control)
-               || NULL == popup_control) {
-               WDS_LOGE("App control operation Failed !");
+       uid_t uid = 0;
+       int ret = 0;
+       ret = __wfd_util_find_login_user(&uid);
+       if (ret < 0) {
+               WDS_LOGE("__wfd_util_find_login_user Failed !");
                return -1;
        }
-       if (APP_CONTROL_ERROR_NONE != app_control_set_operation(popup_control,
-               APP_CONTROL_OPERATION_DEFAULT)) {
-               WDS_LOGE("App control operation Failed !");
-               app_control_destroy(popup_control);
-               return -1;
-       }
-       if (APP_CONTROL_ERROR_NONE != app_control_set_app_id(popup_control,
-               "org.tizen.wifi-direct-popup")) {
-               WDS_LOGE("App control operation Failed !");
-               app_control_destroy(popup_control);
-               return -1;
-       }
-       if (APP_CONTROL_ERROR_NONE !=
-               app_control_send_launch_request(popup_control, NULL, NULL)) {
-               WDS_LOGE("App control operation Failed !");
-               app_control_destroy(popup_control);
+
+       if (AUL_R_OK != aul_launch_app_for_uid(
+               "org.tizen.wifi-direct-popup", NULL, uid)) {
+               WDS_LOGE("aul_launch_for_uid Failed !");
                return -1;
        }
 
-       app_control_destroy(popup_control);
-
        WDS_LOGD("Succeeded to launch wifi-direct-popup");
        __WDS_LOG_FUNC_EXIT__;
        return 0;
@@ -625,9 +643,17 @@ int wfd_util_stop_wifi_direct_popup()
 {
        __WDS_LOG_FUNC_ENTER__;
 
-       int pid = aul_app_get_pid("org.tizen.wifi-direct-popup");
+       uid_t uid = 0;
+       int ret = 0;
+       ret = __wfd_util_find_login_user(&uid);
+       if (ret < 0) {
+               WDS_LOGE("__wfd_util_find_login_user Failed !");
+               return -1;
+       }
+
+       int pid = aul_app_get_pid_for_uid("org.tizen.wifi-direct-popup", uid);
        if (pid > 0) {
-               if (aul_terminate_pid(pid) != AUL_R_OK) {
+               if (aul_terminate_pid_for_uid(pid, uid) != AUL_R_OK) {
                        WDS_LOGD("Failed to destroy wifi-direct-popup pid[%d]", pid);
                        return -1;
                } else {