Update Wi-Fi configs restrictions

* Update isNetworkLockedDown in WifiUtils
  to check the profile owner if the device
  is an organization-owned managed profile
  device.
* Update the logic to check if a Wi-Fi
  network can be forgotten (for both the
  device owner and profile owner of an
  organization-owned device).

Bug: 150197944
Bug: 153605361
Test: manual testing
      make RunSettingsRoboTests -j ROBOTEST_FILTER=WifiDetailPreferenceController2Test
      make RunSettingsRoboTests -j ROBOTEST_FILTER=WifiUtilsTest

Manual Testing Steps
A. Provision TestDPC in 'Device Owner' mode.
   - Create a Wi-Fi config in TestDPC.
   - Enable 'DO created Wi-Fi configs are
     modifiable only by DO'.
   - Go to Settings and verify that the network
     created cannot be modified and the 'Forget'
     button is not displayed.
B. Provision TestDPC in 'Profile Owner of an
   organization-owned managed profile' mode.
   - Create a Wi-Fi config in the work profile
     instance of TestDPC.
   - Enable 'DO created Wi-Fi configs are
     modifiable only by DO'.
   - Go to Settings and verify that the network
     created cannot be modified and the 'Forget'
     button is not displayed.
C. Provision CtsVerifier in 'Device Owner' mode.
   - Go to 'Device owner tests' > 'Wifi
     configuration lockdown'.
   - Create a Wi-Fi config then follow the
     instructions.

Change-Id: Ie3c71113441a3aca62563310ad0e53d89fa04226
This commit is contained in:
Alex Johnston
2020-04-15 11:57:26 +01:00
parent 517dfeb385
commit d1a31ab6b3
4 changed files with 48 additions and 4 deletions

View File

@@ -660,7 +660,7 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
}
private void refreshButtons() {
final boolean canForgetNetwork = mWifiEntry.canForget();
final boolean canForgetNetwork = canForgetNetwork();
final boolean showCaptivePortalButton = updateCaptivePortalButton();
final boolean canConnectDisconnectNetwork = mWifiEntry.canConnect()
|| mWifiEntry.canDisconnect();
@@ -787,6 +787,14 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
&& !WifiUtils.isNetworkLockedDown(mContext, mWifiEntry.getWifiConfiguration());
}
/**
* Returns whether the network represented by this preference can be forgotten.
*/
public boolean canForgetNetwork() {
return mWifiEntry.canForget()
&& !WifiUtils.isNetworkLockedDown(mContext, mWifiEntry.getWifiConfiguration());
}
/**
* Returns whether the user can sign into the network represented by this preference.
*/