Add bluetooth-tethering test 42/69542/2
authorSeok Hong <seok85.hong@samsung.com>
Mon, 16 May 2016 00:27:17 +0000 (09:27 +0900)
committerJaemin Ryu <jm77.ryu@samsung.com>
Mon, 16 May 2016 09:08:21 +0000 (02:08 -0700)
Change-Id: I6fc14557d57bfdcacbae05f2c886b31958c3b90e
Signed-off-by: Seok Hong <seok85.hong@samsung.com>
data/test.xml
src/restriction.c

index 8d8bfca..801c74e 100755 (executable)
                </policy>
                <policy id="GET_WIFI_HOTSPOT_STATE" desc="Get Wifi Hotspot State" status="ON">
                </policy>
+               <policy id="SET_BLUETOOTH_TETHERING_STATE" desc="Set Bluetooth Tethering State" status="ON">
+               </policy>
+               <policy id="GET_BLUETOOTH_TETHERING_STATE" desc="Get Bluetooth Tethering State" status="ON">
+               </policy>
        </policy-group>
 
        <policy-group id="ZONE">
index 8d50f8c..15609e8 100644 (file)
@@ -705,6 +705,76 @@ int get_wifi_hotspot_state_handler(struct dpm_toolkit_entity *self)
        return POLICY_RESULT_FAIL;
 }
 
+int set_bluetooth_tethering_state_handler(struct dpm_toolkit_entity *self)
+{
+       char radio_text[][MAX_RADIO_TEXT_LEN] = {"ALLOW", "DISALLOW"};
+       dpm_restriction_policy_h policy;
+       dpm_context_h context;
+       int ret;
+
+       dlog_print(DLOG_DEBUG, LOG_TAG, __func__);
+
+       handler_display_radio_popup((char *)xmlGetProp(self->model, (xmlChar *) "desc"),
+               self, radio_text, sizeof(radio_text) / sizeof(char) / MAX_RADIO_TEXT_LEN);
+
+       context = dpm_context_create();
+       if (context == NULL) {
+               dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to create client context");
+               return POLICY_RESULT_FAIL;
+       }
+
+       policy = dpm_context_acquire_restriction_policy(context);
+
+       if (policy == NULL) {
+               dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to get restriction policy interface");
+               dpm_context_destroy(context);
+               return POLICY_RESULT_FAIL;
+       }
+
+       ret = dpm_restriction_set_bluetooth_tethering_state(policy, self->radio_index);
+
+       dpm_context_release_restriction_policy(context, policy);
+       dpm_context_destroy(context);
+
+       return (ret == DPM_ERROR_NONE) ? POLICY_RESULT_SUCCESS : POLICY_RESULT_FAIL;
+}
+
+int get_bluetooth_tethering_state_handler(struct dpm_toolkit_entity *self)
+{
+       dpm_restriction_policy_h policy;
+       dpm_context_h context;
+       int state, ret;
+
+       dlog_print(DLOG_DEBUG, LOG_TAG, __func__);
+
+       context = dpm_context_create();
+       if (context == NULL) {
+               dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to create client context");
+               return POLICY_RESULT_FAIL;
+       }
+
+       policy = dpm_context_acquire_restriction_policy(context);
+
+       if (policy == NULL) {
+               dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to get restriction policy interface");
+               dpm_context_destroy(context);
+               return POLICY_RESULT_FAIL;
+       }
+
+       ret = dpm_restriction_get_bluetooth_tethering_state(policy, &state);
+
+       dpm_context_release_restriction_policy(context, policy);
+       dpm_context_destroy(context);
+
+       if (ret == DPM_ERROR_NONE) {
+               display_result_popup((char *)xmlGetProp(self->model, (xmlChar *) "desc"), state ? "DISALLOWED" : "ALLOWED");
+
+               return POLICY_RESULT_NONE;
+       }
+
+       return POLICY_RESULT_FAIL;
+}
+
 dpm_toolkit_entity_t dpm_toolkit_restriction_policy[] = {
        {
         .id = "SET_CAMERA_STATE",
@@ -769,6 +839,14 @@ dpm_toolkit_entity_t dpm_toolkit_restriction_policy[] = {
        {
         .id = "GET_WIFI_HOTSPOT_STATE",
         .handler = get_wifi_hotspot_state_handler
+       },
+       {
+        .id = "SET_BLUETOOTH_TETHERING_STATE",
+        .handler = set_bluetooth_tethering_state_handler
+       },
+       {
+        .id = "GET_BLUETOOTH_TETHERING_STATE",
+        .handler = get_bluetooth_tethering_state_handler
        }
 };