return POLICY_RESULT_FAIL;
}
+int set_bluetooth_pairing_state_handler(struct xtk_policy *self)
+{
+ int state;
+ int allow;
+ dpm_context_h context = NULL;
+ dpm_restriction_policy_h policy = NULL;
+
+ if (xtk_open_radio_popup(self, STATE_CHANGE_OPTIONS, &allow) == XTK_EVENT_CANCEL) {
+ return POLICY_RESULT_FAIL;
+ }
+
+ context = dpm_context_create();
+ if (context == NULL) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create device policy context handle");
+ return POLICY_RESULT_FAIL;
+ }
+
+ policy = dpm_context_acquire_restriction_policy(context);
+ if (policy == NULL) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create usb tethering policy handle");
+ dpm_context_destroy(context);
+ return POLICY_RESULT_FAIL;
+ }
+
+ if (dpm_restriction_set_bluetooth_pairing_state(policy, allow) != 0) {
+ dpm_context_release_restriction_policy(context, policy);
+ dpm_context_destroy(context);
+ return POLICY_RESULT_FAIL;
+ }
+
+ if (dpm_restriction_get_bluetooth_pairing_state(policy, &state) != 0) {
+ dpm_context_release_restriction_policy(context, policy);
+ dpm_context_destroy(context);
+ return POLICY_RESULT_FAIL;
+ }
+
+ if (state == allow) {
+ dpm_context_release_restriction_policy(context, policy);
+ dpm_context_destroy(context);
+ xtk_open_message_popup(self, STATE_CHANGE_MESSAGE(state));
+ return POLICY_RESULT_NONE;
+ }
+
+ dpm_context_release_restriction_policy(context, policy);
+ dpm_context_destroy(context);
+
+ return POLICY_RESULT_FAIL;
+}
+
+int get_bluetooth_pairing_state_handler(struct xtk_policy *self)
+{
+ int state;
+ dpm_context_h context = NULL;
+ dpm_restriction_policy_h policy = NULL;
+
+ context = dpm_context_create();
+ if (context == NULL) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create device policy context handle");
+ return POLICY_RESULT_FAIL;
+ }
+
+ policy = dpm_context_acquire_restriction_policy(context);
+ if (policy == NULL) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create usb tethering policy handle");
+ dpm_context_destroy(context);
+ return POLICY_RESULT_FAIL;
+ }
+
+ if (dpm_restriction_get_bluetooth_pairing_state(policy, &state) == 0) {
+ dpm_context_release_restriction_policy(context, policy);
+ dpm_context_destroy(context);
+ xtk_open_message_popup(self, STATE_CHANGE_MESSAGE(state));
+ return POLICY_RESULT_NONE;
+ }
+
+ dpm_context_release_restriction_policy(context, policy);
+ dpm_context_destroy(context);
+
+ return POLICY_RESULT_FAIL;
+}
+
xtk_policy_t xtk_restriction_policy[] = {
{
.id = "SET_CAMERA_STATE",
{
.id = "GET_BLUETOOTH_DESKTOP_CONNECTIVITY_STATE",
.handler = get_bluetooth_desktop_connectivity_state_handler
+ },
+ {
+ .id = "SET_BLUETOOTH_PAIRING_STATE",
+ .handler = set_bluetooth_pairing_state_handler
+ },
+ {
+ .id = "GET_BLUETOOTH_PAIRING_STATE",
+ .handler = get_bluetooth_pairing_state_handler
}
};