From a8c37a18067da6b12bd32170283aa1f4bf91cfff Mon Sep 17 00:00:00 2001 From: Ricky Wai Date: Tue, 5 Apr 2016 17:10:04 +0100 Subject: [PATCH] Fix SystemUI crash for work challenge We should not assume createConfirmDeviceCredentialIntent() can always return an intent, for example, it has separate work challenge but lock type is None, then createConfirmDeviceCredentialIntent() will return null. Bug: 27782917 Change-Id: I33e40f893f61e35a2e6ce732a47d651139f246a1 --- .../systemui/statusbar/BaseStatusBar.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 4ed64260dc7f9..f5f5a92ca3b89 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -1843,11 +1843,12 @@ public abstract class BaseStatusBar extends SystemUI implements .getIdentifier(); if (mLockPatternUtils.isSeparateProfileChallengeEnabled(userId) && mKeyguardManager.isDeviceLocked(userId)) { - // Show work challenge, do not run pendingintent and - // remove notification - startWorkChallenge(userId, intent.getIntentSender(), - notificationKey); - return; + if (startWorkChallengeIfNecessary(userId, + intent.getIntentSender(), notificationKey)) { + // Show work challenge, do not run pendingintent and + // remove notification + return; + } } } try { @@ -1885,21 +1886,25 @@ public abstract class BaseStatusBar extends SystemUI implements }, afterKeyguardGone); } - public void startWorkChallenge(int userId, IntentSender intendSender, + public boolean startWorkChallengeIfNecessary(int userId, IntentSender intendSender, String notificationKey) { + final Intent newIntent = mKeyguardManager.createConfirmDeviceCredentialIntent(null, + null, userId); + if (newIntent == null) { + return false; + } final Intent callBackIntent = new Intent( WORK_CHALLENGE_UNLOCKED_NOTIFICATION_ACTION); callBackIntent.putExtra(Intent.EXTRA_INTENT, intendSender); callBackIntent.putExtra(Intent.EXTRA_INDEX, notificationKey); callBackIntent.setPackage(mContext.getPackageName()); - final Intent newIntent = mKeyguardManager.createConfirmDeviceCredentialIntent(null, - null, userId); newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_CLEAR_TASK); newIntent.putExtra(Intent.EXTRA_INTENT, PendingIntent .getBroadcast(mContext, 0, callBackIntent, 0).getIntentSender()); mContext.startActivity(newIntent); + return true; } public void register(ExpandableNotificationRow row, StatusBarNotification sbn) {