From d9c6712a1fb8326163e81002ee86bfb41699f37b Mon Sep 17 00:00:00 2001 From: Pavel Grafov Date: Wed, 8 Mar 2023 13:51:09 +0000 Subject: [PATCH] Show work lock confirmation in a task overlay WorkLockActivity is added on top of each task that has any work activity when the profile is locked. This activity is a task overlay meaning it stays on top of other activities. It then starts ConfirmDeviceCredentialActivity, also as an overlay because otherwise it will sink under WorkLockActivity. But when CDCA launches CofirmLockPattern, it is not set as an overlay and as a result is not visible. These CLs add a boolean extra to instruct CDCA to launch CLP (or other activities) as an overlay. Bug: 271840143 Bug: 234002331 Test: manual, with TestDPC setting password reset token. Change-Id: Ib3f82279cdc8b070c3fb716232459c8315c59602 --- core/java/android/app/KeyguardManager.java | 8 ++++++++ .../android/systemui/keyguard/WorkLockActivity.java | 12 ++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/core/java/android/app/KeyguardManager.java b/core/java/android/app/KeyguardManager.java index be0d1c9ddb16e..6260d0097b9d8 100644 --- a/core/java/android/app/KeyguardManager.java +++ b/core/java/android/app/KeyguardManager.java @@ -154,6 +154,14 @@ public class KeyguardManager { public static final String EXTRA_START_LOCKSCREEN_VALIDATION_REQUEST = "android.app.extra.START_LOCKSCREEN_VALIDATION_REQUEST"; + /** + * A boolean indicating that credential confirmation activity should be a task overlay. + * {@link #ACTION_CONFIRM_DEVICE_CREDENTIAL_WITH_USER}. + * @hide + */ + public static final String EXTRA_FORCE_TASK_OVERLAY = + "android.app.KeyguardManager.FORCE_TASK_OVERLAY"; + /** * Result code returned by the activity started by * {@link #createConfirmFactoryResetCredentialIntent} or diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivity.java b/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivity.java index 450fa1420408d..82be009a75609 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivity.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivity.java @@ -176,10 +176,10 @@ public class WorkLockActivity extends Activity { return; } - final Intent credential = getKeyguardManager() + final Intent confirmCredentialIntent = getKeyguardManager() .createConfirmDeviceCredentialIntent(null, null, getTargetUserId(), true /* disallowBiometricsIfPolicyExists */); - if (credential == null) { + if (confirmCredentialIntent == null) { return; } @@ -193,14 +193,18 @@ public class WorkLockActivity extends Activity { PendingIntent.FLAG_IMMUTABLE, options.toBundle()); if (target != null) { - credential.putExtra(Intent.EXTRA_INTENT, target.getIntentSender()); + confirmCredentialIntent.putExtra(Intent.EXTRA_INTENT, target.getIntentSender()); } + // WorkLockActivity is started as a task overlay, so unless credential confirmation is also + // started as an overlay, it won't be visible. final ActivityOptions launchOptions = ActivityOptions.makeBasic(); launchOptions.setLaunchTaskId(getTaskId()); launchOptions.setTaskOverlay(true /* taskOverlay */, true /* canResume */); + // Propagate it in case more than one activity is launched. + confirmCredentialIntent.putExtra(KeyguardManager.EXTRA_FORCE_TASK_OVERLAY, true); - startActivityForResult(credential, REQUEST_CODE_CONFIRM_CREDENTIALS, + startActivityForResult(confirmCredentialIntent, REQUEST_CODE_CONFIRM_CREDENTIALS, launchOptions.toBundle()); }