*state = ret;
return DPM_ERROR_NONE;
}
+
+int dpm_restriction_set_bluetooth_tethering_state(dpm_restriction_policy_h handle, int enable)
+{
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+
+ RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+ return restriction.setBluetoothTetheringState(enable);
+}
+
+int dpm_restriction_get_bluetooth_tethering_state(dpm_restriction_policy_h handle, int *state)
+{
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
+
+ RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+ int ret = restriction.getBluetoothTetheringState();
+ if (ret < 0) {
+ return -1;
+ }
+ *state = ret;
+ return DPM_ERROR_NONE;
+}
DPM_API int dpm_restriction_get_wifi_hotspot_state(dpm_restriction_policy_h handle, int *enable);
/**
+ * @brief Allows or disallows the user to change Bluetooth tethering settings
+ * @details An administrator can use this API to restrict changing Bluetooth tethering settings.
+ * When restricted, the UI is grayed out so the user cannot modify the settings.
+ * @since_tizen 3.0
+ * @param[in] handle The restriction policy handle
+ * @param[in] enable TRUE to restrict wifi hostspot setting, else FALSE
+ * @return #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval #DPM_ERROR_NONE Successful
+ * @retval #DPM_ERROR_TIMEOUT Time out
+ * @retval #DPM_ERROR_NOT_SUPPORTED Not supported
+ * @retval #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DPM_ERROR_PERMISSION_DENIED The application does not have
+ * the privilege to call this API
+ * @pre handle must be created by dpm_context_acquire_restriction_policy()
+ * @see dpm_context_acquire_restriction_policy()
+ * @see dpm_context_release_restriction_policy()
+ * @see dpm_restriction_get_bluetooth_tethering_state()
+ */
+DPM_API int dpm_restriction_set_bluetooth_tethering_state(dpm_restriction_policy_h handle, int enable);
+
+/**
+ * @brief Checks whether the the Bluetooth tethering is restricted.
+ * @details An administrator can use this API to check whether the Bluetooth tethering
+ * is restricted.
+ * If the Bluetooth tethering is restricted, the UI is grayed out so user can not
+ * change its state.
+ * @since_tizen 3.0
+ * @param[in] handle The restriction policy handle
+ * @param[out] enable TRUE if modification is allowed,
+ * FALSE if modification is denied
+ * @return #DPM_ERROR_NONE on success, otherwise a negative value
+ * @retval #DPM_ERROR_NONE Successful
+ * @retval #DPM_ERROR_TIMEOUT Time out
+ * @retval #DPM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre handle must be created by dpm_context_acquire_restriction_policy()
+ * @see dpm_context_acquire_restriction_policy()
+ * @see dpm_context_release_restriction_policy()
+ * @see dpm_restriction_set_bluetooth_tethering_state()
+ */
+DPM_API int dpm_restriction_get_bluetooth_tethering_state(dpm_restriction_policy_h handle, int *enable);
+
+/**
* @} // end of DPM_RESTRICTION_POLICY
*/
}
}
+int RestrictionPolicy::setBluetoothTetheringState(bool enable)
+{
+ try {
+ return context->methodCall<int>("RestrictionPolicy::setBluetoothTetheringState", enable);
+ } catch (runtime::Exception& e) {
+ return -1;
+ }
+}
+
+bool RestrictionPolicy::getBluetoothTetheringState()
+{
+ try {
+ return context->methodCall<bool>("RestrictionPolicy::getBluetoothTetheringState");
+ } catch (runtime::Exception &e) {
+ return -1;
+ }
+}
+
} //namespace DevicePolicyManager
int setWifiHotspotState(bool enable);
bool getWifiHotspotState();
+ int setBluetoothTetheringState(bool enable);
+ bool getBluetoothTetheringState();
+
private:
PolicyControlContext& context;
};
context.registerNonparametricMethod(this, (bool)(RestrictionPolicy::getWifiState));
context.registerParametricMethod(this, (int)(RestrictionPolicy::setWifiHotspotState)(bool));
context.registerNonparametricMethod(this, (bool)(RestrictionPolicy::getWifiHotspotState));
+ context.registerParametricMethod(this, (int)(RestrictionPolicy::setBluetoothTetheringState)(bool));
+ context.registerNonparametricMethod(this, (bool)(RestrictionPolicy::getBluetoothTetheringState));
context.createNotification("camera");
context.createNotification("clipboard");
context.createNotification("usb-debugging");
context.createNotification("wifi");
context.createNotification("wifi-hotspot");
+ context.createNotification("bluetooth-tethering");
}
RestrictionPolicy::~RestrictionPolicy()
return IsPolicyAllowed(context, "wifi-hotspot");
}
+int RestrictionPolicy::setBluetoothTetheringState(bool enable)
+{
+ SetPolicyAllowed(context, "bluetooth-tethering", enable);
+ return 0;
+}
+
+bool RestrictionPolicy::getBluetoothTetheringState()
+{
+ return IsPolicyAllowed(context, "bluetooth-tethering");
+}
+
RestrictionPolicy restrictionPolicy(Server::instance());
} // namespace DevicePolicyManager
else
printf("usb_debugging state: %s\n", state_text[p_state]);
}
+
+void bluetooth_tethering_policy_handler(int command, int state)
+{
+ int ret = 1;
+ int p_state = 1;
+ char state_text[2][10] = {"DISALLOW", "ALLOW"};
+
+ if (command == 'v') {
+ p_state = state;
+ ret = set_bluetooth_tethering_state_handler(p_state);
+ } else
+ ret = get_bluetooth_tethering_state_handler(&p_state);
+
+ if (ret < 0)
+ printf("bluetooth-tethering policy operation is failed.\n");
+ else
+ printf("bluetooth-tethering state: %s\n", state_text[p_state]);
+}
void clipboard_policy_handler(int command, int state);
void settings_policy_handler(int command, int state);
void usb_debugging_policy_handler(int command, int state);
+void bluetooth_tethering_policy_handler(int command, int state);
int set_password_quality_handler(int password_quality);
int set_password_min_length_handler(int min_length);
int get_settings_changes_restriction_handler(int *state);
int set_usb_debugging_state_handler(int state);
int get_usb_debugging_state_handler(int *state);
+int set_bluetooth_tethering_state_handler(int state);
+int get_bluetooth_tethering_state_handler(int *state);
#endif /* !__DPM_CLI_TOOLKIT_H__ */
settings_policy_handler(command, state);
else if (strcmp(policy, "usb_debugging") == 0)
usb_debugging_policy_handler(command, state);
+ else if (strcmp(policy, "bluetooth-tethering") == 0)
+ bluetooth_tethering_policy_handler(command, state);
else {
printf("Wrong policy name! Please refer to the policy names bleow.\n");
print_rule();
else
return 0;
}
+
+int set_bluetooth_tethering_state_handler(int state)
+{
+ dpm_context_h context = NULL;
+ dpm_restriction_policy_h policy = NULL;
+ int ret = 0;
+ int get_value = 0;
+
+ context = dpm_context_create();
+ if (context == NULL) {
+ printf("Failed in dpm_context_create()\n");
+ return -1;
+ }
+
+ policy = dpm_context_acquire_restriction_policy(context);
+ if (policy == NULL) {
+ printf("Failed in dpm_context_acquire_restriction_policy()\n");
+ dpm_context_destroy(context);
+ return -1;
+ }
+
+ if (dpm_restriction_set_bluetooth_tethering_state(policy, state) != 0) {
+ printf("Failed in dpm_restriction_set_bluetooth_tethering_state()\n");
+ ret = -1;
+ goto out;
+ }
+
+ if (dpm_restriction_get_bluetooth_tethering_state(policy, &get_value) < 0) {
+ printf("Failed in dpm_restriction_get_bluetooth_tethering_state()\n");
+ ret = -1;
+ goto out;
+ }
+
+ if (state != get_value) {
+ printf("Failed to set value of restriction\n");
+ ret = -1;
+ goto out;
+ }
+
+out:
+ dpm_context_release_restriction_policy(context, policy);
+ dpm_context_destroy(context);
+
+ if (ret == -1)
+ return ret;
+ else
+ return 0;
+}
+
+int get_bluetooth_tethering_state_handler(int *state)
+{
+ dpm_context_h context = NULL;
+ dpm_restriction_policy_h policy = NULL;
+ int ret = 0;
+
+ context = dpm_context_create();
+ if (context == NULL) {
+ printf("Failed in dpm_context_create()\n");
+ return -1;
+ }
+
+ policy = dpm_context_acquire_restriction_policy(context);
+ if (policy == NULL) {
+ printf("Failed in dpm_context_acquire_restriction_policy()\n");
+ dpm_context_destroy(context);
+ return -1;
+ }
+
+ if (dpm_restriction_get_bluetooth_tethering_state(policy, state) < 0) {
+ printf("Failed in dpm_restriction_get_bluetooth_tethering_state()\n");
+ ret = -1;
+ goto out;
+ }
+
+ if (*state == 1 || *state == 0)
+ ret = 0;
+ else
+ ret = -1;
+
+out:
+ dpm_context_release_restriction_policy(context, policy);
+ dpm_context_destroy(context);
+
+ if (ret == -1)
+ return ret;
+ else
+ return 0;
+}