summaryrefslogtreecommitdiffstats
path: root/core/java/android/content/Intent.java
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2009-04-20 18:14:05 -0700
committerDianne Hackborn <hackbod@google.com>2009-04-22 18:03:21 -0700
commit1d442e0d990b581357f33f5463c7c5cb49b551e8 (patch)
tree58963b9ba095e179ba7c63e52dfd525b93cb978e /core/java/android/content/Intent.java
parenta0c9e8526b094e3b4f2c2747622059215d00516f (diff)
downloadframeworks_base-1d442e0d990b581357f33f5463c7c5cb49b551e8.zip
frameworks_base-1d442e0d990b581357f33f5463c7c5cb49b551e8.tar.gz
frameworks_base-1d442e0d990b581357f33f5463c7c5cb49b551e8.tar.bz2
More optimization of dumpsys output.
There are three major classes of changes here: - Avoid writing lines where their values are often empty, false, or some other typical thing. - Use partial writes to the PrintWriter to avoid creating temporary strings. - Use StringBuilder where we need to generate real String objects (and where possible cache the result).
Diffstat (limited to 'core/java/android/content/Intent.java')
-rw-r--r--core/java/android/content/Intent.java79
1 files changed, 65 insertions, 14 deletions
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index e82a86c..b3e81d7 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -4390,12 +4390,35 @@ public class Intent implements Parcelable {
@Override
public String toString() {
- StringBuilder b = new StringBuilder();
+ StringBuilder b = new StringBuilder(128);
- b.append("Intent {");
- if (mAction != null) b.append(" action=").append(mAction);
+ b.append("Intent { ");
+ toShortString(b, true, true);
+ b.append(" }");
+
+ return b.toString();
+ }
+
+ /** @hide */
+ public String toShortString(boolean comp, boolean extras) {
+ StringBuilder b = new StringBuilder(128);
+ toShortString(b, comp, extras);
+ return b.toString();
+ }
+
+ /** @hide */
+ public void toShortString(StringBuilder b, boolean comp, boolean extras) {
+ boolean first = true;
+ if (mAction != null) {
+ b.append("act=").append(mAction);
+ first = false;
+ }
if (mCategories != null) {
- b.append(" categories={");
+ if (!first) {
+ b.append(' ');
+ }
+ first = false;
+ b.append("cat=[");
Iterator<String> i = mCategories.iterator();
boolean didone = false;
while (i.hasNext()) {
@@ -4403,20 +4426,48 @@ public class Intent implements Parcelable {
didone = true;
b.append(i.next());
}
- b.append("}");
+ b.append("]");
+ }
+ if (mData != null) {
+ if (!first) {
+ b.append(' ');
+ }
+ first = false;
+ b.append("dat=").append(mData);
+ }
+ if (mType != null) {
+ if (!first) {
+ b.append(' ');
+ }
+ first = false;
+ b.append("typ=").append(mType);
+ }
+ if (mFlags != 0) {
+ if (!first) {
+ b.append(' ');
+ }
+ first = false;
+ b.append("flg=0x").append(Integer.toHexString(mFlags));
+ }
+ if (comp && mComponent != null) {
+ if (!first) {
+ b.append(' ');
+ }
+ first = false;
+ b.append("cmp=").append(mComponent.flattenToShortString());
+ }
+ if (extras && mExtras != null) {
+ if (!first) {
+ b.append(' ');
+ }
+ first = false;
+ b.append("(has extras)");
}
- if (mData != null) b.append(" data=").append(mData);
- if (mType != null) b.append(" type=").append(mType);
- if (mFlags != 0) b.append(" flags=0x").append(Integer.toHexString(mFlags));
- if (mComponent != null) b.append(" comp=").append(mComponent.toShortString());
- if (mExtras != null) b.append(" (has extras)");
- b.append(" }");
-
- return b.toString();
}
public String toURI() {
- StringBuilder uri = new StringBuilder(mData != null ? mData.toString() : "");
+ StringBuilder uri = new StringBuilder(128);
+ if (mData != null) uri.append(mData.toString());
uri.append("#Intent;");