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
This commit is contained in:
Vlad Popa
2023-08-18 16:21:46 -07:00
parent 5329b06ae7
commit 6af54b3225

View File

@@ -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,