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

Commit c8e27d42 authored by Song Chun Fan's avatar Song Chun Fan
Browse files

[ADI][19/N] support lite verification mode

+ VerificationStatus.isLite()
+ New Extra as part of the install result that inidicate the
  verification was a lite verification.
+ User action reason code sent to the user confirmation dialog to inform
  the user that a lite verification was conducted on the target app.
+ New string in user action confirmation dialog

FLAG: android.content.pm.verification_service
BUG: 360129657
Test: atest VerifierControllerTest
Test: cts tests to be added
API-Coverage-Bug: 367776952

Merged-In: I0b19b2ff4f754be4d831a6b7071afb397cf3fd53
Change-Id: I0b19b2ff4f754be4d831a6b7071afb397cf3fd53
parent 2dde455f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -13122,6 +13122,7 @@ package android.content.pm {
    field @FlaggedApi("android.content.pm.archiving") public static final String EXTRA_UNARCHIVE_STATUS = "android.content.pm.extra.UNARCHIVE_STATUS";
    field @FlaggedApi("android.content.pm.verification_service") public static final String EXTRA_VERIFICATION_EXTENSION_RESPONSE = "android.content.pm.extra.VERIFICATION_EXTENSION_RESPONSE";
    field @FlaggedApi("android.content.pm.verification_service") public static final String EXTRA_VERIFICATION_FAILURE_REASON = "android.content.pm.extra.VERIFICATION_FAILURE_REASON";
    field @FlaggedApi("android.content.pm.verification_service") public static final String EXTRA_VERIFICATION_LITE_PERFORMED = "android.content.pm.extra.VERIFICATION_LITE_PERFORMED";
    field public static final int PACKAGE_SOURCE_DOWNLOADED_FILE = 4; // 0x4
    field public static final int PACKAGE_SOURCE_LOCAL_FILE = 3; // 0x3
    field public static final int PACKAGE_SOURCE_OTHER = 1; // 0x1
+3 −0
Original line number Diff line number Diff line
@@ -4382,6 +4382,7 @@ package android.content.pm {
    method public int getVerificationUserActionNeededReason();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.PackageInstaller.VerificationUserConfirmationInfo> CREATOR;
    field public static final int VERIFICATION_USER_ACTION_NEEDED_REASON_LITE_VERIFICATION = 3; // 0x3
    field public static final int VERIFICATION_USER_ACTION_NEEDED_REASON_NETWORK_UNAVAILABLE = 1; // 0x1
    field public static final int VERIFICATION_USER_ACTION_NEEDED_REASON_PACKAGE_BLOCKED = 2; // 0x2
    field public static final int VERIFICATION_USER_ACTION_NEEDED_REASON_UNKNOWN = 0; // 0x0
@@ -4813,6 +4814,7 @@ package android.content.pm.verify.pkg {
    method public int describeContents();
    method public int getAslStatus();
    method @NonNull public String getFailureMessage();
    method public boolean isLite();
    method public boolean isVerified();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.verify.pkg.VerificationStatus> CREATOR;
@@ -4826,6 +4828,7 @@ package android.content.pm.verify.pkg {
    method @NonNull public android.content.pm.verify.pkg.VerificationStatus build();
    method @NonNull public android.content.pm.verify.pkg.VerificationStatus.Builder setAslStatus(int);
    method @NonNull public android.content.pm.verify.pkg.VerificationStatus.Builder setFailureMessage(@NonNull String);
    method @NonNull public android.content.pm.verify.pkg.VerificationStatus.Builder setLite(boolean);
    method @NonNull public android.content.pm.verify.pkg.VerificationStatus.Builder setVerified(boolean);
  }
+17 −0
Original line number Diff line number Diff line
@@ -486,6 +486,16 @@ public class PackageInstaller {
    public static final String EXTRA_VERIFICATION_EXTENSION_RESPONSE =
            "android.content.pm.extra.VERIFICATION_EXTENSION_RESPONSE";

    /**
     * An extra containing a boolean indicating whether the lite verification was performed on
     * the app to be installed. It is included in the installation result returned via the
     * {@link IntentSender} in {@link Session#commit(IntentSender)} when the installation failed.
     */
    @FlaggedApi(Flags.FLAG_VERIFICATION_SERVICE)
    public static final String EXTRA_VERIFICATION_LITE_PERFORMED =
            "android.content.pm.extra.VERIFICATION_LITE_PERFORMED";


    /**
     * Streaming installation pending.
     * Caller should make sure DataLoader is able to prepare image and reinitiate the operation.
@@ -5035,6 +5045,12 @@ public class PackageInstaller {
         */
        public static final int VERIFICATION_USER_ACTION_NEEDED_REASON_PACKAGE_BLOCKED = 2;

        /**
         * Verification requires user intervention because only the lite version of the
         * verification was completed on the request, not the full verification.
         */
        public static final int VERIFICATION_USER_ACTION_NEEDED_REASON_LITE_VERIFICATION = 3;

        /**
         * @hide
         */
@@ -5042,6 +5058,7 @@ public class PackageInstaller {
                VERIFICATION_USER_ACTION_NEEDED_REASON_UNKNOWN,
                VERIFICATION_USER_ACTION_NEEDED_REASON_NETWORK_UNAVAILABLE,
                VERIFICATION_USER_ACTION_NEEDED_REASON_PACKAGE_BLOCKED,
                VERIFICATION_USER_ACTION_NEEDED_REASON_LITE_VERIFICATION
        })
        @Retention(RetentionPolicy.SOURCE)
        public @interface UserActionNeededReason {
+1 −1
Original line number Diff line number Diff line
@@ -60,8 +60,8 @@ public final class VerificationSession implements Parcelable {
     * @hide
     */
    @IntDef(prefix = {"VERIFICATION_INCOMPLETE_"}, value = {
            VERIFICATION_INCOMPLETE_NETWORK_UNAVAILABLE,
            VERIFICATION_INCOMPLETE_UNKNOWN,
            VERIFICATION_INCOMPLETE_NETWORK_UNAVAILABLE,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface VerificationIncompleteReason {
+42 −11
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.os.Parcelable;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Objects;

/**
 * This class is used by the verifier to describe the status of the verification request, whether
@@ -67,12 +68,19 @@ public final class VerificationStatus implements Parcelable {
    @Retention(RetentionPolicy.SOURCE)
    public @interface VerifierStatusAsl {}

    private boolean mIsVerified;
    private @VerifierStatusAsl int mAslStatus;
    private final boolean mIsVerified;
    private final boolean mIsLite;
    private final @VerifierStatusAsl int mAslStatus;
    @NonNull
    private String mFailuresMessage = "";

    private VerificationStatus() {}
    private final String mFailuresMessage;

    private VerificationStatus(boolean isVerified, boolean isLite, @VerifierStatusAsl int aslStatus,
            @NonNull String failuresMessage) {
        mIsVerified = isVerified;
        mIsLite = isLite;
        mAslStatus = aslStatus;
        mFailuresMessage = failuresMessage;
    }

    /**
     * @return whether the status is set to verified or not.
@@ -81,6 +89,13 @@ public final class VerificationStatus implements Parcelable {
        return mIsVerified;
    }

    /**
     * @return true when the only the lite variation of the verification was conducted.
     */
    public boolean isLite() {
        return mIsLite;
    }

    /**
     * @return the failure message associated with the failure status.
     */
@@ -100,14 +115,27 @@ public final class VerificationStatus implements Parcelable {
     * Builder to construct a {@link VerificationStatus} object.
     */
    public static final class Builder {
        final VerificationStatus mStatus = new VerificationStatus();
        private boolean mIsVerified = false;
        private boolean mIsLite = false;
        private @VerifierStatusAsl int mAslStatus = VERIFIER_STATUS_ASL_UNDEFINED;
        private String mFailuresMessage = "";

        /**
         * Set in the status whether the verification has succeeded or failed.
         */
        @NonNull
        public Builder setVerified(boolean verified) {
            mStatus.mIsVerified = verified;
        public Builder setVerified(boolean isVerified) {
            mIsVerified = isVerified;
            return this;
        }

        /**
         * Set in the status whether the lite variation of the verification was conducted
         * instead of the full verification.
         */
        @NonNull
        public Builder setLite(boolean isLite) {
            mIsLite = isLite;
            return this;
        }

@@ -116,7 +144,8 @@ public final class VerificationStatus implements Parcelable {
         */
        @NonNull
        public Builder setFailureMessage(@NonNull String failureMessage) {
            mStatus.mFailuresMessage = failureMessage;
            Objects.requireNonNull(failureMessage, "failureMessage cannot be null");
            mFailuresMessage = failureMessage;
            return this;
        }

@@ -125,7 +154,7 @@ public final class VerificationStatus implements Parcelable {
         */
        @NonNull
        public Builder setAslStatus(@VerifierStatusAsl int aslStatus) {
            mStatus.mAslStatus = aslStatus;
            mAslStatus = aslStatus;
            return this;
        }

@@ -134,12 +163,13 @@ public final class VerificationStatus implements Parcelable {
         */
        @NonNull
        public VerificationStatus build() {
            return mStatus;
            return new VerificationStatus(mIsVerified, mIsLite, mAslStatus, mFailuresMessage);
        }
    }

    private VerificationStatus(Parcel in) {
        mIsVerified = in.readBoolean();
        mIsLite = in.readBoolean();
        mAslStatus = in.readInt();
        mFailuresMessage = in.readString8();
    }
@@ -147,6 +177,7 @@ public final class VerificationStatus implements Parcelable {
    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeBoolean(mIsVerified);
        dest.writeBoolean(mIsLite);
        dest.writeInt(mAslStatus);
        dest.writeString8(mFailuresMessage);
    }
Loading