Merge "Show work lock confirmation in a task overlay" into udc-dev

This commit is contained in:
Pavel Grafov
2023-03-14 19:41:30 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 4 deletions

View File

@@ -154,6 +154,14 @@ public class KeyguardManager {
public static final String EXTRA_REMOTE_LOCKSCREEN_VALIDATION_SESSION =
"android.app.extra.REMOTE_LOCKSCREEN_VALIDATION_SESSION";
/**
* 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

View File

@@ -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());
}