Do not disable LE audio offload as the developer option being disabled

The logic wrong to check the a2dp offload disable status to disable LE
audio offload together as the user turn off the developer option. Change
to use the support status, and reset the state to align the support
status.

Bug: 395725497
Fix: 395725497
Flag: EXEMPT, trivial bug fix
Test: Manual turn off developer option to check the status change
Test: atest SettingsRoboTests:com.android.settings.development.BluetoothLeAudioHwOffloadPreferenceControllerTest
Change-Id: I59d3e378495c90f007b46f05b74fdaf19d1520ce
This commit is contained in:
Alice Kuo
2025-02-12 09:17:27 +08:00
parent 74e862de8d
commit 4251ebecca
2 changed files with 23 additions and 6 deletions

View File

@@ -16,6 +16,7 @@
package com.android.settings.development;
import static com.android.settings.development.BluetoothA2dpHwOffloadPreferenceController.A2DP_OFFLOAD_SUPPORTED_PROPERTY;
import static com.android.settings.development.BluetoothA2dpHwOffloadPreferenceController.A2DP_OFFLOAD_DISABLED_PROPERTY;
import android.bluetooth.BluetoothAdapter;
@@ -105,13 +106,14 @@ public class BluetoothLeAudioHwOffloadPreferenceController
(mBluetoothAdapter.isLeAudioSupported() == BluetoothStatusCodes.FEATURE_SUPPORTED);
final boolean leAudioOffloadSupported =
SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_SUPPORTED_PROPERTY, false);
final boolean a2dpOffloadDisabled =
SystemProperties.getBoolean(A2DP_OFFLOAD_DISABLED_PROPERTY, false);
if (leAudioEnabled && leAudioOffloadSupported && !a2dpOffloadDisabled) {
((TwoStatePreference) mPreference).setChecked(true);
SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, "true");
} else {
final boolean a2dpOffloadSupported =
SystemProperties.getBoolean(A2DP_OFFLOAD_SUPPORTED_PROPERTY, false);
if(!leAudioEnabled || !leAudioOffloadSupported || !a2dpOffloadSupported) {
mPreference.setEnabled(false);
} else {
((TwoStatePreference) mPreference).setChecked(false);
SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, "false");
}
}

View File

@@ -20,6 +20,8 @@ import static android.bluetooth.BluetoothStatusCodes.FEATURE_SUPPORTED;
import static com.android.settings.development.BluetoothA2dpHwOffloadPreferenceController
.A2DP_OFFLOAD_DISABLED_PROPERTY;
import static com.android.settings.development.BluetoothA2dpHwOffloadPreferenceController
.A2DP_OFFLOAD_SUPPORTED_PROPERTY;
import static com.android.settings.development.BluetoothLeAudioHwOffloadPreferenceController
.LE_AUDIO_OFFLOAD_DISABLED_PROPERTY;
import static com.android.settings.development.BluetoothLeAudioHwOffloadPreferenceController
@@ -120,4 +122,17 @@ public class BluetoothLeAudioHwOffloadPreferenceControllerTest {
leAueioDisabled = SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, false);
assertThat(leAueioDisabled).isTrue();
}
@Test
public void asDisableDeveloperOption_ResetLEOffloadBasedOnA2dpLeAudioOffloadSupported() {
SystemProperties.set(LE_AUDIO_OFFLOAD_SUPPORTED_PROPERTY, Boolean.toString(true));
SystemProperties.set(A2DP_OFFLOAD_SUPPORTED_PROPERTY, Boolean.toString(true));
SystemProperties.set(
LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(true));
mController.onDeveloperOptionsSwitchDisabled();
boolean leAueioDisabled =
SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, false);
assertThat(leAueioDisabled).isFalse();
}
}