Merge "Restrict Wi-Fi configuration if settings UI is restricted" into tm-qpr-dev
diff --git a/src/com/android/settings/network/NetworkProviderSettings.java b/src/com/android/settings/network/NetworkProviderSettings.java
index ec17dd3..1c480e0 100644
--- a/src/com/android/settings/network/NetworkProviderSettings.java
+++ b/src/com/android/settings/network/NetworkProviderSettings.java
@@ -1324,6 +1324,12 @@
@VisibleForTesting
void launchConfigNewNetworkFragment(WifiEntry wifiEntry) {
+ if (mIsRestricted) {
+ Log.e(TAG, "Can't configure Wi-Fi because NetworkProviderSettings is restricted.");
+ EventLog.writeEvent(0x534e4554, "246301667", -1 /* UID */, "Fragment is restricted.");
+ return;
+ }
+
final Bundle bundle = new Bundle();
bundle.putString(WifiNetworkDetailsFragment.KEY_CHOSEN_WIFIENTRY_KEY,
wifiEntry.getKey());
diff --git a/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java b/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java
index 1424d0e..5122def 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java
@@ -751,6 +751,15 @@
assertThat(keys).contains(NetworkProviderSettings.PREF_KEY_WIFI_TOGGLE);
}
+ @Test
+ public void launchConfigNewNetworkFragment_fragmentIsRestricted_ignoreWifiEntry() {
+ mNetworkProviderSettings.mIsRestricted = true;
+
+ mNetworkProviderSettings.launchConfigNewNetworkFragment(mWifiEntry);
+
+ verify(mWifiEntry, never()).getKey();
+ }
+
@Implements(PreferenceFragmentCompat.class)
public static class ShadowPreferenceFragmentCompat {