Fix issue #7214090: Need to be able to post notifications to all users

Also fix a bunch of system services that should be doing this.  And
while doing that, found I needed to fix PendingIntent to evaluate
USER_CURRENT at the point of sending, not creation.

Note that this may end up with us having some notification shown to
non-primary users that lead to settings UI that should only be for
the primary user (such as the vpn notification).  I'm not sure what
to do about this, maybe we need a different UI to come up there or
something, but showing the actual notification for those users at
least seems less broken than not telling them at all.

Change-Id: Iffc51e2d7c847e3d05064d292ab93937646a1ab7
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index a6f2974..a21f6d5 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -4595,8 +4595,16 @@
         
         synchronized(this) {
             int callingUid = Binder.getCallingUid();
+            int origUserId = userId;
             userId = handleIncomingUserLocked(Binder.getCallingPid(), callingUid, userId,
-                    false, true, "getIntentSender", null);
+                    type == ActivityManager.INTENT_SENDER_BROADCAST, true,
+                    "getIntentSender", null);
+            if (origUserId == UserHandle.USER_CURRENT) {
+                // We don't want to evaluate this until the pending intent is
+                // actually executed.  However, we do want to always do the
+                // security checking for it above.
+                userId = UserHandle.USER_CURRENT;
+            }
             try {
                 if (callingUid != 0 && callingUid != Process.SYSTEM_UID) {
                     int uid = AppGlobals.getPackageManager()
@@ -14303,6 +14311,10 @@
         }
     }
 
+    int getCurrentUserIdLocked() {
+        return mCurrentUserId;
+    }
+
     @Override
     public boolean isUserRunning(int userId) {
         if (checkCallingPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)