diff options
author | Rahul Sabnis <rahulsabnis@google.com> | 2020-08-05 21:18:10 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-08-05 21:18:10 +0000 |
commit | 00fd683aece05eb33266bda074ddee12ba529055 (patch) | |
tree | 809ea3806cccce7c4e58bf4b896f310b11ee8d7a | |
parent | 6d86ead0e375e283a936ebf5681037cc2193beaf (diff) | |
parent | b2adda81771a671faee455e229471ad2161bd414 (diff) | |
download | bt-00fd683aece05eb33266bda074ddee12ba529055.tar.gz |
Merge "Check whether local device is an ATV device to determine whether to show the consent dialog for BLE pairing in JUSTWORKS and ENCRYPTION_ONLY mode" into oc-dev am: b2adda8177
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/bt/+/12309020
Change-Id: I3cc71adac1897fb29ce5fb4012ed8b1567f1e614
-rw-r--r-- | btif/include/btif_api.h | 12 | ||||
-rw-r--r-- | btif/src/bluetooth.cc | 6 | ||||
-rw-r--r-- | service/hal/bluetooth_interface.cc | 2 | ||||
-rw-r--r-- | stack/smp/smp_act.cc | 11 | ||||
-rw-r--r-- | test/suite/adapter/adapter_unittest.cc | 2 |
5 files changed, 26 insertions, 7 deletions
diff --git a/btif/include/btif_api.h b/btif/include/btif_api.h index e066b8361..9eb64d8a7 100644 --- a/btif/include/btif_api.h +++ b/btif/include/btif_api.h @@ -105,6 +105,18 @@ bool is_restricted_mode(void); /******************************************************************************* * + * Function is_atv_device + * + * Description Returns true if the local device is an Android TV + * device, false if it is not. + * + * Returns bool + * + ******************************************************************************/ +bool is_atv_device(void); + +/******************************************************************************* + * * Function btif_get_adapter_properties * * Description Fetches all local adapter properties diff --git a/btif/src/bluetooth.cc b/btif/src/bluetooth.cc index 988511717..87acbfe63 100644 --- a/btif/src/bluetooth.cc +++ b/btif/src/bluetooth.cc @@ -75,6 +75,7 @@ bt_callbacks_t* bt_hal_cbacks = NULL; bool restricted_mode = false; +bool is_local_device_atv = false; /******************************************************************************* * Externs @@ -131,7 +132,7 @@ static bool is_profile(const char* p1, const char* p2) { * ****************************************************************************/ -static int init(bt_callbacks_t* callbacks) { +static int init(bt_callbacks_t* callbacks, bool is_atv) { LOG_INFO(LOG_TAG, "%s", __func__); if (interface_ready()) return BT_STATUS_DONE; @@ -141,6 +142,7 @@ static int init(bt_callbacks_t* callbacks) { #endif bt_hal_cbacks = callbacks; + is_local_device_atv = is_atv; stack_manager_get_interface()->init_stack(); btif_debug_init(); return BT_STATUS_SUCCESS; @@ -168,6 +170,8 @@ static void cleanup(void) { stack_manager_get_interface()->clean_up_stack(); } bool is_restricted_mode() { return restricted_mode; } +bool is_atv_device() { return is_local_device_atv; } + static int get_adapter_properties(void) { /* sanity check */ if (interface_ready() == false) return BT_STATUS_NOT_READY; diff --git a/service/hal/bluetooth_interface.cc b/service/hal/bluetooth_interface.cc index cf55afda8..2a17485bd 100644 --- a/service/hal/bluetooth_interface.cc +++ b/service/hal/bluetooth_interface.cc @@ -258,7 +258,7 @@ class BluetoothInterfaceImpl : public BluetoothInterface { // Initialize the Bluetooth interface. Set up the adapter (Bluetooth DM) API // callbacks. - status = hal_iface_->init(&bt_callbacks); + status = hal_iface_->init(&bt_callbacks, false); if (status != BT_STATUS_SUCCESS) { LOG(ERROR) << "Failed to initialize Bluetooth stack"; return false; diff --git a/stack/smp/smp_act.cc b/stack/smp/smp_act.cc index 45a8677e8..70b90bd3d 100644 --- a/stack/smp/smp_act.cc +++ b/stack/smp/smp_act.cc @@ -18,6 +18,7 @@ #include <log/log.h> #include <string.h> +#include "btif_api.h" #include "btif_common.h" #include "device/include/interop.h" #include "include/bt_target.h" @@ -1238,8 +1239,9 @@ void smp_decide_association_model(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { p = (tSMP_INT_DATA*)&failure; int_evt = SMP_AUTH_CMPL_EVT; } else { - if (p_cb->local_io_capability != SMP_IO_CAP_NONE && - p_cb->local_io_capability != SMP_IO_CAP_IN) { + if (!is_atv_device() && + (p_cb->local_io_capability == SMP_IO_CAP_IO || + p_cb->local_io_capability == SMP_IO_CAP_KBDISP)) { /* display consent dialog if this device has a display */ SMP_TRACE_DEBUG("ENCRYPTION_ONLY showing Consent Dialog"); p_cb->cb_evt = SMP_CONSENT_REQ_EVT; @@ -1599,8 +1601,9 @@ void smp_process_peer_nonce(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) { } if (p_cb->selected_association_model == SMP_MODEL_SEC_CONN_JUSTWORKS) { - if (p_cb->local_io_capability != SMP_IO_CAP_NONE && - p_cb->local_io_capability != SMP_IO_CAP_IN) { + if (!is_atv_device() && + (p_cb->local_io_capability == SMP_IO_CAP_IO || + p_cb->local_io_capability == SMP_IO_CAP_KBDISP)) { /* display consent dialog */ SMP_TRACE_DEBUG("JUST WORKS showing Consent Dialog"); p_cb->cb_evt = SMP_CONSENT_REQ_EVT; diff --git a/test/suite/adapter/adapter_unittest.cc b/test/suite/adapter/adapter_unittest.cc index f53de3255..6670e7f02 100644 --- a/test/suite/adapter/adapter_unittest.cc +++ b/test/suite/adapter/adapter_unittest.cc @@ -178,7 +178,7 @@ TEST_F(BluetoothTest, AdapterCleanupDuringDiscovery) { ASSERT_TRUE(bt_callbacks != nullptr); for (int i = 0; i < kTestRepeatCount; ++i) { - bt_interface()->init(bt_callbacks); + bt_interface()->init(bt_callbacks, false); EXPECT_EQ(bt_interface()->enable(false), BT_STATUS_SUCCESS); semaphore_wait(adapter_state_changed_callback_sem_); EXPECT_EQ(GetState(), BT_STATE_ON) << "Adapter did not turn on."; |