The applications can subscribe the policy changed event listed below table if they want to restrict
their operations in some circumstance.
-+------------------------------+----------------------+-------------------------------------------------+
-| Policy Name | Policy state | Query API |
-+------------------------------+----------------------+-------------------------------------------------+
-| wifi | allowed / disallowed | dpm_restriction_get_wifi_state |
-| wifi-hotspot | allowed / disallowed | dpm_restriction_get_wifi_hotspot |
-| wifi-profile-change | allowed / disallowed | dpm_wifi_is_profile_change_restricted |
-| wifi-ssid-restriction | allowed / disallowed | dpm_wifi_is_network_access_restricted |
-| bluetooth | allowed / disallowed | dpm_restriction_get_bluetooth_mode_change_state |
-| bluetooth-tethering | allowed / disallowed | dpm_restriction_get_bluetooth_tethering_state |
-| bluetooth-device-restriction | allowed / disallowed | dpm_bluetooth_is_device_restricted |
-| bluetooth-uuid-restriction | allowed / disallowed | dpm_bluetooth_is_uuid_restricted |
-| usb | allowed / disallowed | dpm_restriction_get_usb_state |
-| usb-tethering | allowed / disallowed | dpm_restriction_get_usb_tethering_state |
-| usb-debugging | allowed / disallowed | dpm_restriction_get_usb_debugging_state |
-| settings-changes | allowed / disallowed | dpm_restriction_get_setting_changes_state |
-| external-storage | allowed / disallowed | dpm_restriction_get_external_storage_state |
-| camera | allowed / disallowed | dpm_restriction_get_camera_state |
-| clipboard | allowed / disallowed | dpm_restriction_get_clipboard_state |
-| location | allowed / disallowed | dpm_restriction_get_location_state |
-| microphone | allowed / disallowed | dpm_restriction_get_microphone_state |
-+------------------------------+----------------------+-------------------------------------------------+
++--------------------------------+----------------------+----------------------------------------------------------+
+| Policy Name | Policy state | Query API |
++--------------------------------+----------------------+----------------------------------------------------------+
+| wifi | allowed / disallowed | dpm_restriction_get_wifi_state |
+| wifi-hotspot | allowed / disallowed | dpm_restriction_get_wifi_hotspot |
+| wifi-profile-change | allowed / disallowed | dpm_wifi_is_profile_change_restricted |
+| wifi-ssid-restriction | allowed / disallowed | dpm_wifi_is_network_access_restricted |
+| bluetooth | allowed / disallowed | dpm_restriction_get_bluetooth_mode_change_state |
+| bluetooth-tethering | allowed / disallowed | dpm_restriction_get_bluetooth_tethering_state |
+| bluetooth-desktop-connectivity | allowed / disallowed | dpm_restriction_get_bluetooth_desktop_connectivity_state |
+| bluetooth-device-restriction | allowed / disallowed | dpm_bluetooth_is_device_restricted |
+| bluetooth-uuid-restriction | allowed / disallowed | dpm_bluetooth_is_uuid_restricted |
+| usb | allowed / disallowed | dpm_restriction_get_usb_state |
+| usb-tethering | allowed / disallowed | dpm_restriction_get_usb_tethering_state |
+| usb-debugging | allowed / disallowed | dpm_restriction_get_usb_debugging_state |
+| settings-changes | allowed / disallowed | dpm_restriction_get_setting_changes_state |
+| external-storage | allowed / disallowed | dpm_restriction_get_external_storage_state |
+| camera | allowed / disallowed | dpm_restriction_get_camera_state |
+| clipboard | allowed / disallowed | dpm_restriction_get_clipboard_state |
+| location | allowed / disallowed | dpm_restriction_get_location_state |
+| microphone | allowed / disallowed | dpm_restriction_get_microphone_state |
++--------------------------------+----------------------+----------------------------------------------------------+
To subscribe the policy changed event, application should create context and then register
the policy changed callback like:
}
}
+int BluetoothPolicy::setDesktopConnectivityState(const bool enable)
+{
+ try {
+ return context->methodCall<bool>("BluetoothPolicy::setDesktopConnectivityState");
+ } catch (runtime::Exception& e) {
+ return -1;
+ }
+}
+
+bool BluetoothPolicy::getDesktopConnectivityState()
+{
+ try {
+ return context->methodCall<bool>("BluetoothPolicy::getDesktopConnectivityState");
+ } catch (runtime::Exception& e) {
+ return -1;
+ }
+}
+
+
// for bluetooth CAPIs
int BluetoothPolicy::addDeviceToBlacklist(const std::string& mac)
{
return DPM_ERROR_NONE;
}
+
+int dpm_restriction_set_bluetooth_desktop_connectivity_state(dpm_restriction_policy_h handle, const int enable)
+{
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+
+ BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+ return bluetooth.setDesktopConnectivityState(enable);
+}
+
+int dpm_restriction_get_bluetooth_desktop_connectivity_state(dpm_restriction_policy_h handle, int *enable)
+{
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
+
+ BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+ int ret = bluetooth.getDesktopConnectivityState();
+ if (ret < 0) {
+ return -1;
+ }
+ *enable = ret;
+
+ return DPM_ERROR_NONE;
+}
DPM_API int dpm_restriction_get_bluetooth_mode_change_state(dpm_restriction_policy_h handle, int *enable);
/**
+ * @brief Checks whether the the Bluetooth desktop connectivity is restricted.
+ * @details An administrator can use this API to check whether the Bluetooth desktop connectivity
+ * is restricted.
+ * If the Bluetooth desktop connectivity 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_get_bluetooth_desktop_connectivity_state()
+ */
+DPM_API int dpm_restriction_set_bluetooth_desktop_connectivity_state(dpm_restriction_policy_h handle, const int enable);
+
+/**
+ * @brief Checks whether the the Bluetooth desktop connectivity is restricted.
+ * @details An administrator can use this API to check whether the Bluetooth desktop connectivity is restricted.
+ * If the Bluetooth desktop connectivity 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_desktop_connectivity_state()
+ */
+DPM_API int dpm_restriction_get_bluetooth_desktop_connectivity_state(dpm_restriction_policy_h handle, int *enable);
+
+/**
* @} // end of DPM_RESTRICTION_POLICY
*/
// for restriction CPIs
int setModeChangeState(const bool enable);
bool getModeChangeState();
+ int setDesktopConnectivityState(const bool enable);
+ bool getDesktopConnectivityState();
// for bluetooth CAPIs
int addDeviceToBlacklist(const std::string& mac);
if (ret != BLUETOOTH_DPM_RESULT_SUCCESS) {
// TODO(seok85.hong): we can notify to admin client with this notification.
}
+ ret = policy.setDesktopConnectivityState(IsPolicyEnabled(context, "bluetooth-desktop-connectivity"));
+ if (ret != BLUETOOTH_DPM_RESULT_SUCCESS) {
+ // TODO(seok85.hong): we can notify to admin client with this notification.
+ }
ret = policy.setDeviceRestriction(IsPolicyEnabled(context, "bluetooth-device-restriction"));
if (ret != BLUETOOTH_DPM_RESULT_SUCCESS) {
// TODO(seok85.hong): we can notify to admin client with this notification.
// for restriction CPIs
ctxt.registerParametricMethod(this, (int)(BluetoothPolicy::setModeChangeState)(bool));
ctxt.registerNonparametricMethod(this, (bool)(BluetoothPolicy::getModeChangeState));
+ ctxt.registerParametricMethod(this, (int)(BluetoothPolicy::setDesktopConnectivityState)(bool));
+ ctxt.registerNonparametricMethod(this, (bool)(BluetoothPolicy::getDesktopConnectivityState));
// for bluetooth CPIs
ctxt.registerParametricMethod(this, (int)(BluetoothPolicy::addDeviceToBlacklist)(std::string));
ctxt.registerParametricMethod(this, (int)(BluetoothPolicy::removeDeviceFromBlacklist)(std::string));
ctxt.registerNonparametricMethod(this, (bool)(BluetoothPolicy::isUuidRestricted));
ctxt.createNotification("bluetooth");
+ ctxt.createNotification("bluetooth-desktop-connectivity");
ctxt.createNotification("bluetooth-uuid-restriction");
ctxt.createNotification("bluetooth-device-restriction");
return IsPolicyEnabled(context, "bluetooth");
}
+int BluetoothPolicy::setDesktopConnectivityState(const bool enable)
+{
+ int ret = BLUETOOTH_DPM_RESULT_SUCCESS;
+ ret = bluetooth_dpm_set_desktop_connectivity_state(enable == true ? BLUETOOTH_DPM_ALLOWED : BLUETOOTH_DPM_RESTRICTED);
+ if (ret == BLUETOOTH_DPM_RESULT_ACCESS_DENIED ||
+ ret == BLUETOOTH_DPM_RESULT_FAIL) {
+ return -1;
+ }
+
+ SetPolicyEnabled(context, "bluetooth-desktop-connectivity", enable);
+
+ return 0;
+}
+
+bool BluetoothPolicy::getDesktopConnectivityState()
+{
+ return IsPolicyEnabled(context, "bluetooth-desktop-connectivity");
+}
+
int BluetoothPolicy::addDeviceToBlacklist(const std::string& mac)
{
int ret = BLUETOOTH_DPM_RESULT_SUCCESS;
else
printf("bluetooth-tethering state: %s\n", state_text[p_state]);
}
+
+void bluetooth_desktop_connectivity_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_desktop_connectivity_handler(p_state);
+ } else
+ ret = get_bluetooth_desktop_connectivity_handler(&p_state);
+
+ if (ret < 0)
+ printf("bluetooth-desktop-connectivity policy operation is failed.\n");
+ else
+ printf("bluetooth-desktop-connectivity state: %s\n", state_text[p_state]);
+}
void usb_debugging_policy_handler(int command, int state);
void usb_tethering_policy_handler(int command, int state);
void bluetooth_tethering_policy_handler(int command, int state);
+void bluetooth_desktop_connectivity_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_usb_tethering_state_handler(int *state);
int set_bluetooth_tethering_state_handler(int state);
int get_bluetooth_tethering_state_handler(int *state);
+int set_bluetooth_desktop_connectivity_handler(int state);
+int get_bluetooth_desktop_connectivity_handler(int *state);
#endif /* !__DPM_CLI_TOOLKIT_H__ */
printf("--------------------------------------------------------------\n");
printf("[Restrictioin Policy]\n");
printf("camera, microphone, location, clipboard, settings, usb_debugging\n");
- printf("usb_tethering, bluetooth_tethering\n");
+ printf("usb_tethering, bluetooth_tethering, bluetooth_desktop_connectivity\n");
printf("Usage: dpm-cli-toolkit -s [policy-name] -v [value: 0 or 1]\n");
printf("Ex: dpm-cli-toolkit -s camera -v 1\n");
printf("--------------------------------------------------------------\n");
usb_tethering_policy_handler(command, state);
else if (strcmp(policy, "bluetooth_tethering") == 0)
bluetooth_tethering_policy_handler(command, state);
+ else if (strcmp(policy, "bluetooth_desktop_connectivity") == 0)
+ bluetooth_desktop_connectivity_policy_handler(command, state);
else {
printf("Wrong policy name! Please refer to the policy names bleow.\n");
print_rule();
return 0;
}
+
+int set_bluetooth_desktop_connectivity_handler(int state)
+{
+ dpm_context_h context;
+ context = dpm_context_create();
+ if (context == NULL) {
+ printf("Failed to create client context\n");
+ return -1;
+ }
+
+ dpm_restriction_policy_h policy = dpm_context_acquire_restriction_policy(context);
+ if (policy == NULL) {
+ printf("Failed to get restriction policy interface\n");
+ dpm_context_destroy(context);
+ return -1;
+ }
+
+ if (dpm_restriction_set_bluetooth_desktop_connectivity_state(policy, state) < 0) {
+ printf("Failed to set mode change state\n");
+ dpm_context_release_restriction_policy(context, policy);
+ dpm_context_destroy(context);
+ return -1;
+ }
+
+ return 0;
+}
+
+int get_bluetooth_desktop_connectivity_handler(int *state)
+{
+ dpm_context_h context;
+ context = dpm_context_create();
+ if (context == NULL) {
+ printf("Failed to create client context\n");
+ return -1;
+ }
+
+ dpm_restriction_policy_h policy = dpm_context_acquire_restriction_policy(context);
+ if (policy == NULL) {
+ printf("Failed to get restriction policy interface\n");
+ dpm_context_destroy(context);
+ return -1;
+ }
+
+ if (dpm_restriction_get_bluetooth_desktop_connectivity_state(policy, state) != DPM_ERROR_NONE) {
+ printf("Failed to check mode change state\n");
+ dpm_context_release_restriction_policy(context, policy);
+ dpm_context_destroy(context);
+ return -1;
+ }
+
+ dpm_context_release_restriction_policy(context, policy);
+ dpm_context_destroy(context);
+
+ return 0;
+}