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

Commit 49c3fa74 authored by Dario Freni's avatar Dario Freni
Browse files

Disable package verifier for staged installs.

This is a temporary measure to allow staged installs for APKs to work on
dev-signed devices.

Test: adb install --staged file.apk on taimen-eng target; adb
install-multi-package file1.apex file2.apex file3.apk file4.apk
Bug: 123753157
Change-Id: I537afbb08cb0a5db37bb823f4b084691dcd2f5d1
parent 92f6c4c5
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -866,6 +866,14 @@ public abstract class PackageManager {
     */
    public static final int INSTALL_ENABLE_ROLLBACK = 0x00040000;

    /**
     * Flag parameter for {@link #installPackage} to indicate that package verification should be
     * disabled for this package.
     *
     * @hide
     */
    public static final int INSTALL_DISABLE_VERIFICATION = 0x00080000;

    /** @hide */
    @IntDef(flag = true, prefix = { "DONT_KILL_APP" }, value = {
            DONT_KILL_APP
+4 −0
Original line number Diff line number Diff line
@@ -13492,6 +13492,10 @@ public class PackageManagerService extends IPackageManager.Stub
            return false;
        }
        if ((installFlags & PackageManager.INSTALL_DISABLE_VERIFICATION) != 0) {
            return false;
        }
        boolean ensureVerifyAppsEnabled = isUserRestricted(userId, UserManager.ENSURE_VERIFY_APPS);
        // Check if installing from ADB
+2 −0
Original line number Diff line number Diff line
@@ -186,6 +186,7 @@ public class StagingManager {
    private void preRebootVerification(@NonNull PackageInstallerSession session) {
        boolean success = true;

        // STOPSHIP: TODO(b/123753157): Verify APKs through Package Verifier.
        if (!sessionContainsApex(session)) {
            // TODO: Decide whether we want to fail fast by detecting signature mismatches for APKs,
            // right away.
@@ -336,6 +337,7 @@ public class StagingManager {

        PackageInstaller.SessionParams params = originalSession.params.copy();
        params.isStaged = false;
        params.installFlags |= PackageManager.INSTALL_DISABLE_VERIFICATION;
        int apkSessionId = mPi.createSession(
                params, originalSession.getInstallerPackageName(), originalSession.userId);
        PackageInstallerSession apkSession = mPi.getSession(apkSessionId);