From f60aeb446261cc859d28e79b6eb32402bc81cb3a Mon Sep 17 00:00:00 2001 From: Andre Eisenbach Date: Tue, 7 Feb 2017 20:28:32 -0800 Subject: [PATCH] Bluetooth: Disable low power managerment on Hal->close() This ensures the vendor library can release any wakelocks held and perform any additional cleanup steps as necessary. Change-Id: Ibfeac161109162ac375eef9c20f147f0506de602 Fixes: 35097918 Test: manual; disable Bluetooth, monitor wakelocks --- bluetooth/1.0/default/vendor_interface.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bluetooth/1.0/default/vendor_interface.cc b/bluetooth/1.0/default/vendor_interface.cc index f2289828..7f14e689 100644 --- a/bluetooth/1.0/default/vendor_interface.cc +++ b/bluetooth/1.0/default/vendor_interface.cc @@ -277,7 +277,7 @@ bool VendorInterface::Open(InitializeCompleteCallback initialize_complete_cb, [this](int fd) { OnDataReady(fd); }); // Initially, the power management is off. - lpm_wake_deasserted = false; + lpm_wake_deasserted = true; // Start configuring the firmware firmware_startup_timer_ = new FirmwareStartupTimer(); @@ -290,6 +290,9 @@ void VendorInterface::Close() { fd_watcher_.StopWatchingFileDescriptor(); if (lib_interface_ != nullptr) { + bt_vendor_lpm_mode_t mode = BT_VND_LPM_DISABLE; + lib_interface_->op(BT_VND_OP_LPM_SET_MODE, &mode); + lib_interface_->op(BT_VND_OP_USERIAL_CLOSE, nullptr); uart_fd_ = INVALID_FD; int power_state = BT_VND_PWR_OFF; @@ -352,9 +355,6 @@ void VendorInterface::OnFirmwareConfigured(uint8_t result) { ALOGD("%s Calling StartLowPowerWatchdog()", __func__); fd_watcher_.ConfigureTimeout(std::chrono::milliseconds(lpm_timeout_ms), [this]() { OnTimeout(); }); - - bt_vendor_lpm_wake_state_t wakeState = BT_VND_LPM_WAKE_ASSERT; - lib_interface_->op(BT_VND_OP_LPM_WAKE_SET_STATE, &wakeState); } void VendorInterface::OnTimeout() { -- 2.11.0