From c697af178709670fd189a7ca0b04df65e3cb531f Mon Sep 17 00:00:00 2001 From: Bidhya Date: Mon, 7 Mar 2022 21:24:29 +0000 Subject: [PATCH] Remove developer option for bluetooth Gabeldorche Bug:220175020 Test: Manually verified Change-Id: I3c37228f7142892f2eb45552f2aced51360651af --- res/xml/development_settings.xml | 5 - ...toothGabeldorschePreferenceController.java | 73 ----------- .../DevelopmentSettingsDashboardFragment.java | 1 - ...hGabeldorschePreferenceControllerTest.java | 118 ------------------ 4 files changed, 197 deletions(-) delete mode 100644 src/com/android/settings/development/BluetoothGabeldorschePreferenceController.java delete mode 100644 tests/robotests/src/com/android/settings/development/BluetoothGabeldorschePreferenceControllerTest.java diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml index 831c190a5f6..cd37f4cbb96 100644 --- a/res/xml/development_settings.xml +++ b/res/xml/development_settings.xml @@ -308,11 +308,6 @@ android:title="@string/bluetooth_disable_absolute_volume" android:summary="@string/bluetooth_disable_absolute_volume_summary" /> - - diff --git a/src/com/android/settings/development/BluetoothGabeldorschePreferenceController.java b/src/com/android/settings/development/BluetoothGabeldorschePreferenceController.java deleted file mode 100644 index f5c30f5811c..00000000000 --- a/src/com/android/settings/development/BluetoothGabeldorschePreferenceController.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.settings.development; - -import android.content.Context; -import android.provider.DeviceConfig; - -import androidx.annotation.VisibleForTesting; -import androidx.preference.Preference; -import androidx.preference.SwitchPreference; - -import com.android.settings.core.PreferenceControllerMixin; -import com.android.settingslib.development.DeveloperOptionsPreferenceController; - -/** - * Preference controller for Bluetooth Gabeldorche feature - */ -public class BluetoothGabeldorschePreferenceController extends - DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, - PreferenceControllerMixin { - - private static final String BLUETOOTH_GABELDORSCHE_KEY = - "bluetooth_gabeldorsche_enable"; - - @VisibleForTesting - static final String CURRENT_GD_FLAG = "INIT_gd_scanning"; - - public BluetoothGabeldorschePreferenceController(Context context) { - super(context); - } - - @Override - public String getPreferenceKey() { - return BLUETOOTH_GABELDORSCHE_KEY; - } - - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - final boolean isEnabled = (Boolean) newValue; - DeviceConfig.setProperty(DeviceConfig.NAMESPACE_BLUETOOTH, - CURRENT_GD_FLAG, isEnabled ? "true" : "false", false /* makeDefault */); - return true; - } - - @Override - public void updateState(Preference preference) { - final boolean isEnabled = DeviceConfig.getBoolean( - DeviceConfig.NAMESPACE_BLUETOOTH, CURRENT_GD_FLAG, false /* default */); - ((SwitchPreference) mPreference).setChecked(isEnabled); - } - - @Override - protected void onDeveloperOptionsSwitchDisabled() { - super.onDeveloperOptionsSwitchDisabled(); - DeviceConfig.setProperty(DeviceConfig.NAMESPACE_BLUETOOTH, - CURRENT_GD_FLAG, null, false /* makeDefault */); - ((SwitchPreference) mPreference).setChecked(false); - } -} diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java index 94b67aa76bb..7556d23f25a 100644 --- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java +++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java @@ -510,7 +510,6 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra controllers.add(new TetheringHardwareAccelPreferenceController(context)); controllers.add(new BluetoothDeviceNoNamePreferenceController(context)); controllers.add(new BluetoothAbsoluteVolumePreferenceController(context)); - controllers.add(new BluetoothGabeldorschePreferenceController(context)); controllers.add(new BluetoothAvrcpVersionPreferenceController(context)); controllers.add(new BluetoothMapVersionPreferenceController(context)); controllers.add(new BluetoothA2dpHwOffloadPreferenceController(context, fragment)); diff --git a/tests/robotests/src/com/android/settings/development/BluetoothGabeldorschePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothGabeldorschePreferenceControllerTest.java deleted file mode 100644 index 1916bf22af9..00000000000 --- a/tests/robotests/src/com/android/settings/development/BluetoothGabeldorschePreferenceControllerTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.settings.development; - -import static com.android.settings.development.BluetoothGabeldorschePreferenceController - .CURRENT_GD_FLAG; - -import static com.google.common.truth.Truth.assertThat; - -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import android.content.Context; -import android.provider.DeviceConfig; - -import androidx.preference.PreferenceScreen; -import androidx.preference.SwitchPreference; - -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; - -@RunWith(RobolectricTestRunner.class) -public class BluetoothGabeldorschePreferenceControllerTest { - - @Mock - private SwitchPreference mPreference; - @Mock - private PreferenceScreen mPreferenceScreen; - - private BluetoothGabeldorschePreferenceController mController; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - Context context = RuntimeEnvironment.application; - mController = new BluetoothGabeldorschePreferenceController(context); - when(mPreferenceScreen.findPreference(mController.getPreferenceKey())) - .thenReturn(mPreference); - mController.displayPreference(mPreferenceScreen); - } - - @Test - @Ignore - public void onPreferenceChanged_settingEnabled_shouldTurnOnBluetoothGabeldorsche() { - mController.onPreferenceChange(mPreference, true /* new value */); - - boolean enabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_BLUETOOTH, - CURRENT_GD_FLAG, false /* defaultValue */); - - assertThat(enabled).isTrue(); - } - - @Test - @Ignore - public void onPreferenceChanged_settingDisabled_shouldTurnOffBluetoothGabeldorsche() { - mController.onPreferenceChange(mPreference, false /* new value */); - - boolean enabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_BLUETOOTH, - CURRENT_GD_FLAG, false /* defaultValue */); - - assertThat(enabled).isFalse(); - } - - @Test - @Ignore - public void updateState_settingEnabled_preferenceShouldBeChecked() { - DeviceConfig.setProperty(DeviceConfig.NAMESPACE_BLUETOOTH, - CURRENT_GD_FLAG, "true", false /* makeDefault */); - - mController.updateState(mPreference); - - verify(mPreference).setChecked(true); - } - - @Test - @Ignore - public void updateState_settingDisabled_preferenceShouldNotBeChecked() { - DeviceConfig.setProperty(DeviceConfig.NAMESPACE_BLUETOOTH, - CURRENT_GD_FLAG, "false", false /* makeDefault */); - - mController.updateState(mPreference); - - verify(mPreference).setChecked(false); - } - - @Test - @Ignore - public void onDeveloperOptionsDisabled_shouldDisablePreference() { - mController.onDeveloperOptionsDisabled(); - - String configStr = DeviceConfig.getProperty(DeviceConfig.NAMESPACE_BLUETOOTH, - CURRENT_GD_FLAG); - - assertThat(configStr).isNull(); - verify(mPreference).setEnabled(false); - verify(mPreference).setChecked(false); - } -}