From 75f1cff15d065747329a01b7d17b055a66fe0255 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Thu, 15 Jun 2023 20:00:17 +0200 Subject: AudioDeviceInventory: fix purge of device role cache. Commit ace96019 which modifies purgeRoles() method compares device address strings with == but it should use equals() operator instead. Bug: 282907547 Test: repro steps in the bug. Change-Id: I302e470bd6a0fbcd288508d3e6bf394087de9361 --- .../core/java/com/android/server/audio/AudioDeviceInventory.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/audio/AudioDeviceInventory.java b/services/core/java/com/android/server/audio/AudioDeviceInventory.java index ec85d577a8e7..0c7f11f98809 100644 --- a/services/core/java/com/android/server/audio/AudioDeviceInventory.java +++ b/services/core/java/com/android/server/audio/AudioDeviceInventory.java @@ -1199,11 +1199,16 @@ public class AudioDeviceInventory { AudioDeviceInfo device = Stream.of(connectedDevices) .filter(d -> d.getInternalType() == ada.getInternalType()) .filter(d -> (!AudioSystem.isBluetoothDevice(d.getInternalType()) - || (d.getAddress() == ada.getAddress()))) + || (d.getAddress().equals(ada.getAddress())))) .findFirst() .orElse(null); if (device == null) { + if (AudioService.DEBUG_DEVICES) { + Slog.i(TAG, "purgeRoles() removing device: " + ada.toString() + + ", for strategy: " + keyRole.first + + " and role: " + keyRole.second); + } asi.deviceRoleAction(keyRole.first, keyRole.second, Arrays.asList(ada)); itDev.remove(); } -- cgit v1.2.3-59-g8ed1b