Introducing manifest flag requiredAccountType

This can be used by apps that won't work without an account of that
type in the limited user environment. This way we can avoid letting
users select these apps when setting up a limited user.

Bug: 8600261
Change-Id: Iaa0dd5ff88e89fa7a1d8a4e70317290268411bdb
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 5a50ec2..3586573 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -289,6 +289,7 @@
         pi.installLocation = p.installLocation;
         pi.requiredForAllUsers = p.mRequiredForAllUsers;
         pi.restrictedAccountType = p.mRestrictedAccountType;
+        pi.requiredAccountType = p.mRequiredAccountType;
         pi.firstInstallTime = firstInstallTime;
         pi.lastUpdateTime = lastUpdateTime;
         if ((flags&PackageManager.GET_GIDS) != 0) {
@@ -1816,13 +1817,19 @@
                     false)) {
                 owner.mRequiredForAllUsers = true;
             }
-            String accountType = sa.getString(com.android.internal.R.styleable
+            String restrictedAccountType = sa.getString(com.android.internal.R.styleable
                     .AndroidManifestApplication_restrictedAccountType);
-            if (accountType != null && accountType.length() > 0) {
-                owner.mRestrictedAccountType = accountType;
+            if (restrictedAccountType != null && restrictedAccountType.length() > 0) {
+                owner.mRestrictedAccountType = restrictedAccountType;
             }
         }
 
+        String requiredAccountType = sa.getString(com.android.internal.R.styleable
+                .AndroidManifestApplication_requiredAccountType);
+        if (requiredAccountType != null && requiredAccountType.length() > 0) {
+            owner.mRequiredAccountType = requiredAccountType;
+        }
+
         if (sa.getBoolean(
                 com.android.internal.R.styleable.AndroidManifestApplication_debuggable,
                 false)) {
@@ -3339,6 +3346,9 @@
         /* The restricted account authenticator type that is used by this application */
         public String mRestrictedAccountType;
 
+        /* The required account type without which this application will not function */
+        public String mRequiredAccountType;
+
         /**
          * Digest suitable for comparing whether this package's manifest is the
          * same as another.