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

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

Merge "Update UserState for the user created during installation" into main

parents d2fc9b2b ed2f7592
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -184,6 +184,7 @@ import com.android.server.pm.permission.Permission;
import com.android.server.pm.permission.PermissionManagerServiceInternal;
import com.android.server.pm.pkg.AndroidPackage;
import com.android.server.pm.pkg.PackageStateInternal;
import com.android.server.pm.pkg.PackageUserStateInternal;
import com.android.server.pm.pkg.SharedLibraryWrapper;
import com.android.server.rollback.RollbackManagerInternal;
import com.android.server.utils.WatchedArrayMap;
@@ -2617,6 +2618,22 @@ final class InstallPackageHelper {
                    }
                    // Clear any existing archive state.
                    mPm.mInstallerService.mPackageArchiver.clearArchiveState(ps, userId);

                    // Check for new user that was created at the same time of this installation
                    // and has no UserState if pkg is installed for first time.
                    final SparseArray<? extends PackageUserStateInternal> us = ps.getUserStates();
                    if (allUsers.length != us.size()) {
                        for (int i = 0; i < allUsers.length; i++) {
                            final int currentUserId = allUsers[i];
                            final PackageUserStateInternal pus = us.get(currentUserId);
                            if (pus == null) {
                                // If a user state doesn't exist, explicitly set the app to
                                // be not installed on the user, otherwise the default installed
                                // state on that user would become true, which is incorrect.
                                ps.setInstalled(false, currentUserId);
                            }
                        }
                    }
                } else {
                    // The caller explicitly specified INSTALL_ALL_USERS flag.
                    // Thus, updating the settings to install the app for all users.
+1 −1
Original line number Diff line number Diff line
@@ -853,7 +853,7 @@ public class PackageSetting extends SettingBase implements PackageStateInternal
        usesStaticLibrariesVersions = other.usesStaticLibrariesVersions != null
                ? Arrays.copyOf(other.usesStaticLibrariesVersions,
                other.usesStaticLibrariesVersions.length) : null;
        mUserStates.clear();

        for (int i = 0; i < other.mUserStates.size(); i++) {
            if (sealedSnapshot) {
                mUserStates.put(other.mUserStates.keyAt(i),