From f8767cdd3108bf02e1b5a484d4d24599dc822b6c Mon Sep 17 00:00:00 2001 From: Alice Kuo Date: Thu, 5 Oct 2023 05:28:36 +0800 Subject: [PATCH] Remove allowlist reboot behavior As we switch to use allowlist or bypass it, it would only impact the default connection after the paring. So based on it, we don't need to force device reboot to apply the setting Bug: 300012501 Test: m SettingsGoogle Change-Id: I0b63a68e1263692e922968c122b96b5635b9861f --- ...hLeAudioAllowListPreferenceController.java | 26 ------------ .../DevelopmentSettingsDashboardFragment.java | 10 ----- ...udioAllowListPreferenceControllerTest.java | 41 ------------------- 3 files changed, 77 deletions(-) diff --git a/src/com/android/settings/development/BluetoothLeAudioAllowListPreferenceController.java b/src/com/android/settings/development/BluetoothLeAudioAllowListPreferenceController.java index 013124e521f..532db85373e 100644 --- a/src/com/android/settings/development/BluetoothLeAudioAllowListPreferenceController.java +++ b/src/com/android/settings/development/BluetoothLeAudioAllowListPreferenceController.java @@ -49,9 +49,6 @@ public class BluetoothLeAudioAllowListPreferenceController private final DevelopmentSettingsDashboardFragment mFragment; - @VisibleForTesting - boolean mChanged = false; - public BluetoothLeAudioAllowListPreferenceController(Context context, DevelopmentSettingsDashboardFragment fragment) { super(context); @@ -66,8 +63,6 @@ public class BluetoothLeAudioAllowListPreferenceController @Override public boolean onPreferenceChange(Preference preference, Object newValue) { - BluetoothRebootDialog.show(mFragment); - mChanged = true; return false; } @@ -92,25 +87,4 @@ public class BluetoothLeAudioAllowListPreferenceController ((SwitchPreference) mPreference).setChecked(false); } } - - /** - * Called when the RebootDialog confirm is clicked. - */ - public void onRebootDialogConfirmed() { - if (!mChanged) { - return; - } - - final boolean leAudioAllowListEnabled = - SystemProperties.getBoolean(LE_AUDIO_ALLOW_LIST_ENABLED_PROPERTY, false); - SystemProperties.set(LE_AUDIO_ALLOW_LIST_ENABLED_PROPERTY, - Boolean.toString(leAudioAllowListEnabled)); - } - - /** - * Called when the RebootDialog cancel is clicked. - */ - public void onRebootDialogCanceled() { - mChanged = false; - } } diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java index 47b9d093bb9..f0cf59a0bfc 100644 --- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java +++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java @@ -442,11 +442,6 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra getDevelopmentOptionsController( BluetoothLeAudioPreferenceController.class); leAudioFeatureController.onRebootDialogConfirmed(); - - final BluetoothLeAudioAllowListPreferenceController leAudioAllowListController = - getDevelopmentOptionsController( - BluetoothLeAudioAllowListPreferenceController.class); - leAudioAllowListController.onRebootDialogConfirmed(); } @Override @@ -464,11 +459,6 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra getDevelopmentOptionsController( BluetoothLeAudioPreferenceController.class); leAudioFeatureController.onRebootDialogCanceled(); - - final BluetoothLeAudioAllowListPreferenceController leAudioAllowListController = - getDevelopmentOptionsController( - BluetoothLeAudioAllowListPreferenceController.class); - leAudioAllowListController.onRebootDialogCanceled(); } @Override diff --git a/tests/robotests/src/com/android/settings/development/BluetoothLeAudioAllowListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothLeAudioAllowListPreferenceControllerTest.java index f4e52bada6a..d85d522b2e0 100644 --- a/tests/robotests/src/com/android/settings/development/BluetoothLeAudioAllowListPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/development/BluetoothLeAudioAllowListPreferenceControllerTest.java @@ -18,23 +18,16 @@ package com.android.settings.development; import static android.bluetooth.BluetoothStatusCodes.FEATURE_SUPPORTED; -import static com.android.settings.development.BluetoothLeAudioAllowListPreferenceController - .LE_AUDIO_ALLOW_LIST_ENABLED_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; import androidx.preference.PreferenceScreen; import androidx.preference.SwitchPreference; import org.junit.Before; -import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -69,38 +62,4 @@ public class BluetoothLeAudioAllowListPreferenceControllerTest { when(mBluetoothAdapter.isLeAudioSupported()) .thenReturn(FEATURE_SUPPORTED); } - - @Test - public void onRebootDialogConfirmedAsLeAudioAllowListDisabled_shouldSwitchStatus() { - SystemProperties.set(LE_AUDIO_ALLOW_LIST_ENABLED_PROPERTY, Boolean.toString(false)); - mController.mChanged = true; - - mController.onRebootDialogConfirmed(); - final boolean mode = SystemProperties.getBoolean( - LE_AUDIO_ALLOW_LIST_ENABLED_PROPERTY, false); - assertThat(mode).isFalse(); - } - - - @Test - public void onRebootDialogConfirmedAsLeAudioAllowListEnabled_shouldSwitchStatus() { - SystemProperties.set(LE_AUDIO_ALLOW_LIST_ENABLED_PROPERTY, Boolean.toString(true)); - mController.mChanged = true; - - mController.onRebootDialogConfirmed(); - final boolean status = SystemProperties.getBoolean( - LE_AUDIO_ALLOW_LIST_ENABLED_PROPERTY, false); - assertThat(status).isTrue(); - } - - @Test - public void onRebootDialogCanceled_shouldNotSwitchStatus() { - SystemProperties.set(LE_AUDIO_ALLOW_LIST_ENABLED_PROPERTY, Boolean.toString(false)); - mController.mChanged = true; - - mController.onRebootDialogCanceled(); - final boolean status = SystemProperties.getBoolean( - LE_AUDIO_ALLOW_LIST_ENABLED_PROPERTY, false); - assertThat(status).isFalse(); - } }