Improve debug printing in activity manager.

Dumping per-package data is now much cleaning, and only really
prints information related to the package.  Also clean up the
formatting and such of the new activity stack states.

Change-Id: Ie5f31d72b7e77b34fd9acd835f28ed1db1dff328
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 5e88d3b..5e6bdb1 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -3334,13 +3334,17 @@
     }
 
     boolean dumpActivitiesLocked(FileDescriptor fd, PrintWriter pw, boolean dumpAll,
-            boolean dumpClient, String dumpPackage, boolean needSep) {
+            boolean dumpClient, String dumpPackage, boolean needSep, String header) {
         boolean printed = false;
         for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
             final TaskRecord task = mTaskHistory.get(taskNdx);
             printed |= ActivityStackSupervisor.dumpHistoryList(fd, pw,
                     mTaskHistory.get(taskNdx).mActivities, "    ", "Hist", true, !dumpAll,
-                    dumpClient, dumpPackage, needSep, "    Task " + taskNdx + ": id #" + task.taskId);
+                    dumpClient, dumpPackage, needSep, header,
+                    "    Task " + taskNdx + ": id #" + task.taskId);
+            if (printed) {
+                header = null;
+            }
         }
         return printed;
     }