Fix issue #7211769 and #7244492, thrash around on #7226656.

Issue #7211769: Crash dialog from background user has non-working "report"

The report button now launches the issue reporter for the correct user.
Also for crashes on background users, either disable the report button,
or simply don't show the dialog depending on the build config.

Issue #7244492: Bugreport button in Quick Settings doesn't actually do anything

Now they do.

Issue #7226656: second user seeing primary user's apps

I haven't had any success at reproducing this.  I have tried to tighten up
the path where we create the user to ensure nothing could cause the
user's applications to be accessed before the user it fully created and thus
make them installed...  but I can't convince myself that is the actual problem.

Also tightened up the user switch code to use forground broadcasts for all
of the updates about the switch (since this is really a foreground operation),
added a facility to have BOOT_COMPELTED broadcasts not get launched for
secondary users and use that on a few key system receivers, fixed some debug
output.

Change-Id: Iadf8f8e4878a86def2e495e9d0dc40c4fb347021
diff --git a/services/java/com/android/server/pm/PackageSettingBase.java b/services/java/com/android/server/pm/PackageSettingBase.java
index d8f7345..6a363a8 100644
--- a/services/java/com/android/server/pm/PackageSettingBase.java
+++ b/services/java/com/android/server/pm/PackageSettingBase.java
@@ -20,6 +20,7 @@
 import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
 import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
 
+import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageUserState;
 import android.content.pm.UserInfo;
 import android.util.SparseArray;
@@ -64,7 +65,8 @@
     boolean permissionsFixed;
     boolean haveGids;
 
-    private static final PackageUserState DEFAULT_USER_STATE = new PackageUserState();
+    private static final PackageUserState DEFAULT_USER_STATE = new PackageUserState(false);
+    private static final PackageUserState DEFAULT_SYSTEM_USER_STATE = new PackageUserState(true);
 
     // Whether this package is currently stopped, thus can not be
     // started until explicitly launched by the user.
@@ -174,7 +176,7 @@
     private PackageUserState modifyUserState(int userId) {
         PackageUserState state = userState.get(userId);
         if (state == null) {
-            state = new PackageUserState();
+            state = new PackageUserState((pkgFlags&ApplicationInfo.FLAG_SYSTEM) != 0);
             userState.put(userId, state);
         }
         return state;
@@ -182,7 +184,11 @@
 
     public PackageUserState readUserState(int userId) {
         PackageUserState state = userState.get(userId);
-        return state != null ? state : DEFAULT_USER_STATE;
+        if (state != null) {
+            return state;
+        }
+        return ((pkgFlags&ApplicationInfo.FLAG_SYSTEM) != 0)
+                ? DEFAULT_SYSTEM_USER_STATE : DEFAULT_USER_STATE;
     }
 
     void setEnabled(int state, int userId) {