/* * If mParcelledData is non-null, then mMap will be null and the * data are stored as a Parcel containing a Bundle. When the data * are unparcelled, mParcelledData willbe set to null. */ ParcelmParcelledData=null;
/* package */voidunparcel() { synchronized (this) { finalParcelsource= mParcelledData; if (source != null) { initializeFromParcelLocked(source, /*recycleParcel=*/true); } else { if (DEBUG) { Log.d(TAG, "unparcel " + Integer.toHexString(System.identityHashCode(this)) + ": no parcelled data"); } } } } privatevoidinitializeFromParcelLocked(@NonNull Parcel parcelledData, boolean recycleParcel) { if (LOG_DEFUSABLE && sShouldDefuse && (mFlags & FLAG_DEFUSABLE) == 0) { Slog.wtf(TAG, "Attempting to unparcel a Bundle while in transit; this may " + "clobber all data inside!", newThrowable()); }
BaseBundle(Parcel parcelledData) { readFromParcelInner(parcelledData); } voidreadFromParcelInner(Parcel parcel) { // Keep implementation in sync with readFromParcel() in // frameworks/native/libs/binder/PersistableBundle.cpp. intlength= parcel.readInt(); readFromParcelInner(parcel, length); } privatevoidreadFromParcelInner(Parcel parcel, int length) { if (length < 0) { thrownewRuntimeException("Bad length in parcel: " + length);
} elseif (length == 0) { // Empty Bundle or end of data. mParcelledData = NoImagePreloadHolder.EMPTY_PARCEL; return; }
finalintmagic= parcel.readInt(); if (magic != BUNDLE_MAGIC) { thrownewIllegalStateException("Bad magic number for Bundle: 0x" + Integer.toHexString(magic)); }
if (parcel.hasReadWriteHelper()) { // If the parcel has a read-write helper, then we can't lazily-unparcel it, so just // unparcel right away. synchronized (this) { initializeFromParcelLocked(parcel, /*recycleParcel=*/false); } return; }
// Advance within this Parcel intoffset= parcel.dataPosition(); parcel.setDataPosition(MathUtils.addOrThrow(offset, length));