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. Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.password Change-Id: Ie9b593696a24ad0c435b36eef80e3fe760c588ba
This commit is contained in:
@@ -21,12 +21,14 @@ import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
|
|||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.ActivityOptions;
|
||||||
import android.app.KeyguardManager;
|
import android.app.KeyguardManager;
|
||||||
import android.app.RemoteLockscreenValidationSession;
|
import android.app.RemoteLockscreenValidationSession;
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentSender;
|
import android.content.IntentSender;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -147,7 +149,8 @@ public final class ChooseLockSettingsHelper {
|
|||||||
private boolean mRemoteLockscreenValidation;
|
private boolean mRemoteLockscreenValidation;
|
||||||
@Nullable private RemoteLockscreenValidationSession mRemoteLockscreenValidationSession;
|
@Nullable private RemoteLockscreenValidationSession mRemoteLockscreenValidationSession;
|
||||||
@Nullable private ComponentName mRemoteLockscreenValidationServiceComponent;
|
@Nullable private ComponentName mRemoteLockscreenValidationServiceComponent;
|
||||||
boolean mRequestGatekeeperPasswordHandle;
|
private boolean mRequestGatekeeperPasswordHandle;
|
||||||
|
private boolean mTaskOverlay;
|
||||||
|
|
||||||
public Builder(@NonNull Activity activity) {
|
public Builder(@NonNull Activity activity) {
|
||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
@@ -252,6 +255,14 @@ public final class ChooseLockSettingsHelper {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param taskOverlay specifies whether the activity should be launched as a task overlay.
|
||||||
|
*/
|
||||||
|
@NonNull public Builder setTaskOverlay(boolean taskOverlay) {
|
||||||
|
mTaskOverlay = taskOverlay;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param foregroundOnly if true, the confirmation activity will be finished if it loses
|
* @param foregroundOnly if true, the confirmation activity will be finished if it loses
|
||||||
* foreground.
|
* foreground.
|
||||||
@@ -371,7 +382,8 @@ public final class ChooseLockSettingsHelper {
|
|||||||
mBuilder.mCheckBoxLabel, mBuilder.mRemoteLockscreenValidation,
|
mBuilder.mCheckBoxLabel, mBuilder.mRemoteLockscreenValidation,
|
||||||
mBuilder.mRemoteLockscreenValidationSession,
|
mBuilder.mRemoteLockscreenValidationSession,
|
||||||
mBuilder.mRemoteLockscreenValidationServiceComponent, mBuilder.mAllowAnyUserId,
|
mBuilder.mRemoteLockscreenValidationServiceComponent, mBuilder.mAllowAnyUserId,
|
||||||
mBuilder.mForegroundOnly, mBuilder.mRequestGatekeeperPasswordHandle);
|
mBuilder.mForegroundOnly, mBuilder.mRequestGatekeeperPasswordHandle,
|
||||||
|
mBuilder.mTaskOverlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
|
private boolean launchConfirmationActivity(int request, @Nullable CharSequence title,
|
||||||
@@ -381,7 +393,8 @@ public final class ChooseLockSettingsHelper {
|
|||||||
@Nullable CharSequence checkboxLabel, boolean remoteLockscreenValidation,
|
@Nullable CharSequence checkboxLabel, boolean remoteLockscreenValidation,
|
||||||
@Nullable RemoteLockscreenValidationSession remoteLockscreenValidationSession,
|
@Nullable RemoteLockscreenValidationSession remoteLockscreenValidationSession,
|
||||||
@Nullable ComponentName remoteLockscreenValidationServiceComponent,
|
@Nullable ComponentName remoteLockscreenValidationServiceComponent,
|
||||||
boolean allowAnyUser, boolean foregroundOnly, boolean requestGatekeeperPasswordHandle) {
|
boolean allowAnyUser, boolean foregroundOnly, boolean requestGatekeeperPasswordHandle,
|
||||||
|
boolean taskOverlay) {
|
||||||
Optional<Class<?>> activityClass = determineAppropriateActivityClass(
|
Optional<Class<?>> activityClass = determineAppropriateActivityClass(
|
||||||
returnCredentials, forceVerifyPath, userId, remoteLockscreenValidationSession);
|
returnCredentials, forceVerifyPath, userId, remoteLockscreenValidationSession);
|
||||||
if (activityClass.isEmpty()) {
|
if (activityClass.isEmpty()) {
|
||||||
@@ -392,7 +405,7 @@ public final class ChooseLockSettingsHelper {
|
|||||||
returnCredentials, external, forceVerifyPath, userId, alternateButton,
|
returnCredentials, external, forceVerifyPath, userId, alternateButton,
|
||||||
checkboxLabel, remoteLockscreenValidation, remoteLockscreenValidationSession,
|
checkboxLabel, remoteLockscreenValidation, remoteLockscreenValidationSession,
|
||||||
remoteLockscreenValidationServiceComponent, allowAnyUser, foregroundOnly,
|
remoteLockscreenValidationServiceComponent, allowAnyUser, foregroundOnly,
|
||||||
requestGatekeeperPasswordHandle);
|
requestGatekeeperPasswordHandle, taskOverlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean launchConfirmationActivity(int request, CharSequence title, CharSequence header,
|
private boolean launchConfirmationActivity(int request, CharSequence title, CharSequence header,
|
||||||
@@ -402,7 +415,8 @@ public final class ChooseLockSettingsHelper {
|
|||||||
boolean remoteLockscreenValidation,
|
boolean remoteLockscreenValidation,
|
||||||
@Nullable RemoteLockscreenValidationSession remoteLockscreenValidationSession,
|
@Nullable RemoteLockscreenValidationSession remoteLockscreenValidationSession,
|
||||||
@Nullable ComponentName remoteLockscreenValidationServiceComponent,
|
@Nullable ComponentName remoteLockscreenValidationServiceComponent,
|
||||||
boolean allowAnyUser, boolean foregroundOnly, boolean requestGatekeeperPasswordHandle) {
|
boolean allowAnyUser, boolean foregroundOnly, boolean requestGatekeeperPasswordHandle,
|
||||||
|
boolean taskOverlay) {
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
intent.putExtra(ConfirmDeviceCredentialBaseFragment.TITLE_TEXT, title);
|
intent.putExtra(ConfirmDeviceCredentialBaseFragment.TITLE_TEXT, title);
|
||||||
intent.putExtra(ConfirmDeviceCredentialBaseFragment.HEADER_TEXT, header);
|
intent.putExtra(ConfirmDeviceCredentialBaseFragment.HEADER_TEXT, header);
|
||||||
@@ -434,28 +448,39 @@ public final class ChooseLockSettingsHelper {
|
|||||||
Intent inIntent = mFragment != null ? mFragment.getActivity().getIntent() :
|
Intent inIntent = mFragment != null ? mFragment.getActivity().getIntent() :
|
||||||
mActivity.getIntent();
|
mActivity.getIntent();
|
||||||
copyInternalExtras(inIntent, intent);
|
copyInternalExtras(inIntent, intent);
|
||||||
|
Bundle launchOptions = createLaunchOptions(taskOverlay);
|
||||||
if (external) {
|
if (external) {
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
||||||
copyOptionalExtras(inIntent, intent);
|
copyOptionalExtras(inIntent, intent);
|
||||||
if (mActivityResultLauncher != null) {
|
if (mActivityResultLauncher != null) {
|
||||||
mActivityResultLauncher.launch(intent);
|
mActivityResultLauncher.launch(intent);
|
||||||
} else if (mFragment != null) {
|
} else if (mFragment != null) {
|
||||||
mFragment.startActivity(intent);
|
mFragment.startActivity(intent, launchOptions);
|
||||||
} else {
|
} else {
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent, launchOptions);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mActivityResultLauncher != null) {
|
if (mActivityResultLauncher != null) {
|
||||||
mActivityResultLauncher.launch(intent);
|
mActivityResultLauncher.launch(intent);
|
||||||
} else if (mFragment != null) {
|
} else if (mFragment != null) {
|
||||||
mFragment.startActivityForResult(intent, request);
|
mFragment.startActivityForResult(intent, request, launchOptions);
|
||||||
} else {
|
} else {
|
||||||
mActivity.startActivityForResult(intent, request);
|
mActivity.startActivityForResult(intent, request, launchOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Bundle createLaunchOptions(boolean taskOverlay) {
|
||||||
|
if (!taskOverlay) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
ActivityOptions options = ActivityOptions.makeBasic();
|
||||||
|
options.setLaunchTaskId(mActivity.getTaskId());
|
||||||
|
options.setTaskOverlay(true /* taskOverlay */, true /* canResume */);
|
||||||
|
return options.toBundle();
|
||||||
|
}
|
||||||
|
|
||||||
private Optional<Integer> passwordQualityToLockTypes(int quality) {
|
private Optional<Integer> passwordQualityToLockTypes(int quality) {
|
||||||
switch (quality) {
|
switch (quality) {
|
||||||
case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
|
case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
|
||||||
|
@@ -24,8 +24,6 @@ import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROF
|
|||||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_PATTERN;
|
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_PATTERN;
|
||||||
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_PIN;
|
import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONFIRM_PIN;
|
||||||
|
|
||||||
import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.KeyguardManager;
|
import android.app.KeyguardManager;
|
||||||
import android.app.RemoteLockscreenValidationSession;
|
import android.app.RemoteLockscreenValidationSession;
|
||||||
@@ -63,13 +61,6 @@ import java.util.concurrent.Executor;
|
|||||||
public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
||||||
public static final String TAG = ConfirmDeviceCredentialActivity.class.getSimpleName();
|
public static final String TAG = ConfirmDeviceCredentialActivity.class.getSimpleName();
|
||||||
|
|
||||||
/**
|
|
||||||
* If the intent is sent from {@link com.android.systemui.keyguard.WorkLockActivityController}
|
|
||||||
* then check for device policy management flags.
|
|
||||||
*/
|
|
||||||
public static final String EXTRA_FROM_WORK_LOCK_ACTIVITY_CONTROLLER =
|
|
||||||
"from_work_lock_activity_controller";
|
|
||||||
|
|
||||||
// The normal flow that apps go through
|
// The normal flow that apps go through
|
||||||
private static final int CREDENTIAL_NORMAL = 1;
|
private static final int CREDENTIAL_NORMAL = 1;
|
||||||
// Unlocks the managed profile when the primary profile is unlocked
|
// Unlocks the managed profile when the primary profile is unlocked
|
||||||
@@ -80,15 +71,6 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
|||||||
public static class InternalActivity extends ConfirmDeviceCredentialActivity {
|
public static class InternalActivity extends ConfirmDeviceCredentialActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Intent createIntent(CharSequence title, CharSequence details) {
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.setClassName(SETTINGS_PACKAGE_NAME,
|
|
||||||
ConfirmDeviceCredentialActivity.class.getName());
|
|
||||||
intent.putExtra(KeyguardManager.EXTRA_TITLE, title);
|
|
||||||
intent.putExtra(KeyguardManager.EXTRA_DESCRIPTION, details);
|
|
||||||
return intent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private BiometricFragment mBiometricFragment;
|
private BiometricFragment mBiometricFragment;
|
||||||
private DevicePolicyManager mDevicePolicyManager;
|
private DevicePolicyManager mDevicePolicyManager;
|
||||||
private LockPatternUtils mLockPatternUtils;
|
private LockPatternUtils mLockPatternUtils;
|
||||||
@@ -97,6 +79,7 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
|||||||
private Handler mHandler = new Handler(Looper.getMainLooper());
|
private Handler mHandler = new Handler(Looper.getMainLooper());
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private boolean mCheckDevicePolicyManager;
|
private boolean mCheckDevicePolicyManager;
|
||||||
|
private boolean mTaskOverlay;
|
||||||
|
|
||||||
private String mTitle;
|
private String mTitle;
|
||||||
private CharSequence mDetails;
|
private CharSequence mDetails;
|
||||||
@@ -186,6 +169,8 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
|||||||
boolean frp = KeyguardManager.ACTION_CONFIRM_FRP_CREDENTIAL.equals(intent.getAction());
|
boolean frp = KeyguardManager.ACTION_CONFIRM_FRP_CREDENTIAL.equals(intent.getAction());
|
||||||
boolean remoteValidation =
|
boolean remoteValidation =
|
||||||
KeyguardManager.ACTION_CONFIRM_REMOTE_DEVICE_CREDENTIAL.equals(intent.getAction());
|
KeyguardManager.ACTION_CONFIRM_REMOTE_DEVICE_CREDENTIAL.equals(intent.getAction());
|
||||||
|
mTaskOverlay = isInternalActivity()
|
||||||
|
&& intent.getBooleanExtra(KeyguardManager.EXTRA_FORCE_TASK_OVERLAY, false);
|
||||||
|
|
||||||
mUserId = UserHandle.myUserId();
|
mUserId = UserHandle.myUserId();
|
||||||
if (isInternalActivity()) {
|
if (isInternalActivity()) {
|
||||||
@@ -417,6 +402,12 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
|||||||
*/
|
*/
|
||||||
private void showConfirmCredentials() {
|
private void showConfirmCredentials() {
|
||||||
boolean launched = false;
|
boolean launched = false;
|
||||||
|
ChooseLockSettingsHelper.Builder builder = new ChooseLockSettingsHelper.Builder(this)
|
||||||
|
.setHeader(mTitle)
|
||||||
|
.setDescription(mDetails)
|
||||||
|
.setExternal(true)
|
||||||
|
.setUserId(mUserId)
|
||||||
|
.setTaskOverlay(mTaskOverlay);
|
||||||
// The only difference between CREDENTIAL_MANAGED and CREDENTIAL_NORMAL is that for
|
// The only difference between CREDENTIAL_MANAGED and CREDENTIAL_NORMAL is that for
|
||||||
// CREDENTIAL_MANAGED, we launch the real confirm credential activity with an explicit
|
// CREDENTIAL_MANAGED, we launch the real confirm credential activity with an explicit
|
||||||
// but fake challenge value (0L). This will result in ConfirmLockPassword calling
|
// but fake challenge value (0L). This will result in ConfirmLockPassword calling
|
||||||
@@ -429,22 +420,9 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
|||||||
// LockPatternChecker and LockPatternUtils. verifyPassword should be the only API to use,
|
// LockPatternChecker and LockPatternUtils. verifyPassword should be the only API to use,
|
||||||
// which optionally accepts a challenge.
|
// which optionally accepts a challenge.
|
||||||
if (mCredentialMode == CREDENTIAL_MANAGED) {
|
if (mCredentialMode == CREDENTIAL_MANAGED) {
|
||||||
final ChooseLockSettingsHelper.Builder builder =
|
launched = builder.setForceVerifyPath(true).show();
|
||||||
new ChooseLockSettingsHelper.Builder(this);
|
|
||||||
launched = builder.setHeader(mTitle)
|
|
||||||
.setDescription(mDetails)
|
|
||||||
.setExternal(true)
|
|
||||||
.setUserId(mUserId)
|
|
||||||
.setForceVerifyPath(true)
|
|
||||||
.show();
|
|
||||||
} else if (mCredentialMode == CREDENTIAL_NORMAL) {
|
} else if (mCredentialMode == CREDENTIAL_NORMAL) {
|
||||||
final ChooseLockSettingsHelper.Builder builder =
|
launched = builder.show();
|
||||||
new ChooseLockSettingsHelper.Builder(this);
|
|
||||||
launched = builder.setHeader(mTitle) // Show the title string in the header area
|
|
||||||
.setDescription(mDetails)
|
|
||||||
.setExternal(true)
|
|
||||||
.setUserId(mUserId)
|
|
||||||
.show();
|
|
||||||
}
|
}
|
||||||
if (!launched) {
|
if (!launched) {
|
||||||
Log.d(TAG, "No pin/pattern/pass set");
|
Log.d(TAG, "No pin/pattern/pass set");
|
||||||
|
Reference in New Issue
Block a user