summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLianchao Song2017-12-25 03:29:40 -0600
committerMyles Watson2018-01-09 15:14:47 -0600
commit424ffd0da56d818510000acd56b23824c960d7d7 (patch)
tree00c0fb700d00a4fc653f05db588fe4a40fc9bc43 /bluetooth/1.0
parent207e97c7354050cd5162feb45a1e1d51aab048f0 (diff)
downloadplatform-hardware-interfaces-424ffd0da56d818510000acd56b23824c960d7d7.tar.gz
platform-hardware-interfaces-424ffd0da56d818510000acd56b23824c960d7d7.tar.xz
platform-hardware-interfaces-424ffd0da56d818510000acd56b23824c960d7d7.zip
BT Interface: fix hci cmd timeout
Add mutex in function Send() and OnTimeout() to do mutual exclusive access on lpm_wake_deasserted. If lpm_wake_deasserted is out of sync with the actual wake state, then platforms which use the lpm hint will break. Bug: 64299848 Test: run affected platform for a long period of time and find that hci commands do not time out Change-Id: I9f630d6f40f84b9c047c6488632cd44d6602bb14
Diffstat (limited to 'bluetooth/1.0')
-rw-r--r--bluetooth/1.0/default/vendor_interface.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/bluetooth/1.0/default/vendor_interface.cc b/bluetooth/1.0/default/vendor_interface.cc
index 6ce2f11f..a8f5bb40 100644
--- a/bluetooth/1.0/default/vendor_interface.cc
+++ b/bluetooth/1.0/default/vendor_interface.cc
@@ -49,6 +49,7 @@ uint32_t lpm_timeout_ms;
49bool recent_activity_flag; 49bool recent_activity_flag;
50 50
51VendorInterface* g_vendor_interface = nullptr; 51VendorInterface* g_vendor_interface = nullptr;
52std::mutex wakeup_mutex_;
52 53
53HC_BT_HDR* WrapPacketAndCopy(uint16_t event, const hidl_vec<uint8_t>& data) { 54HC_BT_HDR* WrapPacketAndCopy(uint16_t event, const hidl_vec<uint8_t>& data) {
54 size_t packet_size = data.size() + sizeof(HC_BT_HDR); 55 size_t packet_size = data.size() + sizeof(HC_BT_HDR);
@@ -308,6 +309,7 @@ void VendorInterface::Close() {
308} 309}
309 310
310size_t VendorInterface::Send(uint8_t type, const uint8_t* data, size_t length) { 311size_t VendorInterface::Send(uint8_t type, const uint8_t* data, size_t length) {
312 std::unique_lock<std::mutex> lock(wakeup_mutex_);
311 recent_activity_flag = true; 313 recent_activity_flag = true;
312 314
313 if (lpm_wake_deasserted == true) { 315 if (lpm_wake_deasserted == true) {
@@ -350,6 +352,7 @@ void VendorInterface::OnFirmwareConfigured(uint8_t result) {
350 352
351void VendorInterface::OnTimeout() { 353void VendorInterface::OnTimeout() {
352 ALOGV("%s", __func__); 354 ALOGV("%s", __func__);
355 std::unique_lock<std::mutex> lock(wakeup_mutex_);
353 if (recent_activity_flag == false) { 356 if (recent_activity_flag == false) {
354 lpm_wake_deasserted = true; 357 lpm_wake_deasserted = true;
355 bt_vendor_lpm_wake_state_t wakeState = BT_VND_LPM_WAKE_DEASSERT; 358 bt_vendor_lpm_wake_state_t wakeState = BT_VND_LPM_WAKE_DEASSERT;