|
| 1 | +From 100e07a6bd96c34c87013f1ef7d1e0ed1f094f27 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Roman Stratiienko <r.stratiienko@gmail.com> |
| 3 | +Date: Thu, 12 Dec 2024 05:19:03 +0200 |
| 4 | +Subject: [PATCH 2/2] HCI: Fix improper rfkill handling |
| 5 | + |
| 6 | +Current behavior with kernel rfkill module loaded produces a cascade of |
| 7 | +crash events starting from the following logcat error: |
| 8 | + |
| 9 | + unable to bind bluetooth user channel: Operation not possible due to RF-kill |
| 10 | + |
| 11 | +However, the same device configuration worked well with btlinux HAL, |
| 12 | +which I assume was used as a base for this HAL. |
| 13 | + |
| 14 | +After some investigation, I found that the rfkill(1) function call in the |
| 15 | +btlinux call changed the state to 1, which is RFKILL_STATE_UNBLOCKED. |
| 16 | +The current rfkill(1) sets the soft block value to 1, which corresponds |
| 17 | +to the state value 0 (RFKILL_STATE_SOFT_BLOCKED). |
| 18 | + |
| 19 | +Fix it by providing the correct values to the rfkill() call. |
| 20 | + |
| 21 | +Change-Id: I7a62744f9c21d80b9f8fa37f6c172afa2a5b6c8a |
| 22 | +Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com> |
| 23 | +--- |
| 24 | + bluetooth/aidl/default/net_bluetooth_mgmt.cpp | 8 ++++---- |
| 25 | + 1 file changed, 4 insertions(+), 4 deletions(-) |
| 26 | + |
| 27 | +diff --git a/bluetooth/aidl/default/net_bluetooth_mgmt.cpp b/bluetooth/aidl/default/net_bluetooth_mgmt.cpp |
| 28 | +index 24693effcd..6b0cd63166 100644 |
| 29 | +--- a/bluetooth/aidl/default/net_bluetooth_mgmt.cpp |
| 30 | ++++ b/bluetooth/aidl/default/net_bluetooth_mgmt.cpp |
| 31 | +@@ -259,8 +259,8 @@ int NetBluetoothMgmt::rfkill(int block) { |
| 32 | + int NetBluetoothMgmt::openHci(int hci_interface) { |
| 33 | + ALOGI("opening hci interface %d", hci_interface); |
| 34 | + |
| 35 | +- // Block Bluetooth. |
| 36 | +- rfkill(1); |
| 37 | ++ // Unblock Bluetooth. |
| 38 | ++ rfkill(0); |
| 39 | + |
| 40 | + // Wait for the HCI interface to complete initialization or to come online. |
| 41 | + int hci = waitHciDev(hci_interface); |
| 42 | +@@ -300,8 +300,8 @@ void NetBluetoothMgmt::closeHci() { |
| 43 | + bt_fd_ = -1; |
| 44 | + } |
| 45 | + |
| 46 | +- // Unblock Bluetooth. |
| 47 | +- rfkill(0); |
| 48 | ++ // Block Bluetooth. |
| 49 | ++ rfkill(1); |
| 50 | + } |
| 51 | + |
| 52 | + } // namespace aidl::android::hardware::bluetooth::impl |
| 53 | +-- |
| 54 | +2.43.0 |
| 55 | + |
0 commit comments