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

Commit 896bf5ab authored by Dmitry Dementyev's avatar Dmitry Dementyev Committed by Automerger Merge Worker
Browse files

Merge "Refactor remote lockscreen verification API." into udc-dev am: fde45f72

parents a0f4c825 fde45f72
Loading
Loading
Loading
Loading
+20 −19
Original line number Original line Diff line number Diff line
@@ -925,7 +925,7 @@ package android.app {
  public class KeyguardManager {
  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 @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 public android.content.Intent createConfirmFactoryResetCredentialIntent(CharSequence, CharSequence, CharSequence);
    method @RequiresPermission("android.permission.SET_INITIAL_LOCK") public int getMinLockLength(boolean, int);
    method @RequiresPermission("android.permission.SET_INITIAL_LOCK") public int getMinLockLength(boolean, int);
    method @RequiresPermission(android.Manifest.permission.CONTROL_KEYGUARD_SECURE_NOTIFICATIONS) public boolean getPrivateNotificationsAllowed();
    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.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.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 @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 @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[]);
    method @NonNull @RequiresPermission(android.Manifest.permission.CHECK_REMOTE_LOCKSCREEN) public android.app.RemoteLockscreenValidationResult validateRemoteLockscreen(@NonNull byte[]);
    field public static final int PASSWORD = 0; // 0x0
    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_GUESS_VALID = 1; // 0x1
    field public static final int RESULT_LOCKOUT = 3; // 0x3
    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_NO_REMAINING_ATTEMPTS = 4; // 0x4
    field public static final int RESULT_SESSION_EXPIRED = 5; // 0x5
  }
  }
  public static final class RemoteLockscreenValidationResult.Builder {
  public static final class RemoteLockscreenValidationResult.Builder {
@@ -1035,6 +1036,23 @@ package android.app {
    method @NonNull public android.app.RemoteLockscreenValidationResult.Builder setTimeoutMillis(long);
    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 {
  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);
    ctor public RuntimeAppOpAccessMessage(@IntRange(from=0L) int, @IntRange(from=0L) int, @NonNull String, @Nullable String, @NonNull String, int);
    method public int describeContents();
    method public int describeContents();
@@ -1052,23 +1070,6 @@ package android.app {
    method public void launchAssist(@Nullable android.os.Bundle);
    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 {
  public class StatusBarManager {
    method @NonNull @RequiresPermission(android.Manifest.permission.STATUS_BAR) public android.app.StatusBarManager.DisableInfo getDisableInfo();
    method @NonNull @RequiresPermission(android.Manifest.permission.STATUS_BAR) public android.app.StatusBarManager.DisableInfo getDisableInfo();
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public int getNavBarMode();
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public int getNavBarMode();
+9 −12
Original line number Original line Diff line number Diff line
@@ -146,13 +146,13 @@ public class KeyguardManager {
    public static final String EXTRA_CHECKBOX_LABEL = "android.app.extra.CHECKBOX_LABEL";
    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
     * {@link #ACTION_CONFIRM_REMOTE_DEVICE_CREDENTIAL} containing the data needed to prompt for
     * a remote device's lock screen.
     * a remote device's lock screen.
     * @hide
     * @hide
     */
     */
    public static final String EXTRA_START_LOCKSCREEN_VALIDATION_REQUEST =
    public static final String EXTRA_REMOTE_LOCKSCREEN_VALIDATION_SESSION =
            "android.app.extra.START_LOCKSCREEN_VALIDATION_REQUEST";
            "android.app.extra.REMOTE_LOCKSCREEN_VALIDATION_SESSION";


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


@@ -1165,11 +1163,10 @@ public class KeyguardManager {
     * Verifies credentials guess from a remote device.
     * Verifies credentials guess from a remote device.
     *
     *
     * <p>Secret must be encrypted using {@code SecureBox} library
     * <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.
     * and header set to {@code "encrypted_remote_credentials"} in UTF-8 encoding.
     *
     *
     * @throws IllegalStateException if there is no active lock screen validation session or
     * @throws IllegalStateException if there was a decryption error.
     * there was a decryption error.
     *
     *
     * @hide
     * @hide
     */
     */
+7 −1
Original line number Original line Diff line number Diff line
@@ -55,10 +55,16 @@ public final class RemoteLockscreenValidationResult implements Parcelable {
     */
     */
    public static final int RESULT_NO_REMAINING_ATTEMPTS = 4;
    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,
    @IntDef({RESULT_GUESS_VALID,
            RESULT_GUESS_INVALID,
            RESULT_GUESS_INVALID,
            RESULT_LOCKOUT,
            RESULT_LOCKOUT,
            RESULT_NO_REMAINING_ATTEMPTS})
            RESULT_NO_REMAINING_ATTEMPTS,
            RESULT_SESSION_EXPIRED})
    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
    @interface ResultCode {}
    @interface ResultCode {}


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


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


    @LockTypes
    @LockTypes
    private int mLockscreenUiType;
    private int mLockType;


    private byte[] mSourcePublicKey;
    private byte[] mSourcePublicKey;


    private int mRemainingAttempts;
    private int mRemainingAttempts;


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


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




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


        /**
        /**
         * Sets UI type.
         * Sets UI type.
         * Default value is {@code LockTypes.PASSWORD}
         * Default value is {@code LockTypes.PASSWORD}
         *
         *
         * @param lockscreenUiType The UI format
         * @param lockType The UI format
         * @return This builder.
         * @return This builder.
         */
         */
        public @NonNull Builder setLockscreenUiType(@LockTypes int lockscreenUiType) {
        public @NonNull Builder setLockType(@LockTypes int lockType) {
            mInstance.mLockscreenUiType = lockscreenUiType;
            mInstance.mLockType = lockType;
            return this;
            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.
         * @throws NullPointerException if required fields are not set.
         */
         */
        public @NonNull StartLockscreenValidationRequest build() {
        public @NonNull RemoteLockscreenValidationSession build() {
            Objects.requireNonNull(mInstance.mSourcePublicKey);
            Objects.requireNonNull(mInstance.mSourcePublicKey);
            return mInstance;
            return mInstance;
        }
        }
@@ -105,8 +106,8 @@ public final class StartLockscreenValidationRequest implements Parcelable {
    /**
    /**
     * Specifies lock screen credential type.
     * Specifies lock screen credential type.
     */
     */
    public @LockTypes int getLockscreenUiType() {
    public @LockTypes int getLockType() {
        return mLockscreenUiType;
        return mLockType;
    }
    }


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


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


    private StartLockscreenValidationRequest() {
    private RemoteLockscreenValidationSession() {
    }
    }


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