SystemService.isUserSupported uses isProfile
Previously, SystemService's isUserSupported() used isManagedProfile, but in many cases, it makes more sense to use isProfile: most of the particular cases already done probably just care about profile, not managed profile. So we introduce an isProfile(). We also modify how the userType is stored in this class, to make it more extensible in the future. Bug: 170249807 Test: treehugger. This is a no-op since there currently aren't really other supported profile types anyway Change-Id: I43168939001d0e68ed6de95127161f1197683b10
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(')');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user