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

Commit 0c696c94 authored by Rubin Xu's avatar Rubin Xu
Browse files

Fix SecurityException when calling DevicePolicyManager.setMaximumTimeToLock

Test: atest com.android.cts.devicepolicy.DeviceOwnerTest#testSecurityLoggingWithSingleUser (only on cuttlefish)
Change-Id: Icd8a24481c281842e9690c6e16c9c31d2d613a2c
Fix: 127264133
parent 9050dc68
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -5246,12 +5246,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                // would allow bypassing of the maximum time to lock.
                mInjector.settingsGlobalPutInt(Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0);
            }
            getPowerManagerInternal().setMaximumScreenOffTimeoutFromDeviceAdmin(
                    UserHandle.USER_SYSTEM, timeMs);
        } finally {
            mInjector.binderRestoreCallingIdentity(ident);
        }
        getPowerManagerInternal().setMaximumScreenOffTimeoutFromDeviceAdmin(
                UserHandle.USER_SYSTEM, timeMs);
    }
    private void updateProfileLockTimeoutLocked(@UserIdInt int userId) {
@@ -5269,8 +5268,13 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        }
        policy.mLastMaximumTimeToLock = timeMs;
        final long ident = mInjector.binderClearCallingIdentity();
        try {
            getPowerManagerInternal().setMaximumScreenOffTimeoutFromDeviceAdmin(
                    userId, policy.mLastMaximumTimeToLock);
        } finally {
            mInjector.binderRestoreCallingIdentity(ident);
        }
    }
    @Override