Fix issue #7232952: Settings crash on tapping on Downloaded apps on a secondary user

Also tweak bind flags for new location services so they
aren't put so aggressively up in the oom adj list.

Change-Id: I9da25a3fea7681013b4d95b7db7e9a808f2d733b
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 370d427..0221245 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -11514,8 +11514,9 @@
          * Prevent non-system code (defined here to be non-persistent
          * processes) from sending protected broadcasts.
          */
-        if (callingUid == Process.SYSTEM_UID || callingUid == Process.PHONE_UID
-            || callingUid == Process.SHELL_UID || callingUid == Process.BLUETOOTH_UID ||
+        int callingAppId = UserHandle.getAppId(callingUid);
+        if (callingAppId == Process.SYSTEM_UID || callingAppId == Process.PHONE_UID
+            || callingAppId == Process.SHELL_UID || callingAppId == Process.BLUETOOTH_UID ||
             callingUid == 0) {
             // Always okay.
         } else if (callerApp == null || !callerApp.persistent) {