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

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

Merge changes from topic "verification_service_implementation" into main

* changes:
  [ADI][17/N] aggressively auto-disconnect from the verifier service
  [ADI][16/N] Fix build after auto-merge
  [ADI][15/N] fix build after auto-merge
  [ADI][14/N] enable verifier on multi-user
parents 79fd35a4 5a291f84
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1371,7 +1371,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            // Start binding to the verification service, if not bound already.
            mVerifierController.bindToVerifierServiceIfNeeded(mPm::snapshotComputer, userId);
            if (!TextUtils.isEmpty(params.appPackageName)) {
                mVerifierController.notifyPackageNameAvailable(params.appPackageName);
                mVerifierController.notifyPackageNameAvailable(params.appPackageName, userId);
            }
        }
    }
@@ -3209,7 +3209,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
         */
        public void onTimeout() {
            // Always notify the verifier, regardless of the policy.
            mVerifierController.notifyVerificationTimeout(sessionId);
            mVerifierController.notifyVerificationTimeout(sessionId, userId);
            mHandler.post(() -> {
                if (mCurrentVerificationPolicy.get() != VERIFICATION_POLICY_BLOCK_FAIL_CLOSED) {
                    // Continue with the rest of the verification and installation.
@@ -6035,7 +6035,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            // Only notify for the cancellation if the verification request has not
            // been sent out, which happens right after commit() is called.
            mVerifierController.notifyVerificationCancelled(
                    params.appPackageName);
                    params.appPackageName, userId);
        }
    }

+21 −1
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.server.pm.verify.pkg;
import android.annotation.CurrentTimeMillisLong;
import android.annotation.DurationMillisLong;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;

import com.android.internal.annotations.VisibleForTesting;

@@ -31,6 +33,7 @@ public final class VerificationStatusTracker {
    private final @CurrentTimeMillisLong long mMaxTimeoutTime;
    @NonNull
    private final VerifierController.Injector mInjector;
    private final @UserIdInt int mUserId;

    /**
     * By default, the timeout time is the default timeout duration plus the current time (when
@@ -41,11 +44,12 @@ public final class VerificationStatusTracker {
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PROTECTED)
    public VerificationStatusTracker(@DurationMillisLong long defaultTimeoutMillis,
            @DurationMillisLong long maxExtendedTimeoutMillis,
            @NonNull VerifierController.Injector injector) {
            @NonNull VerifierController.Injector injector, @UserIdInt int userId) {
        mStartTime = injector.getCurrentTimeMillis();
        mTimeoutTime = mStartTime + defaultTimeoutMillis;
        mMaxTimeoutTime = mStartTime + maxExtendedTimeoutMillis;
        mInjector = injector;
        mUserId = userId;
    }

    /**
@@ -90,4 +94,20 @@ public final class VerificationStatusTracker {
    public boolean isTimeout() {
        return mInjector.getCurrentTimeMillis() >= mTimeoutTime;
    }

    public @UserIdInt int getUserId() {
        return mUserId;
    }

    @Override
    public boolean equals(@Nullable Object o) {
        if (o instanceof VerificationStatusTracker that) {
            return this.mStartTime == that.mStartTime
                    && this.mTimeoutTime == that.mTimeoutTime
                    && this.mMaxTimeoutTime == that.mMaxTimeoutTime
                    && this.mInjector == that.mInjector
                    && this.mUserId == that.mUserId;
        }
        return false;
    }
}
+214 −92

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ public class VerificationStatusTrackerTest {
                .thenReturn(TEST_REQUEST_START_TIME + TEST_MAX_TIMEOUT_DURATION_MILLIS - 100)
                .thenReturn(TEST_REQUEST_START_TIME + TEST_MAX_TIMEOUT_DURATION_MILLIS);
        mTracker = new VerificationStatusTracker(TEST_TIMEOUT_DURATION_MILLIS,
                TEST_MAX_TIMEOUT_DURATION_MILLIS, mInjector);
                TEST_MAX_TIMEOUT_DURATION_MILLIS, mInjector, 0);
    }

    @Test
+211 −30

File changed.

Preview size limit exceeded, changes collapsed.