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

Commit 34573b28 authored by Chad Brubaker's avatar Chad Brubaker
Browse files

Prevent downgrade of targetSandboxVersion

Bug: 34761192
Test: manual
Change-Id: I0a17006156213ebbc748a37bc5b4ceaa8cc8dd94
parent 748bf772
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11118,6 +11118,7 @@ package android.content.pm {
    field public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23; // 0xffffffe9
    field public static final int INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE = -26; // 0xffffffe6
    field public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10; // 0xfffffff6
    field public static final int INSTALL_FAILED_SANDBOX_VERSION_DOWNGRADE = -27; // 0xffffffe5
    field public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8; // 0xfffffff8
    field public static final int INSTALL_FAILED_TEST_ONLY = -15; // 0xfffffff1
    field public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7; // 0xfffffff9
+10 −0
Original line number Diff line number Diff line
@@ -1046,6 +1046,16 @@ public abstract class PackageManager {
    @SystemApi
    public static final int INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE = -26;

    /**
     * Installation return code: this is passed to the
     * {@link IPackageInstallObserver} if the new package attempts to downgrade the
     * target sandbox version of the app.
     *
     * @hide
     */
    @SystemApi
    public static final int INSTALL_FAILED_SANDBOX_VERSION_DOWNGRADE = -27;

    /**
     * Installation parse return code: this is passed to the
     * {@link IPackageInstallObserver} if the parser was given a path that is
+10 −0
Original line number Diff line number Diff line
@@ -16804,6 +16804,16 @@ public class PackageManagerService extends IPackageManager.Stub {
                                        + " target SDK " + oldTargetSdk + " does.");
                        return;
                    }
                    // Prevent apps from downgrading their targetSandbox.
                    final int oldTargetSandbox = oldPackage.applicationInfo.targetSandboxVersion;
                    final int newTargetSandbox = pkg.applicationInfo.targetSandboxVersion;
                    if (oldTargetSandbox == 2 && newTargetSandbox != 2) {
                        res.setError(PackageManager.INSTALL_FAILED_SANDBOX_VERSION_DOWNGRADE,
                                "Package " + pkg.packageName + " new target sandbox "
                                + newTargetSandbox + " is incompatible with the previous value of"
                                + oldTargetSandbox + ".");
                        return;
                    }
                    // Prevent installing of child packages
                    if (oldPackage.parentPackage != null) {