added privacy popup feature
authorJaeho Lee <jaeho81.lee@samsung.com>
Mon, 15 Apr 2013 12:38:18 +0000 (21:38 +0900)
committerJaeho Lee <jaeho81.lee@samsung.com>
Mon, 15 Apr 2013 12:38:18 +0000 (21:38 +0900)
Signed-off-by: Jaeho Lee <jaeho81.lee@samsung.com>
CMakeLists.txt
am_daemon/amd_appinfo.c
am_daemon/amd_appinfo.h
am_daemon/amd_launch.c
include/aul.h
launchpad_src/launchpad.c
packaging/aul.spec

index 3bb7071..4dbb1ce 100755 (executable)
@@ -20,7 +20,7 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
 # Set required packages
 INCLUDE(FindPkgConfig)
 
-pkg_check_modules(pkgs REQUIRED dlog ecore x11 libprivilege-control app-checker rua glib-2.0 ecore-x ecore-input evas vconf pkgmgr-info app2sd)
+pkg_check_modules(pkgs REQUIRED dlog ecore x11 libprivilege-control app-checker rua glib-2.0 ecore-x ecore-input evas vconf pkgmgr-info app2sd privacy-manager-client)
 pkg_check_modules(libpkgs REQUIRED dlog bundle dbus-glib-1 ail xdgmime app-checker libsmack)
 PKG_CHECK_MODULES(PKGS REQUIRED glib-2.0 gio-2.0 dlog bundle)
 
index 3ba94f4..e51298f 100755 (executable)
@@ -30,6 +30,7 @@ enum _appinfo_idx {
        _AI_MULTI,
        _AI_HWACC,
        _AI_PERM,
+       _AI_PKGID,
        _AI_MAX,
 };
 #define _AI_START _AI_NAME /* start index */
