Apply dpm policy 47/74447/3 accepted/tizen/common/20160616.151808 accepted/tizen/ivi/20160617.081500 accepted/tizen/mobile/20160617.081155 accepted/tizen/tv/20160617.081236 submit/tizen/20160615.100519 submit/tizen/20160616.005920
authorSeonah Moon <seonah1.moon@samsung.com>
Tue, 14 Jun 2016 08:24:20 +0000 (17:24 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Tue, 14 Jun 2016 10:07:59 +0000 (19:07 +0900)
Change-Id: Id2f6a6d96aa12b8e7606b072fa2fb779acd1f1bc
Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
CMakeLists.txt
include/mh_popup.h
packaging/ug-setting-mobileap-efl.spec
src/mh_popup.c
src/mh_view_main.c
ug-setting-mobileap-efl.xml

index 151f131..789b8cd 100755 (executable)
@@ -27,7 +27,7 @@ ENDIF (TIZEN_FEATURE_DUALSIM_ENABLE)
 
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
 
-SET(dependents "elementary evas ui-gadget-1 capi-network-tethering capi-network-connection capi-network-wifi notification efl-extension")
+SET(dependents "elementary evas ui-gadget-1 capi-network-tethering capi-network-connection capi-network-wifi notification aul bundle efl-extension dpm")
 
 SET(CMAKE_BUILD_TYPE "Release")
 
index 36025ce..a576ec5 100644 (file)
@@ -36,6 +36,7 @@ void _destroy_popup(mh_appdata_t *ad);
 void _teth_on(mh_appdata_t* ad);
 void _prepare_popup_type(int type);
 void _handle_mobile_data_onoff(mh_appdata_t *ad);
+void _create_security_restriction_noti(tethering_type_e type);
 
 #ifdef __cplusplus
 }
index 7da945a..7265fed 100755 (executable)
@@ -3,7 +3,7 @@
 
 Name:          ug-setting-mobileap-efl
 Summary:       Tethering UI Gadget Library
-Version:       1.0.139
+Version:       1.0.140
 Release:       1
 Group:         App/Network
 License:       Flora-1.1
@@ -23,7 +23,10 @@ BuildRequires:       pkgconfig(capi-network-wifi)
 BuildRequires: pkgconfig(capi-network-tethering)
 BuildRequires: pkgconfig(capi-network-connection)
 BuildRequires: pkgconfig(notification)
+BuildRequires: pkgconfig(aul)
+BuildRequires: pkgconfig(bundle)
 BuildRequires: pkgconfig(efl-extension)
+BuildRequires: pkgconfig(dpm)
 BuildRequires: cmake
 BuildRequires: edje-bin
 BuildRequires: gettext-tools
index c74ae96..cd4ed32 100755 (executable)
 
 #include <efl_extension.h>
 #include <app_control_internal.h>
+#include <bundle.h>
+#include <aul.h>
 
 #include "mh_common_utility.h"
 #include "mobile_hotspot.h"
 #include "mh_popup.h"
 #include "mh_string.h"
 
+#define MAX_BUF_SIZE   (256u)
+#define NETPOPUP               "net.netpopup"
+
 static mh_popup_type_e popup_type = MH_POPUP_NONE;
 static Evas_Object *popup_content = NULL;
 static char *popup_string = NULL;
@@ -625,3 +630,38 @@ void _destroy_popup(mh_appdata_t *ad)
 
        return;
 }
+
+void _create_security_restriction_noti(tethering_type_e type)
+{
+       bundle *b = NULL;
+       char restricted_type[MAX_BUF_SIZE] = {0, };
+       int ret;
+
+       switch (type) {
+               case TETHERING_TYPE_WIFI:
+                       g_strlcpy(restricted_type, "wifi tethering", MAX_BUF_SIZE - 1);
+                       break;
+               case TETHERING_TYPE_USB:
+                       g_strlcpy(restricted_type, "usb tethering", MAX_BUF_SIZE - 1);
+                       break;
+               case TETHERING_TYPE_BT:
+                       g_strlcpy(restricted_type, "bt tethering", MAX_BUF_SIZE - 1);
+                       break;
+               default:
+                       ERR("Invalid type.\n");
+                       return;
+       }
+       b = bundle_create();
+
+       bundle_add(b, "_SYSPOPUP_TYPE_", "toast_popup");
+       bundle_add(b, "_SYSPOPUP_CONTENT_", "security restriction");
+       bundle_add(b, "_RESTRICTED_TYPE_", restricted_type);
+
+       DBG("Launch security restriction alert network popup");
+       ret = aul_launch_app(NETPOPUP, b);
+       if (ret < 0)
+               ERR("Fail to launch syspopup");
+
+       bundle_free(b);
+       return;
+}
index 6f2af60..0892e08 100755 (executable)
@@ -20,6 +20,7 @@
 #include <time.h>
 #include <limits.h>
 #include <efl_extension.h>
