diff --git a/core/java/android/content/ClipData.java b/core/java/android/content/ClipData.java index 78eb8591a3e95..c4d98671a5984 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,29 +1080,24 @@ public class ClipData implements Parcelable { b.append('x'); b.append(mIcon.getHeight()); } - for (int i=0; i 0) { - if (!first) { - b.append(' '); - } - for (int i=0; i 0) { if (!first) { diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 9216a08718707..ef92dd1825547 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -10484,17 +10484,6 @@ public class Intent implements Parcelable, Cloneable { return b.toString(); } - /** @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); @@ -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) {