summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2019-02-21 10:20:53 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-02-21 10:20:53 +0000
commit05ddacce30e6adbeca477d5559d13e46adb0756b (patch)
treecc55dae1edbe2d07b3d30df9a924be0501aab6c7
parentb226f96c4884ac768d87060123ec98a6c43ee94a (diff)
parent77535ce22a71b04fd45f526e8c03976e42761ec2 (diff)
Merge "Fix deadlock in LocalBluetoothManager"
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java10
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java14
-rw-r--r--packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java15
3 files changed, 8 insertions, 31 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java
index 4f18d450462d..402ce90d6ec5 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java
@@ -420,14 +420,20 @@ public class BluetoothEventManager {
private class ClassChangedHandler implements Handler {
public void onReceive(Context context, Intent intent,
BluetoothDevice device) {
- mDeviceManager.onBtClassChanged(device);
+ CachedBluetoothDevice cachedDevice = mDeviceManager.findDevice(device);
+ if (cachedDevice != null) {
+ cachedDevice.refresh();
+ }
}
}
private class UuidChangedHandler implements Handler {
public void onReceive(Context context, Intent intent,
BluetoothDevice device) {
- mDeviceManager.onUuidChanged(device);
+ CachedBluetoothDevice cachedDevice = mDeviceManager.findDevice(device);
+ if (cachedDevice != null) {
+ cachedDevice.onUuidChanged();
+ }
}
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java
index 5b4a8b4f259e..33e754044873 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java
@@ -206,20 +206,6 @@ public class CachedBluetoothDeviceManager {
}
}
- public synchronized void onBtClassChanged(BluetoothDevice device) {
- CachedBluetoothDevice cachedDevice = findDevice(device);
- if (cachedDevice != null) {
- cachedDevice.dispatchAttributesChanged();
- }
- }
-
- public synchronized void onUuidChanged(BluetoothDevice device) {
- CachedBluetoothDevice cachedDevice = findDevice(device);
- if (cachedDevice != null) {
- cachedDevice.onUuidChanged();
- }
- }
-
public synchronized void onBluetoothStateChanged(int bluetoothState) {
// When Bluetooth is turning off, we need to clear the non-bonded devices
// Otherwise, they end up showing up on the next BT enable
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java
index 43b289464e1d..dc47de8546db 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java
@@ -369,21 +369,6 @@ public class CachedBluetoothDeviceManagerTest {
}
/**
- * Test to verify onBtClassChanged().
- */
- @Test
- public void onBtClassChanged_validBtClass_classChanged() {
- CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mDevice1);
- assertThat(cachedDevice1).isNotNull();
- assertThat(cachedDevice1.getBtClass()).isEqualTo(DEVICE_CLASS_1);
-
- final BluetoothClass newBluetoothClass = DEVICE_CLASS_2;
- when(mDevice1.getBluetoothClass()).thenReturn(newBluetoothClass);
- mCachedDeviceManager.onBtClassChanged(mDevice1);
- assertThat(cachedDevice1.getBtClass()).isEqualTo(newBluetoothClass);
- }
-
- /**
* Test to verify onDeviceDisappeared().
*/
@Test