Debugging for issue #2250075: Desk dock clock app sometimes doesn't

This adds a history of the last 100 broadcasts that is printed in the
debug log, to be able to see what recently happened at the time the
bug report was taken.  Also does some optimization of the printing of
the broadcast records to make it feasible to print this number of
entries.  (We kind-of need to do this because there are some broadcasts
like SIG_STR and SYNC_STATE_CHANGED that are being broadcast a LOT.)

Change-Id: I775e1ec0f63369c8bca8c83cee27b95ddc5ec450
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index 7a65af8..1800c30 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -270,21 +270,31 @@
 
     public void dump(Printer pw, String prefix) {
         super.dumpFront(pw, prefix);
-        pw.println(prefix + "className=" + className);
-        pw.println(prefix + "permission=" + permission
-                + " uid=" + uid);
-        pw.println(prefix + "taskAffinity=" + taskAffinity);
-        pw.println(prefix + "theme=0x" + Integer.toHexString(theme));
+        if (className != null) {
+            pw.println(prefix + "className=" + className);
+        }
+        if (permission != null) {
+            pw.println(prefix + "permission=" + permission);
+        }
+        pw.println(prefix + "uid=" + uid + " taskAffinity=" + taskAffinity);
+        if (theme != 0) {
+            pw.println(prefix + "theme=0x" + Integer.toHexString(theme));
+        }
         pw.println(prefix + "flags=0x" + Integer.toHexString(flags)
                 + " processName=" + processName);
         pw.println(prefix + "sourceDir=" + sourceDir);
         pw.println(prefix + "publicSourceDir=" + publicSourceDir);
-        pw.println(prefix + "sharedLibraryFiles=" + sharedLibraryFiles);
         pw.println(prefix + "dataDir=" + dataDir);
-        pw.println(prefix + "targetSdkVersion=" + targetSdkVersion);
-        pw.println(prefix + "enabled=" + enabled);
-        pw.println(prefix + "manageSpaceActivityName="+manageSpaceActivityName);
-        pw.println(prefix + "description=0x"+Integer.toHexString(descriptionRes));
+        if (sharedLibraryFiles != null) {
+            pw.println(prefix + "sharedLibraryFiles=" + sharedLibraryFiles);
+        }
+        pw.println(prefix + "enabled=" + enabled + " targetSdkVersion=" + targetSdkVersion);
+        if (manageSpaceActivityName != null) {
+            pw.println(prefix + "manageSpaceActivityName="+manageSpaceActivityName);
+        }
+        if (descriptionRes != 0) {
+            pw.println(prefix + "description=0x"+Integer.toHexString(descriptionRes));
+        }
         super.dumpBack(pw, prefix);
     }