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

Commit 59193413 authored by Pavel Grafov's avatar Pavel Grafov Committed by Android (Google) Code Review
Browse files

Merge "Remove mDeviceOwnerName - it's never read"

parents 46b9a96e 8a168e8a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -510,7 +510,6 @@ interface IActivityManager {
    void noteAlarmFinish(in IIntentSender sender, in WorkSource workSource, int sourceUid, in String tag);
    @UnsupportedAppUsage
    int getPackageProcessState(in String packageName, in String callingPackage);
    void updateDeviceOwner(in String packageName);

    // Start of N transactions
    // Start Binder transaction tracking for all applications.
+0 −17
Original line number Diff line number Diff line
@@ -694,12 +694,6 @@ public class ActivityManagerService extends IActivityManager.Stub
        return (isFg) ? mFgBroadcastQueue : mBgBroadcastQueue;
    }
    /**
     * The package name of the DeviceOwner. This package is not permitted to have its data cleared.
     * <p>Not actually used</p>
     */
    private volatile String mDeviceOwnerName;
    private volatile int mDeviceOwnerUid = INVALID_UID;
    /**
@@ -6237,17 +6231,6 @@ public class ActivityManagerService extends IActivityManager.Stub
        return ActivityClient.getInstance().getTaskForActivity(token, onlyRoot);
    }
    @Override
    public void updateDeviceOwner(String packageName) {
        final int callingUid = Binder.getCallingUid();
        if (callingUid != 0 && callingUid != SYSTEM_UID) {
            throw new SecurityException("updateDeviceOwner called from non-system process");
        }
        synchronized (this) {
            mDeviceOwnerName = packageName;
        }
    }
    @Override
    public void updateLockTaskPackages(int userId, String[] packages) {
        mActivityTaskManager.updateLockTaskPackages(userId, packages);
+0 −22
Original line number Diff line number Diff line
@@ -1999,9 +1999,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
            mOwners.load();
            setDeviceOwnershipSystemPropertyLocked();
            findOwnerComponentIfNecessaryLocked();
            // TODO PO may not have a class name either due to b/17652534.  Address that too.
            updateDeviceOwnerLocked();
        }
    }
@@ -3142,23 +3139,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        }
    }
    private void updateDeviceOwnerLocked() {
        long ident = mInjector.binderClearCallingIdentity();
        try {
            // TODO This is to prevent DO from getting "clear data"ed, but it should also check the
            // user id and also protect all other DAs too.
            final ComponentName deviceOwnerComponent = mOwners.getDeviceOwnerComponent();
            if (deviceOwnerComponent != null) {
                mInjector.getIActivityManager()
                        .updateDeviceOwner(deviceOwnerComponent.getPackageName());
            }
        } catch (RemoteException e) {
            // Not gonna happen.
        } finally {
            mInjector.binderRestoreCallingIdentity(ident);
        }
    }
    static void validateQualityConstant(int quality) {
        switch (quality) {
            case PASSWORD_QUALITY_UNSPECIFIED:
@@ -8590,7 +8570,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
            mOwners.setDeviceOwner(admin, ownerName, userId);
            mOwners.writeDeviceOwner();
            updateDeviceOwnerLocked();
            setDeviceOwnershipSystemPropertyLocked();
            //TODO(b/180371154): when provisionFullyManagedDevice is used in tests, remove this
@@ -8951,7 +8930,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        mOwners.clearDeviceOwner();
        mOwners.writeDeviceOwner();
        updateDeviceOwnerLocked();
        clearDeviceOwnerUserRestriction(UserHandle.of(userId));
        mInjector.securityLogSetLoggingEnabledProperty(false);
+0 −16
Original line number Diff line number Diff line
@@ -1137,9 +1137,6 @@ public class DevicePolicyManagerTest extends DpmTestBase {
        mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;

        // Verify internal calls.
        verify(getServices().iactivityManager, times(1)).updateDeviceOwner(
                eq(admin1.getPackageName()));

        verify(getServices().userManager, times(1)).setUserRestriction(
                eq(UserManager.DISALLOW_ADD_MANAGED_PROFILE),
                eq(true), eq(UserHandle.SYSTEM));
@@ -1205,9 +1202,6 @@ public class DevicePolicyManagerTest extends DpmTestBase {
        assertThat(dpm.getDeviceOwnerComponentOnAnyUser()).isEqualTo(admin1);

        // Verify internal calls.
        verify(getServices().iactivityManager).updateDeviceOwner(
                eq(admin1.getPackageName()));

        verify(mContext.spiedContext).sendBroadcastAsUser(
                MockUtils.checkIntentAction(DevicePolicyManager.ACTION_DEVICE_OWNER_CHANGED),
                MockUtils.checkUserHandle(UserHandle.USER_SYSTEM));
@@ -1392,11 +1386,6 @@ public class DevicePolicyManagerTest extends DpmTestBase {
        setUpPackageManagerForAdmin(admin1, DpmMockContext.CALLER_SYSTEM_USER_UID);
        dpm.setActiveAdmin(admin1, /* replace =*/ false);
        assertThat(dpm.setDeviceOwner(admin1, "owner-name", UserHandle.USER_SYSTEM)).isTrue();

        // Verify internal calls.
        verify(getServices().iactivityManager, times(1)).updateDeviceOwner(
                eq(admin1.getPackageName()));

        assertThat(dpm.getDeviceOwnerComponentOnAnyUser()).isEqualTo(admin1);

        dpm.addUserRestriction(admin1, UserManager.DISALLOW_ADD_USER);
@@ -1501,11 +1490,6 @@ public class DevicePolicyManagerTest extends DpmTestBase {
        setUpPackageManagerForAdmin(admin1, DpmMockContext.CALLER_SYSTEM_USER_UID);
        dpm.setActiveAdmin(admin1, /* replace =*/ false);
        assertThat(dpm.setDeviceOwner(admin1, "owner-name", UserHandle.USER_SYSTEM)).isTrue();

        // Verify internal calls.
        verify(getServices().iactivityManager, times(1)).updateDeviceOwner(
                eq(admin1.getPackageName()));

        assertThat(dpm.getDeviceOwnerComponentOnAnyUser()).isEqualTo(admin1);

        // Now call clear from the secondary user, which should throw.