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

Commit c3e39c0b authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[ADI][30/N] store verification result in package setting" into main

parents 73221d1f b7e770c5
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2529,6 +2529,10 @@ final class InstallPackageHelper {
                // cases.
                ps.setSplitNames(null);
                ps.setSplitRevisionCodes(null);

                // Store the developer verification result in the package setting
                ps.setDeveloperVerificationStatusInternal(
                        installRequest.getDeveloperVerificationStatus());
            }
            installRequest.onCommitFinished();
        }
+10 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import com.android.server.pm.pkg.AndroidPackage;
import com.android.server.pm.pkg.PackageState;
import com.android.server.pm.pkg.PackageStateInternal;
import com.android.server.pm.pkg.PackageUserStateInternal;
import com.android.server.pm.verify.developer.DeveloperVerificationStatusInternal;

import java.io.File;
import java.util.ArrayList;
@@ -172,6 +173,8 @@ final class InstallRequest {
    private boolean mKeepArtProfile = false;
    private final boolean mDependencyInstallerEnabled;
    private final int mMissingSharedLibraryCount;
    @Nullable
    private final DeveloperVerificationStatusInternal mDeveloperVerificationStatus;;

    // New install
    InstallRequest(InstallingSession params) {
@@ -194,6 +197,7 @@ final class InstallRequest {
        mHasAppMetadataFileFromInstaller = params.mHasAppMetadataFile;
        mDependencyInstallerEnabled = params.mDependencyInstallerEnabled;
        mMissingSharedLibraryCount = params.mMissingSharedLibraryCount;
        mDeveloperVerificationStatus = params.mDeveloperVerificationStatus;
    }

    // Install existing package as user
@@ -215,6 +219,7 @@ final class InstallRequest {
        mHasAppMetadataFileFromInstaller = false;
        mDependencyInstallerEnabled = false;
        mMissingSharedLibraryCount = 0;
        mDeveloperVerificationStatus = null;
    }

    // addForInit
@@ -239,6 +244,7 @@ final class InstallRequest {
        mHasAppMetadataFileFromInstaller = false;
        mDependencyInstallerEnabled = false;
        mMissingSharedLibraryCount = 0;
        mDeveloperVerificationStatus = null;
    }

    @Nullable
@@ -1098,4 +1104,8 @@ final class InstallRequest {
    boolean isDependencyInstallerEnabled() {
        return mDependencyInstallerEnabled;
    }

    DeveloperVerificationStatusInternal getDeveloperVerificationStatus() {
        return mDeveloperVerificationStatus;
    }
}
+6 −1
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import com.android.internal.content.InstallLocationUtils;
import com.android.internal.content.NativeLibraryHelper;
import com.android.internal.pm.parsing.PackageParser2;
import com.android.internal.util.Preconditions;
import com.android.server.pm.verify.developer.DeveloperVerificationStatusInternal;

import libcore.io.IoUtils;

@@ -105,6 +106,7 @@ class InstallingSession {
    @Nullable final String mDexoptCompilerFilter;
    final boolean mDependencyInstallerEnabled;
    final int mMissingSharedLibraryCount;
    @Nullable final DeveloperVerificationStatusInternal mDeveloperVerificationStatus;

    // For move install
    InstallingSession(OriginInfo originInfo, MoveInfo moveInfo, IPackageInstallObserver2 observer,
@@ -142,6 +144,7 @@ class InstallingSession {
        mDexoptCompilerFilter = null;
        mDependencyInstallerEnabled = false;
        mMissingSharedLibraryCount = 0;
        mDeveloperVerificationStatus = null;
    }

    InstallingSession(int sessionId, File stagedDir, IPackageInstallObserver2 observer,
@@ -149,7 +152,8 @@ class InstallingSession {
            UserHandle user, SigningDetails signingDetails, int installerUid,
            PackageLite packageLite, DomainSet preVerifiedDomains, PackageManagerService pm,
            boolean hasAppMetadatafile, boolean dependencyInstallerEnabled,
            int missingSharedLibraryCount) {
            int missingSharedLibraryCount,
            DeveloperVerificationStatusInternal developerVerificationStatus) {
        mPm = pm;
        mUser = user;
        mOriginInfo = OriginInfo.fromStagedFile(stagedDir);
@@ -182,6 +186,7 @@ class InstallingSession {
        mDexoptCompilerFilter = sessionParams.dexoptCompilerFilter;
        mDependencyInstallerEnabled = dependencyInstallerEnabled;
        mMissingSharedLibraryCount = missingSharedLibraryCount;
        mDeveloperVerificationStatus = developerVerificationStatus;
    }

    @Override
+33 −24
Original line number Diff line number Diff line
@@ -218,6 +218,7 @@ import com.android.server.pm.Installer.InstallerException;
import com.android.server.pm.dex.DexManager;
import com.android.server.pm.pkg.AndroidPackage;
import com.android.server.pm.pkg.PackageStateInternal;
import com.android.server.pm.verify.developer.DeveloperVerificationStatusInternal;
import com.android.server.pm.verify.developer.DeveloperVerifierController;
import com.android.server.Watchdog;

@@ -494,9 +495,11 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
    private String mVerificationFailedMessage = null;

    /**
     * Indicates whether a lite verification was conducted on the installation.
     * The developer verification status which will be preserved into the package state if the
     * installation is successful.
     */
    private boolean mVerificationLiteEnabled = false;
    private final DeveloperVerificationStatusInternal mDeveloperVerificationStatusInternal =
            DeveloperVerificationStatusInternal.UNKNOWN;

    /** Staging location where client data is written. */
    final File stageDir;
@@ -3209,9 +3212,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
         */
        private void onConnectionInfeasible() {
            mHandler.post(() -> {
                mDeveloperVerificationStatusInternal.setInternalStatus(
                        DeveloperVerificationStatusInternal.STATUS_INFEASIBLE);
                synchronized (mMetrics) {
                    mMetrics.onDeveloperVerifierResponseReceived(
                            SessionMetrics.DeveloperVerifierResponse.OTHER);
                    mMetrics.onDeveloperVerificationFinished(mDeveloperVerificationStatusInternal);
                }
                if (mCurrentVerificationPolicy.get()
                        != DEVELOPER_VERIFICATION_POLICY_BLOCK_FAIL_CLOSED) {
@@ -3234,9 +3238,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
         */
        public void onConnectionFailed() {
            mHandler.post(() -> {
                mDeveloperVerificationStatusInternal.setInternalStatus(
                        DeveloperVerificationStatusInternal.STATUS_DISCONNECTED);
                synchronized (mMetrics) {
                    mMetrics.onDeveloperVerifierResponseReceived(
                            SessionMetrics.DeveloperVerifierResponse.DISCONNECTED);
                    mMetrics.onDeveloperVerificationFinished(mDeveloperVerificationStatusInternal);
                }
                if (mCurrentVerificationPolicy.get()
                        != DEVELOPER_VERIFICATION_POLICY_BLOCK_FAIL_CLOSED) {
@@ -3270,9 +3275,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            // Always notify the verifier, regardless of the policy.
            mDeveloperVerifierController.notifyVerificationTimeout(sessionId, userId);
            mHandler.post(() -> {
                mDeveloperVerificationStatusInternal.setInternalStatus(
                        DeveloperVerificationStatusInternal.STATUS_TIMEOUT);
                synchronized (mMetrics) {
                    mMetrics.onDeveloperVerifierResponseReceived(
                            SessionMetrics.DeveloperVerifierResponse.TIMEOUT);
                    mMetrics.onDeveloperVerificationFinished(mDeveloperVerificationStatusInternal);
                }
                if (mCurrentVerificationPolicy.get()
                        != DEVELOPER_VERIFICATION_POLICY_BLOCK_FAIL_CLOSED) {
@@ -3298,11 +3304,16 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                @NonNull DeveloperVerificationStatus statusReceived,
                @Nullable PersistableBundle extensionResponse) {
            mHandler.post(() -> {
                final int internalStatus = statusReceived.isVerified()
                        ? DeveloperVerificationStatusInternal.STATUS_COMPLETED_WITH_PASS
                        : DeveloperVerificationStatusInternal.STATUS_COMPLETED_WITH_REJECT;
                mDeveloperVerificationStatusInternal.setInternalStatus(internalStatus);
                mDeveloperVerificationStatusInternal.setAppMetadataVerificationStatus(
                        statusReceived.getAppMetadataVerificationStatus());
                mDeveloperVerificationStatusInternal.setLiteVerification(
                        statusReceived.isLiteVerification());
                synchronized (mMetrics) {
                    mMetrics.onDeveloperVerifierResponseReceived(statusReceived.isVerified()
                            ? SessionMetrics.DeveloperVerifierResponse.COMPLETE_WITH_PASS
                            : SessionMetrics.DeveloperVerifierResponse.COMPLETE_WITH_REJECT);
                    mMetrics.onAslStatusReceived(statusReceived.getAppMetadataVerificationStatus());
                    mMetrics.onDeveloperVerificationFinished(mDeveloperVerificationStatusInternal);
                }
                if (mCurrentVerificationPolicy.get() == DEVELOPER_VERIFICATION_POLICY_NONE) {
                    // No policy applied. Continue with the rest of the verification and install.
@@ -3311,10 +3322,6 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                }
                if (statusReceived.isVerified()) {
                    if (statusReceived.isLiteVerification()) {
                        mVerificationLiteEnabled = true;
                        synchronized (mMetrics) {
                            mMetrics.onDeveloperVerificationLiteEnabled();
                        }
                        // This is a lite verification. Need further user action.
                        mVerificationUserActionNeededReason =
                                DEVELOPER_VERIFICATION_USER_ACTION_NEEDED_REASON_LITE_VERIFICATION;
@@ -3353,10 +3360,12 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            mHandler.post(() -> {
                final boolean isNetworkUnavailable =
                        incompleteReason == DEVELOPER_VERIFICATION_INCOMPLETE_NETWORK_UNAVAILABLE;
                final int internalStatus = isNetworkUnavailable
                        ? DeveloperVerificationStatusInternal.STATUS_INCOMPLETE_NETWORK_UNAVAILABLE
                        : DeveloperVerificationStatusInternal.STATUS_INCOMPLETE_UNKNOWN;
                mDeveloperVerificationStatusInternal.setInternalStatus(internalStatus);
                synchronized (mMetrics) {
                    mMetrics.onDeveloperVerifierResponseReceived(isNetworkUnavailable
                            ? SessionMetrics.DeveloperVerifierResponse.INCOMPLETE_NETWORK
                            : SessionMetrics.DeveloperVerifierResponse.INCOMPLETE_UNKNOWN);
                    mMetrics.onDeveloperVerificationFinished(mDeveloperVerificationStatusInternal);
                }
                if (mCurrentVerificationPolicy.get() == DEVELOPER_VERIFICATION_POLICY_NONE) {
                    // Continue with the rest of the verification and installation.
@@ -3399,7 +3408,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            bundle.putInt(EXTRA_DEVELOPER_VERIFICATION_FAILURE_REASON,
                    getVerificationFailureReason(mVerificationUserActionNeededReason));
            bundle.putBoolean(EXTRA_DEVELOPER_VERIFICATION_LITE_PERFORMED,
                    mVerificationLiteEnabled);
                    mDeveloperVerificationStatusInternal.isLiteVerification());
            bundle.putParcelable(Intent.EXTRA_INTENT, intent);
            if (extensionResponse != null) {
                bundle.putParcelable(EXTRA_DEVELOPER_VERIFICATION_EXTENSION_RESPONSE,
@@ -3899,7 +3908,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            return new InstallingSession(sessionId, stageDir, localObserver, params, mInstallSource,
                    user, mSigningDetails, mInstallerUid, mPackageLite, mPreVerifiedDomains, mPm,
                    mHasAppMetadataFile, mDependencyInstallerEnabled.get(),
                    mMissingSharedLibraryCount.get());
                    mMissingSharedLibraryCount.get(), mDeveloperVerificationStatusInternal);
        }
    }

@@ -5083,7 +5092,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                bundle.putInt(EXTRA_DEVELOPER_VERIFICATION_FAILURE_REASON,
                        getVerificationFailureReason(mVerificationUserActionNeededReason));
                bundle.putBoolean(EXTRA_DEVELOPER_VERIFICATION_LITE_PERFORMED,
                        mVerificationLiteEnabled);
                        mDeveloperVerificationStatusInternal.isLiteVerification());

                setSessionFailed(INSTALL_FAILED_VERIFICATION_FAILURE, errorMsg);
                onSessionVerificationFailure(INSTALL_FAILED_VERIFICATION_FAILURE, errorMsg, bundle);
@@ -5095,7 +5104,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                bundle.putInt(EXTRA_DEVELOPER_VERIFICATION_FAILURE_REASON,
                        getVerificationFailureReason(mVerificationUserActionNeededReason));
                bundle.putBoolean(EXTRA_DEVELOPER_VERIFICATION_LITE_PERFORMED,
                        mVerificationLiteEnabled);
                        mDeveloperVerificationStatusInternal.isLiteVerification());

                setSessionFailed(INSTALL_FAILED_VERIFICATION_FAILURE, errorMsg);
                onSessionVerificationFailure(INSTALL_FAILED_VERIFICATION_FAILURE, errorMsg, bundle);
@@ -5106,7 +5115,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                bundle.putInt(EXTRA_DEVELOPER_VERIFICATION_FAILURE_REASON,
                        getVerificationFailureReason(mVerificationUserActionNeededReason));
                bundle.putBoolean(EXTRA_DEVELOPER_VERIFICATION_LITE_PERFORMED,
                        mVerificationLiteEnabled);
                        mDeveloperVerificationStatusInternal.isLiteVerification());

                setSessionFailed(INSTALL_FAILED_VERIFICATION_FAILURE, mVerificationFailedMessage);
                onSessionVerificationFailure(INSTALL_FAILED_VERIFICATION_FAILURE,
+20 −3

File changed.

Preview size limit exceeded, changes collapsed.

Loading