Trusted profiles and restricted profiles concept are similar.
Trusted profiles concept supports 3 states for each profile:
1. Unknown state: Let the user decide using authorization.
2. Blocked: Do not allow connection
3. Trusted: Always accept connection
In case of restricted profiles we only have Blocked and Trusted
states but Unknown state can be treated as Trusted because by
default, we should allow connection in case of Audio profiles.
We can remove Restricted Profiles implementation and this would
reduce redundant code.
Change-Id: I6e83f20bf7ba6a82c63a5208ef90050c3d443fc2
Signed-off-by: Biman Paul <biman.paul@samsung.com>
/**
* @internal
* @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
- * @brief Sets a profile restricted connection for a device
- * @since_tizen 3.0
+ * @brief Set a profile trusted or untrusted for a device.
+ * @since_tizen 2.4
* @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
+ * @retval #BT_ERROR_INTERNAL Internal Error
+ * @retval #BT_ERROR_NOT_INITIALIZED Not supported
+ * @retval #BT_ERROR_INVALID_PARAMETER Invalid Parameter
+ * @retval #BT_ERROR_NOT_ENABLED Invalid Parameter
*/
-int bt_device_set_profile_restricted(const char *device_address, bt_restricted_profile_t profile, bool restricted);
+int bt_device_set_profile_trusted(const char *device_address,
+ bt_trusted_profile_t profile, bool trust);
/**
* @internal
* @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
- * @brief Gets a profile restricted connection for a device
- * @since_tizen 3.0
- *
+ * @brief Get a profile is trusted or untrusted for a device.
+ * @since_tizen 2.4
+ * @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
+ * @retval #BT_ERROR_INTERNAL Internal Error
+ * @retval #BT_ERROR_NOT_INITIALIZED Not supported
+ * @retval #BT_ERROR_NOT_ENABLED Invalid Parameter
+ * @retval #BT_ERROR_INVALID_PARAMETER Invalid Parameter
*/
-int bt_device_get_profile_restricted(const char *device_address, bt_restricted_profile_t profile, int *restricted);
+int bt_device_get_profile_trusted(const char *device_address,
+ bt_trusted_profile_t profile, int *trust);
/**
* @internal
BT_TRUSTED_PROFILE_PBAP = 1,
BT_TRUSTED_PROFILE_MAP,
BT_TRUSTED_PROFILE_SAP,
+ BT_TRUSTED_PROFILE_HFP_HS,
+ BT_TRUSTED_PROFILE_A2DP,
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_ADAPTER_MODULE
* @brief Enumerations of the authentication event types.
/**
* @internal
* @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
- * @brief Sets a profile restricted connection for a device
- * @since_tizen 3.0
+ * @brief Set a profile trusted or untrusted for a device.
+ * @since_tizen 2.4
* @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
+ * @retval #BT_ERROR_INTERNAL Internal Error
+ * @retval #BT_ERROR_NOT_INITIALIZED Not supported
+ * @retval #BT_ERROR_INVALID_PARAMETER Invalid Parameter
+ * @retval #BT_ERROR_NOT_ENABLED Invalid Parameter
*/
-int bt_device_set_profile_restricted(const char *device_address, bt_restricted_profile_t profile, bool restricted);
+int bt_device_set_profile_trusted(const char *device_address,
+ bt_trusted_profile_t profile, bool trust);
/**
* @internal
* @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
- * @brief Gets a profile restricted connection for a device
- * @since_tizen 3.0
- *
+ * @brief Get a profile is trusted or untrusted for a device.
+ * @since_tizen 2.4
+ * @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
+ * @retval #BT_ERROR_INTERNAL Internal Error
+ * @retval #BT_ERROR_NOT_INITIALIZED Not supported
+ * @retval #BT_ERROR_NOT_ENABLED Invalid Parameter
+ * @retval #BT_ERROR_INVALID_PARAMETER Invalid Parameter
*/
-int bt_device_get_profile_restricted(const char *device_address, bt_restricted_profile_t profile, int *restricted);
+int bt_device_get_profile_trusted(const char *device_address,
+ bt_trusted_profile_t profile, int *trust);
/**
* @internal
BT_TRUSTED_PROFILE_PBAP = 1,
BT_TRUSTED_PROFILE_MAP,
BT_TRUSTED_PROFILE_SAP,
+ BT_TRUSTED_PROFILE_HFP_HS,
+ BT_TRUSTED_PROFILE_A2DP,
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_ADAPTER_MODULE
* @brief Enumerations of the authentication event types.
/**
* @internal
* @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
- * @brief Sets a profile restricted connection for a device
- * @since_tizen 3.0
+ * @brief Set a profile trusted or untrusted for a device.
+ * @since_tizen 2.4
* @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
+ * @retval #BT_ERROR_INTERNAL Internal Error
+ * @retval #BT_ERROR_NOT_INITIALIZED Not supported
+ * @retval #BT_ERROR_INVALID_PARAMETER Invalid Parameter
+ * @retval #BT_ERROR_NOT_ENABLED Invalid Parameter
*/
-int bt_device_set_profile_restricted(const char *device_address, bt_restricted_profile_t profile, bool restricted);
+int bt_device_set_profile_trusted(const char *device_address,
+ bt_trusted_profile_t profile, bool trust);
/**
* @internal
* @ingroup CAPI_NETWORK_BLUETOOTH_DEVICE_MODULE
- * @brief Gets a profile restricted connection for a device
- * @since_tizen 3.0
- *
+ * @brief Get a profile is trusted or untrusted for a device.
+ * @since_tizen 2.4
+ * @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
+ * @retval #BT_ERROR_INTERNAL Internal Error
+ * @retval #BT_ERROR_NOT_INITIALIZED Not supported
+ * @retval #BT_ERROR_NOT_ENABLED Invalid Parameter
+ * @retval #BT_ERROR_INVALID_PARAMETER Invalid Parameter
*/
-int bt_device_get_profile_restricted(const char *device_address, bt_restricted_profile_t profile, int *restricted);
+int bt_device_get_profile_trusted(const char *device_address,
+ bt_trusted_profile_t profile, int *trust);
/**
* @internal
BT_TRUSTED_PROFILE_PBAP = 1,
BT_TRUSTED_PROFILE_MAP,
BT_TRUSTED_PROFILE_SAP,
+ BT_TRUSTED_PROFILE_HFP_HS,
+ BT_TRUSTED_PROFILE_A2DP,
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_ADAPTER_MODULE
* @brief Enumerations of the authentication event types.
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_adapter_get_bonded_device_is_alias_set(const char *remote_address, gboolean *alias_set)
{
int ret;