Add internal API about restricted profile set/get 44/87644/1
authorHyuk Lee <hyuk0512.lee@samsung.com>
Fri, 9 Sep 2016 04:11:03 +0000 (13:11 +0900)
committerHyuk Lee <hyuk0512.lee@samsung.com>
Fri, 9 Sep 2016 04:11:03 +0000 (13:11 +0900)
Change-Id: I33732ed309d9bffb571f6366c2f7bb842c5c4b9c
Signed-off-by: Hyuk Lee <hyuk0512.lee@samsung.com>
include/mobile/bluetooth_internal.h
include/mobile/bluetooth_type_internal.h
src/bluetooth-device.c

index 66e7d3187e98d3fa1e8006595283b21a01eca100..f7f124dd9f700a6042aac21e7eefb87b3c681efa 100644 (file)
@@ -1086,6 +1086,44 @@ int bt_device_create_bond_by_type(const char *remote_address,
  */
 int bt_device_cancel_service_search(void);
 
+/**
+ * @internal
+ * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
+ * @brief Sets a profile restricted connection for a device
+ * @since_tizen 3.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/bluetooth.admin
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE  Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
+ * @retval #BT_ERROR_NOT_ENABLED  Not enabled
+ * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED  Remote device not bonded
+ * @retval #BT_ERROR_NOT_IN_PROGRESS  Operation not in progress
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ */
+int bt_device_set_profile_restricted(const char *device_address, bt_restricted_profile_t profile, bool restricted);
+
+/**
+ * @internal
+ * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
+ * @brief Gets a profile restricted connection for a device
+ * @since_tizen 3.0
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE  Successful
+ * @retval #BT_ERROR_NOT_INITIALIZED  Not initialized
+ * @retval #BT_ERROR_NOT_ENABLED  Not enabled
+ * @retval #BT_ERROR_REMOTE_DEVICE_NOT_BONDED  Remote device not bonded
+ * @retval #BT_ERROR_NOT_IN_PROGRESS  Operation not in progress
+ * @retval #BT_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #BT_ERROR_PERMISSION_DENIED  Permission denied
+ * @retval #BT_ERROR_NOT_SUPPORTED  Not supported
+ */
+int bt_device_get_profile_restricted(const char *device_address, bt_restricted_profile_t profile, int *restricted);
+
 /**
  * @internal
  * @ingroup CAPI_NETWORK_BLUETOOTH_SOCKET_MODULE
index 55b7555a5935005d367aca5735eb676f92848487..81586400a57e7ef0bd80f15edba27ab484689542 100644 (file)
@@ -392,6 +392,19 @@ typedef enum {
        BT_TRUSTED_PROFILE_ALL = 0xFFFFFFFF,
 } bt_trusted_profile_t;
 
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
+ * @brief Restricted Profile enumeration.
+ * @since_tizen 3.0
+ *
+ * @see bt_device_set_profile_restricted()
+ * @see bt_device_get_profile_restricted()
+ */
+typedef enum {
+       BT_RESTRICTED_PROFILE_HFP_HS = 1,
+       BT_RESTRICTED_PROFILE_A2DP,
+} bt_restricted_profile_t;
+
 /**
  * @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
  * @brief  Called when Trusted Profiles is changed.
index c042977151935be574de4b3372cf30adcdc093f0..558f55c75217318b042b72e9d662ef524c64c1cc 100644 (file)
@@ -899,6 +899,46 @@ int bt_device_unset_trusted_profile_cb(void)
        return BT_ERROR_NONE;
 }
 
+int bt_device_set_profile_restricted(const char *device_address,
+               bt_restricted_profile_t profile, bool restricted)
+{
+       bluetooth_device_address_t addr_hex = { {0,} };
+       int error_code = BT_ERROR_NONE;
+
+       BT_CHECK_INIT_STATUS();
+       BT_CHECK_INPUT_PARAMETER(device_address);
+
+       _bt_convert_address_to_hex(&addr_hex, device_address);
+       error_code = _bt_get_error_code(bluetooth_set_profile_restricted(&addr_hex,
+                       profile, restricted));
+       if (error_code != BT_ERROR_NONE) {
+               BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+       }
+
+       return error_code;
+}
+
+int bt_device_get_profile_restricted(const char *device_address,
+               bt_restricted_profile_t profile, int *restricted)
+{
+       bluetooth_device_address_t addr_hex = { {0,} };
+       int profile_restricted;
+       int error_code = BT_ERROR_NONE;
+
+       BT_CHECK_INIT_STATUS();
+       BT_CHECK_INPUT_PARAMETER(device_address);
+
+       _bt_convert_address_to_hex(&addr_hex, device_address);
+       error_code = _bt_get_error_code(bluetooth_get_profile_restricted(&addr_hex,
+                       profile, &profile_restricted));
+       if (error_code != BT_ERROR_NONE) {
+               BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+       }
+       if (restricted)
+               *restricted = profile_restricted;
+       return error_code;
+}
+
 int bt_device_le_set_data_length(const char *remote_address,
                unsigned int max_tx_Octets,  unsigned int max_tx_Time)
 {