Merge "ParcelableHolder shouldn't write anything for empty case" am: 97c2606bbd
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1509888 Change-Id: I5f288f4e83a26b378bed41edc082ed501bb1f5a1
This commit is contained in:
@@ -170,16 +170,21 @@ public final class ParcelableHolder implements Parcelable {
|
||||
|
||||
mParcelable = null;
|
||||
|
||||
int dataSize = parcel.readInt();
|
||||
if (dataSize < 0) {
|
||||
throw new IllegalArgumentException("dataSize from parcel is negative");
|
||||
} else if (dataSize == 0) {
|
||||
if (mParcel != null) {
|
||||
mParcel.recycle();
|
||||
mParcel = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (mParcel == null) {
|
||||
mParcel = Parcel.obtain();
|
||||
}
|
||||
mParcel.setDataPosition(0);
|
||||
mParcel.setDataSize(0);
|
||||
|
||||
int dataSize = parcel.readInt();
|
||||
if (dataSize < 0) {
|
||||
throw new IllegalArgumentException("dataSize from parcel is negative");
|
||||
}
|
||||
int dataStartPos = parcel.dataPosition();
|
||||
|
||||
mParcel.appendFrom(parcel, dataStartPos, dataSize);
|
||||
@@ -196,6 +201,11 @@ public final class ParcelableHolder implements Parcelable {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mParcelable == null) {
|
||||
parcel.writeInt(0);
|
||||
return;
|
||||
}
|
||||
|
||||
int sizePos = parcel.dataPosition();
|
||||
parcel.writeInt(0);
|
||||
int dataStartPos = parcel.dataPosition();
|
||||
|
||||
Reference in New Issue
Block a user