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

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

Merge "[pm] properly nullify pkg when DELETE_KEEP_DATA" into main

parents bca7297a e91a54a9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1519,6 +1519,7 @@ public class ComputerEngine implements Computer {
            ai.privateFlags = ps.getPrivateFlags();
            pi.applicationInfo = PackageInfoUtils.generateDelegateApplicationInfo(
                    ai, flags, state, userId);
            pi.signingInfo = ps.getSigningInfo();

            if (DEBUG_PACKAGE_INFO) {
                Log.v(TAG, "ps.pkg is n/a for ["
+0 −1
Original line number Diff line number Diff line
@@ -470,7 +470,6 @@ final class DeletePackageHelper {
                        // We need to set it back to 'installed' so the uninstall
                        // broadcasts will be sent correctly.
                        if (DEBUG_REMOVE) Slog.d(TAG, "Not installed by other users, full delete");
                        ps.setPkg(null);
                        ps.setInstalled(true, userId);
                        mPm.mSettings.writeKernelMappingLPr(ps);
                        clearPackageStateAndReturn = false;
+8 −0
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@ final class RemovePackageHelper {
        cacher.cleanCachedResult(codePath);
    }

    // Used for system apps only
    public void removePackage(AndroidPackage pkg, boolean chatty) {
        synchronized (mPm.mInstallLock) {
            removePackageLI(pkg, chatty);
@@ -284,6 +285,13 @@ final class RemovePackageHelper {
        }

        removePackageLI(deletedPs.getPackageName(), (flags & PackageManager.DELETE_CHATTY) != 0);
        if (!deletedPs.isSystem()) {
            // A non-system app's AndroidPackage object has been removed from the service.
            // Explicitly nullify the corresponding app's PackageSetting's pkg object to
            // prevent any future usage of it, in case the PackageSetting object will remain because
            // of DELETE_KEEP_DATA.
            deletedPs.setPkg(null);
        }

        if ((flags & PackageManager.DELETE_KEEP_DATA) == 0) {
            final AndroidPackage resolvedPkg;
+14 −11
Original line number Diff line number Diff line
@@ -966,10 +966,12 @@ public class PackageManagerTests extends AndroidTestCase {
    }

    private static void assertUninstalled(ApplicationInfo info) throws Exception {
        if (info.nativeLibraryDir != null) {
            File nativeLibraryFile = new File(info.nativeLibraryDir);
            assertFalse("Native library directory " + info.nativeLibraryDir
                    + " should be erased", nativeLibraryFile.exists());
        }
    }

    public void deleteFromRawResource(int iFlags, int dFlags) throws Exception {
        InstallParams ip = sampleInstallFromRawResource(iFlags, false);
@@ -2883,14 +2885,15 @@ public class PackageManagerTests extends AndroidTestCase {
                    break;
                }
            }
            assertNotNull("activities should not be null", packageInfo.activities);
            assertNotNull("configPreferences should not be null", packageInfo.configPreferences);
            assertNotNull("instrumentation should not be null", packageInfo.instrumentation);
            assertNotNull("permissions should not be null", packageInfo.permissions);
            assertNotNull("providers should not be null", packageInfo.providers);
            assertNotNull("receivers should not be null", packageInfo.receivers);
            assertNotNull("services should not be null", packageInfo.services);
            assertNotNull("signatures should not be null", packageInfo.signatures);
            assertNotNull("applicationInfo should not be null", packageInfo.applicationInfo);
            assertNull("activities should be null", packageInfo.activities);
            assertNull("configPreferences should be null", packageInfo.configPreferences);
            assertNull("instrumentation should be null", packageInfo.instrumentation);
            assertNull("permissions should be null", packageInfo.permissions);
            assertNull("providers should be null", packageInfo.providers);
            assertNull("receivers should be null", packageInfo.receivers);
            assertNull("services should be null", packageInfo.services);
            assertNotNull("signingInfo should not be null", packageInfo.signingInfo);
        } finally {
            cleanUpInstall(ip);
        }