From 64328862bd6e89b9e30852ed7469b6b6f91d3090 Mon Sep 17 00:00:00 2001 From: Oscar Shu Date: Fri, 25 Jan 2019 01:16:29 +0000 Subject: [PATCH] Revert "Wifi MAC Randomization: Developer Options" This reverts commit 8c6d8daaf00f80344336ea8181d7e84a38486252. Reason for revert: Bug: 123408542 Test: unit tests Test: Manual test to verify dev option is gone Change-Id: Iae667a331b5d4fb4cb6fe07077eb9f3954f3089e --- res/values/config.xml | 4 - res/xml/development_settings.xml | 5 - .../DevelopmentSettingsDashboardFragment.java | 1 - ...dMacRandomizationPreferenceController.java | 80 ----------- .../wifi/WifiInfoPreferenceController.java | 7 +- tests/robotests/res/values-mcc999/config.xml | 1 - tests/robotests/res/values/config.xml | 1 - ...RandomizationPreferenceControllerTest.java | 124 ------------------ .../WifiInfoPreferenceControllerTest.java | 44 ++++--- 9 files changed, 31 insertions(+), 236 deletions(-) delete mode 100644 src/com/android/settings/development/WifiConnectedMacRandomizationPreferenceController.java delete mode 100644 tests/robotests/src/com/android/settings/development/WifiConnectedMacRandomizationPreferenceControllerTest.java diff --git a/res/values/config.xml b/res/values/config.xml index a6e5e1ce332..529332b5559 100755 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -41,10 +41,6 @@ false - - false - com.android.settings.overlay.FeatureFactoryImpl diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml index 6d22a1d1480..2c0a759dbfd 100644 --- a/res/xml/development_settings.xml +++ b/res/xml/development_settings.xml @@ -221,11 +221,6 @@ android:title="@string/wifi_verbose_logging" android:summary="@string/wifi_verbose_logging_summary" /> - - false false false - false false false false diff --git a/tests/robotests/res/values/config.xml b/tests/robotests/res/values/config.xml index 1252ecef048..15ae89927f1 100644 --- a/tests/robotests/res/values/config.xml +++ b/tests/robotests/res/values/config.xml @@ -20,7 +20,6 @@ true true true - true diff --git a/tests/robotests/src/com/android/settings/development/WifiConnectedMacRandomizationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/WifiConnectedMacRandomizationPreferenceControllerTest.java deleted file mode 100644 index 60e7d47feea..00000000000 --- a/tests/robotests/src/com/android/settings/development/WifiConnectedMacRandomizationPreferenceControllerTest.java +++ /dev/null @@ -1,124 +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 static com.android.settings.development.WifiConnectedMacRandomizationPreferenceController - .SETTING_VALUE_OFF; -import static com.android.settings.development.WifiConnectedMacRandomizationPreferenceController - .SETTING_VALUE_ON; - -import static com.google.common.truth.Truth.assertThat; - -import static org.mockito.Mockito.when; - -import android.content.Context; -import android.provider.Settings; - -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; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; - -@RunWith(RobolectricTestRunner.class) -public class WifiConnectedMacRandomizationPreferenceControllerTest { - - @Mock - private PreferenceScreen mPreferenceScreen; - - private Context mContext; - private SwitchPreference mPreference; - private WifiConnectedMacRandomizationPreferenceController mController; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - mContext = RuntimeEnvironment.application; - mController = new WifiConnectedMacRandomizationPreferenceController(mContext); - mPreference = new SwitchPreference(mContext); - when(mPreferenceScreen.findPreference(mController.getPreferenceKey())) - .thenReturn(mPreference); - mController.displayPreference(mPreferenceScreen); - } - - @Test - public void isAvailable_trueSupportFlag_shouldReturnTrue() { - assertThat(mController.isAvailable()).isTrue(); - } - - @Test - @Config(qualifiers = "mcc999") - public void isAvailable_falseSupportFlag_shouldReturnFalse() { - assertThat(mController.isAvailable()).isFalse(); - } - - @Test - public void onPreferenceChange_settingEnabled_shouldEnableConnectedMacRandomization() { - mController.onPreferenceChange(mPreference, true /* new value */); - - final int mode = Settings.Global.getInt(mContext.getContentResolver(), - Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, -1 /* default */); - - assertThat(mode).isEqualTo(SETTING_VALUE_ON); - } - - @Test - public void onPreferenceChange_settingDisabled_shouldDisableConnectedMacRandomization() { - mController.onPreferenceChange(mPreference, false /* new value */); - - final int mode = Settings.Global.getInt(mContext.getContentResolver(), - Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, -1 /* default */); - - assertThat(mode).isEqualTo(SETTING_VALUE_OFF); - } - - @Test - public void updateState_settingEnabled_shouldEnablePreference() { - Settings.Global.putInt(mContext.getContentResolver(), - Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, SETTING_VALUE_ON); - mController.updateState(mPreference); - - assertThat(mPreference.isChecked()).isTrue(); - } - - @Test - public void updateState_settingDisabled_shouldDisablePreference() { - Settings.Global.putInt(mContext.getContentResolver(), - Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, SETTING_VALUE_OFF); - mController.updateState(mPreference); - - assertThat(mPreference.isChecked()).isFalse(); - } - - @Test - public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() { - mController.onDeveloperOptionsSwitchDisabled(); - - final int mode = Settings.Global.getInt(mContext.getContentResolver(), - Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, -1 /* default */); - - assertThat(mode).isEqualTo(SETTING_VALUE_OFF); - assertThat(mPreference.isChecked()).isFalse(); - assertThat(mPreference.isEnabled()).isFalse(); - } -} diff --git a/tests/robotests/src/com/android/settings/wifi/WifiInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiInfoPreferenceControllerTest.java index c4a5c787d8f..85d7726ee66 100644 --- a/tests/robotests/src/com/android/settings/wifi/WifiInfoPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/wifi/WifiInfoPreferenceControllerTest.java @@ -29,6 +29,7 @@ import static org.mockito.Mockito.when; import android.content.BroadcastReceiver; import android.content.Context; import android.content.IntentFilter; +import android.content.res.Resources; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.provider.Settings; @@ -65,6 +66,8 @@ public class WifiInfoPreferenceControllerTest { private Preference mMacPreference; @Mock private WifiInfo mWifiInfo; + @Mock + private Resources mResources; private Lifecycle mLifecycle; private LifecycleOwner mLifecycleOwner; @@ -82,6 +85,7 @@ public class WifiInfoPreferenceControllerTest { .thenReturn(mIpPreference); when(mWifiManager.getConnectionInfo()).thenReturn(mWifiInfo); when(mWifiManager.getCurrentNetwork()).thenReturn(null); + when(mContext.getResources()).thenReturn(mResources); mController = new WifiInfoPreferenceController(mContext, mLifecycle, mWifiManager); } @@ -117,8 +121,9 @@ public class WifiInfoPreferenceControllerTest { @Test public void updateWifiInfo_nullWifiInfoWithMacRandomizationOff_setMacUnavailable() { - Settings.Global.putInt(mContext.getContentResolver(), - Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 0); + when(mResources.getBoolean( + com.android.internal.R.bool.config_wifi_connected_mac_randomization_supported)) + .thenReturn(false); mController.displayPreference(mScreen); when(mWifiManager.getConnectionInfo()).thenReturn(null); @@ -129,8 +134,9 @@ public class WifiInfoPreferenceControllerTest { @Test public void updateWifiInfo_nullMacWithMacRandomizationOff_setMacUnavailable() { - Settings.Global.putInt(mContext.getContentResolver(), - Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 0); + when(mResources.getBoolean( + com.android.internal.R.bool.config_wifi_connected_mac_randomization_supported)) + .thenReturn(false); mController.displayPreference(mScreen); when(mWifiInfo.getMacAddress()).thenReturn(null); @@ -141,8 +147,9 @@ public class WifiInfoPreferenceControllerTest { @Test public void updateWifiInfo_defaultMacWithMacRandomizationOff_setMacUnavailable() { - Settings.Global.putInt(mContext.getContentResolver(), - Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 0); + when(mResources.getBoolean( + com.android.internal.R.bool.config_wifi_connected_mac_randomization_supported)) + .thenReturn(false); mController.displayPreference(mScreen); when(mWifiInfo.getMacAddress()).thenReturn(WifiInfo.DEFAULT_MAC_ADDRESS); @@ -153,8 +160,9 @@ public class WifiInfoPreferenceControllerTest { @Test public void updateWifiInfo_validMacWithMacRandomizationOff_setValidMac() { - Settings.Global.putInt(mContext.getContentResolver(), - Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 0); + when(mResources.getBoolean( + com.android.internal.R.bool.config_wifi_connected_mac_randomization_supported)) + .thenReturn(false); mController.displayPreference(mScreen); when(mWifiInfo.getMacAddress()).thenReturn(TEST_MAC_ADDRESS); @@ -165,8 +173,9 @@ public class WifiInfoPreferenceControllerTest { @Test public void updateWifiInfo_nullWifiInfoWithMacRandomizationOn_setMacUnavailable() { - Settings.Global.putInt(mContext.getContentResolver(), - Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 1); + when(mResources.getBoolean( + com.android.internal.R.bool.config_wifi_connected_mac_randomization_supported)) + .thenReturn(true); mController.displayPreference(mScreen); when(mWifiManager.getConnectionInfo()).thenReturn(null); @@ -177,8 +186,9 @@ public class WifiInfoPreferenceControllerTest { @Test public void updateWifiInfo_nullMacWithMacRandomizationOn_setMacUnavailable() { - Settings.Global.putInt(mContext.getContentResolver(), - Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 1); + when(mResources.getBoolean( + com.android.internal.R.bool.config_wifi_connected_mac_randomization_supported)) + .thenReturn(true); mController.displayPreference(mScreen); when(mWifiInfo.getMacAddress()).thenReturn(null); @@ -189,8 +199,9 @@ public class WifiInfoPreferenceControllerTest { @Test public void updateWifiInfo_defaultMacWithMacRandomizationOn_setMacRandomized() { - Settings.Global.putInt(mContext.getContentResolver(), - Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 1); + when(mResources.getBoolean( + com.android.internal.R.bool.config_wifi_connected_mac_randomization_supported)) + .thenReturn(true); mController.displayPreference(mScreen); when(mWifiInfo.getMacAddress()).thenReturn(WifiInfo.DEFAULT_MAC_ADDRESS); @@ -201,8 +212,9 @@ public class WifiInfoPreferenceControllerTest { @Test public void updateWifiInfo_validMacWithMacRandomizationOn_setValidMac() { - Settings.Global.putInt(mContext.getContentResolver(), - Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 1); + when(mResources.getBoolean( + com.android.internal.R.bool.config_wifi_connected_mac_randomization_supported)) + .thenReturn(true); mController.displayPreference(mScreen); when(mWifiInfo.getMacAddress()).thenReturn(TEST_MAC_ADDRESS);