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

Commit 962cf28b authored by Song Chun Fan's avatar Song Chun Fan Committed by Android (Google) Code Review
Browse files

Merge changes from topic "verification_service_implementation" into main

* changes:
  [ADI][29/N] addressing API feedback
  [ADI][28/N] addressing API feedback
  [ADI][27/N] addressing API feedback
parents 018df5aa 60845919
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -13254,7 +13254,7 @@ package android.content.pm {
    method @Deprecated @Nullable public android.content.pm.PackageInstaller.SessionInfo getActiveStagedSession();
    method @NonNull public java.util.List<android.content.pm.PackageInstaller.SessionInfo> getActiveStagedSessions();
    method @NonNull public java.util.List<android.content.pm.PackageInstaller.SessionInfo> getAllSessions();
    method @FlaggedApi("android.content.pm.verification_service") @Nullable public final String getDeveloperVerificationServiceProvider();
    method @FlaggedApi("android.content.pm.verification_service") @Nullable public final android.content.ComponentName getDeveloperVerificationServiceProvider();
    method @NonNull public java.util.List<android.content.pm.PackageInstaller.SessionInfo> getMySessions();
    method @Nullable public android.content.pm.PackageInstaller.SessionInfo getSessionInfo(int);
    method @NonNull public java.util.List<android.content.pm.PackageInstaller.SessionInfo> getStagedSessions();
+14 −15
Original line number Diff line number Diff line
@@ -4343,11 +4343,10 @@ package android.content.pm {
  }
  @FlaggedApi("android.content.pm.verification_service") public static final class PackageInstaller.DeveloperVerificationUserConfirmationInfo implements android.os.Parcelable {
    ctor public PackageInstaller.DeveloperVerificationUserConfirmationInfo();
    ctor public PackageInstaller.DeveloperVerificationUserConfirmationInfo(int, int);
    method public int describeContents();
    method public int getUserActionNeededReason();
    method public int getVerificationPolicy();
    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.DeveloperVerificationUserConfirmationInfo> CREATOR;
    field public static final int DEVELOPER_VERIFICATION_USER_ACTION_NEEDED_REASON_DEVELOPER_BLOCKED = 2; // 0x2
@@ -4755,20 +4754,20 @@ package android.content.pm.verify.developer {
  @FlaggedApi("android.content.pm.verification_service") public final class DeveloperVerificationSession implements android.os.Parcelable {
    method public int describeContents();
    method public long extendTimeRemaining(long);
    method @NonNull public java.time.Duration extendTimeout(@NonNull java.time.Duration);
    method @NonNull public java.util.List<android.content.pm.SharedLibraryInfo> getDeclaredLibraries();
    method @NonNull public android.os.PersistableBundle getExtensionParams();
    method public int getId();
    method public int getInstallSessionId();
    method @NonNull public String getPackageName();
    method public int getPolicy();
    method @NonNull public android.content.pm.SigningInfo getSigningInfo();
    method @NonNull public android.net.Uri getStagedPackageUri();
    method public long getTimeoutTime();
    method public int getVerificationPolicy();
    method @NonNull public java.time.Instant getTimeoutTime();
    method public void reportVerificationComplete(@NonNull android.content.pm.verify.developer.DeveloperVerificationStatus);
    method public void reportVerificationComplete(@NonNull android.content.pm.verify.developer.DeveloperVerificationStatus, @NonNull android.os.PersistableBundle);
    method public void reportVerificationIncomplete(int);
    method public boolean setVerificationPolicy(int);
    method public boolean setPolicy(int);
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.verify.developer.DeveloperVerificationSession> CREATOR;
    field public static final int DEVELOPER_VERIFICATION_INCOMPLETE_NETWORK_UNAVAILABLE = 1; // 0x1
@@ -4777,23 +4776,23 @@ package android.content.pm.verify.developer {
  @FlaggedApi("android.content.pm.verification_service") public final class DeveloperVerificationStatus implements android.os.Parcelable {
    method public int describeContents();
    method public int getAslStatus();
    method @NonNull public String getFailureMessage();
    method public boolean isLite();
    method public int getAppMetadataVerificationStatus();
    method @Nullable public String getFailureMessage();
    method public boolean isLiteVerification();
    method public boolean isVerified();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field public static final int APP_METADATA_VERIFICATION_STATUS_BAD = 2; // 0x2
    field public static final int APP_METADATA_VERIFICATION_STATUS_GOOD = 1; // 0x1
    field public static final int APP_METADATA_VERIFICATION_STATUS_UNDEFINED = 0; // 0x0
    field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.verify.developer.DeveloperVerificationStatus> CREATOR;
    field public static final int DEVELOPER_VERIFIER_STATUS_ASL_BAD = 2; // 0x2
    field public static final int DEVELOPER_VERIFIER_STATUS_ASL_GOOD = 1; // 0x1
    field public static final int DEVELOPER_VERIFIER_STATUS_ASL_UNDEFINED = 0; // 0x0
  }
  public static final class DeveloperVerificationStatus.Builder {
    ctor public DeveloperVerificationStatus.Builder();
    method @NonNull public android.content.pm.verify.developer.DeveloperVerificationStatus build();
    method @NonNull public android.content.pm.verify.developer.DeveloperVerificationStatus.Builder setAslStatus(int);
    method @NonNull public android.content.pm.verify.developer.DeveloperVerificationStatus.Builder setFailureMessage(@NonNull String);
    method @NonNull public android.content.pm.verify.developer.DeveloperVerificationStatus.Builder setLite(boolean);
    method @NonNull public android.content.pm.verify.developer.DeveloperVerificationStatus.Builder setAppMetadataVerificationStatus(int);
    method @NonNull public android.content.pm.verify.developer.DeveloperVerificationStatus.Builder setFailureMessage(@Nullable String);
    method @NonNull public android.content.pm.verify.developer.DeveloperVerificationStatus.Builder setLiteVerification(boolean);
    method @NonNull public android.content.pm.verify.developer.DeveloperVerificationStatus.Builder setVerified(boolean);
  }
+2 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.content.pm;

import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.pm.ArchivedPackageParcel;
import android.content.pm.IPackageDeleteObserver2;
import android.content.pm.IPackageInstallerCallback;
@@ -99,7 +100,7 @@ interface IPackageInstaller {
    int getDeveloperVerificationPolicy(int userId);
    @EnforcePermission("DEVELOPER_VERIFICATION_AGENT")
    boolean setDeveloperVerificationPolicy(int policy, int userId);
    String getDeveloperVerificationServiceProvider();
    ComponentName getDeveloperVerificationServiceProvider();

    @EnforcePermission("SET_DEVELOPER_VERIFICATION_USER_RESPONSE")
    void setDeveloperVerificationUserResponse(int sessionId, int developerVerificationUserResponse);
+23 −13
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import android.app.AppGlobals;
import android.app.PendingIntent;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -1781,14 +1782,14 @@ public class PackageInstaller {
    }

    /**
     *  Return the package name of the developer verification service provider, for the
     *  Return the component name of the developer verification service provider, for the
     *  purpose of interacting with the specific verifier in relation to
     *  extension parameters and response structure.  Return null if the system
     *  verifier service provider is not available to the caller, or if there is no
     *  such provider specified by the system.
     */
    @FlaggedApi(Flags.FLAG_VERIFICATION_SERVICE)
    public final @Nullable String getDeveloperVerificationServiceProvider() {
    public final @Nullable ComponentName getDeveloperVerificationServiceProvider() {
        try {
            return mInstaller.getDeveloperVerificationServiceProvider();
        } catch (RemoteException e) {
@@ -5075,33 +5076,42 @@ public class PackageInstaller {
        }

        @DeveloperVerificationPolicy
        private int mVerificationPolicy;
        private final int mVerificationPolicy;

        @UserActionNeededReason
        private int mVerificationUserActionNeededReason;

        public DeveloperVerificationUserConfirmationInfo() {
        }
        private final int mUserActionNeededReason;

        /**
         * Used by the system to inform the device's default package installer about the ongoing
         * developer verification session that requires user confirmation.
         */
        public DeveloperVerificationUserConfirmationInfo(@DeveloperVerificationPolicy int policy,
                @UserActionNeededReason int reason) {
            mVerificationPolicy = policy;
            mVerificationUserActionNeededReason = reason;
            mUserActionNeededReason = reason;
        }

        private DeveloperVerificationUserConfirmationInfo(@NonNull Parcel in) {
            mVerificationPolicy = in.readInt();
            mVerificationUserActionNeededReason = in.readInt();
            mUserActionNeededReason = in.readInt();
        }

        /**
         * @return The policy used for this developer verification session, which may affect the
         * content or format of user confirmation.
         */
        @DeveloperVerificationPolicy
        public int getVerificationPolicy() {
            return mVerificationPolicy;
        }

        /**
         * @return The reason for requesting user confirmation this developer verification session,
         * which may affect the content or format of user confirmation.
         */
        @UserActionNeededReason
        public int getVerificationUserActionNeededReason() {
            return mVerificationUserActionNeededReason;
        public int getUserActionNeededReason() {
            return mUserActionNeededReason;
        }

        @Override
@@ -5112,7 +5122,7 @@ public class PackageInstaller {
        @Override
        public void writeToParcel(@NonNull Parcel dest, int flags) {
            dest.writeInt(mVerificationPolicy);
            dest.writeInt(mVerificationUserActionNeededReason);
            dest.writeInt(mUserActionNeededReason);
        }

        public static final @NonNull Parcelable.Creator<DeveloperVerificationUserConfirmationInfo>
@@ -5133,7 +5143,7 @@ public class PackageInstaller {
        public String toString() {
            return "VerificationUserConfirmationInfo{"
                    + "verificationPolicy=" + mVerificationPolicy
                    + ", verificationUserActionReason=" + mVerificationUserActionNeededReason
                    + ", verificationUserActionReason=" + mUserActionNeededReason
                    + '}';
        }
    }
+23 −20
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package android.content.pm.verify.developer;

import android.annotation.CurrentTimeMillisLong;
import android.annotation.DurationMillisLong;
import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -35,6 +33,8 @@ import android.os.RemoteException;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.time.Duration;
import java.time.Instant;
import java.util.Collections;
import java.util.List;

@@ -84,12 +84,12 @@ public final class DeveloperVerificationSession implements Parcelable {
    /**
     * The current policy that is active for the developer verification session. It might not be
     * the same as the original policy that was initially assigned for this verification session,
     * because the active policy can be overridden by {@link #setVerificationPolicy(int)}.
     * because the active policy can be overridden by {@link #setPolicy(int)}.
     * <p>To improve the latency, store the original policy value and any changes made to it,
     * so that {@link #getVerificationPolicy()} does not need to make a binder call to retrieve the
     * so that {@link #getPolicy()} does not need to make a binder call to retrieve the
     * currently active policy.</p>
     */
    private volatile @PackageInstaller.DeveloperVerificationPolicy int mVerificationPolicy;
    private volatile @PackageInstaller.DeveloperVerificationPolicy int mPolicy;

    /**
     * Constructor used by the system to describe the details of a developer verification session.
@@ -108,7 +108,7 @@ public final class DeveloperVerificationSession implements Parcelable {
        mSigningInfo = signingInfo;
        mDeclaredLibraries = declaredLibraries;
        mExtensionParams = extensionParams;
        mVerificationPolicy = defaultPolicy;
        mPolicy = defaultPolicy;
        mSession = session;
    }

@@ -169,16 +169,17 @@ public final class DeveloperVerificationSession implements Parcelable {
    }

    /**
     * Get the value of Clock.elapsedRealtime() at which time this developer verification session
     * Get the point in time when this developer verification session
     * will timeout as incomplete if no other verification response is provided.
     * @throws SecurityException if the caller is not the current verifier bound by the system.
     * @throws IllegalStateException if this is called after the session has finished, because
     * the {@link #reportVerificationComplete} or {@link #reportVerificationIncomplete} have
     * been called, or because the session has timed out.
     */
    public @CurrentTimeMillisLong long getTimeoutTime() {
    @NonNull
    public Instant getTimeoutTime() {
        try {
            return mSession.getTimeoutTime(mId);
            return Instant.ofEpochMilli(mSession.getTimeoutTimeMillis(mId));
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -186,13 +187,13 @@ public final class DeveloperVerificationSession implements Parcelable {

    /**
     * Return the current policy that is active for this developer verification session.
     * <p>If the policy for this session has been changed by {@link #setVerificationPolicy},
     * <p>If the policy for this session has been changed by {@link #setPolicy},
     * the return value of this method is the current policy that is active for this session.
     * Otherwise, the return value is the same as the initial policy that was assigned to the
     * session when it was first created.</p>
     */
    public @PackageInstaller.DeveloperVerificationPolicy int getVerificationPolicy() {
        return mVerificationPolicy;
    public @PackageInstaller.DeveloperVerificationPolicy int getPolicy() {
        return mPolicy;
    }

    /**
@@ -204,14 +205,14 @@ public final class DeveloperVerificationSession implements Parcelable {
     * been called, or because the session has timed out, unless the new policy value is the same
     * as the existing one.
     */
    public boolean setVerificationPolicy(@PackageInstaller.DeveloperVerificationPolicy int policy) {
        if (mVerificationPolicy == policy) {
    public boolean setPolicy(@PackageInstaller.DeveloperVerificationPolicy int policy) {
        if (mPolicy == policy) {
            // No effective policy change
            return true;
        }
        try {
            if (mSession.setVerificationPolicy(mId, policy)) {
                mVerificationPolicy = policy;
                mPolicy = policy;
                return true;
            } else {
                return false;
@@ -222,7 +223,7 @@ public final class DeveloperVerificationSession implements Parcelable {
    }

    /**
     * Extend the timeout for this developer verification session by the provided additionalMs to
     * Extend the timeout for this developer verification session by the provided duration to
     * fetch relevant information over the network or wait for the network.
     * <p>
     * This may be called multiple times. If the request would bypass any max
@@ -231,9 +232,11 @@ public final class DeveloperVerificationSession implements Parcelable {
     * </p>
     * @throws SecurityException if the caller is not the current verifier bound by the system.
     */
    public @DurationMillisLong long extendTimeRemaining(@DurationMillisLong long additionalMs) {
    @NonNull
    public Duration extendTimeout(@NonNull Duration additionalDuration) {
        try {
            return mSession.extendTimeRemaining(mId, additionalMs);
            return Duration.ofMillis(
                    mSession.extendTimeoutMillis(mId, additionalDuration.toMillis()));
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -298,7 +301,7 @@ public final class DeveloperVerificationSession implements Parcelable {
        mSigningInfo = SigningInfo.CREATOR.createFromParcel(in);
        mDeclaredLibraries = in.createTypedArrayList(SharedLibraryInfo.CREATOR);
        mExtensionParams = in.readPersistableBundle(getClass().getClassLoader());
        mVerificationPolicy = in.readInt();
        mPolicy = in.readInt();
        mSession = IDeveloperVerificationSessionInterface.Stub.asInterface(in.readStrongBinder());
    }

@@ -316,7 +319,7 @@ public final class DeveloperVerificationSession implements Parcelable {
        mSigningInfo.writeToParcel(dest, flags);
        dest.writeTypedList(mDeclaredLibraries);
        dest.writePersistableBundle(mExtensionParams);
        dest.writeInt(mVerificationPolicy);
        dest.writeInt(mPolicy);
        dest.writeStrongBinder(mSession.asBinder());
    }

Loading