Merge "SystemService.isUserSupported uses isProfile"

This commit is contained in:
Adam Bookatz
2022-05-24 05:28:01 +00:00
committed by Android (Google) Code Review
3 changed files with 23 additions and 9 deletions

View File

@@ -360,7 +360,7 @@ public final class AutofillManagerService
@Override // from SystemService
public boolean isUserSupported(TargetUser user) {
return user.isFull() || user.isManagedProfile();
return user.isFull() || user.isProfile();
}
@Override // from SystemService

View File

@@ -228,7 +228,7 @@ public final class ContentCaptureManagerService extends
@Override // from SystemService
public boolean isUserSupported(TargetUser user) {
return user.isFull() || user.isManagedProfile();
return user.isFull() || user.isProfile();
}
@Override // from SystemService

View File

@@ -146,14 +146,16 @@ public abstract class SystemService {
// moment it's started until after it's shutdown).
private final @UserIdInt int mUserId;
private final boolean mFull;
private final boolean mManagedProfile;
private final boolean mProfile;
private final String mUserType;
private final boolean mPreCreated;
/** @hide */
public TargetUser(@NonNull UserInfo userInfo) {
mUserId = userInfo.id;
mFull = userInfo.isFull();
mManagedProfile = userInfo.isManagedProfile();
mProfile = userInfo.isProfile();
mUserType = userInfo.userType;
mPreCreated = userInfo.preCreated;
}
@@ -167,12 +169,24 @@ public abstract class SystemService {
}
/**
* Checks if the target user is a managed profile.
* Checks if the target user is a {@link UserInfo#isProfile() profile]}.
*
* @hide
*/
public boolean isProfile() {
return mProfile;
}
/**
* Checks if the target user is a {@link UserInfo#isManagedProfile() managed profile]}.
*
* This is only specifically for managed profiles; for profiles more generally,
* use {@link #isProfile()}.
*
* @hide
*/
public boolean isManagedProfile() {
return mManagedProfile;
return UserManager.isUserTypeManagedProfile(mUserType);
}
/**
@@ -212,16 +226,16 @@ public abstract class SystemService {
public void dump(@NonNull PrintWriter pw) {
pw.print(getUserIdentifier());
if (!isFull() && !isManagedProfile()) return;
if (!isFull() && !isProfile()) return;
pw.print('(');
boolean addComma = false;
if (isFull()) {
pw.print("full");
}
if (isManagedProfile()) {
if (isProfile()) {
if (addComma) pw.print(',');
pw.print("mp");
pw.print("profile");
}
pw.print(')');
}