Restrict Wi-Fi configuration if settings UI is restricted
- Don't launch W-Fi configuration settings if the settings UI is restricted (including guest users). Bug: 246301667 Test: manual test make RunSettingsRoboTests ROBOTEST_FILTER=NetworkProviderSettingsTest Change-Id: Id82498f41765f955e01bb311bb221d26f9574f31
This commit is contained in:
@@ -1324,6 +1324,12 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
|
||||
|
||||
@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());
|
||||
|
@@ -751,6 +751,15 @@ public class NetworkProviderSettingsTest {
|
||||
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 {
|
||||
|
||||
|
Reference in New Issue
Block a user