Merge "Use updated lockscreen validation API in Settings."
This commit is contained in:
committed by
Android (Google) Code Review
commit
77a4bbe35c
@@ -22,7 +22,7 @@ import android.annotation.NonNull;
|
|||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.KeyguardManager;
|
import android.app.KeyguardManager;
|
||||||
import android.app.StartLockscreenValidationRequest;
|
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;
|
||||||
@@ -145,7 +145,7 @@ public final class ChooseLockSettingsHelper {
|
|||||||
private boolean mAllowAnyUserId;
|
private boolean mAllowAnyUserId;
|
||||||
private boolean mForceVerifyPath;
|
private boolean mForceVerifyPath;
|
||||||
private boolean mRemoteLockscreenValidation;
|
private boolean mRemoteLockscreenValidation;
|
||||||
@Nullable private StartLockscreenValidationRequest mStartLockscreenValidationRequest;
|
@Nullable private RemoteLockscreenValidationSession mRemoteLockscreenValidationSession;
|
||||||
@Nullable private ComponentName mRemoteLockscreenValidationServiceComponent;
|
@Nullable private ComponentName mRemoteLockscreenValidationServiceComponent;
|
||||||
boolean mRequestGatekeeperPasswordHandle;
|
boolean mRequestGatekeeperPasswordHandle;
|
||||||
|
|
||||||
@@ -272,7 +272,7 @@ public final class ChooseLockSettingsHelper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param isRemoteLockscreenValidation if true, remote device validation flow will be
|
* @param isRemoteLockscreenValidation if true, remote device validation flow will be
|
||||||
* started. {@link #setStartLockscreenValidationRequest} and
|
* started. {@link #setRemoteLockscreenValidationSession},
|
||||||
* {@link #setRemoteLockscreenValidationServiceComponent}
|
* {@link #setRemoteLockscreenValidationServiceComponent}
|
||||||
* must also be used to set the required data.
|
* must also be used to set the required data.
|
||||||
*/
|
*/
|
||||||
@@ -283,14 +283,14 @@ public final class ChooseLockSettingsHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param startLockScreenValidationRequest contains information necessary to perform remote
|
* @param remoteLockscreenValidationSession contains information necessary to perform remote
|
||||||
* lockscreen validation such as the remote device's
|
* lockscreen validation such as the remote device's
|
||||||
* lockscreen type, public key to be used for
|
* lockscreen type, public key to be used for
|
||||||
* encryption, and remaining attempts.
|
* encryption, and remaining attempts.
|
||||||
*/
|
*/
|
||||||
@NonNull public Builder setStartLockscreenValidationRequest(
|
@NonNull public Builder setRemoteLockscreenValidationSession(
|
||||||
StartLockscreenValidationRequest startLockScreenValidationRequest) {
|
RemoteLockscreenValidationSession remoteLockscreenValidationSession) {
|
||||||
mStartLockscreenValidationRequest = startLockScreenValidationRequest;
|
mRemoteLockscreenValidationSession = remoteLockscreenValidationSession;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,7 +369,7 @@ public final class ChooseLockSettingsHelper {
|
|||||||
mBuilder.mDescription, mBuilder.mReturnCredentials, mBuilder.mExternal,
|
mBuilder.mDescription, mBuilder.mReturnCredentials, mBuilder.mExternal,
|
||||||
mBuilder.mForceVerifyPath, mBuilder.mUserId, mBuilder.mAlternateButton,
|
mBuilder.mForceVerifyPath, mBuilder.mUserId, mBuilder.mAlternateButton,
|
||||||
mBuilder.mCheckBoxLabel, mBuilder.mRemoteLockscreenValidation,
|
mBuilder.mCheckBoxLabel, mBuilder.mRemoteLockscreenValidation,
|
||||||
mBuilder.mStartLockscreenValidationRequest,
|
mBuilder.mRemoteLockscreenValidationSession,
|
||||||
mBuilder.mRemoteLockscreenValidationServiceComponent, mBuilder.mAllowAnyUserId,
|
mBuilder.mRemoteLockscreenValidationServiceComponent, mBuilder.mAllowAnyUserId,
|
||||||
mBuilder.mForegroundOnly, mBuilder.mRequestGatekeeperPasswordHandle);
|
mBuilder.mForegroundOnly, mBuilder.mRequestGatekeeperPasswordHandle);
|
||||||
}
|
}
|
||||||
@@ -379,18 +379,18 @@ public final class ChooseLockSettingsHelper {
|
|||||||
boolean returnCredentials, boolean external, boolean forceVerifyPath,
|
boolean returnCredentials, boolean external, boolean forceVerifyPath,
|
||||||
int userId, @Nullable CharSequence alternateButton,
|
int userId, @Nullable CharSequence alternateButton,
|
||||||
@Nullable CharSequence checkboxLabel, boolean remoteLockscreenValidation,
|
@Nullable CharSequence checkboxLabel, boolean remoteLockscreenValidation,
|
||||||
@Nullable StartLockscreenValidationRequest startLockScreenValidationRequest,
|
@Nullable RemoteLockscreenValidationSession remoteLockscreenValidationSession,
|
||||||
@Nullable ComponentName remoteLockscreenValidationServiceComponent,
|
@Nullable ComponentName remoteLockscreenValidationServiceComponent,
|
||||||
boolean allowAnyUser, boolean foregroundOnly, boolean requestGatekeeperPasswordHandle) {
|
boolean allowAnyUser, boolean foregroundOnly, boolean requestGatekeeperPasswordHandle) {
|
||||||
Optional<Class<?>> activityClass = determineAppropriateActivityClass(
|
Optional<Class<?>> activityClass = determineAppropriateActivityClass(
|
||||||
returnCredentials, forceVerifyPath, userId, startLockScreenValidationRequest);
|
returnCredentials, forceVerifyPath, userId, remoteLockscreenValidationSession);
|
||||||
if (activityClass.isEmpty()) {
|
if (activityClass.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return launchConfirmationActivity(request, title, header, description, activityClass.get(),
|
return launchConfirmationActivity(request, title, header, description, activityClass.get(),
|
||||||
returnCredentials, external, forceVerifyPath, userId, alternateButton,
|
returnCredentials, external, forceVerifyPath, userId, alternateButton,
|
||||||
checkboxLabel, remoteLockscreenValidation, startLockScreenValidationRequest,
|
checkboxLabel, remoteLockscreenValidation, remoteLockscreenValidationSession,
|
||||||
remoteLockscreenValidationServiceComponent, allowAnyUser, foregroundOnly,
|
remoteLockscreenValidationServiceComponent, allowAnyUser, foregroundOnly,
|
||||||
requestGatekeeperPasswordHandle);
|
requestGatekeeperPasswordHandle);
|
||||||
}
|
}
|
||||||
@@ -400,7 +400,7 @@ public final class ChooseLockSettingsHelper {
|
|||||||
boolean external, boolean forceVerifyPath, int userId,
|
boolean external, boolean forceVerifyPath, int userId,
|
||||||
@Nullable CharSequence alternateButton, @Nullable CharSequence checkbox,
|
@Nullable CharSequence alternateButton, @Nullable CharSequence checkbox,
|
||||||
boolean remoteLockscreenValidation,
|
boolean remoteLockscreenValidation,
|
||||||
@Nullable StartLockscreenValidationRequest startLockScreenValidationRequest,
|
@Nullable RemoteLockscreenValidationSession remoteLockscreenValidationSession,
|
||||||
@Nullable ComponentName remoteLockscreenValidationServiceComponent,
|
@Nullable ComponentName remoteLockscreenValidationServiceComponent,
|
||||||
boolean allowAnyUser, boolean foregroundOnly, boolean requestGatekeeperPasswordHandle) {
|
boolean allowAnyUser, boolean foregroundOnly, boolean requestGatekeeperPasswordHandle) {
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
@@ -419,8 +419,8 @@ public final class ChooseLockSettingsHelper {
|
|||||||
intent.putExtra(Intent.EXTRA_USER_ID, userId);
|
intent.putExtra(Intent.EXTRA_USER_ID, userId);
|
||||||
intent.putExtra(KeyguardManager.EXTRA_ALTERNATE_BUTTON_LABEL, alternateButton);
|
intent.putExtra(KeyguardManager.EXTRA_ALTERNATE_BUTTON_LABEL, alternateButton);
|
||||||
intent.putExtra(KeyguardManager.EXTRA_CHECKBOX_LABEL, checkbox);
|
intent.putExtra(KeyguardManager.EXTRA_CHECKBOX_LABEL, checkbox);
|
||||||
intent.putExtra(KeyguardManager.EXTRA_START_LOCKSCREEN_VALIDATION_REQUEST,
|
intent.putExtra(KeyguardManager.EXTRA_REMOTE_LOCKSCREEN_VALIDATION_SESSION,
|
||||||
startLockScreenValidationRequest);
|
remoteLockscreenValidationSession);
|
||||||
intent.putExtra(Intent.EXTRA_COMPONENT_NAME, remoteLockscreenValidationServiceComponent);
|
intent.putExtra(Intent.EXTRA_COMPONENT_NAME, remoteLockscreenValidationServiceComponent);
|
||||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOREGROUND_ONLY, foregroundOnly);
|
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOREGROUND_ONLY, foregroundOnly);
|
||||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_ALLOW_ANY_USER, allowAnyUser);
|
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_ALLOW_ANY_USER, allowAnyUser);
|
||||||
@@ -477,10 +477,10 @@ public final class ChooseLockSettingsHelper {
|
|||||||
|
|
||||||
private Optional<Class<?>> determineAppropriateActivityClass(boolean returnCredentials,
|
private Optional<Class<?>> determineAppropriateActivityClass(boolean returnCredentials,
|
||||||
boolean forceVerifyPath, int userId,
|
boolean forceVerifyPath, int userId,
|
||||||
@Nullable StartLockscreenValidationRequest startLockscreenValidationRequest) {
|
@Nullable RemoteLockscreenValidationSession remoteLockscreenValidationSession) {
|
||||||
int lockType;
|
int lockType;
|
||||||
if (startLockscreenValidationRequest != null) {
|
if (remoteLockscreenValidationSession != null) {
|
||||||
lockType = startLockscreenValidationRequest.getLockscreenUiType();
|
lockType = remoteLockscreenValidationSession.getLockType();
|
||||||
} else {
|
} else {
|
||||||
final int effectiveUserId = UserManager
|
final int effectiveUserId = UserManager
|
||||||
.get(mActivity).getCredentialOwnerProfile(userId);
|
.get(mActivity).getCredentialOwnerProfile(userId);
|
||||||
|
@@ -28,7 +28,7 @@ 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.StartLockscreenValidationRequest;
|
import android.app.RemoteLockscreenValidationSession;
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.app.trust.TrustManager;
|
import android.app.trust.TrustManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
@@ -235,10 +235,10 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
|||||||
.setUserId(LockPatternUtils.USER_FRP)
|
.setUserId(LockPatternUtils.USER_FRP)
|
||||||
.show();
|
.show();
|
||||||
} else if (remoteValidation) {
|
} else if (remoteValidation) {
|
||||||
StartLockscreenValidationRequest startLockScreenValidationRequest =
|
RemoteLockscreenValidationSession remoteLockscreenValidationSession =
|
||||||
intent.getParcelableExtra(
|
intent.getParcelableExtra(
|
||||||
KeyguardManager.EXTRA_START_LOCKSCREEN_VALIDATION_REQUEST,
|
KeyguardManager.EXTRA_REMOTE_LOCKSCREEN_VALIDATION_SESSION,
|
||||||
StartLockscreenValidationRequest.class);
|
RemoteLockscreenValidationSession.class);
|
||||||
ComponentName remoteLockscreenValidationServiceComponent =
|
ComponentName remoteLockscreenValidationServiceComponent =
|
||||||
intent.getParcelableExtra(Intent.EXTRA_COMPONENT_NAME, ComponentName.class);
|
intent.getParcelableExtra(Intent.EXTRA_COMPONENT_NAME, ComponentName.class);
|
||||||
|
|
||||||
@@ -247,7 +247,7 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
|
|||||||
new ChooseLockSettingsHelper.Builder(this);
|
new ChooseLockSettingsHelper.Builder(this);
|
||||||
launchedCDC = builder
|
launchedCDC = builder
|
||||||
.setRemoteLockscreenValidation(true)
|
.setRemoteLockscreenValidation(true)
|
||||||
.setStartLockscreenValidationRequest(startLockScreenValidationRequest)
|
.setRemoteLockscreenValidationSession(remoteLockscreenValidationSession)
|
||||||
.setRemoteLockscreenValidationServiceComponent(
|
.setRemoteLockscreenValidationServiceComponent(
|
||||||
remoteLockscreenValidationServiceComponent)
|
remoteLockscreenValidationServiceComponent)
|
||||||
.setHeader(mTitle) // Show the title in the header location
|
.setHeader(mTitle) // Show the title in the header location
|
||||||
|
@@ -25,7 +25,7 @@ import android.annotation.Nullable;
|
|||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.KeyguardManager;
|
import android.app.KeyguardManager;
|
||||||
import android.app.RemoteLockscreenValidationResult;
|
import android.app.RemoteLockscreenValidationResult;
|
||||||
import android.app.StartLockscreenValidationRequest;
|
import android.app.RemoteLockscreenValidationSession;
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.app.admin.ManagedSubscriptionsPolicy;
|
import android.app.admin.ManagedSubscriptionsPolicy;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
@@ -107,7 +107,7 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
|
|||||||
protected boolean mRemoteValidation;
|
protected boolean mRemoteValidation;
|
||||||
protected CharSequence mAlternateButtonText;
|
protected CharSequence mAlternateButtonText;
|
||||||
protected BiometricManager mBiometricManager;
|
protected BiometricManager mBiometricManager;
|
||||||
@Nullable protected StartLockscreenValidationRequest mStartLockscreenValidationRequest;
|
@Nullable protected RemoteLockscreenValidationSession mRemoteLockscreenValidationSession;
|
||||||
/** Credential saved so the credential can be set for device if remote validation passes */
|
/** Credential saved so the credential can be set for device if remote validation passes */
|
||||||
@Nullable protected LockscreenCredential mDeviceCredentialGuess;
|
@Nullable protected LockscreenCredential mDeviceCredentialGuess;
|
||||||
@Nullable protected RemoteLockscreenValidationClient mRemoteLockscreenValidationClient;
|
@Nullable protected RemoteLockscreenValidationClient mRemoteLockscreenValidationClient;
|
||||||
@@ -141,12 +141,12 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mRemoteValidation) {
|
if (mRemoteValidation) {
|
||||||
mStartLockscreenValidationRequest = intent.getParcelableExtra(
|
mRemoteLockscreenValidationSession = intent.getParcelableExtra(
|
||||||
KeyguardManager.EXTRA_START_LOCKSCREEN_VALIDATION_REQUEST,
|
KeyguardManager.EXTRA_REMOTE_LOCKSCREEN_VALIDATION_SESSION,
|
||||||
StartLockscreenValidationRequest.class);
|
RemoteLockscreenValidationSession.class);
|
||||||
if (mStartLockscreenValidationRequest == null
|
if (mRemoteLockscreenValidationSession == null
|
||||||
|| mStartLockscreenValidationRequest.getRemainingAttempts() == 0) {
|
|| mRemoteLockscreenValidationSession.getRemainingAttempts() == 0) {
|
||||||
Log.e(TAG, "StartLockscreenValidationRequest is null or "
|
Log.e(TAG, "RemoteLockscreenValidationSession is null or "
|
||||||
+ "no more attempts for remote lockscreen validation.");
|
+ "no more attempts for remote lockscreen validation.");
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
}
|
}
|
||||||
@@ -437,7 +437,7 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
|
|||||||
|
|
||||||
private byte[] encryptDeviceCredentialGuess(byte[] guess) {
|
private byte[] encryptDeviceCredentialGuess(byte[] guess) {
|
||||||
try {
|
try {
|
||||||
byte[] encodedPublicKey = mStartLockscreenValidationRequest.getSourcePublicKey();
|
byte[] encodedPublicKey = mRemoteLockscreenValidationSession.getSourcePublicKey();
|
||||||
PublicKey publicKey = SecureBox.decodePublicKey(encodedPublicKey);
|
PublicKey publicKey = SecureBox.decodePublicKey(encodedPublicKey);
|
||||||
return SecureBox.encrypt(
|
return SecureBox.encrypt(
|
||||||
publicKey,
|
publicKey,
|
||||||
|
@@ -166,7 +166,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
mErrorTextView = (TextView) view.findViewById(R.id.errorText);
|
mErrorTextView = (TextView) view.findViewById(R.id.errorText);
|
||||||
|
|
||||||
if (mRemoteValidation) {
|
if (mRemoteValidation) {
|
||||||
mIsAlpha = mStartLockscreenValidationRequest.getLockscreenUiType()
|
mIsAlpha = mRemoteLockscreenValidationSession.getLockType()
|
||||||
== KeyguardManager.PASSWORD;
|
== KeyguardManager.PASSWORD;
|
||||||
// ProgressBar visibility is set to GONE until interacted with.
|
// ProgressBar visibility is set to GONE until interacted with.
|
||||||
// Set progress bar to INVISIBLE, so the EditText does not get bumped down later.
|
// Set progress bar to INVISIBLE, so the EditText does not get bumped down later.
|
||||||
@@ -633,6 +633,9 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
break;
|
break;
|
||||||
case RemoteLockscreenValidationResult.RESULT_NO_REMAINING_ATTEMPTS:
|
case RemoteLockscreenValidationResult.RESULT_NO_REMAINING_ATTEMPTS:
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
|
break;
|
||||||
|
case RemoteLockscreenValidationResult.RESULT_SESSION_EXPIRED:
|
||||||
|
getActivity().finish();
|
||||||
}
|
}
|
||||||
mGlifLayout.setProgressBarShown(false);
|
mGlifLayout.setProgressBarShown(false);
|
||||||
}
|
}
|
||||||
|
@@ -646,6 +646,9 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
break;
|
break;
|
||||||
case RemoteLockscreenValidationResult.RESULT_NO_REMAINING_ATTEMPTS:
|
case RemoteLockscreenValidationResult.RESULT_NO_REMAINING_ATTEMPTS:
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
|
break;
|
||||||
|
case RemoteLockscreenValidationResult.RESULT_SESSION_EXPIRED:
|
||||||
|
getActivity().finish();
|
||||||
}
|
}
|
||||||
mGlifLayout.setProgressBarShown(false);
|
mGlifLayout.setProgressBarShown(false);
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@ package com.android.settings.password;
|
|||||||
|
|
||||||
import static com.android.settings.password.TestUtils.COMPONENT_NAME;
|
import static com.android.settings.password.TestUtils.COMPONENT_NAME;
|
||||||
import static com.android.settings.password.TestUtils.VALID_REMAINING_ATTEMPTS;
|
import static com.android.settings.password.TestUtils.VALID_REMAINING_ATTEMPTS;
|
||||||
import static com.android.settings.password.TestUtils.createStartLockscreenValidationRequest;
|
import static com.android.settings.password.TestUtils.createRemoteLockscreenValidationSession;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.KeyguardManager;
|
import android.app.KeyguardManager;
|
||||||
import android.app.StartLockscreenValidationRequest;
|
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;
|
||||||
@@ -170,13 +170,13 @@ public class ChooseLockSettingsHelperTest {
|
|||||||
public void launchConfirmPassword_remoteValidation_passwordLockType() throws Exception {
|
public void launchConfirmPassword_remoteValidation_passwordLockType() throws Exception {
|
||||||
Activity activity = Robolectric.setupActivity(Activity.class);
|
Activity activity = Robolectric.setupActivity(Activity.class);
|
||||||
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
||||||
StartLockscreenValidationRequest request = createStartLockscreenValidationRequest(
|
RemoteLockscreenValidationSession request = createRemoteLockscreenValidationSession(
|
||||||
KeyguardManager.PASSWORD, VALID_REMAINING_ATTEMPTS);
|
KeyguardManager.PASSWORD, VALID_REMAINING_ATTEMPTS);
|
||||||
|
|
||||||
ChooseLockSettingsHelper chooseLockSettingsHelper = getChooseLockSettingsHelper(
|
ChooseLockSettingsHelper chooseLockSettingsHelper = getChooseLockSettingsHelper(
|
||||||
new ChooseLockSettingsHelper.Builder(activity)
|
new ChooseLockSettingsHelper.Builder(activity)
|
||||||
.setRemoteLockscreenValidation(true)
|
.setRemoteLockscreenValidation(true)
|
||||||
.setStartLockscreenValidationRequest(request)
|
.setRemoteLockscreenValidationSession(request)
|
||||||
.setRemoteLockscreenValidationServiceComponent(COMPONENT_NAME));
|
.setRemoteLockscreenValidationServiceComponent(COMPONENT_NAME));
|
||||||
chooseLockSettingsHelper.launch();
|
chooseLockSettingsHelper.launch();
|
||||||
|
|
||||||
@@ -187,8 +187,8 @@ public class ChooseLockSettingsHelperTest {
|
|||||||
ConfirmDeviceCredentialBaseFragment.IS_REMOTE_LOCKSCREEN_VALIDATION, false)
|
ConfirmDeviceCredentialBaseFragment.IS_REMOTE_LOCKSCREEN_VALIDATION, false)
|
||||||
).isTrue();
|
).isTrue();
|
||||||
assertThat(startedIntent.getParcelableExtra(
|
assertThat(startedIntent.getParcelableExtra(
|
||||||
KeyguardManager.EXTRA_START_LOCKSCREEN_VALIDATION_REQUEST,
|
KeyguardManager.EXTRA_REMOTE_LOCKSCREEN_VALIDATION_SESSION,
|
||||||
StartLockscreenValidationRequest.class)
|
RemoteLockscreenValidationSession.class)
|
||||||
).isEqualTo(request);
|
).isEqualTo(request);
|
||||||
assertThat(startedIntent.getParcelableExtra(
|
assertThat(startedIntent.getParcelableExtra(
|
||||||
Intent.EXTRA_COMPONENT_NAME, ComponentName.class)
|
Intent.EXTRA_COMPONENT_NAME, ComponentName.class)
|
||||||
@@ -199,13 +199,13 @@ public class ChooseLockSettingsHelperTest {
|
|||||||
public void launchConfirmPassword_remoteValidation_pinLockType() throws Exception {
|
public void launchConfirmPassword_remoteValidation_pinLockType() throws Exception {
|
||||||
Activity activity = Robolectric.setupActivity(Activity.class);
|
Activity activity = Robolectric.setupActivity(Activity.class);
|
||||||
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
||||||
StartLockscreenValidationRequest request = createStartLockscreenValidationRequest(
|
RemoteLockscreenValidationSession request = createRemoteLockscreenValidationSession(
|
||||||
KeyguardManager.PIN, VALID_REMAINING_ATTEMPTS);
|
KeyguardManager.PIN, VALID_REMAINING_ATTEMPTS);
|
||||||
|
|
||||||
ChooseLockSettingsHelper chooseLockSettingsHelper = getChooseLockSettingsHelper(
|
ChooseLockSettingsHelper chooseLockSettingsHelper = getChooseLockSettingsHelper(
|
||||||
new ChooseLockSettingsHelper.Builder(activity)
|
new ChooseLockSettingsHelper.Builder(activity)
|
||||||
.setRemoteLockscreenValidation(true)
|
.setRemoteLockscreenValidation(true)
|
||||||
.setStartLockscreenValidationRequest(request)
|
.setRemoteLockscreenValidationSession(request)
|
||||||
.setRemoteLockscreenValidationServiceComponent(COMPONENT_NAME));
|
.setRemoteLockscreenValidationServiceComponent(COMPONENT_NAME));
|
||||||
chooseLockSettingsHelper.launch();
|
chooseLockSettingsHelper.launch();
|
||||||
|
|
||||||
@@ -216,8 +216,8 @@ public class ChooseLockSettingsHelperTest {
|
|||||||
ConfirmDeviceCredentialBaseFragment.IS_REMOTE_LOCKSCREEN_VALIDATION, false)
|
ConfirmDeviceCredentialBaseFragment.IS_REMOTE_LOCKSCREEN_VALIDATION, false)
|
||||||
).isTrue();
|
).isTrue();
|
||||||
assertThat(startedIntent.getParcelableExtra(
|
assertThat(startedIntent.getParcelableExtra(
|
||||||
KeyguardManager.EXTRA_START_LOCKSCREEN_VALIDATION_REQUEST,
|
KeyguardManager.EXTRA_REMOTE_LOCKSCREEN_VALIDATION_SESSION,
|
||||||
StartLockscreenValidationRequest.class)
|
RemoteLockscreenValidationSession.class)
|
||||||
).isEqualTo(request);
|
).isEqualTo(request);
|
||||||
assertThat(startedIntent.getParcelableExtra(
|
assertThat(startedIntent.getParcelableExtra(
|
||||||
Intent.EXTRA_COMPONENT_NAME, ComponentName.class)
|
Intent.EXTRA_COMPONENT_NAME, ComponentName.class)
|
||||||
@@ -228,13 +228,13 @@ public class ChooseLockSettingsHelperTest {
|
|||||||
public void launchConfirmPattern_remoteValidation_patternLockType() throws Exception {
|
public void launchConfirmPattern_remoteValidation_patternLockType() throws Exception {
|
||||||
Activity activity = Robolectric.setupActivity(Activity.class);
|
Activity activity = Robolectric.setupActivity(Activity.class);
|
||||||
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
||||||
StartLockscreenValidationRequest request = createStartLockscreenValidationRequest(
|
RemoteLockscreenValidationSession request = createRemoteLockscreenValidationSession(
|
||||||
KeyguardManager.PATTERN, VALID_REMAINING_ATTEMPTS);
|
KeyguardManager.PATTERN, VALID_REMAINING_ATTEMPTS);
|
||||||
|
|
||||||
ChooseLockSettingsHelper chooseLockSettingsHelper = getChooseLockSettingsHelper(
|
ChooseLockSettingsHelper chooseLockSettingsHelper = getChooseLockSettingsHelper(
|
||||||
new ChooseLockSettingsHelper.Builder(activity)
|
new ChooseLockSettingsHelper.Builder(activity)
|
||||||
.setRemoteLockscreenValidation(true)
|
.setRemoteLockscreenValidation(true)
|
||||||
.setStartLockscreenValidationRequest(request)
|
.setRemoteLockscreenValidationSession(request)
|
||||||
.setRemoteLockscreenValidationServiceComponent(COMPONENT_NAME));
|
.setRemoteLockscreenValidationServiceComponent(COMPONENT_NAME));
|
||||||
chooseLockSettingsHelper.launch();
|
chooseLockSettingsHelper.launch();
|
||||||
|
|
||||||
@@ -245,8 +245,8 @@ public class ChooseLockSettingsHelperTest {
|
|||||||
ConfirmDeviceCredentialBaseFragment.IS_REMOTE_LOCKSCREEN_VALIDATION, false)
|
ConfirmDeviceCredentialBaseFragment.IS_REMOTE_LOCKSCREEN_VALIDATION, false)
|
||||||
).isTrue();
|
).isTrue();
|
||||||
assertThat(startedIntent.getParcelableExtra(
|
assertThat(startedIntent.getParcelableExtra(
|
||||||
KeyguardManager.EXTRA_START_LOCKSCREEN_VALIDATION_REQUEST,
|
KeyguardManager.EXTRA_REMOTE_LOCKSCREEN_VALIDATION_SESSION,
|
||||||
StartLockscreenValidationRequest.class)
|
RemoteLockscreenValidationSession.class)
|
||||||
).isEqualTo(request);
|
).isEqualTo(request);
|
||||||
assertThat(startedIntent.getParcelableExtra(
|
assertThat(startedIntent.getParcelableExtra(
|
||||||
Intent.EXTRA_COMPONENT_NAME, ComponentName.class)
|
Intent.EXTRA_COMPONENT_NAME, ComponentName.class)
|
||||||
|
@@ -23,7 +23,7 @@ import static com.android.settings.password.TestUtils.VALID_REMAINING_ATTEMPTS;
|
|||||||
import static com.android.settings.password.TestUtils.buildConfirmDeviceCredentialBaseActivity;
|
import static com.android.settings.password.TestUtils.buildConfirmDeviceCredentialBaseActivity;
|
||||||
import static com.android.settings.password.TestUtils.createPackageInfoWithService;
|
import static com.android.settings.password.TestUtils.createPackageInfoWithService;
|
||||||
import static com.android.settings.password.TestUtils.createRemoteLockscreenValidationIntent;
|
import static com.android.settings.password.TestUtils.createRemoteLockscreenValidationIntent;
|
||||||
import static com.android.settings.password.TestUtils.createStartLockscreenValidationRequest;
|
import static com.android.settings.password.TestUtils.createRemoteLockscreenValidationSession;
|
||||||
import static com.android.settings.password.TestUtils.getConfirmDeviceCredentialBaseFragment;
|
import static com.android.settings.password.TestUtils.getConfirmDeviceCredentialBaseFragment;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
@@ -132,8 +132,8 @@ public class ConfirmCredentialTest {
|
|||||||
throws Exception {
|
throws Exception {
|
||||||
Intent intentWithInvalidComponentName = new Intent()
|
Intent intentWithInvalidComponentName = new Intent()
|
||||||
.putExtra(ConfirmDeviceCredentialBaseFragment.IS_REMOTE_LOCKSCREEN_VALIDATION, true)
|
.putExtra(ConfirmDeviceCredentialBaseFragment.IS_REMOTE_LOCKSCREEN_VALIDATION, true)
|
||||||
.putExtra(KeyguardManager.EXTRA_START_LOCKSCREEN_VALIDATION_REQUEST,
|
.putExtra(KeyguardManager.EXTRA_REMOTE_LOCKSCREEN_VALIDATION_SESSION,
|
||||||
createStartLockscreenValidationRequest(
|
createRemoteLockscreenValidationSession(
|
||||||
KeyguardManager.PASSWORD, VALID_REMAINING_ATTEMPTS))
|
KeyguardManager.PASSWORD, VALID_REMAINING_ATTEMPTS))
|
||||||
.putExtra(Intent.EXTRA_COMPONENT_NAME, new ComponentName("pkg", "cls"));
|
.putExtra(Intent.EXTRA_COMPONENT_NAME, new ComponentName("pkg", "cls"));
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@ package com.android.settings.password;
|
|||||||
|
|
||||||
import android.app.KeyguardManager;
|
import android.app.KeyguardManager;
|
||||||
import android.app.RemoteLockscreenValidationResult;
|
import android.app.RemoteLockscreenValidationResult;
|
||||||
import android.app.StartLockscreenValidationRequest;
|
import android.app.RemoteLockscreenValidationSession;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
@@ -79,15 +79,15 @@ public final class TestUtils {
|
|||||||
int lockscreenType, int remainingAttempts) throws Exception {
|
int lockscreenType, int remainingAttempts) throws Exception {
|
||||||
return new Intent()
|
return new Intent()
|
||||||
.putExtra(ConfirmDeviceCredentialBaseFragment.IS_REMOTE_LOCKSCREEN_VALIDATION, true)
|
.putExtra(ConfirmDeviceCredentialBaseFragment.IS_REMOTE_LOCKSCREEN_VALIDATION, true)
|
||||||
.putExtra(KeyguardManager.EXTRA_START_LOCKSCREEN_VALIDATION_REQUEST,
|
.putExtra(KeyguardManager.EXTRA_REMOTE_LOCKSCREEN_VALIDATION_SESSION,
|
||||||
createStartLockscreenValidationRequest(lockscreenType, remainingAttempts))
|
createRemoteLockscreenValidationSession(lockscreenType, remainingAttempts))
|
||||||
.putExtra(Intent.EXTRA_COMPONENT_NAME, COMPONENT_NAME);
|
.putExtra(Intent.EXTRA_COMPONENT_NAME, COMPONENT_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StartLockscreenValidationRequest createStartLockscreenValidationRequest(
|
public static RemoteLockscreenValidationSession createRemoteLockscreenValidationSession(
|
||||||
int lockscreenType, int remainingAttempts) throws NoSuchAlgorithmException {
|
int lockscreenType, int remainingAttempts) throws NoSuchAlgorithmException {
|
||||||
return new StartLockscreenValidationRequest.Builder()
|
return new RemoteLockscreenValidationSession.Builder()
|
||||||
.setLockscreenUiType(lockscreenType)
|
.setLockType(lockscreenType)
|
||||||
.setRemainingAttempts(remainingAttempts)
|
.setRemainingAttempts(remainingAttempts)
|
||||||
.setSourcePublicKey(SecureBox.genKeyPair().getPublic().getEncoded())
|
.setSourcePublicKey(SecureBox.genKeyPair().getPublic().getEncoded())
|
||||||
.build();
|
.build();
|
||||||
|
Reference in New Issue
Block a user