diff options
| -rw-r--r-- | core/java/android/content/ClipData.java | 105 | ||||
| -rw-r--r-- | core/java/android/content/ClipDescription.java | 29 | ||||
| -rw-r--r-- | core/java/android/content/Intent.java | 28 |
3 files changed, 82 insertions, 80 deletions
diff --git a/core/java/android/content/ClipData.java b/core/java/android/content/ClipData.java index 78eb8591a3e9..c4d98671a598 100644 --- a/core/java/android/content/ClipData.java +++ b/core/java/android/content/ClipData.java @@ -651,45 +651,57 @@ public class ClipData implements Parcelable { StringBuilder b = new StringBuilder(128); b.append("ClipData.Item { "); - toShortString(b); + toShortString(b, true); b.append(" }"); return b.toString(); } - /** @hide */ - public void toShortString(StringBuilder b) { + /** + * Appends this item to the given builder. + * @param redactContent If true, redacts common forms of PII; otherwise appends full + * details. + * @hide + */ + public void toShortString(StringBuilder b, boolean redactContent) { + boolean first = true; if (mHtmlText != null) { - b.append("H:"); - b.append(mHtmlText); - } else if (mText != null) { - b.append("T:"); - b.append(mText); - } else if (mUri != null) { - b.append("U:"); - b.append(mUri); - } else if (mIntent != null) { - b.append("I:"); - mIntent.toShortString(b, true, true, true, true); - } else { - b.append("NULL"); + first = false; + if (redactContent) { + b.append("H(").append(mHtmlText.length()).append(')'); + } else { + b.append("H:").append(mHtmlText); + } } - } - - /** @hide */ - public void toShortSummaryString(StringBuilder b) { - if (mHtmlText != null) { - b.append("HTML"); - } else if (mText != null) { - b.append("TEXT"); - } else if (mUri != null) { - b.append("U:"); - b.append(mUri); - } else if (mIntent != null) { + if (mText != null) { + if (!first) { + b.append(' '); + } + first = false; + if (redactContent) { + b.append("T(").append(mText.length()).append(')'); + } else { + b.append("T:").append(mText); + } + } + if (mUri != null) { + if (!first) { + b.append(' '); + } + first = false; + if (redactContent) { + b.append("U(").append(mUri.getScheme()).append(')'); + } else { + b.append("U:").append(mUri); + } + } + if (mIntent != null) { + if (!first) { + b.append(' '); + } + first = false; b.append("I:"); - mIntent.toShortString(b, true, true, true, true); - } else { - b.append("NULL"); + mIntent.toShortString(b, redactContent, true, true, true); } } @@ -1040,17 +1052,21 @@ public class ClipData implements Parcelable { StringBuilder b = new StringBuilder(128); b.append("ClipData { "); - toShortString(b); + toShortString(b, true); b.append(" }"); return b.toString(); } - /** @hide */ - public void toShortString(StringBuilder b) { + /** + * Appends this clip to the given builder. + * @param redactContent If true, redacts common forms of PII; otherwise appends full details. + * @hide + */ + public void toShortString(StringBuilder b, boolean redactContent) { boolean first; if (mClipDescription != null) { - first = !mClipDescription.toShortString(b); + first = !mClipDescription.toShortString(b, redactContent); } else { first = true; } @@ -1064,26 +1080,21 @@ public class ClipData implements Parcelable { b.append('x'); b.append(mIcon.getHeight()); } - for (int i=0; i<mItems.size(); i++) { + if (mItems.size() != 1) { if (!first) { b.append(' '); } first = false; - b.append('{'); - mItems.get(i).toShortString(b); - b.append('}'); + b.append(mItems.size()).append(" items:"); } - } - - /** @hide */ - public void toShortStringShortItems(StringBuilder b, boolean first) { - if (mItems.size() > 0) { + for (int i = 0; i < mItems.size(); i++) { if (!first) { b.append(' '); } - for (int i=0; i<mItems.size(); i++) { - b.append("{...}"); - } + first = false; + b.append('{'); + mItems.get(i).toShortString(b, redactContent); + b.append('}'); } } diff --git a/core/java/android/content/ClipDescription.java b/core/java/android/content/ClipDescription.java index f9e6308515cf..73becb1c0f1c 100644 --- a/core/java/android/content/ClipDescription.java +++ b/core/java/android/content/ClipDescription.java @@ -330,30 +330,45 @@ public class ClipDescription implements Parcelable { StringBuilder b = new StringBuilder(128); b.append("ClipDescription { "); - toShortString(b); + toShortString(b, true); b.append(" }"); return b.toString(); } - /** @hide */ - public boolean toShortString(StringBuilder b) { + /** + * Appends this description to the given builder. + * @param redactContent If true, redacts common forms of PII; otherwise appends full details. + * @hide + */ + public boolean toShortString(StringBuilder b, boolean redactContent) { boolean first = !toShortStringTypesOnly(b); if (mLabel != null) { if (!first) { b.append(' '); } first = false; - b.append('"'); - b.append(mLabel); - b.append('"'); + if (redactContent) { + b.append("hasLabel(").append(mLabel.length()).append(')'); + } else { + b.append('"').append(mLabel).append('"'); + } } if (mExtras != null) { if (!first) { b.append(' '); } first = false; - b.append(mExtras.toString()); + if (redactContent) { + if (mExtras.isParcelled()) { + // We don't want this toString function to trigger un-parcelling. + b.append("hasExtras"); + } else { + b.append("hasExtras(").append(mExtras.size()).append(')'); + } + } else { + b.append(mExtras.toString()); + } } if (mTimeStamp > 0) { if (!first) { diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 9216a0871870..ef92dd182554 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -10485,17 +10485,6 @@ public class Intent implements Parcelable, Cloneable { } /** @hide */ - public String toInsecureStringWithClip() { - StringBuilder b = new StringBuilder(128); - - b.append("Intent { "); - toShortString(b, false, true, true, true); - b.append(" }"); - - return b.toString(); - } - - /** @hide */ public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) { StringBuilder b = new StringBuilder(128); toShortString(b, secure, comp, extras, clip); @@ -10581,16 +10570,7 @@ public class Intent implements Parcelable, Cloneable { b.append(' '); } b.append("clip={"); - if (clip) { - mClipData.toShortString(b); - } else { - if (mClipData.getDescription() != null) { - first = !mClipData.getDescription().toShortStringTypesOnly(b); - } else { - first = true; - } - mClipData.toShortStringShortItems(b, first); - } + mClipData.toShortString(b, !clip || secure); first = false; b.append('}'); } @@ -10668,11 +10648,7 @@ public class Intent implements Parcelable, Cloneable { } if (mClipData != null) { StringBuilder b = new StringBuilder(); - if (clip) { - mClipData.toShortString(b); - } else { - mClipData.toShortStringShortItems(b, false); - } + mClipData.toShortString(b, !clip || secure); proto.write(IntentProto.CLIP_DATA, b.toString()); } if (extras && mExtras != null) { |