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

Commit 8c6791a5 authored by Siyamed Sinir's avatar Siyamed Sinir Committed by Tim Schumacher
Browse files

Fix ClipboardService device lock check for cross profile

ClipboardService.isDeviceLocked should clear callingIdentity before
accessing KeyguardManager.

Test: bit
CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.ManagedProfileTest

Bug: 64934810
Change-Id: I00d491e5fb6d1c5451c7f8c453931b26e6134452
parent 9895b5bf
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -254,15 +254,22 @@ public class ClipboardService extends IClipboard.Stub {

    private boolean isDeviceLocked() {
        boolean isLocked = false;
        KeyguardManager keyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
        final long token = Binder.clearCallingIdentity();
        try {
            final KeyguardManager keyguardManager = (KeyguardManager) mContext.getSystemService(
                    Context.KEYGUARD_SERVICE);
            boolean inKeyguardRestrictedInputMode = keyguardManager.inKeyguardRestrictedInputMode();
            if (inKeyguardRestrictedInputMode) {
               isLocked = true;
            } else {
            PowerManager powerManager = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
               PowerManager powerManager = (PowerManager)mContext.getSystemService(
                 Context.POWER_SERVICE);
               isLocked = !powerManager.isScreenOn();
            }
            return isLocked;
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }

    private final void checkUriOwnerLocked(Uri uri, int uid) {