From 5c49d2c9844d1a0edf832f1b66e07351610e4f0f Mon Sep 17 00:00:00 2001 From: Aritra Sen Date: Wed, 15 Feb 2023 21:17:53 +0000 Subject: [PATCH] Revert "AudioService: handle BT profile disconnections" This reverts commit 47cd8283f10086e3142673e7ea58a313c33c0d8f. Reason for revert: b/269238085 Change-Id: Ic8bc8ef2ab8e368a51cafe7834e2dbbafc21ab86 --- .../server/audio/AudioDeviceBroker.java | 1 - .../com/android/server/audio/BtHelper.java | 70 +++---------------- 2 files changed, 8 insertions(+), 63 deletions(-) diff --git a/services/core/java/com/android/server/audio/AudioDeviceBroker.java b/services/core/java/com/android/server/audio/AudioDeviceBroker.java index a88055d0cb2be..b001f3d0c892d 100644 --- a/services/core/java/com/android/server/audio/AudioDeviceBroker.java +++ b/services/core/java/com/android/server/audio/AudioDeviceBroker.java @@ -1556,7 +1556,6 @@ import java.util.concurrent.atomic.AtomicBoolean; case MSG_I_BT_SERVICE_DISCONNECTED_PROFILE: if (msg.arg1 != BluetoothProfile.HEADSET) { synchronized (mDeviceStateLock) { - mBtHelper.onBtProfileDisconnected(msg.arg1); mDeviceInventory.onBtProfileDisconnected(msg.arg1); } } else { diff --git a/services/core/java/com/android/server/audio/BtHelper.java b/services/core/java/com/android/server/audio/BtHelper.java index 4ab23c5ac84fa..df65dbd53e061 100644 --- a/services/core/java/com/android/server/audio/BtHelper.java +++ b/services/core/java/com/android/server/audio/BtHelper.java @@ -278,11 +278,7 @@ public class BtHelper { } AudioService.sVolumeLogger.enqueue(new AudioServiceEvents.VolumeEvent( AudioServiceEvents.VolumeEvent.VOL_SET_AVRCP_VOL, index)); - try { - mA2dp.setAvrcpAbsoluteVolume(index); - } catch (Exception e) { - Log.e(TAG, "Exception while changing abs volume", e); - } + mA2dp.setAvrcpAbsoluteVolume(index); } /*package*/ synchronized @AudioSystem.AudioFormatNativeEnumForBtCodec int getA2dpCodec( @@ -290,12 +286,7 @@ public class BtHelper { if (mA2dp == null) { return AudioSystem.AUDIO_FORMAT_DEFAULT; } - final BluetoothCodecStatus btCodecStatus = null; - try { - mA2dp.getCodecStatus(device); - } catch (Exception e) { - Log.e(TAG, "Exception while getting status of " + device, e); - } + final BluetoothCodecStatus btCodecStatus = mA2dp.getCodecStatus(device); if (btCodecStatus == null) { return AudioSystem.AUDIO_FORMAT_DEFAULT; } @@ -429,11 +420,7 @@ public class BtHelper { } AudioService.sVolumeLogger.enqueue(new AudioServiceEvents.VolumeEvent( AudioServiceEvents.VolumeEvent.VOL_SET_LE_AUDIO_VOL, index, maxIndex)); - try { - mLeAudio.setVolume(volume); - } catch (Exception e) { - Log.e(TAG, "Exception while setting LE volume", e); - } + mLeAudio.setVolume(volume); } /*package*/ synchronized void setHearingAidVolume(int index, int streamType, @@ -459,11 +446,7 @@ public class BtHelper { AudioService.sVolumeLogger.enqueue(new AudioServiceEvents.VolumeEvent( AudioServiceEvents.VolumeEvent.VOL_SET_HEARING_AID_VOL, index, gainDB)); } - try { - mHearingAid.setVolume(gainDB); - } catch (Exception e) { - Log.i(TAG, "Exception while setting hearing aid volume", e); - } + mHearingAid.setVolume(gainDB); } /*package*/ synchronized void onBroadcastScoConnectionState(int state) { @@ -488,7 +471,7 @@ public class BtHelper { } // @GuardedBy("AudioDeviceBroker.mSetModeLock") - //@GuardedBy("AudioDeviceBroker.mDeviceStateLock") + @GuardedBy("AudioDeviceBroker.mDeviceStateLock") /*package*/ synchronized void resetBluetoothSco() { mScoAudioState = SCO_STATE_INACTIVE; broadcastScoConnectionState(AudioManager.SCO_AUDIO_STATE_DISCONNECTED); @@ -503,35 +486,6 @@ public class BtHelper { mBluetoothHeadset = null; } - //@GuardedBy("AudioDeviceBroker.mDeviceStateLock") - /*package*/ synchronized void onBtProfileDisconnected(int profile) { - switch (profile) { - case BluetoothProfile.A2DP: - mA2dp = null; - break; - case BluetoothProfile.HEARING_AID: - mHearingAid = null; - break; - case BluetoothProfile.LE_AUDIO: - mLeAudio = null; - break; - - case BluetoothProfile.A2DP_SINK: - case BluetoothProfile.LE_AUDIO_BROADCAST: - // shouldn't be received here as profile doesn't involve BtHelper - Log.e(TAG, "onBtProfileDisconnected: Not a profile handled by BtHelper " - + BluetoothProfile.getProfileName(profile)); - break; - - default: - // Not a valid profile to disconnect - Log.e(TAG, "onBtProfileDisconnected: Not a valid profile to disconnect " - + BluetoothProfile.getProfileName(profile)); - break; - } - } - - @GuardedBy("AudioDeviceBroker.mDeviceStateLock") /*package*/ synchronized void onBtProfileConnected(int profile, BluetoothProfile proxy) { if (profile == BluetoothProfile.HEADSET) { onHeadsetProfileConnected((BluetoothHeadset) proxy); @@ -717,6 +671,7 @@ public class BtHelper { public void onServiceConnected(int profile, BluetoothProfile proxy) { switch(profile) { case BluetoothProfile.A2DP: + case BluetoothProfile.A2DP_SINK: case BluetoothProfile.HEADSET: case BluetoothProfile.HEARING_AID: case BluetoothProfile.LE_AUDIO: @@ -726,10 +681,6 @@ public class BtHelper { mDeviceBroker.postBtProfileConnected(profile, proxy); break; - case BluetoothProfile.A2DP_SINK: - // no A2DP sink functionality handled by BtHelper - case BluetoothProfile.LE_AUDIO_BROADCAST: - // no broadcast functionality handled by BtHelper default: break; } @@ -738,19 +689,14 @@ public class BtHelper { switch (profile) { case BluetoothProfile.A2DP: + case BluetoothProfile.A2DP_SINK: case BluetoothProfile.HEADSET: case BluetoothProfile.HEARING_AID: case BluetoothProfile.LE_AUDIO: - AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent( - "BT profile service: disconnecting " - + BluetoothProfile.getProfileName(profile) + " profile")); + case BluetoothProfile.LE_AUDIO_BROADCAST: mDeviceBroker.postBtProfileDisconnected(profile); break; - case BluetoothProfile.A2DP_SINK: - // no A2DP sink functionality handled by BtHelper - case BluetoothProfile.LE_AUDIO_BROADCAST: - // no broadcast functionality handled by BtHelper default: break; }