From 4251ebeccac90a3d797604d0fe486371c5a53302 Mon Sep 17 00:00:00 2001 From: Alice Kuo Date: Wed, 12 Feb 2025 09:17:27 +0800 Subject: [PATCH] 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 --- ...toothLeAudioHwOffloadPreferenceController.java | 14 ++++++++------ ...hLeAudioHwOffloadPreferenceControllerTest.java | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/com/android/settings/development/BluetoothLeAudioHwOffloadPreferenceController.java b/src/com/android/settings/development/BluetoothLeAudioHwOffloadPreferenceController.java index 1890fbd9818..dfa808f644d 100644 --- a/src/com/android/settings/development/BluetoothLeAudioHwOffloadPreferenceController.java +++ b/src/com/android/settings/development/BluetoothLeAudioHwOffloadPreferenceController.java @@ -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"); } } diff --git a/tests/robotests/src/com/android/settings/development/BluetoothLeAudioHwOffloadPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothLeAudioHwOffloadPreferenceControllerTest.java index aa05f628f7f..c2a4d033080 100644 --- a/tests/robotests/src/com/android/settings/development/BluetoothLeAudioHwOffloadPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/development/BluetoothLeAudioHwOffloadPreferenceControllerTest.java @@ -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(); + } }