From 547270400e0b904c614aeb71538b4e85de73e863 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Fri, 11 Aug 2023 12:05:17 +0200 Subject: [PATCH] AudioService: fix NPE in AudioDeviceBroker.setCommunicationRouteForClient Commit 19a459b7 added code that should only be executed upon selection of a valid LE device for communication and not when resetting the device. Bug: 295288081 Test: place a call and select/unselect a BT LE audio device Change-Id: I8c560004a6c87b5b33ab9c862b1e4fde2075bb31 --- .../core/java/com/android/server/audio/AudioDeviceBroker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/audio/AudioDeviceBroker.java b/services/core/java/com/android/server/audio/AudioDeviceBroker.java index d8266ec558337..9f9e2eb382883 100644 --- a/services/core/java/com/android/server/audio/AudioDeviceBroker.java +++ b/services/core/java/com/android/server/audio/AudioDeviceBroker.java @@ -435,7 +435,7 @@ public class AudioDeviceBroker { // LE Audio it stays the same and we must trigger the proper stream volume alignment, if // LE Audio communication device is activated after the audio system has already switched to // MODE_IN_CALL mode. - if (isBluetoothLeAudioRequested()) { + if (isBluetoothLeAudioRequested() && device != null) { final int streamType = mAudioService.getBluetoothContextualVolumeStream(); final int leAudioVolIndex = getVssVolumeForDevice(streamType, device.getInternalType()); final int leAudioMaxVolIndex = getMaxVssVolumeForStream(streamType);