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

Commit ab2bc07e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Prevent downgrade of targetSandboxVersion"

parents 707af7c5 34573b28
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11393,6 +11393,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
@@ -1068,6 +1068,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
@@ -16692,6 +16692,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) {