Merge changes I0ea498d2,I2d650eb3,I8adcf27e into tm-d1-dev am: 671c65235c
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/18740333 Change-Id: I30105608cf552ec60582cb296179b9cd94b6d66b Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -18,6 +18,9 @@ package com.android.settings.development;
|
||||
|
||||
import static com.android.settings.development.BluetoothA2dpHwOffloadPreferenceController.A2DP_OFFLOAD_SUPPORTED_PROPERTY;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothManager;
|
||||
import android.bluetooth.BluetoothStatusCodes;
|
||||
import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
|
||||
@@ -43,6 +46,9 @@ public class BluetoothLeAudioHwOffloadPreferenceController
|
||||
static final String LE_AUDIO_OFFLOAD_SUPPORTED_PROPERTY =
|
||||
"ro.bluetooth.leaudio_offload.supported";
|
||||
|
||||
@VisibleForTesting
|
||||
BluetoothAdapter mBluetoothAdapter;
|
||||
|
||||
@VisibleForTesting
|
||||
boolean mChanged = false;
|
||||
|
||||
@@ -50,6 +56,7 @@ public class BluetoothLeAudioHwOffloadPreferenceController
|
||||
DevelopmentSettingsDashboardFragment fragment) {
|
||||
super(context);
|
||||
mFragment = fragment;
|
||||
mBluetoothAdapter = context.getSystemService(BluetoothManager.class).getAdapter();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,10 +73,17 @@ public class BluetoothLeAudioHwOffloadPreferenceController
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
if (mBluetoothAdapter == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean leAudioEnabled =
|
||||
(mBluetoothAdapter.isLeAudioSupported() == BluetoothStatusCodes.FEATURE_SUPPORTED);
|
||||
|
||||
final boolean offloadSupported =
|
||||
SystemProperties.getBoolean(A2DP_OFFLOAD_SUPPORTED_PROPERTY, false)
|
||||
&& SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_SUPPORTED_PROPERTY, false);
|
||||
if (offloadSupported) {
|
||||
if (leAudioEnabled && offloadSupported) {
|
||||
final boolean offloadDisabled =
|
||||
SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, true);
|
||||
((SwitchPreference) mPreference).setChecked(offloadDisabled);
|
||||
@@ -82,12 +96,20 @@ public class BluetoothLeAudioHwOffloadPreferenceController
|
||||
@Override
|
||||
protected void onDeveloperOptionsSwitchDisabled() {
|
||||
super.onDeveloperOptionsSwitchDisabled();
|
||||
if (mBluetoothAdapter == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean leAudioEnabled =
|
||||
(mBluetoothAdapter.isLeAudioSupported() == BluetoothStatusCodes.FEATURE_SUPPORTED);
|
||||
final boolean offloadSupported =
|
||||
SystemProperties.getBoolean(A2DP_OFFLOAD_SUPPORTED_PROPERTY, false)
|
||||
&& SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_SUPPORTED_PROPERTY, false);
|
||||
if (offloadSupported) {
|
||||
if (leAudioEnabled && offloadSupported) {
|
||||
((SwitchPreference) mPreference).setChecked(true);
|
||||
SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, "true");
|
||||
} else {
|
||||
mPreference.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user