Loading src/com/android/settings/development/BluetoothA2dpHwOffloadPreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -102,7 +102,7 @@ public class BluetoothA2dpHwOffloadPreferenceController extends DeveloperOptions final boolean offloadDisabled = SystemProperties.getBoolean(A2DP_OFFLOAD_DISABLED_PROPERTY, false); SystemProperties.set(A2DP_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(!offloadDisabled)); if (offloadDisabled) { if (!offloadDisabled) { SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(!offloadDisabled)); } Loading src/com/android/settings/development/BluetoothLeAudioHwOffloadPreferenceController.java +15 −13 Original line number Diff line number Diff line Loading @@ -16,7 +16,8 @@ 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; import android.bluetooth.BluetoothManager; Loading Loading @@ -79,11 +80,11 @@ public class BluetoothLeAudioHwOffloadPreferenceController 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 (leAudioEnabled && offloadSupported) { 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) { final boolean offloadDisabled = SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, true); ((SwitchPreference) mPreference).setChecked(offloadDisabled); Loading @@ -102,10 +103,11 @@ public class BluetoothLeAudioHwOffloadPreferenceController 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 (leAudioEnabled && offloadSupported) { 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) { ((SwitchPreference) mPreference).setChecked(true); SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, "true"); } else { Loading @@ -118,7 +120,7 @@ public class BluetoothLeAudioHwOffloadPreferenceController */ public boolean isDefaultValue() { final boolean offloadSupported = SystemProperties.getBoolean(A2DP_OFFLOAD_SUPPORTED_PROPERTY, false) !SystemProperties.getBoolean(A2DP_OFFLOAD_DISABLED_PROPERTY, false) && SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_SUPPORTED_PROPERTY, false); final boolean offloadDisabled = SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, false); Loading @@ -133,11 +135,11 @@ public class BluetoothLeAudioHwOffloadPreferenceController return; } final boolean offloadDisabled = final boolean leaudioOffloadDisabled = SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, false); SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(!offloadDisabled)); Boolean.toString(!leaudioOffloadDisabled)); } /** Loading tests/robotests/src/com/android/settings/development/BluetoothA2dpHwOffloadPreferenceControllerTest.java +6 −6 Original line number Diff line number Diff line Loading @@ -65,18 +65,18 @@ public class BluetoothA2dpHwOffloadPreferenceControllerTest { @Test public void onA2dpHwDialogConfirmedAsA2dpOffloadDisabled_shouldChangeProperty() { SystemProperties.set(A2DP_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(false)); SystemProperties.set(A2DP_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(true)); mController.mChanged = true; mController.onRebootDialogConfirmed(); final boolean mode = SystemProperties.getBoolean(A2DP_OFFLOAD_DISABLED_PROPERTY, false); assertThat(mode).isTrue(); assertThat(mode).isFalse(); } @Test public void onA2dpHwDialogConfirmedAsA2dpOffloadEnabled_shouldChangeProperty() { SystemProperties.set(A2DP_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(true)); SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(true)); SystemProperties.set(A2DP_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(false)); SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(false)); mController.mChanged = true; Loading @@ -84,8 +84,8 @@ public class BluetoothA2dpHwOffloadPreferenceControllerTest { final boolean a2dpMode = SystemProperties.getBoolean(A2DP_OFFLOAD_DISABLED_PROPERTY, true); final boolean leAudioMode = SystemProperties .getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, true); assertThat(a2dpMode).isFalse(); assertThat(leAudioMode).isFalse(); assertThat(a2dpMode).isTrue(); assertThat(leAudioMode).isTrue(); } @Test Loading tests/robotests/src/com/android/settings/development/BluetoothLeAudioHwOffloadPreferenceControllerTest.java +29 −0 Original line number Diff line number Diff line Loading @@ -16,14 +16,21 @@ package com.android.settings.development; import static android.bluetooth.BluetoothStatusCodes.FEATURE_SUPPORTED; import static com.android.settings.development.BluetoothA2dpHwOffloadPreferenceController .A2DP_OFFLOAD_DISABLED_PROPERTY; import static com.android.settings.development.BluetoothLeAudioHwOffloadPreferenceController .LE_AUDIO_OFFLOAD_DISABLED_PROPERTY; import static com.android.settings.development.BluetoothLeAudioHwOffloadPreferenceController .LE_AUDIO_OFFLOAD_SUPPORTED_PROPERTY; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import android.bluetooth.BluetoothAdapter; import android.content.Context; import android.os.SystemProperties; Loading @@ -45,6 +52,8 @@ public class BluetoothLeAudioHwOffloadPreferenceControllerTest { private PreferenceScreen mPreferenceScreen; @Mock private DevelopmentSettingsDashboardFragment mFragment; @Mock private BluetoothAdapter mBluetoothAdapter; private Context mContext; private SwitchPreference mPreference; Loading @@ -59,6 +68,9 @@ public class BluetoothLeAudioHwOffloadPreferenceControllerTest { when(mPreferenceScreen.findPreference(mController.getPreferenceKey())) .thenReturn(mPreference); mController.displayPreference(mPreferenceScreen); mController.mBluetoothAdapter = mBluetoothAdapter; when(mBluetoothAdapter.isLeAudioSupported()) .thenReturn(FEATURE_SUPPORTED); } @Test Loading Loading @@ -91,4 +103,21 @@ public class BluetoothLeAudioHwOffloadPreferenceControllerTest { final boolean mode = SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, false); assertThat(mode).isFalse(); } @Test public void asA2dpOffloadDisabled_shouldNotSwitchLeAudioOffloadStatus() { SystemProperties.set(LE_AUDIO_OFFLOAD_SUPPORTED_PROPERTY, Boolean.toString(true)); SystemProperties.set(A2DP_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(true)); SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(false)); mController.updateState(null); boolean leAueioDisabled = SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, false); assertThat(leAueioDisabled).isFalse(); SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(true)); mController.updateState(null); leAueioDisabled = SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, false); assertThat(leAueioDisabled).isTrue(); } } Loading
src/com/android/settings/development/BluetoothA2dpHwOffloadPreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -102,7 +102,7 @@ public class BluetoothA2dpHwOffloadPreferenceController extends DeveloperOptions final boolean offloadDisabled = SystemProperties.getBoolean(A2DP_OFFLOAD_DISABLED_PROPERTY, false); SystemProperties.set(A2DP_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(!offloadDisabled)); if (offloadDisabled) { if (!offloadDisabled) { SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(!offloadDisabled)); } Loading
src/com/android/settings/development/BluetoothLeAudioHwOffloadPreferenceController.java +15 −13 Original line number Diff line number Diff line Loading @@ -16,7 +16,8 @@ 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; import android.bluetooth.BluetoothManager; Loading Loading @@ -79,11 +80,11 @@ public class BluetoothLeAudioHwOffloadPreferenceController 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 (leAudioEnabled && offloadSupported) { 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) { final boolean offloadDisabled = SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, true); ((SwitchPreference) mPreference).setChecked(offloadDisabled); Loading @@ -102,10 +103,11 @@ public class BluetoothLeAudioHwOffloadPreferenceController 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 (leAudioEnabled && offloadSupported) { 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) { ((SwitchPreference) mPreference).setChecked(true); SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, "true"); } else { Loading @@ -118,7 +120,7 @@ public class BluetoothLeAudioHwOffloadPreferenceController */ public boolean isDefaultValue() { final boolean offloadSupported = SystemProperties.getBoolean(A2DP_OFFLOAD_SUPPORTED_PROPERTY, false) !SystemProperties.getBoolean(A2DP_OFFLOAD_DISABLED_PROPERTY, false) && SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_SUPPORTED_PROPERTY, false); final boolean offloadDisabled = SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, false); Loading @@ -133,11 +135,11 @@ public class BluetoothLeAudioHwOffloadPreferenceController return; } final boolean offloadDisabled = final boolean leaudioOffloadDisabled = SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, false); SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(!offloadDisabled)); Boolean.toString(!leaudioOffloadDisabled)); } /** Loading
tests/robotests/src/com/android/settings/development/BluetoothA2dpHwOffloadPreferenceControllerTest.java +6 −6 Original line number Diff line number Diff line Loading @@ -65,18 +65,18 @@ public class BluetoothA2dpHwOffloadPreferenceControllerTest { @Test public void onA2dpHwDialogConfirmedAsA2dpOffloadDisabled_shouldChangeProperty() { SystemProperties.set(A2DP_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(false)); SystemProperties.set(A2DP_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(true)); mController.mChanged = true; mController.onRebootDialogConfirmed(); final boolean mode = SystemProperties.getBoolean(A2DP_OFFLOAD_DISABLED_PROPERTY, false); assertThat(mode).isTrue(); assertThat(mode).isFalse(); } @Test public void onA2dpHwDialogConfirmedAsA2dpOffloadEnabled_shouldChangeProperty() { SystemProperties.set(A2DP_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(true)); SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(true)); SystemProperties.set(A2DP_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(false)); SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(false)); mController.mChanged = true; Loading @@ -84,8 +84,8 @@ public class BluetoothA2dpHwOffloadPreferenceControllerTest { final boolean a2dpMode = SystemProperties.getBoolean(A2DP_OFFLOAD_DISABLED_PROPERTY, true); final boolean leAudioMode = SystemProperties .getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, true); assertThat(a2dpMode).isFalse(); assertThat(leAudioMode).isFalse(); assertThat(a2dpMode).isTrue(); assertThat(leAudioMode).isTrue(); } @Test Loading
tests/robotests/src/com/android/settings/development/BluetoothLeAudioHwOffloadPreferenceControllerTest.java +29 −0 Original line number Diff line number Diff line Loading @@ -16,14 +16,21 @@ package com.android.settings.development; import static android.bluetooth.BluetoothStatusCodes.FEATURE_SUPPORTED; import static com.android.settings.development.BluetoothA2dpHwOffloadPreferenceController .A2DP_OFFLOAD_DISABLED_PROPERTY; import static com.android.settings.development.BluetoothLeAudioHwOffloadPreferenceController .LE_AUDIO_OFFLOAD_DISABLED_PROPERTY; import static com.android.settings.development.BluetoothLeAudioHwOffloadPreferenceController .LE_AUDIO_OFFLOAD_SUPPORTED_PROPERTY; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import android.bluetooth.BluetoothAdapter; import android.content.Context; import android.os.SystemProperties; Loading @@ -45,6 +52,8 @@ public class BluetoothLeAudioHwOffloadPreferenceControllerTest { private PreferenceScreen mPreferenceScreen; @Mock private DevelopmentSettingsDashboardFragment mFragment; @Mock private BluetoothAdapter mBluetoothAdapter; private Context mContext; private SwitchPreference mPreference; Loading @@ -59,6 +68,9 @@ public class BluetoothLeAudioHwOffloadPreferenceControllerTest { when(mPreferenceScreen.findPreference(mController.getPreferenceKey())) .thenReturn(mPreference); mController.displayPreference(mPreferenceScreen); mController.mBluetoothAdapter = mBluetoothAdapter; when(mBluetoothAdapter.isLeAudioSupported()) .thenReturn(FEATURE_SUPPORTED); } @Test Loading Loading @@ -91,4 +103,21 @@ public class BluetoothLeAudioHwOffloadPreferenceControllerTest { final boolean mode = SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, false); assertThat(mode).isFalse(); } @Test public void asA2dpOffloadDisabled_shouldNotSwitchLeAudioOffloadStatus() { SystemProperties.set(LE_AUDIO_OFFLOAD_SUPPORTED_PROPERTY, Boolean.toString(true)); SystemProperties.set(A2DP_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(true)); SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(false)); mController.updateState(null); boolean leAueioDisabled = SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, false); assertThat(leAueioDisabled).isFalse(); SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, Boolean.toString(true)); mController.updateState(null); leAueioDisabled = SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, false); assertThat(leAueioDisabled).isTrue(); } }