| 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_state |
+| 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 |
{
}
+// for restriction CPIs
+int BluetoothPolicy::setModeChangeState(const bool enable)
+{
+ try {
+ return context->methodCall<int>("BluetoothPolicy::setModeChangeState", enable);
+ } catch (runtime::Exception& e) {
+ return -1;
+ }
+}
+
+bool BluetoothPolicy::getModeChangeState()
+{
+ try {
+ return context->methodCall<bool>("BluetoothPolicy::getModeChangeState");
+ } catch (runtime::Exception& e) {
+ return -1;
+ }
+}
+
+// for bluetooth CAPIs
int BluetoothPolicy::addDeviceToBlacklist(const std::string& mac)
{
try {
#include "restriction.h"
#include "restriction.hxx"
+#include "bluetooth.hxx"
#include "debug.h"
#include "policy-client.h"
*state = ret;
return DPM_ERROR_NONE;
}
+
+int dpm_restriction_set_bluetooth_mode_change_state(dpm_restriction_policy_h handle, int enable)
+{
+ RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+
+ BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+ return bluetooth.setModeChangeState(enable);
+}
+
+int dpm_restriction_get_bluetooth_mode_change_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.getModeChangeState();
+ if (ret < 0) {
+ return -1;
+ }
+ *enable = ret;
+
+ return DPM_ERROR_NONE;
+}
DPM_API int dpm_restriction_get_usb_tethering_state(dpm_restriction_policy_h handle, int *enable);
/**
+ * @brief Allows or disallows the user to change Bluetooth settings
+ * @details An administrator can use this API to restrict changing Bluetooth 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_mode_change_state()
+ */
+DPM_API int dpm_restriction_set_bluetooth_mode_change_state(dpm_restriction_policy_h handle, int enable);
+
+/**
+ * @brief Checks whether the the Bluetooth is restricted.
+ * @details An administrator can use this API to check whether the Bluetooth is restricted.
+ * If the Bluetooth 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_mode_change_state()
+ */
+DPM_API int dpm_restriction_get_bluetooth_mode_change_state(dpm_restriction_policy_h handle, int *enable);
+
+/**
* @} // end of DPM_RESTRICTION_POLICY
*/
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(vconf-internal-keys)
BuildRequires: pkgconfig(bluetooth-api)
+BuildRequires: pkgconfig(capi-network-bluetooth)
BuildRequires: pkgconfig(libsmack)
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(auth-fw-admin)
BluetoothPolicy(PolicyControlContext& ctxt);
~BluetoothPolicy();
+ // for restriction CPIs
+ int setModeChangeState(const bool enable);
+ bool getModeChangeState();
+
+ // for bluetooth CAPIs
int addDeviceToBlacklist(const std::string& mac);
int removeDeviceFromBlacklist(const std::string& mac);
int setDeviceRestriction(const bool enable);
deviced
libtzplatform-config
bluetooth-api
+ capi-network-bluetooth
auth-fw-admin
capi-network-wifi
capi-system-info
// TODO(seok85.hong): "re-enforce-policy" : we can notify to admin client with this notification,
// when we should be re-enforced again for the policy that we were failed to set into Bluetooth
int ret = BLUETOOTH_DPM_RESULT_SUCCESS;
+ ret = policy.setModeChangeState(IsPolicyEnabled(context, "bluetooth"));
+ 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.
BluetoothPolicy::BluetoothPolicy(PolicyControlContext& ctxt) :
context(ctxt)
{
+ // for restriction CPIs
+ ctxt.registerParametricMethod(this, (int)(BluetoothPolicy::setModeChangeState)(bool));
+ ctxt.registerNonparametricMethod(this, (bool)(BluetoothPolicy::getModeChangeState));
+ // for bluetooth CPIs
ctxt.registerParametricMethod(this, (int)(BluetoothPolicy::addDeviceToBlacklist)(std::string));
ctxt.registerParametricMethod(this, (int)(BluetoothPolicy::removeDeviceFromBlacklist)(std::string));
ctxt.registerParametricMethod(this, (int)(BluetoothPolicy::setDeviceRestriction)(bool));
bt_deinitialize();
}
+int BluetoothPolicy::setModeChangeState(const bool enable)
+{
+ int ret = BLUETOOTH_DPM_RESULT_SUCCESS;
+ ret = bluetooth_dpm_set_allow_mode(enable == true ? BLUETOOTH_DPM_BT_ALLOWED : BLUETOOTH_DPM_BT_RESTRICTED);
+ if (ret == BLUETOOTH_DPM_RESULT_ACCESS_DENIED ||
+ ret == BLUETOOTH_DPM_RESULT_FAIL) {
+ return -1;
+ }
+
+ SetPolicyEnabled(context, "bluetooth", enable);
+
+ return 0;
+}
+
+bool BluetoothPolicy::getModeChangeState()
+{
+ return IsPolicyEnabled(context, "bluetooth");
+}
+
int BluetoothPolicy::addDeviceToBlacklist(const std::string& mac)
{
int ret = BLUETOOTH_DPM_RESULT_SUCCESS;
printf("6. Remove uuid from blacklist\n");
printf("7. Set uuid restriction\n");
printf("8. Check uuid restriction\n");
+ printf("9. Set mode change state\n");
+ printf("10. Check mode change state\n");
break;
default:
break;
printf("UUID Restriction: Allowed\n");
}
break;
+ case 9:
+ printf("enable(1) or disable(0)> ");
+ if (scanf("%d", &enable) < 0) {
+ input_status = -1;
+ goto out;
+ }
+ if ((enable != 0) && (enable != 1)) {
+ input_status = -1;
+ goto out;
+ }
+ ret = set_mode_change_state_handler(enable);
+ break;
+ case 10:
+ ret = is_mode_change_state_handler(&enable);
+ if (ret == 0) {
+ if (enable == 0)
+ printf("Mode change state: Disallowed\n");
+ else
+ printf("Mode change state: Allowed\n");
+ }
+ break;
default:
printf("Wrong command!\n");
break;
int remove_uuid_from_blacklist_handler(const char *uuid);
int set_uuid_restriction_handler(const int enable);
int is_uuid_restricted_handler(int *enable);
+int set_mode_change_state_handler(const int enable);
+int is_mode_change_state_handler(int *enable);
int set_camera_state_handler(int state);
int get_camera_state_handler(int *state);
else
return 0;
}
+
+int set_mode_change_state_handler(const int enable)
+{
+ 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_mode_change_state(policy, enable) < 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 is_mode_change_state_handler(int *enable)
+{
+ 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_mode_change_state(policy, enable) != 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;
+}