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

Commit 6547a242 authored by Ricky Wai's avatar Ricky Wai Committed by android-build-merger
Browse files

Merge "Fix SystemUI crash for work challenge" into nyc-dev

am: b00ff01f

* commit 'b00ff01f':
  Fix SystemUI crash for work challenge

Change-Id: Ideae53ce87ec6ffeabb0757719e3e8ed2f74245a
parents 5f2be085 b00ff01f
Loading
Loading
Loading
Loading
+13 −8
Original line number Original line Diff line number Diff line
@@ -1847,13 +1847,14 @@ public abstract class BaseStatusBar extends SystemUI implements
                                            .getIdentifier();
                                            .getIdentifier();
                                    if (mLockPatternUtils.isSeparateProfileChallengeEnabled(userId)
                                    if (mLockPatternUtils.isSeparateProfileChallengeEnabled(userId)
                                            && mKeyguardManager.isDeviceLocked(userId)) {
                                            && mKeyguardManager.isDeviceLocked(userId)) {
                                        if (startWorkChallengeIfNecessary(userId,
                                                intent.getIntentSender(), notificationKey)) {
                                            // Show work challenge, do not run pendingintent and
                                            // Show work challenge, do not run pendingintent and
                                            // remove notification
                                            // remove notification
                                        startWorkChallenge(userId, intent.getIntentSender(),
                                                notificationKey);
                                            return;
                                            return;
                                        }
                                        }
                                    }
                                    }
                                }
                                try {
                                try {
                                    intent.send(null, 0, null, null, null, null,
                                    intent.send(null, 0, null, null, null, null,
                                            getActivityOptions());
                                            getActivityOptions());
@@ -1889,21 +1890,25 @@ public abstract class BaseStatusBar extends SystemUI implements
            }, afterKeyguardGone);
            }, afterKeyguardGone);
        }
        }


        public void startWorkChallenge(int userId, IntentSender intendSender,
        public boolean startWorkChallengeIfNecessary(int userId, IntentSender intendSender,
                String notificationKey) {
                String notificationKey) {
            final Intent newIntent = mKeyguardManager.createConfirmDeviceCredentialIntent(null,
                    null, userId);
            if (newIntent == null) {
                return false;
            }
            final Intent callBackIntent = new Intent(
            final Intent callBackIntent = new Intent(
                    WORK_CHALLENGE_UNLOCKED_NOTIFICATION_ACTION);
                    WORK_CHALLENGE_UNLOCKED_NOTIFICATION_ACTION);
            callBackIntent.putExtra(Intent.EXTRA_INTENT, intendSender);
            callBackIntent.putExtra(Intent.EXTRA_INTENT, intendSender);
            callBackIntent.putExtra(Intent.EXTRA_INDEX, notificationKey);
            callBackIntent.putExtra(Intent.EXTRA_INDEX, notificationKey);
            callBackIntent.setPackage(mContext.getPackageName());
            callBackIntent.setPackage(mContext.getPackageName());


            final Intent newIntent = mKeyguardManager.createConfirmDeviceCredentialIntent(null,
                    null, userId);
            newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
            newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                    | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            newIntent.putExtra(Intent.EXTRA_INTENT, PendingIntent
            newIntent.putExtra(Intent.EXTRA_INTENT, PendingIntent
                    .getBroadcast(mContext, 0, callBackIntent, 0).getIntentSender());
                    .getBroadcast(mContext, 0, callBackIntent, 0).getIntentSender());
            mContext.startActivity(newIntent);
            mContext.startActivity(newIntent);
            return true;
        }
        }


        public void register(ExpandableNotificationRow row, StatusBarNotification sbn) {
        public void register(ExpandableNotificationRow row, StatusBarNotification sbn) {