Use Trusted Profiles instead of Restricted Profiles 15/143615/3
authorBiman Paul <biman.paul@samsung.com>
Wed, 9 Aug 2017 14:33:50 +0000 (20:03 +0530)
committerBiman Paul <biman.paul@samsung.com>
Fri, 11 Aug 2017 09:13:00 +0000 (14:43 +0530)
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>
include/mobile/bluetooth_internal.h
include/mobile/bluetooth_type_internal.h
include/tv/bluetooth_internal.h
include/tv/bluetooth_type_internal.h
include/wearable/bluetooth_internal.h
include/wearable/bluetooth_type_internal.h
src/bluetooth-device.c

index bd3af982cbe902abc5d6e9bd4da2810b8195f6e9..f5aace3a912aaaf05f099bc3221a80ec75e8881e 100644 (file)
@@ -1194,40 +1194,36 @@ 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
+ * @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
index 4edee6be8b86ea0879f5ea9ea2776a191ef43d15..f21d987266ecb1dc854b288a8055575ce452ebaf 100644 (file)
@@ -574,22 +574,11 @@ typedef enum {
        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.
index aeed803e951e0f8ae29c549cb0cbb8e43a3f0527..d46806f9c7c5181ffb66523ff032d7ac793aba80 100644 (file)
@@ -1166,40 +1166,36 @@ 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
+ * @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
index 8b2404c742851c6876c677d4480a418b8fd5cf36..4eb9a441362c90a2a8dcdefbc001a73d2f74021b 100644 (file)
@@ -557,22 +557,11 @@ typedef enum {
        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.
index 6d85f328f90586a4c3967fe3b927f3ffa00cc40f..9cf4a024636fdf485c9a01ffcc2304d375e38b18 100644 (file)
@@ -1164,40 +1164,36 @@ int bt_device_get_connection_state(const char *remote_address, bt_device_connect
 /**
  * @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
index e8a77dffaec445e13ac04d3b1ea932af8651056c..5b3b057dea27bf3f8da66b361f7fb623861e2afe 100644 (file)
@@ -612,22 +612,11 @@ typedef enum {
        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.
index 94fc70023f22fba9edcb53a105ba083e39eb4271..08a2bcda5665a13eab4b888a14b31f548b8769bc 100644 (file)
@@ -886,47 +886,6 @@ 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_adapter_get_bonded_device_is_alias_set(const char *remote_address, gboolean *alias_set)
 {
        int ret;