Allow non-zero HCI interface numbers
[Description]
when driver re-register hci device, it may register hci 1
[Root Cause]
In the kernel mechanism, there may be a timing issue. when driver re-register hci device,kernel may not completely unregister hci 0.But aidl only open hci 0.
[Solution]
assign a value to the hci interface based on the device node found by AIDL
[Test Report]
Insert the bt chip into the usb 2.0 port, and then suspend the TV. The bt chip will be disconnected due to the USB power outage. And then quickly resume the TV,check whether the Bluetooth state is on. Suspend and resume for several times, check for bt state.
Change-Id: I57fd4a22c956e0cf2b4a516247c258493163e51a
BUG: 314149416
diff --git a/bluetooth/aidl/default/net_bluetooth_mgmt.cpp b/bluetooth/aidl/default/net_bluetooth_mgmt.cpp
index 937cd57..0699781 100644
--- a/bluetooth/aidl/default/net_bluetooth_mgmt.cpp
+++ b/bluetooth/aidl/default/net_bluetooth_mgmt.cpp
@@ -162,9 +162,9 @@
(struct mgmt_ev_read_index_list*)ev.data;
for (int i = 0; i < data->num_controllers; i++) {
- if (data->index[i] == hci_interface) {
- ALOGI("hci interface %d found", hci_interface);
- ret = 0;
+ if (data->index[i] >= hci_interface) {
+ ALOGI("hci interface %d found", data->index[i]);
+ ret = data->index[i];
goto end;
}
}
@@ -253,8 +253,9 @@
rfkill(1);
// Wait for the HCI interface to complete initialization or to come online.
- if (waitHciDev(hci_interface)) {
- ALOGE("hci interface %d not found", hci_interface);
+ hci_interface = waitHciDev(hci_interface);
+ if (hci_interface < 0) {
+ ALOGE("hci interface not found");
return -1;
}