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

Commit 25a9dfa2 authored by Dmitry Dementyev's avatar Dmitry Dementyev Committed by Android (Google) Code Review
Browse files

Merge "Refactor remote lockscreen verification API."

parents 1f0edc43 34679790
Loading
Loading
Loading
Loading
+20 −19
Original line number Diff line number Diff line
@@ -925,7 +925,7 @@ package android.app {
  public class KeyguardManager {
    method @RequiresPermission(android.Manifest.permission.MANAGE_WEAK_ESCROW_TOKEN) public long addWeakEscrowToken(@NonNull byte[], @NonNull android.os.UserHandle, @NonNull java.util.concurrent.Executor, @NonNull android.app.KeyguardManager.WeakEscrowTokenActivatedListener);
    method @NonNull @RequiresPermission(android.Manifest.permission.CHECK_REMOTE_LOCKSCREEN) public android.content.Intent createConfirmDeviceCredentialForRemoteValidationIntent(@NonNull android.app.StartLockscreenValidationRequest, @NonNull android.content.ComponentName, @Nullable CharSequence, @Nullable CharSequence, @Nullable CharSequence, @Nullable CharSequence);
    method @NonNull @RequiresPermission(android.Manifest.permission.CHECK_REMOTE_LOCKSCREEN) public android.content.Intent createConfirmDeviceCredentialForRemoteValidationIntent(@NonNull android.app.RemoteLockscreenValidationSession, @NonNull android.content.ComponentName, @Nullable CharSequence, @Nullable CharSequence, @Nullable CharSequence, @Nullable CharSequence);
    method public android.content.Intent createConfirmFactoryResetCredentialIntent(CharSequence, CharSequence, CharSequence);
    method @RequiresPermission("android.permission.SET_INITIAL_LOCK") public int getMinLockLength(boolean, int);
    method @RequiresPermission(android.Manifest.permission.CONTROL_KEYGUARD_SECURE_NOTIFICATIONS) public boolean getPrivateNotificationsAllowed();
@@ -937,7 +937,7 @@ package android.app {
    method @RequiresPermission(android.Manifest.permission.SHOW_KEYGUARD_MESSAGE) public void requestDismissKeyguard(@NonNull android.app.Activity, @Nullable CharSequence, @Nullable android.app.KeyguardManager.KeyguardDismissCallback);
    method @RequiresPermission("android.permission.SET_INITIAL_LOCK") public boolean setLock(int, @NonNull byte[], int);
    method @RequiresPermission(android.Manifest.permission.CONTROL_KEYGUARD_SECURE_NOTIFICATIONS) public void setPrivateNotificationsAllowed(boolean);
    method @NonNull @RequiresPermission(android.Manifest.permission.CHECK_REMOTE_LOCKSCREEN) public android.app.StartLockscreenValidationRequest startRemoteLockscreenValidation();
    method @NonNull @RequiresPermission(android.Manifest.permission.CHECK_REMOTE_LOCKSCREEN) public android.app.RemoteLockscreenValidationSession startRemoteLockscreenValidation();
    method @RequiresPermission(android.Manifest.permission.MANAGE_WEAK_ESCROW_TOKEN) public boolean unregisterWeakEscrowTokenRemovedListener(@NonNull android.app.KeyguardManager.WeakEscrowTokenRemovedListener);
    method @NonNull @RequiresPermission(android.Manifest.permission.CHECK_REMOTE_LOCKSCREEN) public android.app.RemoteLockscreenValidationResult validateRemoteLockscreen(@NonNull byte[]);
    field public static final int PASSWORD = 0; // 0x0
@@ -1026,6 +1026,7 @@ package android.app {
    field public static final int RESULT_GUESS_VALID = 1; // 0x1
    field public static final int RESULT_LOCKOUT = 3; // 0x3
    field public static final int RESULT_NO_REMAINING_ATTEMPTS = 4; // 0x4
    field public static final int RESULT_SESSION_EXPIRED = 5; // 0x5
  }
  public static final class RemoteLockscreenValidationResult.Builder {
@@ -1035,6 +1036,23 @@ package android.app {
    method @NonNull public android.app.RemoteLockscreenValidationResult.Builder setTimeoutMillis(long);
  }
  public final class RemoteLockscreenValidationSession implements android.os.Parcelable {
    method public int describeContents();
    method public int getLockType();
    method public int getRemainingAttempts();
    method @NonNull public byte[] getSourcePublicKey();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.RemoteLockscreenValidationSession> CREATOR;
  }
  public static final class RemoteLockscreenValidationSession.Builder {
    ctor public RemoteLockscreenValidationSession.Builder();
    method @NonNull public android.app.RemoteLockscreenValidationSession build();
    method @NonNull public android.app.RemoteLockscreenValidationSession.Builder setLockType(int);
    method @NonNull public android.app.RemoteLockscreenValidationSession.Builder setRemainingAttempts(int);
    method @NonNull public android.app.RemoteLockscreenValidationSession.Builder setSourcePublicKey(@NonNull byte[]);
  }
  public final class RuntimeAppOpAccessMessage implements android.os.Parcelable {
    ctor public RuntimeAppOpAccessMessage(@IntRange(from=0L) int, @IntRange(from=0L) int, @NonNull String, @Nullable String, @NonNull String, int);
    method public int describeContents();
@@ -1052,23 +1070,6 @@ package android.app {
    method public void launchAssist(@Nullable android.os.Bundle);
  }
  public final class StartLockscreenValidationRequest implements android.os.Parcelable {
    method public int describeContents();
    method public int getLockscreenUiType();
    method public int getRemainingAttempts();
    method @NonNull public byte[] getSourcePublicKey();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.StartLockscreenValidationRequest> CREATOR;
  }
  public static final class StartLockscreenValidationRequest.Builder {
    ctor public StartLockscreenValidationRequest.Builder();
    method @NonNull public android.app.StartLockscreenValidationRequest build();
    method @NonNull public android.app.StartLockscreenValidationRequest.Builder setLockscreenUiType(int);
    method @NonNull public android.app.StartLockscreenValidationRequest.Builder setRemainingAttempts(int);
    method @NonNull public android.app.StartLockscreenValidationRequest.Builder setSourcePublicKey(@NonNull byte[]);
  }
  public class StatusBarManager {
    method @NonNull @RequiresPermission(android.Manifest.permission.STATUS_BAR) public android.app.StatusBarManager.DisableInfo getDisableInfo();
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public int getNavBarMode();
+9 −12
Original line number Diff line number Diff line
@@ -146,13 +146,13 @@ public class KeyguardManager {
    public static final String EXTRA_CHECKBOX_LABEL = "android.app.extra.CHECKBOX_LABEL";

    /**
     * A {@link StartLockscreenValidationRequest} extra to be sent along with
     * A {@link RemoteLockscreenValidationSession} extra to be sent along with
     * {@link #ACTION_CONFIRM_REMOTE_DEVICE_CREDENTIAL} containing the data needed to prompt for
     * a remote device's lock screen.
     * @hide
     */
    public static final String EXTRA_START_LOCKSCREEN_VALIDATION_REQUEST =
            "android.app.extra.START_LOCKSCREEN_VALIDATION_REQUEST";
    public static final String EXTRA_REMOTE_LOCKSCREEN_VALIDATION_SESSION =
            "android.app.extra.REMOTE_LOCKSCREEN_VALIDATION_SESSION";

    /**
     * Result code returned by the activity started by
@@ -359,8 +359,7 @@ public class KeyguardManager {
    /**
     * Get an Intent to launch an activity to prompt the user to confirm the
     * credentials (pin, pattern or password) of a remote device.
     * @param startLockscreenValidationRequest contains information necessary to start remote device
     *                                         credential validation.
     * @param session contains information necessary to start remote device credential validation.
     * @param remoteLockscreenValidationServiceComponent
     *          the {@link ComponentName} of the implementation of
     *          {@link android.service.remotelockscreenvalidation.RemoteLockscreenValidationService}
@@ -376,15 +375,14 @@ public class KeyguardManager {
    @RequiresPermission(Manifest.permission.CHECK_REMOTE_LOCKSCREEN)
    @NonNull
    public Intent createConfirmDeviceCredentialForRemoteValidationIntent(
            @NonNull StartLockscreenValidationRequest startLockscreenValidationRequest,
            @NonNull RemoteLockscreenValidationSession session,
            @NonNull ComponentName remoteLockscreenValidationServiceComponent,
            @Nullable CharSequence title,
            @Nullable CharSequence description,
            @Nullable CharSequence checkboxLabel,
            @Nullable CharSequence alternateButtonLabel) {
        Intent intent = new Intent(ACTION_CONFIRM_REMOTE_DEVICE_CREDENTIAL)
                .putExtra(
                        EXTRA_START_LOCKSCREEN_VALIDATION_REQUEST, startLockscreenValidationRequest)
                .putExtra(EXTRA_REMOTE_LOCKSCREEN_VALIDATION_SESSION, session)
                .putExtra(Intent.EXTRA_COMPONENT_NAME, remoteLockscreenValidationServiceComponent)
                .putExtra(EXTRA_TITLE, title)
                .putExtra(EXTRA_DESCRIPTION, description)
@@ -1157,7 +1155,7 @@ public class KeyguardManager {
    @SystemApi
    @RequiresPermission(Manifest.permission.CHECK_REMOTE_LOCKSCREEN)
    @NonNull
    public StartLockscreenValidationRequest startRemoteLockscreenValidation() {
    public RemoteLockscreenValidationSession startRemoteLockscreenValidation() {
        return mLockPatternUtils.startRemoteLockscreenValidation();
    }

@@ -1165,11 +1163,10 @@ public class KeyguardManager {
     * Verifies credentials guess from a remote device.
     *
     * <p>Secret must be encrypted using {@code SecureBox} library
     * with public key from {@code StartLockscreenValidationRequest}
     * with public key from {@code RemoteLockscreenValidationSession}
     * and header set to {@code "encrypted_remote_credentials"} in UTF-8 encoding.
     *
     * @throws IllegalStateException if there is no active lock screen validation session or
     * there was a decryption error.
     * @throws IllegalStateException if there was a decryption error.
     *
     * @hide
     */
+7 −1
Original line number Diff line number Diff line
@@ -55,10 +55,16 @@ public final class RemoteLockscreenValidationResult implements Parcelable {
     */
    public static final int RESULT_NO_REMAINING_ATTEMPTS = 4;

    /**
     * New lockscreen validation session is required to verify guess.
     */
    public static final int RESULT_SESSION_EXPIRED = 5;

    @IntDef({RESULT_GUESS_VALID,
            RESULT_GUESS_INVALID,
            RESULT_LOCKOUT,
            RESULT_NO_REMAINING_ATTEMPTS})
            RESULT_NO_REMAINING_ATTEMPTS,
            RESULT_SESSION_EXPIRED})
    @Retention(RetentionPolicy.SOURCE)
    @interface ResultCode {}

+1 −1
Original line number Diff line number Diff line
@@ -17,4 +17,4 @@
package android.app;

/** {@hide} */
parcelable StartLockscreenValidationRequest;
parcelable RemoteLockscreenValidationSession;
+22 −21
Original line number Diff line number Diff line
@@ -30,44 +30,45 @@ import java.util.Objects;
 * @hide
 */
@SystemApi
public final class StartLockscreenValidationRequest implements Parcelable {
public final class RemoteLockscreenValidationSession implements Parcelable {

    @LockTypes
    private int mLockscreenUiType;
    private int mLockType;

    private byte[] mSourcePublicKey;

    private int mRemainingAttempts;

    public static final @NonNull Parcelable.Creator<StartLockscreenValidationRequest> CREATOR = new
            Parcelable.Creator<StartLockscreenValidationRequest>() {
    public static final @NonNull Parcelable.Creator<RemoteLockscreenValidationSession> CREATOR = new
            Parcelable.Creator<RemoteLockscreenValidationSession>() {
        @Override
        public StartLockscreenValidationRequest createFromParcel(Parcel source) {
            return new StartLockscreenValidationRequest(source);
        public RemoteLockscreenValidationSession createFromParcel(Parcel source) {
            return new RemoteLockscreenValidationSession(source);
        }

        @Override
        public StartLockscreenValidationRequest[] newArray(int size) {
            return new StartLockscreenValidationRequest[size];
        public RemoteLockscreenValidationSession[] newArray(int size) {
            return new RemoteLockscreenValidationSession[size];
        }
    };


    /**
     * Builder for {@code StartLockscreenValidationRequest}
     * Builder for {@code RemoteLockscreenValidationSession}
     */
    public static final class Builder {
        private StartLockscreenValidationRequest mInstance = new StartLockscreenValidationRequest();
        private RemoteLockscreenValidationSession mInstance =
                new RemoteLockscreenValidationSession();

        /**
         * Sets UI type.
         * Default value is {@code LockTypes.PASSWORD}
         *
         * @param lockscreenUiType The UI format
         * @param lockType The UI format
         * @return This builder.
         */
        public @NonNull Builder setLockscreenUiType(@LockTypes int lockscreenUiType) {
            mInstance.mLockscreenUiType = lockscreenUiType;
        public @NonNull Builder setLockType(@LockTypes int lockType) {
            mInstance.mLockType = lockType;
            return this;
        }

@@ -92,11 +93,11 @@ public final class StartLockscreenValidationRequest implements Parcelable {
        }

        /**
         * Creates {@code StartLockscreenValidationRequest}
         * Creates {@code RemoteLockscreenValidationSession}
         *
         * @throws NullPointerException if required fields are not set.
         */
        public @NonNull StartLockscreenValidationRequest build() {
        public @NonNull RemoteLockscreenValidationSession build() {
            Objects.requireNonNull(mInstance.mSourcePublicKey);
            return mInstance;
        }
@@ -105,8 +106,8 @@ public final class StartLockscreenValidationRequest implements Parcelable {
    /**
     * Specifies lock screen credential type.
     */
    public @LockTypes int getLockscreenUiType() {
        return mLockscreenUiType;
    public @LockTypes int getLockType() {
        return mLockType;
    }

    /**
@@ -127,16 +128,16 @@ public final class StartLockscreenValidationRequest implements Parcelable {

    @Override
    public void writeToParcel(@NonNull Parcel out, int flags) {
        out.writeInt(mLockscreenUiType);
        out.writeInt(mLockType);
        out.writeByteArray(mSourcePublicKey);
        out.writeInt(mRemainingAttempts);
    }

    private StartLockscreenValidationRequest() {
    private RemoteLockscreenValidationSession() {
    }

    private StartLockscreenValidationRequest(Parcel in) {
        mLockscreenUiType = in.readInt();
    private RemoteLockscreenValidationSession(Parcel in) {
        mLockType = in.readInt();
        mSourcePublicKey = in.createByteArray();
        mRemainingAttempts = in.readInt();
    }
Loading