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

Commit 57ec8093 authored by Alex Johnston's avatar Alex Johnston
Browse files

Rename lockdown admin configured networks API

* Renamed 'isLockdownAdminConfiguredNetworks'
  to 'hasLockdownAdminConfiguredNetworks'
* Renamed 'setLockdownAdminConfiguredNetworks'
  to 'setConfiguredNetworksLockdownState'

Bug: 148853269
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest
      atest com.android.cts.devicepolicy.MixedDeviceOwnerTest#testAdminConfiguredNetworks
      atest com.android.cts.devicepolicy.OrgOwnedProfileOwnerTest#testAdminConfiguredNetworks

Change-Id: I6bef862b4ef7e5a7997378efcff08477da9de6dc
parent c22d4531
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -6916,6 +6916,7 @@ package android.app.admin {
    method public boolean grantKeyPairToApp(@Nullable android.content.ComponentName, @NonNull String, @NonNull String);
    method public boolean hasCaCertInstalled(@Nullable android.content.ComponentName, byte[]);
    method public boolean hasGrantedPolicy(@NonNull android.content.ComponentName, int);
    method public boolean hasLockdownAdminConfiguredNetworks(@NonNull android.content.ComponentName);
    method public boolean installCaCert(@Nullable android.content.ComponentName, byte[]);
    method public boolean installExistingPackage(@NonNull android.content.ComponentName, String);
    method public boolean installKeyPair(@Nullable android.content.ComponentName, @NonNull java.security.PrivateKey, @NonNull java.security.cert.Certificate, @NonNull String);
@@ -6934,7 +6935,6 @@ package android.app.admin {
    method public boolean isDeviceOwnerApp(String);
    method public boolean isEphemeralUser(@NonNull android.content.ComponentName);
    method public boolean isLockTaskPermitted(String);
    method public boolean isLockdownAdminConfiguredNetworks(@NonNull android.content.ComponentName);
    method public boolean isLogoutEnabled();
    method public boolean isManagedProfile(@NonNull android.content.ComponentName);
    method public boolean isMasterVolumeMuted(@NonNull android.content.ComponentName);
@@ -6981,6 +6981,7 @@ package android.app.admin {
    method public void setCameraDisabled(@NonNull android.content.ComponentName, boolean);
    method @Deprecated public void setCertInstallerPackage(@NonNull android.content.ComponentName, @Nullable String) throws java.lang.SecurityException;
    method public void setCommonCriteriaModeEnabled(@NonNull android.content.ComponentName, boolean);
    method public void setConfiguredNetworksLockdownState(@NonNull android.content.ComponentName, boolean);
    method public void setCrossProfileCalendarPackages(@NonNull android.content.ComponentName, @Nullable java.util.Set<java.lang.String>);
    method public void setCrossProfileCallerIdDisabled(@NonNull android.content.ComponentName, boolean);
    method public void setCrossProfileContactsSearchDisabled(@NonNull android.content.ComponentName, boolean);
@@ -7000,7 +7001,6 @@ package android.app.admin {
    method public void setLocationEnabled(@NonNull android.content.ComponentName, boolean);
    method public void setLockTaskFeatures(@NonNull android.content.ComponentName, int);
    method public void setLockTaskPackages(@NonNull android.content.ComponentName, @NonNull String[]) throws java.lang.SecurityException;
    method public void setLockdownAdminConfiguredNetworks(@NonNull android.content.ComponentName, boolean);
    method public void setLogoutEnabled(@NonNull android.content.ComponentName, boolean);
    method public void setLongSupportMessage(@NonNull android.content.ComponentName, @Nullable CharSequence);
    method public void setManagedProfileMaximumTimeOff(@NonNull android.content.ComponentName, long);
+6 −6
Original line number Diff line number Diff line
@@ -8777,11 +8777,11 @@ public class DevicePolicyManager {
     * @throws SecurityException if caller is not a device owner or a profile owner of an
     *                           organization-owned managed profile.
     */
    public void setLockdownAdminConfiguredNetworks(@NonNull ComponentName admin, boolean lockdown) {
        throwIfParentInstance("setLockdownAdminConfiguredNetworks");
    public void setConfiguredNetworksLockdownState(@NonNull ComponentName admin, boolean lockdown) {
        throwIfParentInstance("setConfiguredNetworksLockdownState");
        if (mService != null) {
            try {
                mService.setLockdownAdminConfiguredNetworks(admin, lockdown);
                mService.setConfiguredNetworksLockdownState(admin, lockdown);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
@@ -8797,11 +8797,11 @@ public class DevicePolicyManager {
     * @throws SecurityException if caller is not a device owner or a profile owner of an
     *                           organization-owned managed profile.
     */
    public boolean isLockdownAdminConfiguredNetworks(@NonNull ComponentName admin) {
        throwIfParentInstance("setLockdownAdminConfiguredNetworks");
    public boolean hasLockdownAdminConfiguredNetworks(@NonNull ComponentName admin) {
        throwIfParentInstance("hasLockdownAdminConfiguredNetworks");
        if (mService != null) {
            try {
                return mService.isLockdownAdminConfiguredNetworks(admin);
                return mService.hasLockdownAdminConfiguredNetworks(admin);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
+2 −2
Original line number Diff line number Diff line
@@ -266,8 +266,8 @@ interface IDevicePolicyManager {
    void setSystemSetting(in ComponentName who, in String setting, in String value);
    void setSecureSetting(in ComponentName who, in String setting, in String value);

    void setLockdownAdminConfiguredNetworks(in ComponentName who, boolean lockdown);
    boolean isLockdownAdminConfiguredNetworks(in ComponentName who);
    void setConfiguredNetworksLockdownState(in ComponentName who, boolean lockdown);
    boolean hasLockdownAdminConfiguredNetworks(in ComponentName who);

    void setLocationEnabled(in ComponentName who, boolean locationEnabled);
    void requestSetLocationProviderAllowed(in ComponentName who, in String provider, boolean providerAllowed);
+2 −2
Original line number Diff line number Diff line
@@ -11519,7 +11519,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
    }
    @Override
    public void setLockdownAdminConfiguredNetworks(ComponentName who, boolean lockdown) {
    public void setConfiguredNetworksLockdownState(ComponentName who, boolean lockdown) {
        if (!mHasFeature) {
            return;
        }
@@ -11538,7 +11538,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
    }
    @Override
    public boolean isLockdownAdminConfiguredNetworks(ComponentName who) {
    public boolean hasLockdownAdminConfiguredNetworks(ComponentName who) {
        if (!mHasFeature) {
            return false;
        }
+8 −8
Original line number Diff line number Diff line
@@ -3781,35 +3781,35 @@ public class DevicePolicyManagerTest extends DpmTestBase {
        assertEquals(-1, dpm.getLastSecurityLogRetrievalTime());
    }

    public void testSetLockdownAdminConfiguredNetworksWithDO() throws Exception {
    public void testSetConfiguredNetworksLockdownStateWithDO() throws Exception {
        mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
        setupDeviceOwner();
        dpm.setLockdownAdminConfiguredNetworks(admin1, true);
        dpm.setConfiguredNetworksLockdownState(admin1, true);
        verify(getServices().settings).settingsGlobalPutInt(
                Settings.Global.WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN, 1);

        dpm.setLockdownAdminConfiguredNetworks(admin1, false);
        dpm.setConfiguredNetworksLockdownState(admin1, false);
        verify(getServices().settings).settingsGlobalPutInt(
                Settings.Global.WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN, 0);
    }

    public void testSetLockdownAdminConfiguredNetworksWithPO() throws Exception {
    public void testSetConfiguredNetworksLockdownStateWithPO() throws Exception {
        setupProfileOwner();
        assertExpectException(SecurityException.class, null,
                () -> dpm.setLockdownAdminConfiguredNetworks(admin1, false));
                () -> dpm.setConfiguredNetworksLockdownState(admin1, false));
        verify(getServices().settings, never()).settingsGlobalPutInt(
                Settings.Global.WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN, 0);
    }

    public void testSetLockdownAdminConfiguredNetworksWithPOOfOrganizationOwnedDevice()
    public void testSetConfiguredNetworksLockdownStateWithPOOfOrganizationOwnedDevice()
            throws Exception {
        setupProfileOwner();
        configureProfileOwnerOfOrgOwnedDevice(admin1, DpmMockContext.CALLER_USER_HANDLE);
        dpm.setLockdownAdminConfiguredNetworks(admin1, true);
        dpm.setConfiguredNetworksLockdownState(admin1, true);
        verify(getServices().settings).settingsGlobalPutInt(
                Settings.Global.WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN, 1);

        dpm.setLockdownAdminConfiguredNetworks(admin1, false);
        dpm.setConfiguredNetworksLockdownState(admin1, false);
        verify(getServices().settings).settingsGlobalPutInt(
                Settings.Global.WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN, 0);
    }