ActivityManagerService sends bug reports on crashes and ANRs

If an installerPackageName was specified when the app was installed,
looks for a receiver of ACTION_APP_ERROR in that package. If found,
this is the bug report receiver and the crash/ANR dialog will get a
"Report" button. If pressed, a bug report will be delivered.
diff --git a/services/java/com/android/server/am/ProcessRecord.java b/services/java/com/android/server/am/ProcessRecord.java
index 68aebc3..419dadf 100644
--- a/services/java/com/android/server/am/ProcessRecord.java
+++ b/services/java/com/android/server/am/ProcessRecord.java
@@ -107,6 +107,10 @@
     ActivityManager.ProcessErrorStateInfo crashingReport;
     ActivityManager.ProcessErrorStateInfo notRespondingReport;
 
+    // Who will be notified of the error. This is usually an activity in the
+    // app that installed the package.
+    ComponentName errorReportReceiver;
+
     void dump(PrintWriter pw, String prefix) {
         if (info.className != null) {
             pw.print(prefix); pw.print("class="); pw.println(info.className);
@@ -157,7 +161,14 @@
                     pw.print(" "); pw.print(crashDialog);
                     pw.print(" notResponding="); pw.print(notResponding);
                     pw.print(" " ); pw.print(anrDialog);
-                    pw.print(" bad="); pw.println(bad);
+                    pw.print(" bad="); pw.print(bad);
+
+                    // crashing or notResponding is always set before errorReportReceiver
+                    if (errorReportReceiver != null) {
+                        pw.print(" errorReportReceiver=");
+                        pw.print(errorReportReceiver.flattenToShortString());
+                    }
+                    pw.println();
         }
         if (activities.size() > 0) {
             pw.print(prefix); pw.print("activities="); pw.println(activities);