From 2303aff05206be361afbd88d99985ce4d8b5ebf2 Mon Sep 17 00:00:00 2001 From: Robert Wu Date: Tue, 27 Sep 2022 23:39:44 +0000 Subject: [PATCH] Bluetooth MIDI: Don't open device automatically In Android T, we experimented with opening Bluetooth devices without the need for a separate app for pairing. We did not end up shipping the feature and we ended up commenting out this code. However, we missed one line in BluetoothMidiService. When a Bluetooth MIDI device is discovered, onServicesDiscovered() calls the same apis as real apps, openBluetoothDevice(). If both apps and BluetoothMidiService tries to open the same Bluetooth device, a myriad of race conditions occur. The fix here is to remove the extra openBluetoothDevice() call. See ag/16644383 and ag/18088048 for the CLs that added and removed the Bluetooth MIDI pairing feature. Bug: 246507339 Test: Repeatedly connect and disconnect Yamaha UD-BT01 with BLE+MIDI app Test: Repeatedly connect and disconnect Yamaha MD-BT01 with BLE+MIDI app Change-Id: I45d6090c3c55a597d6db01fbc30e135f241a11c7 --- .../com/android/bluetoothmidiservice/BluetoothMidiDevice.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java b/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java index 2fe7b1668d084..08a447f45a30a 100644 --- a/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java +++ b/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java @@ -138,8 +138,6 @@ public final class BluetoothMidiDevice { // switch to receiving notifications mBluetoothGatt.readCharacteristic(characteristic); } - - openBluetoothDevice(mBluetoothDevice); } } else { Log.e(TAG, "onServicesDiscovered received: " + status);