Merge "Improve Bundle/PersistableBundle docs" am: 9a2a261abd am: 509a70ea06

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1846255

Change-Id: I76949a83786bebd0cb6d8d10e22648533cf21c49
This commit is contained in:
Treehugger Robot
2021-10-07 14:44:31 +00:00
committed by Automerger Merge Worker
2 changed files with 15 additions and 1 deletions

View File

@@ -33,6 +33,9 @@ import java.util.List;
/** /**
* A mapping from String keys to various {@link Parcelable} values. * A mapping from String keys to various {@link Parcelable} values.
* *
* <p><b>Warning:</b> Note that {@link Bundle} is a lazy container and as such it does NOT implement
* {@link #equals(Object)} or {@link #hashCode()}.
*
* @see PersistableBundle * @see PersistableBundle
*/ */
public final class Bundle extends BaseBundle implements Cloneable, Parcelable { public final class Bundle extends BaseBundle implements Cloneable, Parcelable {
@@ -1230,6 +1233,10 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable {
maybePrefillHasFds(); maybePrefillHasFds();
} }
/**
* Returns a string representation of the {@link Bundle} that may be suitable for debugging. It
* won't print the internal map if its content hasn't been unparcelled.
*/
@Override @Override
public synchronized String toString() { public synchronized String toString() {
if (mParcelledData != null) { if (mParcelledData != null) {

View File

@@ -43,6 +43,9 @@ import java.util.ArrayList;
* supported by this class is purposefully restricted to simple objects that can * supported by this class is purposefully restricted to simple objects that can
* safely be persisted to and restored from disk. * safely be persisted to and restored from disk.
* *
* <p><b>Warning:</b> Note that {@link PersistableBundle} is a lazy container and as such it does
* NOT implement {@link #equals(Object)} or {@link #hashCode()}.
*
* @see Bundle * @see Bundle
*/ */
public final class PersistableBundle extends BaseBundle implements Cloneable, Parcelable, public final class PersistableBundle extends BaseBundle implements Cloneable, Parcelable,
@@ -324,8 +327,12 @@ public final class PersistableBundle extends BaseBundle implements Cloneable, Pa
return new PersistableBundle(); // An empty mutable PersistableBundle return new PersistableBundle(); // An empty mutable PersistableBundle
} }
/**
* Returns a string representation of the {@link PersistableBundle} that may be suitable for
* debugging. It won't print the internal map if its content hasn't been unparcelled.
*/
@Override @Override
synchronized public String toString() { public synchronized String toString() {
if (mParcelledData != null) { if (mParcelledData != null) {
if (isEmptyParcel()) { if (isEmptyParcel()) {
return "PersistableBundle[EMPTY_PARCEL]"; return "PersistableBundle[EMPTY_PARCEL]";