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

Commit 29b74819 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Removed unused DevicePolicyManager.setDeviceOwner() methods."

parents 4d0b9f06 74d1de59
Loading
Loading
Loading
Loading
+0 −27
Original line number Diff line number Diff line
@@ -7707,33 +7707,6 @@ public class DevicePolicyManager {
        }
    }
    /**
     * @hide
     * Sets the given package as the device owner.
     * Same as {@link #setDeviceOwner(ComponentName, String)} but without setting a device owner name.
     * @param who the component name to be registered as device owner.
     * @return whether the package was successfully registered as the device owner.
     * @throws IllegalArgumentException if the package name is null or invalid
     * @throws IllegalStateException If the preconditions mentioned are not met.
     */
    public boolean setDeviceOwner(ComponentName who) {
        return setDeviceOwner(who, null);
    }
    /**
     * @hide
     */
    public boolean setDeviceOwner(ComponentName who, int userId)  {
        return setDeviceOwner(who, null, userId);
    }
    /**
     * @hide
     */
    public boolean setDeviceOwner(ComponentName who, String ownerName) {
        return setDeviceOwner(who, ownerName, UserHandle.USER_SYSTEM);
    }
    /**
     * @hide
     * Sets the given package as the device owner. The package must already be installed. There
+7 −6
Original line number Diff line number Diff line
@@ -1080,7 +1080,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
        dpm.setActiveAdmin(admin1, /* replace =*/ false);

        // Fire!
        assertThat(dpm.setDeviceOwner(admin1, "owner-name")).isTrue();
        assertThat(dpm.setDeviceOwner(admin1, "owner-name", UserHandle.USER_SYSTEM)).isTrue();

        // getDeviceOwnerComponent should return the admin1 component.
        assertThat(dpm.getDeviceOwnerComponentOnCallingUser()).isEqualTo(admin1);
@@ -1311,7 +1311,8 @@ public class DevicePolicyManagerTest extends DpmTestBase {

        assertExpectException(IllegalArgumentException.class,
                /* messageRegex= */ "Invalid component",
                () -> dpm.setDeviceOwner(new ComponentName("a.b.c", ".def")));
                () -> dpm.setDeviceOwner(new ComponentName("a.b.c", ".def"), /* ownerName= */ null,
                        UserHandle.USER_SYSTEM));
    }

    @Test
@@ -1346,7 +1347,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
        mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
        setUpPackageManagerForAdmin(admin1, DpmMockContext.CALLER_SYSTEM_USER_UID);
        dpm.setActiveAdmin(admin1, /* replace =*/ false);
        assertThat(dpm.setDeviceOwner(admin1, "owner-name")).isTrue();
        assertThat(dpm.setDeviceOwner(admin1, "owner-name", UserHandle.USER_SYSTEM)).isTrue();

        // Verify internal calls.
        verify(getServices().iactivityManager, times(1)).updateDeviceOwner(
@@ -1410,7 +1411,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
        mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
        setUpPackageManagerForAdmin(admin1, DpmMockContext.CALLER_SYSTEM_USER_UID);
        dpm.setActiveAdmin(admin1, /* replace =*/ false);
        assertThat(dpm.setDeviceOwner(admin1, "owner-name")).isTrue();
        assertThat(dpm.setDeviceOwner(admin1, "owner-name", UserHandle.USER_SYSTEM)).isTrue();

        verify(getServices().ibackupManager, times(1)).setBackupServiceActive(
                eq(UserHandle.USER_SYSTEM), eq(false));
@@ -1451,7 +1452,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
        mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
        setUpPackageManagerForAdmin(admin1, DpmMockContext.CALLER_SYSTEM_USER_UID);
        dpm.setActiveAdmin(admin1, /* replace =*/ false);
        assertThat(dpm.setDeviceOwner(admin1, "owner-name")).isTrue();
        assertThat(dpm.setDeviceOwner(admin1, "owner-name", UserHandle.USER_SYSTEM)).isTrue();

        // Verify internal calls.
        verify(getServices().iactivityManager, times(1)).updateDeviceOwner(
@@ -3026,7 +3027,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
        // Set a device owner on the system user. Check that the system user becomes affiliated.
        setUpPackageManagerForAdmin(admin1, DpmMockContext.CALLER_SYSTEM_USER_UID);
        dpm.setActiveAdmin(admin1, /* replace =*/ false);
        assertThat(dpm.setDeviceOwner(admin1, "owner-name")).isTrue();
        assertThat(dpm.setDeviceOwner(admin1, "owner-name", UserHandle.USER_SYSTEM)).isTrue();
        assertThat(dpm.isAffiliatedUser()).isTrue();
        assertThat(dpm.getAffiliationIds(admin1).isEmpty()).isTrue();