Debug logs for issue #3101415: Apps seem to have their UID changed over time.

- Activity manager now prints the pid doing a startActivity request.
- Package manager now remembers messages about problems it has parsing
  packages.xml.

Change-Id: I11a75aa3953dbfa5dd41cfbdf69116c764ec228f
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 86c7bdf..f52d322 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -1881,7 +1881,27 @@
             String resultWho, int requestCode,
             int callingPid, int callingUid, boolean onlyIfNeeded,
             boolean componentSpecified) {
-        Slog.i(TAG, "Starting: " + intent);
+
+        int err = START_SUCCESS;
+
+        ProcessRecord callerApp = null;
+        if (caller != null) {
+            callerApp = mService.getRecordForAppLocked(caller);
+            if (callerApp != null) {
+                callingPid = callerApp.pid;
+                callingUid = callerApp.info.uid;
+            } else {
+                Slog.w(TAG, "Unable to find app for caller " + caller
+                      + " (pid=" + callingPid + ") when starting: "
+                      + intent.toString());
+                err = START_PERMISSION_DENIED;
+            }
+        }
+
+        if (err == START_SUCCESS) {
+            Slog.i(TAG, "Starting: " + intent + " from pid "
+                    + (callerApp != null ? callerApp.pid : callingPid));
+        }
 
         ActivityRecord sourceRecord = null;
         ActivityRecord resultRecord = null;
@@ -1916,9 +1936,7 @@
             }
         }
 
-        int err = START_SUCCESS;
-
-        if (intent.getComponent() == null) {
+        if (err == START_SUCCESS && intent.getComponent() == null) {
             // We couldn't find a class that can handle the given Intent.
             // That's the end of that!
             err = START_INTENT_NOT_RESOLVED;
@@ -1930,20 +1948,6 @@
             err = START_CLASS_NOT_FOUND;
         }
 
-        ProcessRecord callerApp = null;
-        if (err == START_SUCCESS && caller != null) {
-            callerApp = mService.getRecordForAppLocked(caller);
-            if (callerApp != null) {
-                callingPid = callerApp.pid;
-                callingUid = callerApp.info.uid;
-            } else {
-                Slog.w(TAG, "Unable to find app for caller " + caller
-                      + " (pid=" + callingPid + ") when starting: "
-                      + intent.toString());
-                err = START_PERMISSION_DENIED;
-            }
-        }
-
         if (err != START_SUCCESS) {
             if (resultRecord != null) {
                 sendActivityResultLocked(-1,