Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6629b12a authored by Weng Su's avatar Weng Su
Browse files

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

Merged-In: Id82498f41765f955e01bb311bb221d26f9574f31
Change-Id: Id82498f41765f955e01bb311bb221d26f9574f31
(cherry picked from commit aaa65fc6)
parent 9ef4f7bf
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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());
+9 −0
Original line number Diff line number Diff line
@@ -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 {