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

Commit a50f1534 authored by Eran Messeri's avatar Eran Messeri Committed by Android (Google) Code Review
Browse files

Merge "Control lock sceen message on organization-owned device"

parents e1edddb4 57b58c72
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -6363,6 +6363,9 @@ public class DevicePolicyManager {
    /**
     * Sets the device owner information to be shown on the lock screen.
     * <p>
     * Device owner information set using this method overrides any owner information manually set
     * by the user and prevents the user from further changing it.
     * <p>
     * If the device owner information is {@code null} or empty then the device owner info is
     * cleared and the user owner info is shown on the lock screen if it is set.
     * <p>
@@ -6372,6 +6375,8 @@ public class DevicePolicyManager {
     * If the device owner information needs to be localized, it is the responsibility of the
     * {@link DeviceAdminReceiver} to listen to the {@link Intent#ACTION_LOCALE_CHANGED} broadcast
     * and set a new version of this string accordingly.
     * <p>
     * May be called by the device owner or the profile owner of an organization-owned device.
     *
     * @param admin The name of the admin component to check.
     * @param info Device owner information which will be displayed instead of the user owner info.
+12 −6
Original line number Diff line number Diff line
@@ -6685,6 +6685,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                    mUserManager.setUserRestriction(
                            UserManager.DISALLOW_REMOVE_MANAGED_PROFILE, false,
                            UserHandle.SYSTEM);
                    // Device-wide policies set by the profile owner need to be cleaned up here.
                    mLockPatternUtils.setDeviceOwnerInfo(null);
                } finally {
                    mInjector.binderRestoreCallingIdentity(ident);
                }
@@ -8334,14 +8337,17 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        }
        synchronized (getLockObject()) {
            getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
            long token = mInjector.binderClearCallingIdentity();
            try {
                mLockPatternUtils.setDeviceOwnerInfo(info != null ? info.toString() : null);
            } finally {
                mInjector.binderRestoreCallingIdentity(token);
            ActiveAdmin admin = getActiveAdminForCallerLocked(who,
                    DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
            if (!isProfileOwnerOfOrganizationOwnedDevice(admin) && !isDeviceOwner(admin)) {
                throw new SecurityException("Only Device Owner or Profile Owner of"
                        + " organization-owned device can set screen lock info.");
            }
        }
        mInjector.binderWithCleanCallingIdentity(() ->
                mLockPatternUtils.setDeviceOwnerInfo(info != null ? info.toString() : null));
        DevicePolicyEventLogger
                .createEvent(DevicePolicyEnums.SET_DEVICE_OWNER_LOCK_SCREEN_INFO)
                .setAdmin(who)