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

Commit 54ffdc59 authored by JW Wang's avatar JW Wang
Browse files

Fix perf regression when creating new users

Don't create data directories for packages with invalid app id
such as APEX

Bug: 234947944
Bug: 225756739
Test: atest CtsPackageManagerMultiUserHostTestCases
Change-Id: I4a4325131001ee47033c2939ca39a0ef1623eda1
parent bab5b292
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -623,7 +623,7 @@ final class AppDataHelper {
    private boolean shouldHaveAppStorage(AndroidPackage pkg) {
        PackageManager.Property noAppDataProp =
                pkg.getProperties().get(PackageManager.PROPERTY_NO_APP_DATA_STORAGE);
        return noAppDataProp == null || !noAppDataProp.getBoolean();
        return (noAppDataProp == null || !noAppDataProp.getBoolean()) && pkg.getUid() >= 0;
    }

    /**
+5 −0
Original line number Diff line number Diff line
@@ -4167,6 +4167,11 @@ public final class Settings implements Watchable, Snappable {
                        UNINSTALL_REASON_USER_TYPE : UNINSTALL_REASON_UNKNOWN;
                ps.setUninstallReason(uninstallReason, userHandle);
                if (shouldReallyInstall) {
                    if (ps.getAppId() < 0) {
                        // No need to create data directories for packages with invalid app id
                        // such as APEX
                        continue;
                    }
                    // Need to create a data directory for all apps installed for this user.
                    // Accumulate all required args and call the installer after mPackages lock
                    // has been released