@@ -49,6 +50,7 @@ static struct appinfo_t _appinfos[] = {
        [_AI_MULTI] = { "Multiple", AIT_MULTI, },
        [_AI_HWACC] = { "Hwacceleration", AIT_HWACC, },
        [_AI_PERM] = { "PermissionType", AIT_PERM, },
+       [_AI_PKGID] = { "PackageId", AIT_PKGID, },
 };
 
 struct appinfo {
@@ -87,6 +89,7 @@ static int __app_info_insert_handler (const pkgmgrinfo_appinfo_h handle, void *d
        char *exec;
        char *type;
        char *appid;
+       char *pkgid;
        bool multiple;
        bool onboot;
        bool restart;
@@ -182,6 +185,9 @@ static int __app_info_insert_handler (const pkgmgrinfo_appinfo_h handle, void *d
                c->val[_AI_PERM] = strdup("normal");
        }
 
+       r = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
+       c->val[_AI_PKGID] = strdup(pkgid);
+
        _D("%s : %s : %s", c->val[_AI_FILE], c->val[_AI_COMP], c->val[_AI_TYPE]);
 
        g_hash_table_insert(cf->tbl, c->val[_AI_FILE], c);
index 609ee58..cfbca2a 100755 (executable)
@@ -14,6 +14,7 @@ enum appinfo_type {
        AIT_MULTI,
        AIT_HWACC,
        AIT_PERM,
+       AIT_PKGID,
 };
 
 int appinfo_init(struct appinfomgr **cf);
index 98d0351..1e3f05c 100755 (executable)
@@ -30,6 +30,7 @@
 #include <app2ext_interface.h>
 #include <sys/prctl.h>
 #include <pkgmgr-info.h>
+#include <privacy_manager_client.h>
 
 #include "amd_config.h"
 #include "amd_launch.h"
@@ -616,8 +617,10 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
        char tmp_pid[MAX_PID_STR_BUFSZ];
        const char *hwacc;
        const char *permission;
+       const char *pkgid;
        char caller_appid[256];
        pkgmgrinfo_cert_compare_result_type_e compare_result;
+       bool consented = true;
 
        int location = -1;
        app2ext_handle *app2_handle = NULL;
@@ -640,10 +643,35 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
 
        ai = appinfo_find(_laf, appid);
 
+       if(ai == NULL) {
+               __real_send(fd, -1);
+               return -1;
+       }
+
+       pkgid = appinfo_get_value(ai, AIT_PKGID);
+
+       if(bundle_get_val(kb, AUL_K_PRIVACY_APPID)){
+               bundle_del(kb, AUL_K_PRIVACY_APPID);
+       } else {
+               privacy_manager_client_check_user_consented(pkgid, &consented);
+
+               _D("consented : %d", consented);
+
+               if(consented == false) {
+                       _D("appid : %s", appid);
+                       bundle_add(kb, AUL_K_PRIVACY_APPID, appid);
+                       appid = PRIVACY_POPUP;
+                       bundle_del(kb, AUL_K_PKG_NAME);
+                       bundle_add(kb, AUL_K_PKG_NAME, appid);
+                       ai = appinfo_find(_laf, appid);
+               }
+       }
+
        componet = appinfo_get_value(ai, AIT_COMP);
        app_path = appinfo_get_value(ai, AIT_EXEC);
        pkg_type = appinfo_get_value(ai, AIT_TYPE);
        permission = appinfo_get_value(ai, AIT_PERM);
+       pkgid = appinfo_get_value(ai, AIT_PKGID);
 
        if(permission && strncmp(permission, "signature", 9) == 0 ) {
                if(caller_uid != 0 && (cmd == APP_START || cmd == APP_START_RES)){
@@ -696,7 +724,7 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
                _E("unkown application");
        }
 
-       location = app2ext_get_app_location(appid);
+       location = app2ext_get_app_location(pkgid);
        if (location == APP2EXT_SD_CARD)
        {
                app2_handle = app2ext_init(APP2EXT_SD_CARD);
@@ -706,7 +734,7 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
                        return -1;
                }
 
-               ret = app2_handle->interface.enable(appid);
+               ret = app2_handle->interface.enable(pkgid);
                if (ret) {
                        _E("app2_handle : app enable API fail Reason %d", ret);
                }
index 3e0c699..0a97652 100755 (executable)
@@ -174,6 +174,10 @@ typedef enum _aul_type{
 /** AUL public key - To support Media key */
 #define AUL_K_MULTI_KEY_EVENT  "__AUL_MULTI_KEY_EVENT__"
 
+/** AUL public bundle value */
+#define AUL_K_PRIVACY_APPID            "__AUL_PRIVACY_APPID__"
+
+
 /** AUL public bundle value - To support Media key*/
 #define AUL_V_KEY_PRESSED      "__AUL_KEY_PRESSED__"
 /** AUL public bundle value - To support Media key*/
@@ -194,6 +198,8 @@ typedef enum _aul_type{
 /** AUL internal private key */
 #define AUL_K_PID              "__AUL_PID__"
 
+#define PRIVACY_POPUP "tizenprv00.privacy-popup"
+
 
 
 /** 
index e3f602b..5adc4f3 100755 (executable)
@@ -194,10 +194,12 @@ _static_ int __prepare_exec(const char *pkg_name,
        __set_oom();
 
        /* SET PRIVILEGES*/
-        _D("pkg_name : %s / pkg_type : %s / app_path : %s ", pkg_name, menu_info->pkg_type, app_path);
-       if ((ret = __set_access(pkg_name, menu_info->pkg_type, app_path)) < 0) {
-                _D("fail to set privileges - check your package's credential : %d\n", ret);
-               return -1;
+       if(bundle_get_val(kb, AUL_K_PRIVACY_APPID) == NULL) {
+                _D("pkg_name : %s / pkg_type : %s / app_path : %s ", pkg_name, menu_info->pkg_type, app_path);
+               if ((ret = __set_access(pkg_name, menu_info->pkg_type, app_path)) < 0) {
+                        _D("fail to set privileges - check your package's credential : %d\n", ret);
+                       return -1;
+               }
        }
        /* SET DUMPABLE - for coredump*/
        prctl(PR_SET_DUMPABLE, 1);
index 6eeacaf..b710dd0 100644 (file)
@@ -34,6 +34,7 @@ BuildRequires:  pkgconfig(vconf)
 BuildRequires:  pkgconfig(pkgmgr-info)
 BuildRequires:  pkgconfig(libsmack)
 BuildRequires: pkgconfig(app2sd)
+BuildRequires:  pkgconfig(privacy-manager-client)
 
 
 %description