Application restrictions API

Adds the ability for apps to export some restrictions. The restrictions
are presented in Settings based on the restriction type. The user's
selections are stored by UserManagerService and provided to the
target user's application as a list of RestrictionEntry objects which
contain the key, value(s).

Also introduce a manifest entry for system apps to request that the
app be automatically installed in all users, so that they cannot be
deselected by the owner user.

Shared account filtering for non-whitelisted apps.

Change-Id: I15b741e3c0f3448883cb364c130783f1f6ea7ce6
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 5eac903..149b8e5 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -289,6 +289,7 @@
         pi.sharedUserLabel = p.mSharedUserLabel;
         pi.applicationInfo = generateApplicationInfo(p, flags, state, userId);
         pi.installLocation = p.installLocation;
+        pi.requiredForAllUsers = p.mRequiredForAllUsers;
         pi.firstInstallTime = firstInstallTime;
         pi.lastUpdateTime = lastUpdateTime;
         if ((flags&PackageManager.GET_GIDS) != 0) {
@@ -1760,6 +1761,11 @@
                     false)) {
                 ai.flags |= ApplicationInfo.FLAG_PERSISTENT;
             }
+            if (sa.getBoolean(
+                    com.android.internal.R.styleable.AndroidManifestApplication_requiredForAllUsers,
+                    false)) {
+                owner.mRequiredForAllUsers = true;
+            }
         }
 
         if (sa.getBoolean(
@@ -3271,6 +3277,9 @@
 
         public int installLocation;
 
+        /* An app that's required for all users and cannot be uninstalled for a user */
+        public boolean mRequiredForAllUsers;
+
         /**
          * Digest suitable for comparing whether this package's manifest is the
          * same as another.