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
diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java
index fc95cdd..51f8caf 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java
@@ -360,7 +360,7 @@
 
     @Override // from SystemService
     public boolean isUserSupported(TargetUser user) {
-        return user.isFull() || user.isManagedProfile();
+        return user.isFull() || user.isProfile();
     }
 
     @Override // from SystemService
diff --git a/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureManagerService.java b/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureManagerService.java
index 61d784e..2133184 100644
--- a/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureManagerService.java
+++ b/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureManagerService.java
@@ -228,7 +228,7 @@
 
     @Override // from SystemService
     public boolean isUserSupported(TargetUser user) {
-        return user.isFull() || user.isManagedProfile();
+        return user.isFull() || user.isProfile();
     }
 
     @Override // from SystemService
diff --git a/services/core/java/com/android/server/SystemService.java b/services/core/java/com/android/server/SystemService.java
index 206a310..933d259 100644
--- a/services/core/java/com/android/server/SystemService.java
+++ b/services/core/java/com/android/server/SystemService.java
@@ -146,14 +146,16 @@
         // 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 @@
         }
 
         /**
-         * 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 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(')');
         }