A mapping from String keys to various Parcelable values. @see PersistableBundle
| 32 | * @see PersistableBundle |
| 33 | */ |
| 34 | public final class Bundle extends BaseBundle implements Cloneable, Parcelable { |
| 35 | @VisibleForTesting |
| 36 | static final int FLAG_HAS_FDS = 1 << 8; |
| 37 | @VisibleForTesting |
| 38 | static final int FLAG_HAS_FDS_KNOWN = 1 << 9; |
| 39 | @VisibleForTesting |
| 40 | static final int FLAG_ALLOW_FDS = 1 << 10; |
| 41 | public static final Bundle EMPTY; |
| 42 | /** |
| 43 | * Special extras used to denote extras have been stripped off. |
| 44 | * @hide |
| 45 | */ |
| 46 | public static final Bundle STRIPPED; |
| 47 | static { |
| 48 | EMPTY = new Bundle(); |
| 49 | EMPTY.mMap = ArrayMap.EMPTY; |
| 50 | STRIPPED = new Bundle(); |
| 51 | STRIPPED.putInt("STRIPPED", 1); |
| 52 | } |
| 53 | /** |
| 54 | * Constructs a new, empty Bundle. |
| 55 | */ |
| 56 | public Bundle() { |
| 57 | super(); |
| 58 | mFlags = FLAG_HAS_FDS_KNOWN | FLAG_ALLOW_FDS; |
| 59 | } |
| 60 | /** |
| 61 | * Constructs a Bundle whose data is stored as a Parcel. The data |
| 62 | * will be unparcelled on first contact, using the assigned ClassLoader. |
| 63 | * |
| 64 | * @param parcelledData a Parcel containing a Bundle |
| 65 | * |
| 66 | * @hide |
| 67 | */ |
| 68 | @VisibleForTesting |
| 69 | public Bundle(Parcel parcelledData) { |
| 70 | super(parcelledData); |
| 71 | mFlags = FLAG_ALLOW_FDS; |
| 72 | maybePrefillHasFds(); |
| 73 | } |
| 74 | /** |
| 75 | * Constructor from a parcel for when the length is known *and is not stored in the parcel.* |
| 76 | * The other constructor that takes a parcel assumes the length is in the parcel. |
| 77 | * |
| 78 | * @hide |
| 79 | */ |
| 80 | @VisibleForTesting |
| 81 | public Bundle(Parcel parcelledData, int length) { |
| 82 | super(parcelledData, length); |
| 83 | mFlags = FLAG_ALLOW_FDS; |
| 84 | maybePrefillHasFds(); |
| 85 | } |
| 86 | /** |
| 87 | * If {@link #mParcelledData} is not null, copy the HAS FDS bit from it because it's fast. |
| 88 | * Otherwise (if {@link #mParcelledData} is already null), leave {@link #FLAG_HAS_FDS_KNOWN} |
| 89 | * unset, because scanning a map is slower. We'll do it lazily in |
| 90 | * {@link #hasFileDescriptors()}. |
| 91 | */ |