Update KeyguardManager.isDeviceLocked API
Bug: 18414067
Change-Id: I0715714c2c9a122f578ec0c6f508faae12e6f752
diff --git a/services/core/java/com/android/server/trust/TrustManagerService.java b/services/core/java/com/android/server/trust/TrustManagerService.java
index 2388c85..361f0e6 100644
--- a/services/core/java/com/android/server/trust/TrustManagerService.java
+++ b/services/core/java/com/android/server/trust/TrustManagerService.java
@@ -61,6 +61,8 @@
import android.util.Slog;
import android.util.SparseBooleanArray;
import android.util.Xml;
+import android.view.WindowManagerGlobal;
+import android.view.WindowManagerInternal;
import java.io.FileDescriptor;
import java.io.IOException;
@@ -590,13 +592,26 @@
}
@Override
- public boolean isTrusted(int userId) throws RemoteException {
+ public boolean isDeviceLocked(int userId) throws RemoteException {
userId = ActivityManager.handleIncomingUser(getCallingPid(), getCallingUid(), userId,
- false /* allowAll */, true /* requireFull */, "isTrusted", null);
+ false /* allowAll */, true /* requireFull */, "isDeviceLocked", null);
userId = resolveProfileParent(userId);
+
+ boolean isSecure = mLockPatternUtils.isSecure(userId);
+
+ boolean isTrusted;
synchronized (mUserIsTrusted) {
- return mUserIsTrusted.get(userId);
+ isTrusted = mUserIsTrusted.get(userId);
}
+
+ boolean isLocked;
+ if (ActivityManager.getCurrentUser() != userId) {
+ isLocked = true;
+ } else {
+ isLocked = WindowManagerGlobal.getWindowManagerService().isKeyguardLocked();
+ }
+
+ return isSecure && isLocked && !isTrusted;
}
private void enforceReportPermission() {