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

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

Merge "Changes PM so apps are not installed for pre-created users." into sc-v2-dev

parents a268d263 c6e6c519
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ import com.android.server.pm.permission.LegacyPermissionState.PermissionState;
import com.android.server.pm.verify.domain.DomainVerificationLegacySettings;
import com.android.server.pm.verify.domain.DomainVerificationManagerInternal;
import com.android.server.pm.verify.domain.DomainVerificationPersistence;
import com.android.server.utils.Slogf;
import com.android.server.utils.Snappable;
import com.android.server.utils.SnapshotCache;
import com.android.server.utils.TimingsTraceAndSlog;
@@ -944,7 +945,8 @@ public final class Settings implements Watchable, Snappable {
                    Slog.i(PackageManagerService.TAG, "Stopping package " + pkgName, e);
                }
                List<UserInfo> users = getAllUsers(userManager);
                final int installUserId = installUser != null ? installUser.getIdentifier() : 0;
                int installUserId = installUser != null ? installUser.getIdentifier()
                        : UserHandle.USER_SYSTEM;
                if (users != null && allowInstall) {
                    for (UserInfo user : users) {
                        // By default we consider this app to be installed
@@ -955,8 +957,14 @@ public final class Settings implements Watchable, Snappable {
                        // user we are installing for.
                        final boolean installed = installUser == null
                                || (installUserId == UserHandle.USER_ALL
                                    && !isAdbInstallDisallowed(userManager, user.id))
                                    && !isAdbInstallDisallowed(userManager, user.id)
                                    && !user.preCreated)
                                || installUserId == user.id;
                        if (DEBUG_MU) {
                            Slogf.d(TAG, "createNewSetting(pkg=%s, installUserId=%s, user=%s, "
                                    + "installed=%b)",
                                    pkgName, installUserId, user.toFullString(), installed);
                        }
                        pkgSetting.setUserState(user.id, 0, COMPONENT_ENABLED_STATE_DEFAULT,
                                installed,
                                true /*stopped*/,
@@ -1980,11 +1988,14 @@ public final class Settings implements Watchable, Snappable {

            serializer.startTag(null, TAG_PACKAGE_RESTRICTIONS);

            if (DEBUG_MU) Log.i(TAG, "Writing " + userPackagesStateFile);
            if (DEBUG_MU) {
                Slogf.i(TAG, "Writing %s (%d packages)", userPackagesStateFile,
                        mPackages.values().size());
            }
            for (final PackageSetting pkg : mPackages.values()) {
                final PackageUserState ustate = pkg.readUserState(userId);
                if (DEBUG_MU) {
                    Log.i(TAG, "  pkg=" + pkg.name + ", installed=" + ustate.installed
                    Log.v(TAG, "  pkg=" + pkg.name + ", installed=" + ustate.installed
                            + ", state=" + ustate.enabled);
                }