Config LE audio connection by default
Use LE audio connection by default, and allow to have the differenct configuration per project (system property). As using LE audio connection by default, the toggle, "Show LE audio toggle in Device Details", would be useless, hide this toggle based on the project configuration Bug: 300012501 Test: make RunSettingsRoboTests ROBOTEST_FILTER=BluetoothLeDeviceDetailsPreferenceControllerTest Change-Id: Ia4df48d6a71b5b9f11bd91a69971c8393412da13
This commit is contained in:
@@ -21,7 +21,6 @@ import android.bluetooth.BluetoothManager;
|
||||
import android.bluetooth.BluetoothStatusCodes;
|
||||
import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
import android.provider.DeviceConfig;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
@@ -39,7 +38,8 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController
|
||||
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
|
||||
|
||||
private static final String PREFERENCE_KEY = "bluetooth_show_leaudio_device_details";
|
||||
private static final String CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT = "le_audio_enabled_by_default";
|
||||
private static final String LE_AUDIO_CONNECTION_BY_DEFAULT_PROPERTY =
|
||||
"ro.bluetooth.leaudio.le_audio_connection_by_default";
|
||||
private static final boolean LE_AUDIO_TOGGLE_VISIBLE_DEFAULT_VALUE = true;
|
||||
static int sLeAudioSupportedStateCache = BluetoothStatusCodes.ERROR_UNKNOWN;
|
||||
|
||||
@@ -48,10 +48,13 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController
|
||||
|
||||
@VisibleForTesting
|
||||
BluetoothAdapter mBluetoothAdapter;
|
||||
@VisibleForTesting boolean mLeAudioEnabledByDefault;
|
||||
|
||||
public BluetoothLeAudioDeviceDetailsPreferenceController(Context context) {
|
||||
super(context);
|
||||
mBluetoothAdapter = context.getSystemService(BluetoothManager.class).getAdapter();
|
||||
mLeAudioEnabledByDefault =
|
||||
SystemProperties.getBoolean(LE_AUDIO_CONNECTION_BY_DEFAULT_PROPERTY, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,7 +73,8 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController
|
||||
}
|
||||
|
||||
// Display the option only if LE Audio is supported
|
||||
return (sLeAudioSupportedStateCache == BluetoothStatusCodes.FEATURE_SUPPORTED);
|
||||
return !mLeAudioEnabledByDefault
|
||||
&& (sLeAudioSupportedStateCache == BluetoothStatusCodes.FEATURE_SUPPORTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,11 +92,7 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController
|
||||
|
||||
final boolean isLeAudioToggleVisible = SystemProperties.getBoolean(
|
||||
LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, LE_AUDIO_TOGGLE_VISIBLE_DEFAULT_VALUE);
|
||||
final boolean leAudioEnabledByDefault = DeviceConfig.getBoolean(
|
||||
DeviceConfig.NAMESPACE_BLUETOOTH, CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT, false);
|
||||
|
||||
mPreference.setEnabled(!leAudioEnabledByDefault);
|
||||
((SwitchPreference) mPreference).setChecked(isLeAudioToggleVisible
|
||||
|| leAudioEnabledByDefault);
|
||||
((SwitchPreference) mPreference).setChecked(isLeAudioToggleVisible);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user