From 6af54b32255f376ad83af32ab85e02e5765fe9f5 Mon Sep 17 00:00:00 2001 From: Vlad Popa Date: Fri, 18 Aug 2023 16:21:46 -0700 Subject: [PATCH] Do not show SA preference for device that do not support it Checking the spatializer immersive level to determine whether to show or not the spatial audio preference in bluetooth settings Test: manual on cheetah and bluejay Bug: 296636479 Change-Id: I2f113f6d66acd30fd25d05556b99407cbc280e0a --- .../BluetoothDetailsSpatialAudioController.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsSpatialAudioController.java b/src/com/android/settings/bluetooth/BluetoothDetailsSpatialAudioController.java index a1e133e6104..bec6b03771f 100644 --- a/src/com/android/settings/bluetooth/BluetoothDetailsSpatialAudioController.java +++ b/src/com/android/settings/bluetooth/BluetoothDetailsSpatialAudioController.java @@ -16,6 +16,8 @@ package com.android.settings.bluetooth; +import static android.media.Spatializer.SPATIALIZER_IMMERSIVE_LEVEL_NONE; + import android.content.Context; import android.media.AudioDeviceAttributes; import android.media.AudioDeviceInfo; @@ -106,6 +108,10 @@ public class BluetoothDetailsSpatialAudioController extends BluetoothDetailsCont @Override protected void refresh() { + if (mAudioDevice == null) { + return; + } + SwitchPreference spatialAudioPref = mProfilesContainer.findPreference(KEY_SPATIAL_AUDIO); if (spatialAudioPref == null) { spatialAudioPref = createSpatialAudioPreference(mProfilesContainer.getContext()); @@ -152,6 +158,14 @@ public class BluetoothDetailsSpatialAudioController extends BluetoothDetailsCont } private void getAvailableDevice() { + if (mSpatializer.getImmersiveAudioLevel() == SPATIALIZER_IMMERSIVE_LEVEL_NONE) { + mIsAvailable = false; + mAudioDevice = null; + Log.d(TAG, "getAvailableDevice() ignored: spatializer not supported"); + + return; + } + AudioDeviceAttributes a2dpDevice = new AudioDeviceAttributes( AudioDeviceAttributes.ROLE_OUTPUT, AudioDeviceInfo.TYPE_BLUETOOTH_A2DP,