From ae13e18c5561537e062f46ddda8e5dff30d1fe26 Mon Sep 17 00:00:00 2001 From: Tony Mak Date: Tue, 17 May 2016 16:36:14 +0100 Subject: [PATCH] Should check isDeviceSecure in shouldConfirmCredentials The NPE is because createConfirmDeviceCredentialIntent returns a null intent when it founds that user does not set a secure lock. So the fix is we should check is the user set a secure lock screen as well. The reason the crash only happens in multi-window flow because we have null checking in the normal flow (i.e. interceptWithConfirmCredentialsIfNeeded). But I think we better check it explicitly. Bug: 28716456 Change-Id: Ib204cd02c0007bd1df36908bb3b5254ec4ffb914 --- services/core/java/com/android/server/am/ActivityStarter.java | 4 ++++ services/core/java/com/android/server/am/UserController.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java index 64b898aea8cea..ad57ae2cecb39 100644 --- a/services/core/java/com/android/server/am/ActivityStarter.java +++ b/services/core/java/com/android/server/am/ActivityStarter.java @@ -620,6 +620,10 @@ class ActivityStarter { .getSystemService(Context.KEYGUARD_SERVICE); final Intent credential = km.createConfirmDeviceCredentialIntent(null, null, userId); + // For safety, check null here in case users changed the setting after the checking. + if (credential == null) { + return; + } final ActivityRecord activityRecord = targetStack.topRunningActivityLocked(); if (activityRecord != null) { final IIntentSender target = mService.getIntentSenderLocked( diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java index c4e39c940e330..595d086abf358 100644 --- a/services/core/java/com/android/server/am/UserController.java +++ b/services/core/java/com/android/server/am/UserController.java @@ -1468,7 +1468,7 @@ final class UserController { } final KeyguardManager km = (KeyguardManager) mService.mContext .getSystemService(KEYGUARD_SERVICE); - return km.isDeviceLocked(userId); + return km.isDeviceLocked(userId) && km.isDeviceSecure(userId); } boolean isLockScreenDisabled(@UserIdInt int userId) {