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

Commit cd855940 authored by Alex Buynytskyy's avatar Alex Buynytskyy
Browse files

Tweak the adb verification logic.

- add a log message when the global setting is overriden by user
  restriction. this will allow easier debugging of verification issues
  in the lab,
- don't check per-install verification disablement flag if verifiers
  disabled globally.

Bug: 271817329
Bug: 275453203
Test: presubmit
Change-Id: I7c7c21058d889ebe2ac2fed288d662b2a6c9702c
parent d5cea623
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -652,20 +652,33 @@ final class VerifyingSession {

    private boolean isAdbVerificationEnabled(PackageInfoLite pkgInfoLite, int userId,
            boolean requestedDisableVerification) {
        boolean verifierIncludeAdb = android.provider.Settings.Global.getInt(
                mPm.mContext.getContentResolver(),
                android.provider.Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, 1) != 0;

        if (mPm.isUserRestricted(userId, UserManager.ENSURE_VERIFY_APPS)) {
            if (!verifierIncludeAdb) {
                Slog.w(TAG, "Force verification of ADB install because of user restriction.");
            }
            return true;
        }
        // Check if the developer wants to skip verification for ADB installs

        // Check if the verification disabled globally, first.
        if (!verifierIncludeAdb) {
            return false;
        }

        // Check if the developer wants to skip verification for ADB installs.
        if (requestedDisableVerification) {
            if (!packageExists(pkgInfoLite.packageName)) {
                // Always verify fresh install
                // Always verify fresh install.
                return true;
            }
            // Only skip when apk is debuggable
            // Only skip when apk is debuggable.
            return !pkgInfoLite.debuggable;
        }
        return android.provider.Settings.Global.getInt(mPm.mContext.getContentResolver(),
                android.provider.Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, 1) != 0;

        return true;
    }

    /**