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

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

Merge "Replaced UserManager.getUsers(excludeDying) by getAliveUsers()"

parents 3c60dbe8 44a4afa9
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -43,11 +43,11 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.FastXmlSerializer;

import libcore.io.IoUtils;

import com.google.android.collect.Lists;
import com.google.android.collect.Maps;

import libcore.io.IoUtils;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;
@@ -793,7 +793,7 @@ public abstract class RegisteredServicesCache<V> {

    @VisibleForTesting
    protected List<UserInfo> getUsers() {
        return UserManager.get(mContext).getUsers(true);
        return UserManager.get(mContext).getAliveUsers();
    }

    @VisibleForTesting
+7 −5
Original line number Diff line number Diff line
@@ -1293,7 +1293,7 @@ public class UserManager {
     * in {@link UserManager} & {@link DevicePolicyManager}.
     * Note: This is slightly different from the real set of user restrictions listed in {@link
     * com.android.server.pm.UserRestrictionsUtils#USER_RESTRICTIONS}. For example
     * {@link #KEY_RESTRICTIONS_PENDING} is not a real user restriction, but is a a legitimate
     * {@link #KEY_RESTRICTIONS_PENDING} is not a real user restriction, but is a legitimate
     * value that can be passed into {@link #hasUserRestriction(String)}.
     * @hide
     */
@@ -3252,7 +3252,8 @@ public class UserManager {
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
    public @NonNull List<UserHandle> getUserHandles(boolean excludeDying) {
        List<UserInfo> users = getUsers(excludeDying);
        List<UserInfo> users = getUsers(/* excludePartial= */ true, excludeDying,
                /* excludePreCreated= */ true);
        List<UserHandle> result = new ArrayList<>(users.size());
        for (UserInfo user : users) {
            result.add(user.getUserHandle());
@@ -3270,7 +3271,8 @@ public class UserManager {
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
    public long[] getSerialNumbersOfUsers(boolean excludeDying) {
        List<UserInfo> users = getUsers(excludeDying);
        List<UserInfo> users = getUsers(/* excludePartial= */ true, excludeDying,
                /* excludePreCreated= */ true);
        long[] result = new long[users.size()];
        for (int i = 0; i < result.length; i++) {
            result[i] = users.get(i).serialNumber;
@@ -3336,7 +3338,7 @@ public class UserManager {
    public boolean canAddMoreUsers() {
        // TODO(b/142482943): UMS has different logic, excluding Demo and Profile from counting. Why
        //                    not here? The logic is inconsistent. See UMS.canAddMoreManagedProfiles
        final List<UserInfo> users = getUsers(true);
        final List<UserInfo> users = getAliveUsers();
        final int totalUserCount = users.size();
        int aliveUserCount = 0;
        for (int i = 0; i < totalUserCount; i++) {
@@ -4144,7 +4146,7 @@ public class UserManager {

    /** Returns whether there are any users (other than the current user) to which to switch. */
    private boolean areThereUsersToWhichToSwitch() {
        final List<UserInfo> users = getUsers(true);
        final List<UserInfo> users = getAliveUsers();
        if (users == null) {
            return false;
        }
+1 −1
Original line number Diff line number Diff line
@@ -870,7 +870,7 @@ public class CallLog {

                // Otherwise, insert to all other users that are running and unlocked.

                final List<UserInfo> users = userManager.getUsers(true);
                final List<UserInfo> users = userManager.getAliveUsers();

                final int count = users.size();
                for (int i = 0; i < count; i++) {
+2 −2
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ public class UserGridRecyclerView extends RecyclerView {
    }

    private List<UserInfo> getUsersForUserGrid() {
        return mUserManager.getUsers(/* excludeDying= */ true)
        return mUserManager.getAliveUsers()
                .stream()
                .filter(UserInfo::supportsSwitchToByUser)
                .collect(Collectors.toList());
@@ -338,7 +338,7 @@ public class UserGridRecyclerView extends RecyclerView {
                maxSupportedUsers -= 1;
            }

            List<UserInfo> users = mUserManager.getUsers(/* excludeDying= */ true);
            List<UserInfo> users = mUserManager.getAliveUsers();

            // Count all users that are managed profiles of another user.
            int managedProfilesCount = 0;
+4 −4
Original line number Diff line number Diff line
@@ -2576,7 +2576,7 @@ public class SettingsProvider extends ContentProvider {
        public void syncSsaidTableOnStart() {
            synchronized (mLock) {
                // Verify that each user's packages and ssaid's are in sync.
                for (UserInfo user : mUserManager.getUsers(true)) {
                for (UserInfo user : mUserManager.getAliveUsers()) {
                    // Get all uids for the user's packages.
                    final List<PackageInfo> packages;
                    try {
@@ -3007,7 +3007,7 @@ public class SettingsProvider extends ContentProvider {

                final long identity = Binder.clearCallingIdentity();
                try {
                    List<UserInfo> users = mUserManager.getUsers(true);
                    List<UserInfo> users = mUserManager.getAliveUsers();

                    final int userCount = users.size();
                    for (int i = 0; i < userCount; i++) {
@@ -3244,7 +3244,7 @@ public class SettingsProvider extends ContentProvider {
            // is a singleton generation entry for the global settings which
            // is already incremented be the caller.
            final Uri uri = getNotificationUriFor(key, name);
            final List<UserInfo> users = mUserManager.getUsers(/*excludeDying*/ true);
            final List<UserInfo> users = mUserManager.getAliveUsers();
            for (int i = 0; i < users.size(); i++) {
                final int userId = users.get(i).id;
                if (mUserManager.isUserRunning(UserHandle.of(userId))) {
@@ -3255,7 +3255,7 @@ public class SettingsProvider extends ContentProvider {
        }

        private void notifyLocationChangeForRunningUsers() {
            final List<UserInfo> users = mUserManager.getUsers(/*excludeDying=*/ true);
            final List<UserInfo> users = mUserManager.getAliveUsers();

            for (int i = 0; i < users.size(); i++) {
                final int userId = users.get(i).id;
Loading