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

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

Merge "[ADI][44/N] add @hide DEVELOPER_VERIFICATION_BYPASSED_REASON_UNSPECIFIED" into main

parents 7680e6a5 801078a9
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -67,6 +67,12 @@ public final class DeveloperVerificationSession implements Parcelable {
    public @interface DeveloperVerificationIncompleteReason {
    }

    /**
     * The developer verification is bypassed because of an unspecified reason. This field is
     * reserved and must not be used when reporting a developer verification bypass.
     * @hide
     */
    public static final int DEVELOPER_VERIFICATION_BYPASSED_REASON_UNSPECIFIED = 0;
    /**
     * The developer verification is bypassed because the installation was initiated from the
     * Android Debug Bridge (ADB) service.
+3 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.annotation.Nullable;
import android.content.pm.DataLoaderType;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageManager;
import android.content.pm.verify.developer.DeveloperVerificationSession;
import android.content.pm.verify.developer.DeveloperVerificationStatus;
import android.os.Handler;

@@ -84,7 +85,8 @@ final class SessionMetrics {
    private long mDeveloperVerificationRetryDurationMillis;

    private int mDeveloperVerifierUid = INVALID_UID;
    private int mIsDeveloperVerificationBypassedReason = 0;
    private int mIsDeveloperVerificationBypassedReason =
            DeveloperVerificationSession.DEVELOPER_VERIFICATION_BYPASSED_REASON_UNSPECIFIED;
    private boolean mIsDeveloperVerificationTimeoutExtensionRequested = false;
    private final boolean mHasDeveloperVerificationExtensionParams;
    private boolean mIsDeveloperVerificationPolicyOverridden = false;
+2 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.pm.verify.developer;

import static android.content.pm.verify.developer.DeveloperVerificationSession.DEVELOPER_VERIFICATION_BYPASSED_REASON_UNSPECIFIED;
import static android.content.pm.verify.developer.DeveloperVerificationSession.DEVELOPER_VERIFICATION_INCOMPLETE_NETWORK_UNAVAILABLE;
import static android.content.pm.verify.developer.DeveloperVerificationSession.DEVELOPER_VERIFICATION_INCOMPLETE_UNKNOWN;
import static android.os.Process.INVALID_UID;
@@ -671,7 +672,7 @@ public class DeveloperVerifierController {
                            + " doesn't exist or has finished");
                }
            }
            if (bypassReason <= 0) {
            if (bypassReason <= DEVELOPER_VERIFICATION_BYPASSED_REASON_UNSPECIFIED) {
                throw new IllegalArgumentException("Verification session " + id
                        + " reported invalid bypass_reason code " + bypassReason);
            }
+4 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.pm.verify.developer;
import static android.content.pm.PackageInstaller.DEVELOPER_VERIFICATION_POLICY_BLOCK_FAIL_CLOSED;
import static android.content.pm.PackageInstaller.DEVELOPER_VERIFICATION_POLICY_BLOCK_FAIL_OPEN;
import static android.content.pm.verify.developer.DeveloperVerificationSession.DEVELOPER_VERIFICATION_BYPASSED_REASON_EMERGENCY;
import static android.content.pm.verify.developer.DeveloperVerificationSession.DEVELOPER_VERIFICATION_BYPASSED_REASON_UNSPECIFIED;
import static android.os.Process.INVALID_UID;

import static com.google.common.truth.Truth.assertThat;
@@ -482,9 +483,10 @@ public class DeveloperVerifierControllerTest {
        // Reason cannot be negative
        expectThrows(IllegalArgumentException.class,
                () -> session.reportVerificationBypassed(-1));
        // Reason cannot be 0
        // Reason cannot be unspecified
        expectThrows(IllegalArgumentException.class,
                () -> session.reportVerificationBypassed(0));
                () -> session.reportVerificationBypassed(
                        DEVELOPER_VERIFICATION_BYPASSED_REASON_UNSPECIFIED));
    }

    @Test