From f591fe0901e4342b9a1fb5838d20b673a5e814d5 Mon Sep 17 00:00:00 2001 From: Arc Wang Date: Thu, 30 Jan 2020 14:46:14 +0800 Subject: [PATCH 1/2] [Wi-Fi] Remove passpoint methods in WifiEntryShell Bug: 143326832 Test: build Change-Id: I9d21909f18df03d50f69447c3f2014b75ecd2d8b --- .../android/settings/wifi/WifiEntryShell.java | 38 ------------------- .../WifiDetailPreferenceController2.java | 5 +-- 2 files changed, 2 insertions(+), 41 deletions(-) diff --git a/src/com/android/settings/wifi/WifiEntryShell.java b/src/com/android/settings/wifi/WifiEntryShell.java index 7c6fc480ba6..385cca16f76 100644 --- a/src/com/android/settings/wifi/WifiEntryShell.java +++ b/src/com/android/settings/wifi/WifiEntryShell.java @@ -23,7 +23,6 @@ import com.android.wifitrackerlib.WifiEntry; * all the unavalable {@link AccessPoint} methods & constants. * * TODO(b/143326832): Replace all methods & constants with WifiEntry version when it's available. - * TODO(b/143326832): How about AccessPoint#getSettingsSummary(boolean convertSavedAsDisconnected)? */ public class WifiEntryShell { public WifiEntryShell(){}; @@ -47,41 +46,4 @@ public class WifiEntryShell { * Upper bound on the 5.0 GHz (802.11a/h/j/n/ac) WLAN channels */ public static final int HIGHER_FREQ_5GHZ = 5900; - - // Passpoint methods - - /** - * Mapping of the corresponding {@link AccessPoint} method - */ - public static boolean isExpired(WifiEntry wifiEntry) { - return false; - } - - /** - * Mapping of the corresponding {@link AccessPoint} method - */ - public static boolean isPasspointConfigurationR1(WifiEntry wifiEntry) { - return false; - } - - /** - * Mapping of the corresponding {@link AccessPoint} method - */ - public static boolean isPasspointConfigurationOsuProvisioned(WifiEntry wifiEntry) { - return false; - } - - /** - * Mapping of the corresponding {@link AccessPoint} method - */ - public static boolean isOsuProvider(WifiEntry wifiEntry) { - return false; - } - - /** - * Mapping of the corresponding {@link AccessPoint} method - */ - public static String getPasspointFqdn(WifiEntry wifiEntry) { - return "Fake passpoint FQDN"; - } } diff --git a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java index b5813cff3e9..350c0add99d 100644 --- a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java +++ b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java @@ -537,7 +537,7 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle } private void refreshSsid() { - if (mWifiEntry.isSubscription() || WifiEntryShell.isOsuProvider(mWifiEntry)) { + if (mWifiEntry.isSubscription()) { mSsidPref.setVisible(true); mSsidPref.setSummary(mWifiEntry.getTitle()); } else { @@ -743,8 +743,7 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle try { mWifiEntry.forget(this); } catch (RuntimeException e) { - Log.e(TAG, "Failed to remove Passpoint configuration for " - + WifiEntryShell.getPasspointFqdn(mWifiEntry)); + Log.e(TAG, "Failed to remove Passpoint configuration: " + e); } mMetricsFeatureProvider.action( mFragment.getActivity(), SettingsEnums.ACTION_WIFI_FORGET); From 41ff138c214fc9eba32289b0dce1623d429c5642 Mon Sep 17 00:00:00 2001 From: Arc Wang Date: Fri, 31 Jan 2020 11:55:08 +0800 Subject: [PATCH 2/2] [Wi-Fi] Fix some test failures of com.android.settings.wifi.details2 WifiMeteredPreferenceController2 always has a non null mWifiEntry, remove redundant test case testController_resilientToNullConfig Bug: 146479774 Test: make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.wifi.details2 Change-Id: I8194476ea0f337e63b29ff73e9071f6df65d13af --- .../WifiMeteredPreferenceController2Test.java | 10 -------- .../WifiPrivacyPreferenceController2Test.java | 24 +++++++------------ 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/tests/robotests/src/com/android/settings/wifi/details2/WifiMeteredPreferenceController2Test.java b/tests/robotests/src/com/android/settings/wifi/details2/WifiMeteredPreferenceController2Test.java index c453db3043f..9c31d4481b8 100644 --- a/tests/robotests/src/com/android/settings/wifi/details2/WifiMeteredPreferenceController2Test.java +++ b/tests/robotests/src/com/android/settings/wifi/details2/WifiMeteredPreferenceController2Test.java @@ -28,7 +28,6 @@ import com.android.settings.R; import com.android.wifitrackerlib.WifiEntry; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -86,13 +85,4 @@ public class WifiMeteredPreferenceController2Test { assertThat(mDropDownPreference.getEntry()).isEqualTo("Detect automatically"); } - - @Test - @Ignore - public void testController_resilientToNullConfig() { - mPreferenceController = spy(new WifiMeteredPreferenceController2(mContext, null)); - - mPreferenceController.getMeteredOverride(); - mPreferenceController.onPreferenceChange(mDropDownPreference, 1); - } } diff --git a/tests/robotests/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2Test.java b/tests/robotests/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2Test.java index 3403e0c56cb..0414b1c9e8e 100644 --- a/tests/robotests/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2Test.java +++ b/tests/robotests/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2Test.java @@ -19,6 +19,7 @@ package com.android.settings.wifi.details2; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; @@ -30,7 +31,6 @@ import com.android.settings.R; import com.android.wifitrackerlib.WifiEntry; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -38,14 +38,12 @@ import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; @RunWith(RobolectricTestRunner.class) -@Ignore public class WifiPrivacyPreferenceController2Test { private static final int PRIVACY_RANDOMIZED = WifiEntry.PRIVACY_RANDOMIZED_MAC; private static final int PRIVACY_TRUSTED = WifiEntry.PRIVACY_DEVICE_MAC; - @Mock - private WifiEntry mWifiEntry; + @Mock private WifiEntry mMockWifiEntry; private WifiPrivacyPreferenceController2 mPreferenceController; private Context mContext; @@ -56,9 +54,10 @@ public class WifiPrivacyPreferenceController2Test { public void setUp() { mContext = RuntimeEnvironment.application; + mMockWifiEntry = mock(WifiEntry.class); WifiPrivacyPreferenceController2 preferenceController = new WifiPrivacyPreferenceController2(mContext); - preferenceController.setWifiEntry(mWifiEntry); + preferenceController.setWifiEntry(mMockWifiEntry); mPreferenceController = spy(preferenceController); mDropDownPreference = new DropDownPreference(mContext); mDropDownPreference.setEntries(R.array.wifi_privacy_entries); @@ -89,18 +88,10 @@ public class WifiPrivacyPreferenceController2Test { assertThat(mDropDownPreference.getEntry()).isEqualTo(mPerferenceStrings[prefValue]); } - @Test - public void testController_resilientToNullConfig() { - mPreferenceController = spy(new WifiPrivacyPreferenceController2(mContext)); - mPreferenceController.setWifiEntry(mWifiEntry); - - mPreferenceController.getRandomizationValue(); - mPreferenceController.onPreferenceChange(mDropDownPreference, "1"); - } - @Test public void testUpdateState_canSetPrivacy_shouldBeSelectable() { - when(mWifiEntry.canSetPrivacy()).thenReturn(true); + when(mMockWifiEntry.canSetPrivacy()).thenReturn(true); + mPreferenceController.updateState(mDropDownPreference); assertThat(mDropDownPreference.isSelectable()).isTrue(); @@ -108,7 +99,8 @@ public class WifiPrivacyPreferenceController2Test { @Test public void testUpdateState_canNotSetPrivacy_shouldNotSelectable() { - when(mWifiEntry.canSetPrivacy()).thenReturn(false); + when(mMockWifiEntry.canSetPrivacy()).thenReturn(false); + mPreferenceController.updateState(mDropDownPreference); assertThat(mDropDownPreference.isSelectable()).isFalse();