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: I81a7adac8c9d56ed801ffc1380fcbc987d5df3e6
Merged-In: I712abfe8d542cd1be9c1816f407c8912321ac480
diff --git a/services/core/java/com/android/server/clipboard/ClipboardService.java b/services/core/java/com/android/server/clipboard/ClipboardService.java
index a94a524..28028ce 100644
--- a/services/core/java/com/android/server/clipboard/ClipboardService.java
+++ b/services/core/java/com/android/server/clipboard/ClipboardService.java
@@ -307,8 +307,14 @@
}
private boolean isDeviceLocked() {
- final KeyguardManager keyguardManager = mContext.getSystemService(KeyguardManager.class);
- return keyguardManager != null && keyguardManager.isDeviceLocked();
+ final long token = Binder.clearCallingIdentity();
+ try {
+ final KeyguardManager keyguardManager = mContext.getSystemService(
+ KeyguardManager.class);
+ return keyguardManager != null && keyguardManager.isDeviceLocked();
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
}
private final void checkUriOwnerLocked(Uri uri, int uid) {