summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorfelipeal <felipeal@google.com>2020-08-11 18:10:54 -0700
committerFelipe Leme <felipeal@google.com>2020-08-26 10:39:01 -0700
commit44a4afa99fe022257d5f8236904215370e1f09c9 (patch)
tree4b963de2d23ada90cf79c3ad80d017ff4858599d /core/java/android
parent9f60e77fd0a298cd273e9e4beeec33588339b93d (diff)
Replaced UserManager.getUsers(excludeDying) by getAliveUsers()
The existing method is confusing (the argument used to be called includeDying) and it puts the burden on the caller (which need to understand what the parameter means). Furthermore: - The majority of calls are for getUsers(excludeDying=true). - The calls for getUsers(excludeDying=false) are equivalent to calls to getUsers() So, a previous CL deprecated getUsers(excludeDying) and this CL replaces all remaining getUsers(true) calls to getAliveUsers() - calls to getUsers(false) were already refactored to call getUsers() in a previous CL. Test: m Test: a RollbackTest VpnTest ConnectivityServiceTest PermissionMonitorTest UserSettingsTest AppInfoDashboardFragmentTest UserHelperTest Bug: 157921703 Change-Id: I94973c91c14ad47c43cc1168ab766dc9e2815e54 Exempt-From-Owner-Approval: owners approval lost after rebase
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/content/pm/RegisteredServicesCache.java6
-rw-r--r--core/java/android/os/UserManager.java12
-rw-r--r--core/java/android/provider/CallLog.java2
3 files changed, 11 insertions, 9 deletions
diff --git a/core/java/android/content/pm/RegisteredServicesCache.java b/core/java/android/content/pm/RegisteredServicesCache.java
index bd909c7a3f59..192470e964e0 100644
--- a/core/java/android/content/pm/RegisteredServicesCache.java
+++ b/core/java/android/content/pm/RegisteredServicesCache.java
@@ -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
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 81a147c68e2e..81ffefd05b19 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -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;
}
diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java
index 276f16216b4d..c3b6d8e2cfe3 100644
--- a/core/java/android/provider/CallLog.java
+++ b/core/java/android/provider/CallLog.java
@@ -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++) {