+#include <dpm/restriction.h>
 
 #include "mh_view_main.h"
 #include "mh_popup.h"
@@ -573,11 +574,57 @@ void _update_main_view(mh_appdata_t *ad, tethering_type_e type)
        return;
 }
 
+static int __is_allowed(tethering_type_e type)
+{
+       int state = 0;
+       dpm_context_h context = NULL;
+       dpm_restriction_policy_h policy = NULL;
+
+       context = dpm_context_create();
+       if (context == NULL) {
+               ERR("Failed to create dpm context!!");
+               return 0;
+       }
+
+       policy = dpm_context_acquire_restriction_policy(context);
+       if (policy == NULL) {
+               ERR("Failed to create policy handle");
+               dpm_context_destroy(context);
+               return 0;
+       }
+
+       switch(type) {
+               case TETHERING_TYPE_WIFI:
+                       dpm_restriction_get_wifi_hotspot_state(policy, &state);
+                       break;
+               case TETHERING_TYPE_USB:
+                       dpm_restriction_get_usb_tethering_state(policy, &state);
+                       break;
+               case TETHERING_TYPE_BT:
+                       dpm_restriction_get_bluetooth_tethering_state(policy, &state);
+                       break;
+               default:
+                       break;
+       }
+
+       dpm_context_release_restriction_policy(context, policy);
+       dpm_context_destroy(context);
+
+       return state;
+}
+
 static void __wifi_onoff_changed_cb(void *data, Evas_Object *obj,
                                                        void *event_info)
 {
        __MOBILE_AP_FUNC_ENTER__;
 
+       if (!__is_allowed(TETHERING_TYPE_WIFI)) {
+               ERR("Wi-Fi tethering is restricted!!");
+               elm_check_state_set(obj, EINA_FALSE);
+               _create_security_restriction_noti(TETHERING_TYPE_WIFI);
+               return;
+       }
+
        if (data == NULL) {
                ERR("The param is NULL\n");
                return;
@@ -621,6 +668,13 @@ static void __bt_onoff_changed_cb(void *data, Evas_Object *obj, void *event_info
 {
        __MOBILE_AP_FUNC_ENTER__;
 
+       if (!__is_allowed(TETHERING_TYPE_BT)) {
+               ERR("BT tethering is restricted!!");
+               elm_check_state_set(obj, EINA_FALSE);
+               _create_security_restriction_noti(TETHERING_TYPE_BT);
+               return;
+       }
+
        if (data == NULL) {
                ERR("The param is NULL\n");
                return;
@@ -669,6 +723,13 @@ static void __usb_onoff_changed_cb(void *data, Evas_Object *obj, void *event_inf
 {
        __MOBILE_AP_FUNC_ENTER__;
 
+       if (!__is_allowed(TETHERING_TYPE_USB)) {
+               ERR("USB tethering is restricted!!");
+               elm_check_state_set(obj, EINA_FALSE);
+               _create_security_restriction_noti(TETHERING_TYPE_USB);
+               return;
+       }
+
        if (data == NULL) {
                ERR("The param is NULL\n");
                return;
index a5a6724..a2b75ea 100644 (file)
@@ -65,5 +65,6 @@
                <privilege>http://tizen.org/privilege/network.get</privilege>
                <privilege>http://tizen.org/privilege/network.set</privilege>
                <privilege>http://tizen.org/privilege/network.profile</privilege>
+               <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
        </privileges>
 </manifest>