Terminate app when privacy of the app is offed 25/139825/3
authorYunjin Lee <yunjin-.lee@samsung.com>
Thu, 20 Jul 2017 14:00:40 +0000 (23:00 +0900)
committerKim Kidong <kd0228.kim@samsung.com>
Thu, 3 Aug 2017 02:14:21 +0000 (02:14 +0000)
- User can change privacy status of an app
  while the app is running on the background.
  In case of changing status to off,
  terminate the app for a clear permission revocation.

Change-Id: I520a9ff5225259472e02133afc540bbd532728f3
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
packaging/org.tizen.privacy-setting.spec
packaging/org.tizen.privacy-setting.xml
ui/CMakeLists.txt
ui/src/package_list_view.c
ui/src/package_privacy_list_view.c

index fed647f36c8b397ad4ce6d0cd1c3ebca171f99c2..b60727e9a608a22c367b0e62c689846da321c6c2 100755 (executable)
@@ -25,6 +25,7 @@ BuildRequires: pkgconfig(libtzplatform-config)
 BuildRequires: pkgconfig(security-privilege-manager)
 BuildRequires: pkgconfig(security-manager)
 BuildRequires: pkgconfig(pkgmgr-info)
+BuildRequires: pkgconfig(capi-appfw-app-manager)
 
 %description
 Application providing ui for managing other installed applications privacy status.
index c317fd3c2e413647d61969abeb26099e95e68943..9d22c37662199d1275956c4ceb7d761dff5f85b9 100755 (executable)
@@ -5,5 +5,6 @@
        </ui-application>
        <privileges>
                <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+               <privilege>http://tizen.org/privilege/appmanager.kill</privilege>
        </privileges>
 </manifest>
index fc967c0a35fff0bebbec3eb2a7f2fb05aaa7e170..eac8d1f79b7f821ed1bf4a8808b795cb91d591ca 100755 (executable)
@@ -1,7 +1,7 @@
 INCLUDE(FindPkgConfig)
 SET(pkg_name "org.tizen.privacy-setting")
 
-pkg_check_modules(${pkg_name} REQUIRED glib-2.0 ui-gadget-1 evas elementary edje eina efl-extension security-privilege-manager dlog security-manager pkgmgr-info)
+pkg_check_modules(${pkg_name} REQUIRED glib-2.0 ui-gadget-1 evas elementary edje eina efl-extension security-privilege-manager dlog security-manager pkgmgr-info capi-appfw-app-manager)
 
 SET(SRCS
        ${CMAKE_SOURCE_DIR}/common/src/common_utils.c
index da64a17194586bf7c7df6c9de8cdc3c24c578049..6558c6e8b30903ad550fd7cb588103cdff9f4c0a 100644 (file)
@@ -140,7 +140,6 @@ static void __get_package_privacy_privilege_status(bool* status, const char* pri
                                break;
                        } else if (strcmp("Deny", result) == 0 || strcmp("Ask user", result) == 0) {
                                *status = EINA_FALSE;
-                               break;
                        } else {
                                LOGE("Unknown policy level: %s", result);
                                break;
index e942ed5c4750457365454422127452fef8c98cdf..d36b99dce5d8ed9f0bb94fdfa8491f486c3bba20 100644 (file)
@@ -27,6 +27,7 @@
 #include <glib.h>
 #include <pkgmgr-info.h>
 #include <tzplatform_config.h>
+#include <app_manager_extension.h>
 
 #include "common_utils.h"
 #include "privacy_view.h"
@@ -89,6 +90,30 @@ static void gl_realized_cb(void *data, Evas_Object *obj, void *event_info)
                elm_object_item_signal_emit(first, "elm,action,title,slide,start", "elm");
 }
 
+
+static void __terminate_app()
+{
+       /* Get app context for each appid */
+       GList *l;
+       for (l = pp_app_list; l != NULL; l = l->next) {
+               char* appid = (char*)l->data;
+               bool is_running = false;
+               /* If app is running then terminate app. */
+               int ret = app_manager_is_running(appid, &is_running);
+               if (is_running) {
+                       app_context_h context = NULL;
+                       ret = app_manager_get_app_context(appid, &context);
+                       if (ret != APP_MANAGER_ERROR_NONE)
+                               LOGE("app_manager_get_app_context failed. ret = %d", ret);
+                       ret = app_manager_terminate_app(context);
+                       if (ret != APP_MANAGER_ERROR_NONE)
+                               LOGE("app_manager_terminate_app failed. ret = %d", ret);
+                       app_context_destroy(context);
+               }
+       }
+
+}
+
 static void package_privacy_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
 {
        Elm_Object_Item *ei = event_info;
@@ -106,6 +131,7 @@ static void package_privacy_check_changed_cb(void *data, Evas_Object *obj, void
        if (pd->status) {
                level = "Ask user";
                pd->status = false;
+               __terminate_app();
        } else {
                level = "Allow";
                pd->status = true;