Merge "Assert Parcel not in pool when used." into main
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index bf7116d..6855d95 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -50,6 +50,7 @@
import dalvik.annotation.optimization.CriticalNative;
import dalvik.annotation.optimization.FastNative;
+import dalvik.annotation.optimization.NeverInline;
import libcore.util.SneakyThrow;
@@ -587,6 +588,17 @@
return parcel;
}
+ @NeverInline
+ private void errorUsedWhileRecycling() {
+ Log.wtf(TAG, "Parcel used while recycled. "
+ + Log.getStackTraceString(new Throwable())
+ + " Original recycle call (if DEBUG_RECYCLE): ", mStack);
+ }
+
+ private void assertNotRecycled() {
+ if (mRecycled) errorUsedWhileRecycling();
+ }
+
/**
* Put a Parcel object back into the pool. You must not touch
* the object after this call.
@@ -635,6 +647,7 @@
* @hide
*/
public void setReadWriteHelper(@Nullable ReadWriteHelper helper) {
+ assertNotRecycled();
mReadWriteHelper = helper != null ? helper : ReadWriteHelper.DEFAULT;
}
@@ -644,6 +657,7 @@
* @hide
*/
public boolean hasReadWriteHelper() {
+ assertNotRecycled();
return (mReadWriteHelper != null) && (mReadWriteHelper != ReadWriteHelper.DEFAULT);
}
@@ -670,6 +684,7 @@
* @hide
*/
public final void markSensitive() {
+ assertNotRecycled();
nativeMarkSensitive(mNativePtr);
}
@@ -686,6 +701,7 @@
* @hide
*/
public final boolean isForRpc() {
+ assertNotRecycled();
return nativeIsForRpc(mNativePtr);
}
@@ -693,21 +709,25 @@
@ParcelFlags
@TestApi
public int getFlags() {
+ assertNotRecycled();
return mFlags;
}
/** @hide */
public void setFlags(@ParcelFlags int flags) {
+ assertNotRecycled();
mFlags = flags;
}
/** @hide */
public void addFlags(@ParcelFlags int flags) {
+ assertNotRecycled();
mFlags |= flags;
}
/** @hide */
private boolean hasFlags(@ParcelFlags int flags) {
+ assertNotRecycled();
return (mFlags & flags) == flags;
}
@@ -720,6 +740,7 @@
// We don't really need to protect it; even if 3p / non-system apps, nothing would happen.
// This would only work when used on a reply parcel by a binder object that's allowed-blocking.
public void setPropagateAllowBlocking() {
+ assertNotRecycled();
addFlags(FLAG_PROPAGATE_ALLOW_BLOCKING);
}
@@ -727,6 +748,7 @@
* Returns the total amount of data contained in the parcel.
*/
public int dataSize() {
+ assertNotRecycled();
return nativeDataSize(mNativePtr);
}
@@ -735,6 +757,7 @@
* parcel. That is, {@link #dataSize}-{@link #dataPosition}.
*/
public final int dataAvail() {
+ assertNotRecycled();
return nativeDataAvail(mNativePtr);
}
@@ -743,6 +766,7 @@
* more than {@link #dataSize}.
*/
public final int dataPosition() {
+ assertNotRecycled();
return nativeDataPosition(mNativePtr);
}
@@ -753,6 +777,7 @@
* data buffer.
*/
public final int dataCapacity() {
+ assertNotRecycled();
return nativeDataCapacity(mNativePtr);
}
@@ -764,6 +789,7 @@
* @param size The new number of bytes in the Parcel.
*/
public final void setDataSize(int size) {
+ assertNotRecycled();
nativeSetDataSize(mNativePtr, size);
}
@@ -773,6 +799,7 @@
* {@link #dataSize}.
*/
public final void setDataPosition(int pos) {
+ assertNotRecycled();
nativeSetDataPosition(mNativePtr, pos);
}
@@ -784,11 +811,13 @@
* with this method.
*/
public final void setDataCapacity(int size) {
+ assertNotRecycled();
nativeSetDataCapacity(mNativePtr, size);
}
/** @hide */
public final boolean pushAllowFds(boolean allowFds) {
+ assertNotRecycled();
return nativePushAllowFds(mNativePtr, allowFds);
}
@@ -809,6 +838,7 @@
* in different versions of the platform.
*/
public final byte[] marshall() {
+ assertNotRecycled();
return nativeMarshall(mNativePtr);
}
@@ -816,15 +846,18 @@
* Fills the raw bytes of this Parcel with the supplied data.
*/
public final void unmarshall(@NonNull byte[] data, int offset, int length) {
+ assertNotRecycled();
nativeUnmarshall(mNativePtr, data, offset, length);
}
public final void appendFrom(Parcel parcel, int offset, int length) {
+ assertNotRecycled();
nativeAppendFrom(mNativePtr, parcel.mNativePtr, offset, length);
}
/** @hide */
public int compareData(Parcel other) {
+ assertNotRecycled();
return nativeCompareData(mNativePtr, other.mNativePtr);
}
@@ -835,6 +868,7 @@
/** @hide */
public final void setClassCookie(Class clz, Object cookie) {
+ assertNotRecycled();
if (mClassCookies == null) {
mClassCookies = new ArrayMap<>();
}
@@ -844,11 +878,13 @@
/** @hide */
@Nullable
public final Object getClassCookie(Class clz) {
+ assertNotRecycled();
return mClassCookies != null ? mClassCookies.get(clz) : null;
}
/** @hide */
public void removeClassCookie(Class clz, Object expectedCookie) {
+ assertNotRecycled();
if (mClassCookies != null) {
Object removedCookie = mClassCookies.remove(clz);
if (removedCookie != expectedCookie) {
@@ -866,21 +902,25 @@
* @hide
*/
public boolean hasClassCookie(Class clz) {
+ assertNotRecycled();
return mClassCookies != null && mClassCookies.containsKey(clz);
}
/** @hide */
public final void adoptClassCookies(Parcel from) {
+ assertNotRecycled();
mClassCookies = from.mClassCookies;
}
/** @hide */
public Map<Class, Object> copyClassCookies() {
+ assertNotRecycled();
return new ArrayMap<>(mClassCookies);
}
/** @hide */
public void putClassCookies(Map<Class, Object> cookies) {
+ assertNotRecycled();
if (cookies == null) {
return;
}
@@ -894,6 +934,7 @@
* Report whether the parcel contains any marshalled file descriptors.
*/
public boolean hasFileDescriptors() {
+ assertNotRecycled();
return nativeHasFileDescriptors(mNativePtr);
}
@@ -909,6 +950,7 @@
* @throws IllegalArgumentException if the parameters are out of the permitted ranges.
*/
public boolean hasFileDescriptors(int offset, int length) {
+ assertNotRecycled();
return nativeHasFileDescriptorsInRange(mNativePtr, offset, length);
}
@@ -993,6 +1035,7 @@
* @hide
*/
public boolean hasBinders() {
+ assertNotRecycled();
return nativeHasBinders(mNativePtr);
}
@@ -1010,6 +1053,7 @@
* @hide
*/
public boolean hasBinders(int offset, int length) {
+ assertNotRecycled();
return nativeHasBindersInRange(mNativePtr, offset, length);
}
@@ -1020,6 +1064,7 @@
* at the beginning of transactions as a header.
*/
public final void writeInterfaceToken(@NonNull String interfaceName) {
+ assertNotRecycled();
nativeWriteInterfaceToken(mNativePtr, interfaceName);
}
@@ -1030,6 +1075,7 @@
* should propagate to the caller.
*/
public final void enforceInterface(@NonNull String interfaceName) {
+ assertNotRecycled();
nativeEnforceInterface(mNativePtr, interfaceName);
}
@@ -1040,6 +1086,7 @@
* When used over binder, this exception should propagate to the caller.
*/
public void enforceNoDataAvail() {
+ assertNotRecycled();
final int n = dataAvail();
if (n > 0) {
throw new BadParcelableException("Parcel data not fully consumed, unread size: " + n);
@@ -1056,6 +1103,7 @@
* @hide
*/
public boolean replaceCallingWorkSourceUid(int workSourceUid) {
+ assertNotRecycled();
return nativeReplaceCallingWorkSourceUid(mNativePtr, workSourceUid);
}
@@ -1072,6 +1120,7 @@
* @hide
*/
public int readCallingWorkSourceUid() {
+ assertNotRecycled();
return nativeReadCallingWorkSourceUid(mNativePtr);
}
@@ -1081,6 +1130,7 @@
* @param b Bytes to place into the parcel.
*/
public final void writeByteArray(@Nullable byte[] b) {
+ assertNotRecycled();
writeByteArray(b, 0, (b != null) ? b.length : 0);
}
@@ -1092,6 +1142,7 @@
* @param len Number of bytes to write.
*/
public final void writeByteArray(@Nullable byte[] b, int offset, int len) {
+ assertNotRecycled();
if (b == null) {
writeInt(-1);
return;
@@ -1113,6 +1164,7 @@
* @see #readBlob()
*/
public final void writeBlob(@Nullable byte[] b) {
+ assertNotRecycled();
writeBlob(b, 0, (b != null) ? b.length : 0);
}
@@ -1131,6 +1183,7 @@
* @see #readBlob()
*/
public final void writeBlob(@Nullable byte[] b, int offset, int len) {
+ assertNotRecycled();
if (b == null) {
writeInt(-1);
return;
@@ -1149,6 +1202,7 @@
* growing dataCapacity() if needed.
*/
public final void writeInt(int val) {
+ assertNotRecycled();
int err = nativeWriteInt(mNativePtr, val);
if (err != OK) {
nativeSignalExceptionForError(err);
@@ -1160,6 +1214,7 @@
* growing dataCapacity() if needed.
*/
public final void writeLong(long val) {
+ assertNotRecycled();
int err = nativeWriteLong(mNativePtr, val);
if (err != OK) {
nativeSignalExceptionForError(err);
@@ -1171,6 +1226,7 @@
* dataPosition(), growing dataCapacity() if needed.
*/
public final void writeFloat(float val) {
+ assertNotRecycled();
int err = nativeWriteFloat(mNativePtr, val);
if (err != OK) {
nativeSignalExceptionForError(err);
@@ -1182,6 +1238,7 @@
* current dataPosition(), growing dataCapacity() if needed.
*/
public final void writeDouble(double val) {
+ assertNotRecycled();
int err = nativeWriteDouble(mNativePtr, val);
if (err != OK) {
nativeSignalExceptionForError(err);
@@ -1193,16 +1250,19 @@
* growing dataCapacity() if needed.
*/
public final void writeString(@Nullable String val) {
+ assertNotRecycled();
writeString16(val);
}
/** {@hide} */
public final void writeString8(@Nullable String val) {
+ assertNotRecycled();
mReadWriteHelper.writeString8(this, val);
}
/** {@hide} */
public final void writeString16(@Nullable String val) {
+ assertNotRecycled();
mReadWriteHelper.writeString16(this, val);
}
@@ -1214,16 +1274,19 @@
* @hide
*/
public void writeStringNoHelper(@Nullable String val) {
+ assertNotRecycled();
writeString16NoHelper(val);
}
/** {@hide} */
public void writeString8NoHelper(@Nullable String val) {
+ assertNotRecycled();
nativeWriteString8(mNativePtr, val);
}
/** {@hide} */
public void writeString16NoHelper(@Nullable String val) {
+ assertNotRecycled();
nativeWriteString16(mNativePtr, val);
}
@@ -1235,6 +1298,7 @@
* for true or false, respectively, but may change in the future.
*/
public final void writeBoolean(boolean val) {
+ assertNotRecycled();
writeInt(val ? 1 : 0);
}
@@ -1246,6 +1310,7 @@
@UnsupportedAppUsage
@RavenwoodThrow(blockedBy = android.text.Spanned.class)
public final void writeCharSequence(@Nullable CharSequence val) {
+ assertNotRecycled();
TextUtils.writeToParcel(val, this, 0);
}
@@ -1254,6 +1319,7 @@
* growing dataCapacity() if needed.
*/
public final void writeStrongBinder(IBinder val) {
+ assertNotRecycled();
nativeWriteStrongBinder(mNativePtr, val);
}
@@ -1262,6 +1328,7 @@
* growing dataCapacity() if needed.
*/
public final void writeStrongInterface(IInterface val) {
+ assertNotRecycled();
writeStrongBinder(val == null ? null : val.asBinder());
}
@@ -1276,6 +1343,7 @@
* if {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE} is set.</p>
*/
public final void writeFileDescriptor(@NonNull FileDescriptor val) {
+ assertNotRecycled();
nativeWriteFileDescriptor(mNativePtr, val);
}
@@ -1284,6 +1352,7 @@
* This will be the new name for writeFileDescriptor, for consistency.
**/
public final void writeRawFileDescriptor(@NonNull FileDescriptor val) {
+ assertNotRecycled();
nativeWriteFileDescriptor(mNativePtr, val);
}
@@ -1294,6 +1363,7 @@
* @param value The array of objects to be written.
*/
public final void writeRawFileDescriptorArray(@Nullable FileDescriptor[] value) {
+ assertNotRecycled();
if (value != null) {
int N = value.length;
writeInt(N);
@@ -1313,6 +1383,7 @@
* the future.
*/
public final void writeByte(byte val) {
+ assertNotRecycled();
writeInt(val);
}
@@ -1328,6 +1399,7 @@
* allows you to avoid mysterious type errors at the point of marshalling.
*/
public final void writeMap(@Nullable Map val) {
+ assertNotRecycled();
writeMapInternal((Map<String, Object>) val);
}
@@ -1336,6 +1408,7 @@
* growing dataCapacity() if needed. The Map keys must be String objects.
*/
/* package */ void writeMapInternal(@Nullable Map<String,Object> val) {
+ assertNotRecycled();
if (val == null) {
writeInt(-1);
return;
@@ -1361,6 +1434,7 @@
* growing dataCapacity() if needed. The Map keys must be String objects.
*/
/* package */ void writeArrayMapInternal(@Nullable ArrayMap<String, Object> val) {
+ assertNotRecycled();
if (val == null) {
writeInt(-1);
return;
@@ -1390,6 +1464,7 @@
*/
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public void writeArrayMap(@Nullable ArrayMap<String, Object> val) {
+ assertNotRecycled();
writeArrayMapInternal(val);
}
@@ -1408,6 +1483,7 @@
*/
public <T extends Parcelable> void writeTypedArrayMap(@Nullable ArrayMap<String, T> val,
int parcelableFlags) {
+ assertNotRecycled();
if (val == null) {
writeInt(-1);
return;
@@ -1429,6 +1505,7 @@
*/
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public void writeArraySet(@Nullable ArraySet<? extends Object> val) {
+ assertNotRecycled();
final int size = (val != null) ? val.size() : -1;
writeInt(size);
for (int i = 0; i < size; i++) {
@@ -1441,6 +1518,7 @@
* growing dataCapacity() if needed.
*/
public final void writeBundle(@Nullable Bundle val) {
+ assertNotRecycled();
if (val == null) {
writeInt(-1);
return;
@@ -1454,6 +1532,7 @@
* growing dataCapacity() if needed.
*/
public final void writePersistableBundle(@Nullable PersistableBundle val) {
+ assertNotRecycled();
if (val == null) {
writeInt(-1);
return;
@@ -1467,6 +1546,7 @@
* growing dataCapacity() if needed.
*/
public final void writeSize(@NonNull Size val) {
+ assertNotRecycled();
writeInt(val.getWidth());
writeInt(val.getHeight());
}
@@ -1476,6 +1556,7 @@
* growing dataCapacity() if needed.
*/
public final void writeSizeF(@NonNull SizeF val) {
+ assertNotRecycled();
writeFloat(val.getWidth());
writeFloat(val.getHeight());
}
@@ -1486,6 +1567,7 @@
* {@link #writeValue} and must follow the specification there.
*/
public final void writeList(@Nullable List val) {
+ assertNotRecycled();
if (val == null) {
writeInt(-1);
return;
@@ -1505,6 +1587,7 @@
* {@link #writeValue} and must follow the specification there.
*/
public final void writeArray(@Nullable Object[] val) {
+ assertNotRecycled();
if (val == null) {
writeInt(-1);
return;
@@ -1525,6 +1608,7 @@
* specification there.
*/
public final <T> void writeSparseArray(@Nullable SparseArray<T> val) {
+ assertNotRecycled();
if (val == null) {
writeInt(-1);
return;
@@ -1540,6 +1624,7 @@
}
public final void writeSparseBooleanArray(@Nullable SparseBooleanArray val) {
+ assertNotRecycled();
if (val == null) {
writeInt(-1);
return;
@@ -1558,6 +1643,7 @@
* @hide
*/
public final void writeSparseIntArray(@Nullable SparseIntArray val) {
+ assertNotRecycled();
if (val == null) {
writeInt(-1);
return;
@@ -1573,6 +1659,7 @@
}
public final void writeBooleanArray(@Nullable boolean[] val) {
+ assertNotRecycled();
if (val != null) {
int N = val.length;
writeInt(N);
@@ -1607,6 +1694,7 @@
}
private void ensureWithinMemoryLimit(int typeSize, @NonNull int... dimensions) {
+ assertNotRecycled();
// For Multidimensional arrays, Calculate total object
// which will be allocated.
int totalObjects = 1;
@@ -1624,6 +1712,7 @@
}
private void ensureWithinMemoryLimit(int typeSize, int length) {
+ assertNotRecycled();
int estimatedAllocationSize = 0;
try {
estimatedAllocationSize = Math.multiplyExact(typeSize, length);
@@ -1647,6 +1736,7 @@
@Nullable
public final boolean[] createBooleanArray() {
+ assertNotRecycled();
int N = readInt();
ensureWithinMemoryLimit(SIZE_BOOLEAN, N);
// >>2 as a fast divide-by-4 works in the create*Array() functions
@@ -1664,6 +1754,7 @@
}
public final void readBooleanArray(@NonNull boolean[] val) {
+ assertNotRecycled();
int N = readInt();
if (N == val.length) {
for (int i=0; i<N; i++) {
@@ -1676,6 +1767,7 @@
/** @hide */
public void writeShortArray(@Nullable short[] val) {
+ assertNotRecycled();
if (val != null) {
int n = val.length;
writeInt(n);
@@ -1690,6 +1782,7 @@
/** @hide */
@Nullable
public short[] createShortArray() {
+ assertNotRecycled();
int n = readInt();
ensureWithinMemoryLimit(SIZE_SHORT, n);
if (n >= 0 && n <= (dataAvail() >> 2)) {
@@ -1705,6 +1798,7 @@
/** @hide */
public void readShortArray(@NonNull short[] val) {
+ assertNotRecycled();
int n = readInt();
if (n == val.length) {
for (int i = 0; i < n; i++) {
@@ -1716,6 +1810,7 @@
}
public final void writeCharArray(@Nullable char[] val) {
+ assertNotRecycled();
if (val != null) {
int N = val.length;
writeInt(N);
@@ -1729,6 +1824,7 @@
@Nullable
public final char[] createCharArray() {
+ assertNotRecycled();
int N = readInt();
ensureWithinMemoryLimit(SIZE_CHAR, N);
if (N >= 0 && N <= (dataAvail() >> 2)) {
@@ -1743,6 +1839,7 @@
}
public final void readCharArray(@NonNull char[] val) {
+ assertNotRecycled();
int N = readInt();
if (N == val.length) {
for (int i=0; i<N; i++) {
@@ -1754,6 +1851,7 @@
}
public final void writeIntArray(@Nullable int[] val) {
+ assertNotRecycled();
if (val != null) {
int N = val.length;
writeInt(N);
@@ -1767,6 +1865,7 @@
@Nullable
public final int[] createIntArray() {
+ assertNotRecycled();
int N = readInt();
ensureWithinMemoryLimit(SIZE_INT, N);
if (N >= 0 && N <= (dataAvail() >> 2)) {
@@ -1781,6 +1880,7 @@
}
public final void readIntArray(@NonNull int[] val) {
+ assertNotRecycled();
int N = readInt();
if (N == val.length) {
for (int i=0; i<N; i++) {
@@ -1792,6 +1892,7 @@
}
public final void writeLongArray(@Nullable long[] val) {
+ assertNotRecycled();
if (val != null) {
int N = val.length;
writeInt(N);
@@ -1805,6 +1906,7 @@
@Nullable
public final long[] createLongArray() {
+ assertNotRecycled();
int N = readInt();
ensureWithinMemoryLimit(SIZE_LONG, N);
// >>3 because stored longs are 64 bits
@@ -1820,6 +1922,7 @@
}
public final void readLongArray(@NonNull long[] val) {
+ assertNotRecycled();
int N = readInt();
if (N == val.length) {
for (int i=0; i<N; i++) {
@@ -1831,6 +1934,7 @@
}
public final void writeFloatArray(@Nullable float[] val) {
+ assertNotRecycled();
if (val != null) {
int N = val.length;
writeInt(N);
@@ -1844,6 +1948,7 @@
@Nullable
public final float[] createFloatArray() {
+ assertNotRecycled();
int N = readInt();
ensureWithinMemoryLimit(SIZE_FLOAT, N);
// >>2 because stored floats are 4 bytes
@@ -1859,6 +1964,7 @@
}
public final void readFloatArray(@NonNull float[] val) {
+ assertNotRecycled();
int N = readInt();
if (N == val.length) {
for (int i=0; i<N; i++) {
@@ -1870,6 +1976,7 @@
}
public final void writeDoubleArray(@Nullable double[] val) {
+ assertNotRecycled();
if (val != null) {
int N = val.length;
writeInt(N);
@@ -1883,6 +1990,7 @@
@Nullable
public final double[] createDoubleArray() {
+ assertNotRecycled();
int N = readInt();
ensureWithinMemoryLimit(SIZE_DOUBLE, N);
// >>3 because stored doubles are 8 bytes
@@ -1898,6 +2006,7 @@
}
public final void readDoubleArray(@NonNull double[] val) {
+ assertNotRecycled();
int N = readInt();
if (N == val.length) {
for (int i=0; i<N; i++) {
@@ -1909,20 +2018,24 @@
}
public final void writeStringArray(@Nullable String[] val) {
+ assertNotRecycled();
writeString16Array(val);
}
@Nullable
public final String[] createStringArray() {
+ assertNotRecycled();
return createString16Array();
}
public final void readStringArray(@NonNull String[] val) {
+ assertNotRecycled();
readString16Array(val);
}
/** {@hide} */
public final void writeString8Array(@Nullable String[] val) {
+ assertNotRecycled();
if (val != null) {
int N = val.length;
writeInt(N);
@@ -1937,6 +2050,7 @@
/** {@hide} */
@Nullable
public final String[] createString8Array() {
+ assertNotRecycled();
int N = readInt();
ensureWithinMemoryLimit(SIZE_COMPLEX_TYPE, N);
if (N >= 0) {
@@ -1952,6 +2066,7 @@
/** {@hide} */
public final void readString8Array(@NonNull String[] val) {
+ assertNotRecycled();
int N = readInt();
if (N == val.length) {
for (int i=0; i<N; i++) {
@@ -1964,6 +2079,7 @@
/** {@hide} */
public final void writeString16Array(@Nullable String[] val) {
+ assertNotRecycled();
if (val != null) {
int N = val.length;
writeInt(N);
@@ -1978,6 +2094,7 @@
/** {@hide} */
@Nullable
public final String[] createString16Array() {
+ assertNotRecycled();
int N = readInt();
ensureWithinMemoryLimit(SIZE_COMPLEX_TYPE, N);
if (N >= 0) {
@@ -1993,6 +2110,7 @@
/** {@hide} */
public final void readString16Array(@NonNull String[] val) {
+ assertNotRecycled();
int N = readInt();
if (N == val.length) {
for (int i=0; i<N; i++) {
@@ -2004,6 +2122,7 @@
}
public final void writeBinderArray(@Nullable IBinder[] val) {
+ assertNotRecycled();
if (val != null) {
int N = val.length;
writeInt(N);
@@ -2028,6 +2147,7 @@
*/
public final <T extends IInterface> void writeInterfaceArray(
@SuppressLint("ArrayReturn") @Nullable T[] val) {
+ assertNotRecycled();
if (val != null) {
int N = val.length;
writeInt(N);
@@ -2043,6 +2163,7 @@
* @hide
*/
public final void writeCharSequenceArray(@Nullable CharSequence[] val) {
+ assertNotRecycled();
if (val != null) {
int N = val.length;
writeInt(N);
@@ -2058,6 +2179,7 @@
* @hide
*/
public final void writeCharSequenceList(@Nullable ArrayList<CharSequence> val) {
+ assertNotRecycled();
if (val != null) {
int N = val.size();
writeInt(N);
@@ -2071,6 +2193,7 @@
@Nullable
public final IBinder[] createBinderArray() {
+ assertNotRecycled();
int N = readInt();
ensureWithinMemoryLimit(SIZE_COMPLEX_TYPE, N);
if (N >= 0) {
@@ -2085,6 +2208,7 @@
}
public final void readBinderArray(@NonNull IBinder[] val) {
+ assertNotRecycled();
int N = readInt();
if (N == val.length) {
for (int i=0; i<N; i++) {
@@ -2106,6 +2230,7 @@
@Nullable
public final <T extends IInterface> T[] createInterfaceArray(
@NonNull IntFunction<T[]> newArray, @NonNull Function<IBinder, T> asInterface) {
+ assertNotRecycled();
int N = readInt();
ensureWithinMemoryLimit(SIZE_COMPLEX_TYPE, N);
if (N >= 0) {
@@ -2130,6 +2255,7 @@
public final <T extends IInterface> void readInterfaceArray(
@SuppressLint("ArrayReturn") @NonNull T[] val,
@NonNull Function<IBinder, T> asInterface) {
+ assertNotRecycled();
int N = readInt();
if (N == val.length) {
for (int i=0; i<N; i++) {
@@ -2155,6 +2281,7 @@
* @see Parcelable
*/
public final <T extends Parcelable> void writeTypedList(@Nullable List<T> val) {
+ assertNotRecycled();
writeTypedList(val, 0);
}
@@ -2174,6 +2301,7 @@
*/
public final <T extends Parcelable> void writeTypedSparseArray(@Nullable SparseArray<T> val,
int parcelableFlags) {
+ assertNotRecycled();
if (val == null) {
writeInt(-1);
return;
@@ -2203,6 +2331,7 @@
* @see Parcelable
*/
public <T extends Parcelable> void writeTypedList(@Nullable List<T> val, int parcelableFlags) {
+ assertNotRecycled();
if (val == null) {
writeInt(-1);
return;
@@ -2228,6 +2357,7 @@
* @see #readStringList
*/
public final void writeStringList(@Nullable List<String> val) {
+ assertNotRecycled();
if (val == null) {
writeInt(-1);
return;
@@ -2253,6 +2383,7 @@
* @see #readBinderList
*/
public final void writeBinderList(@Nullable List<IBinder> val) {
+ assertNotRecycled();
if (val == null) {
writeInt(-1);
return;
@@ -2275,6 +2406,7 @@
* @see #readInterfaceList
*/
public final <T extends IInterface> void writeInterfaceList(@Nullable List<T> val) {
+ assertNotRecycled();
if (val == null) {
writeInt(-1);
return;
@@ -2296,6 +2428,7 @@
* @see #readParcelableList(List, ClassLoader)
*/
public final <T extends Parcelable> void writeParcelableList(@Nullable List<T> val, int flags) {
+ assertNotRecycled();
if (val == null) {
writeInt(-1);
return;
@@ -2330,6 +2463,7 @@
*/
public final <T extends Parcelable> void writeTypedArray(@Nullable T[] val,
int parcelableFlags) {
+ assertNotRecycled();
if (val != null) {
int N = val.length;
writeInt(N);
@@ -2352,6 +2486,7 @@
*/
public final <T extends Parcelable> void writeTypedObject(@Nullable T val,
int parcelableFlags) {
+ assertNotRecycled();
if (val != null) {
writeInt(1);
val.writeToParcel(this, parcelableFlags);
@@ -2389,6 +2524,7 @@
*/
public <T> void writeFixedArray(@Nullable T val, int parcelableFlags,
@NonNull int... dimensions) {
+ assertNotRecycled();
if (val == null) {
writeInt(-1);
return;
@@ -2500,6 +2636,7 @@
* should be used).</p>
*/
public final void writeValue(@Nullable Object v) {
+ assertNotRecycled();
if (v instanceof LazyValue) {
LazyValue value = (LazyValue) v;
value.writeToParcel(this);
@@ -2617,6 +2754,7 @@
* @hide
*/
public void writeValue(int type, @Nullable Object v) {
+ assertNotRecycled();
switch (type) {
case VAL_NULL:
break;
@@ -2730,6 +2868,7 @@
* {@link Parcelable#writeToParcel(Parcel, int) Parcelable.writeToParcel()}.
*/
public final void writeParcelable(@Nullable Parcelable p, int parcelableFlags) {
+ assertNotRecycled();
if (p == null) {
writeString(null);
return;
@@ -2745,6 +2884,7 @@
* @see #readParcelableCreator
*/
public final void writeParcelableCreator(@NonNull Parcelable p) {
+ assertNotRecycled();
String name = p.getClass().getName();
writeString(name);
}
@@ -2783,6 +2923,7 @@
*/
@TestApi
public boolean allowSquashing() {
+ assertNotRecycled();
boolean previous = mAllowSquashing;
mAllowSquashing = true;
return previous;
@@ -2794,6 +2935,7 @@
*/
@TestApi
public void restoreAllowSquashing(boolean previous) {
+ assertNotRecycled();
mAllowSquashing = previous;
if (!mAllowSquashing) {
mWrittenSquashableParcelables = null;
@@ -2850,6 +2992,7 @@
* @hide
*/
public boolean maybeWriteSquashed(@NonNull Parcelable p) {
+ assertNotRecycled();
if (!mAllowSquashing) {
// Don't squash, and don't put it in the map either.
writeInt(0);
@@ -2900,6 +3043,7 @@
@SuppressWarnings("unchecked")
@Nullable
public <T extends Parcelable> T readSquashed(SquashReadHelper<T> reader) {
+ assertNotRecycled();
final int offset = readInt();
final int pos = dataPosition();
@@ -2933,6 +3077,7 @@
* using the other approaches to writing data in to a Parcel.
*/
public final void writeSerializable(@Nullable Serializable s) {
+ assertNotRecycled();
if (s == null) {
writeString(null);
return;
@@ -2985,6 +3130,7 @@
*/
@RavenwoodReplace(blockedBy = AppOpsManager.class)
public final void writeException(@NonNull Exception e) {
+ assertNotRecycled();
AppOpsManager.prefixParcelWithAppOpsIfNeeded(this);
int code = getExceptionCode(e);
@@ -3065,6 +3211,7 @@
/** @hide */
public void writeStackTrace(@NonNull Throwable e) {
+ assertNotRecycled();
final int sizePosition = dataPosition();
writeInt(0); // Header size will be filled in later
StackTraceElement[] stackTrace = e.getStackTrace();
@@ -3090,6 +3237,7 @@
*/
@RavenwoodReplace(blockedBy = AppOpsManager.class)
public final void writeNoException() {
+ assertNotRecycled();
AppOpsManager.prefixParcelWithAppOpsIfNeeded(this);
// Despite the name of this function ("write no exception"),
@@ -3133,6 +3281,7 @@
* @see #writeNoException
*/
public final void readException() {
+ assertNotRecycled();
int code = readExceptionCode();
if (code != 0) {
String msg = readString();
@@ -3156,6 +3305,7 @@
@UnsupportedAppUsage
@TestApi
public final int readExceptionCode() {
+ assertNotRecycled();
int code = readInt();
if (code == EX_HAS_NOTED_APPOPS_REPLY_HEADER) {
AppOpsManager.readAndLogNotedAppops(this);
@@ -3189,6 +3339,7 @@
* @param msg The exception message.
*/
public final void readException(int code, String msg) {
+ assertNotRecycled();
String remoteStackTrace = null;
final int remoteStackPayloadSize = readInt();
if (remoteStackPayloadSize > 0) {
@@ -3219,6 +3370,7 @@
/** @hide */
public Exception createExceptionOrNull(int code, String msg) {
+ assertNotRecycled();
switch (code) {
case EX_PARCELABLE:
if (readInt() > 0) {
@@ -3251,6 +3403,7 @@
* Read an integer value from the parcel at the current dataPosition().
*/
public final int readInt() {
+ assertNotRecycled();
return nativeReadInt(mNativePtr);
}
@@ -3258,6 +3411,7 @@
* Read a long integer value from the parcel at the current dataPosition().
*/
public final long readLong() {
+ assertNotRecycled();
return nativeReadLong(mNativePtr);
}
@@ -3266,6 +3420,7 @@
* dataPosition().
*/
public final float readFloat() {
+ assertNotRecycled();
return nativeReadFloat(mNativePtr);
}
@@ -3274,6 +3429,7 @@
* current dataPosition().
*/
public final double readDouble() {
+ assertNotRecycled();
return nativeReadDouble(mNativePtr);
}
@@ -3282,16 +3438,19 @@
*/
@Nullable
public final String readString() {
+ assertNotRecycled();
return readString16();
}
/** {@hide} */
public final @Nullable String readString8() {
+ assertNotRecycled();
return mReadWriteHelper.readString8(this);
}
/** {@hide} */
public final @Nullable String readString16() {
+ assertNotRecycled();
return mReadWriteHelper.readString16(this);
}
@@ -3303,16 +3462,19 @@
* @hide
*/
public @Nullable String readStringNoHelper() {
+ assertNotRecycled();
return readString16NoHelper();
}
/** {@hide} */
public @Nullable String readString8NoHelper() {
+ assertNotRecycled();
return nativeReadString8(mNativePtr);
}
/** {@hide} */
public @Nullable String readString16NoHelper() {
+ assertNotRecycled();
return nativeReadString16(mNativePtr);
}
@@ -3320,6 +3482,7 @@
* Read a boolean value from the parcel at the current dataPosition().
*/
public final boolean readBoolean() {
+ assertNotRecycled();
return readInt() != 0;
}
@@ -3330,6 +3493,7 @@
@UnsupportedAppUsage
@Nullable
public final CharSequence readCharSequence() {
+ assertNotRecycled();
return TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(this);
}
@@ -3337,6 +3501,7 @@
* Read an object from the parcel at the current dataPosition().
*/
public final IBinder readStrongBinder() {
+ assertNotRecycled();
final IBinder result = nativeReadStrongBinder(mNativePtr);
// If it's a reply from a method with @PropagateAllowBlocking, then inherit allow-blocking
@@ -3352,6 +3517,7 @@
* Read a FileDescriptor from the parcel at the current dataPosition().
*/
public final ParcelFileDescriptor readFileDescriptor() {
+ assertNotRecycled();
FileDescriptor fd = nativeReadFileDescriptor(mNativePtr);
return fd != null ? new ParcelFileDescriptor(fd) : null;
}
@@ -3359,6 +3525,7 @@
/** {@hide} */
@UnsupportedAppUsage
public final FileDescriptor readRawFileDescriptor() {
+ assertNotRecycled();
return nativeReadFileDescriptor(mNativePtr);
}
@@ -3369,6 +3536,7 @@
**/
@Nullable
public final FileDescriptor[] createRawFileDescriptorArray() {
+ assertNotRecycled();
int N = readInt();
if (N < 0) {
return null;
@@ -3388,6 +3556,7 @@
* @return the FileDescriptor array, or null if the array is null.
**/
public final void readRawFileDescriptorArray(FileDescriptor[] val) {
+ assertNotRecycled();
int N = readInt();
if (N == val.length) {
for (int i=0; i<N; i++) {
@@ -3402,6 +3571,7 @@
* Read a byte value from the parcel at the current dataPosition().
*/
public final byte readByte() {
+ assertNotRecycled();
return (byte)(readInt() & 0xff);
}
@@ -3416,6 +3586,7 @@
*/
@Deprecated
public final void readMap(@NonNull Map outVal, @Nullable ClassLoader loader) {
+ assertNotRecycled();
readMapInternal(outVal, loader, /* clazzKey */ null, /* clazzValue */ null);
}
@@ -3429,6 +3600,7 @@
public <K, V> void readMap(@NonNull Map<? super K, ? super V> outVal,
@Nullable ClassLoader loader, @NonNull Class<K> clazzKey,
@NonNull Class<V> clazzValue) {
+ assertNotRecycled();
Objects.requireNonNull(clazzKey);
Objects.requireNonNull(clazzValue);
readMapInternal(outVal, loader, clazzKey, clazzValue);
@@ -3447,6 +3619,7 @@
*/
@Deprecated
public final void readList(@NonNull List outVal, @Nullable ClassLoader loader) {
+ assertNotRecycled();
int N = readInt();
readListInternal(outVal, N, loader, /* clazz */ null);
}
@@ -3468,6 +3641,7 @@
*/
public <T> void readList(@NonNull List<? super T> outVal,
@Nullable ClassLoader loader, @NonNull Class<T> clazz) {
+ assertNotRecycled();
Objects.requireNonNull(clazz);
int n = readInt();
readListInternal(outVal, n, loader, clazz);
@@ -3487,6 +3661,7 @@
@Deprecated
@Nullable
public HashMap readHashMap(@Nullable ClassLoader loader) {
+ assertNotRecycled();
return readHashMapInternal(loader, /* clazzKey */ null, /* clazzValue */ null);
}
@@ -3501,6 +3676,7 @@
@Nullable
public <K, V> HashMap<K, V> readHashMap(@Nullable ClassLoader loader,
@NonNull Class<? extends K> clazzKey, @NonNull Class<? extends V> clazzValue) {
+ assertNotRecycled();
Objects.requireNonNull(clazzKey);
Objects.requireNonNull(clazzValue);
return readHashMapInternal(loader, clazzKey, clazzValue);
@@ -3513,6 +3689,7 @@
*/
@Nullable
public final Bundle readBundle() {
+ assertNotRecycled();
return readBundle(null);
}
@@ -3524,6 +3701,7 @@
*/
@Nullable
public final Bundle readBundle(@Nullable ClassLoader loader) {
+ assertNotRecycled();
int length = readInt();
if (length < 0) {
if (Bundle.DEBUG) Log.d(TAG, "null bundle: length=" + length);
@@ -3544,6 +3722,7 @@
*/
@Nullable
public final PersistableBundle readPersistableBundle() {
+ assertNotRecycled();
return readPersistableBundle(null);
}
@@ -3555,6 +3734,7 @@
*/
@Nullable
public final PersistableBundle readPersistableBundle(@Nullable ClassLoader loader) {
+ assertNotRecycled();
int length = readInt();
if (length < 0) {
if (Bundle.DEBUG) Log.d(TAG, "null bundle: length=" + length);
@@ -3573,6 +3753,7 @@
*/
@NonNull
public final Size readSize() {
+ assertNotRecycled();
final int width = readInt();
final int height = readInt();
return new Size(width, height);
@@ -3583,6 +3764,7 @@
*/
@NonNull
public final SizeF readSizeF() {
+ assertNotRecycled();
final float width = readFloat();
final float height = readFloat();
return new SizeF(width, height);
@@ -3593,6 +3775,7 @@
*/
@Nullable
public final byte[] createByteArray() {
+ assertNotRecycled();
return nativeCreateByteArray(mNativePtr);
}
@@ -3601,6 +3784,7 @@
* given byte array.
*/
public final void readByteArray(@NonNull byte[] val) {
+ assertNotRecycled();
boolean valid = nativeReadByteArray(mNativePtr, val, (val != null) ? val.length : 0);
if (!valid) {
throw new RuntimeException("bad array lengths");
@@ -3613,6 +3797,7 @@
*/
@Nullable
public final byte[] readBlob() {
+ assertNotRecycled();
return nativeReadBlob(mNativePtr);
}
@@ -3623,6 +3808,7 @@
@UnsupportedAppUsage
@Nullable
public final String[] readStringArray() {
+ assertNotRecycled();
return createString16Array();
}
@@ -3632,6 +3818,7 @@
*/
@Nullable
public final CharSequence[] readCharSequenceArray() {
+ assertNotRecycled();
CharSequence[] array = null;
int length = readInt();
@@ -3654,6 +3841,7 @@
*/
@Nullable
public final ArrayList<CharSequence> readCharSequenceList() {
+ assertNotRecycled();
ArrayList<CharSequence> array = null;
int length = readInt();
@@ -3683,6 +3871,7 @@
@Deprecated
@Nullable
public ArrayList readArrayList(@Nullable ClassLoader loader) {
+ assertNotRecycled();
return readArrayListInternal(loader, /* clazz */ null);
}
@@ -3705,6 +3894,7 @@
@Nullable
public <T> ArrayList<T> readArrayList(@Nullable ClassLoader loader,
@NonNull Class<? extends T> clazz) {
+ assertNotRecycled();
Objects.requireNonNull(clazz);
return readArrayListInternal(loader, clazz);
}
@@ -3724,6 +3914,7 @@
@Deprecated
@Nullable
public Object[] readArray(@Nullable ClassLoader loader) {
+ assertNotRecycled();
return readArrayInternal(loader, /* clazz */ null);
}
@@ -3745,6 +3936,7 @@
@SuppressLint({"ArrayReturn", "NullableCollection"})
@Nullable
public <T> T[] readArray(@Nullable ClassLoader loader, @NonNull Class<T> clazz) {
+ assertNotRecycled();
Objects.requireNonNull(clazz);
return readArrayInternal(loader, clazz);
}
@@ -3764,6 +3956,7 @@
@Deprecated
@Nullable
public <T> SparseArray<T> readSparseArray(@Nullable ClassLoader loader) {
+ assertNotRecycled();
return readSparseArrayInternal(loader, /* clazz */ null);
}
@@ -3785,6 +3978,7 @@
@Nullable
public <T> SparseArray<T> readSparseArray(@Nullable ClassLoader loader,
@NonNull Class<? extends T> clazz) {
+ assertNotRecycled();
Objects.requireNonNull(clazz);
return readSparseArrayInternal(loader, clazz);
}
@@ -3796,6 +3990,7 @@
*/
@Nullable
public final SparseBooleanArray readSparseBooleanArray() {
+ assertNotRecycled();
int N = readInt();
if (N < 0) {
return null;
@@ -3812,6 +4007,7 @@
*/
@Nullable
public final SparseIntArray readSparseIntArray() {
+ assertNotRecycled();
int N = readInt();
if (N < 0) {
return null;
@@ -3836,6 +4032,7 @@
*/
@Nullable
public final <T> ArrayList<T> createTypedArrayList(@NonNull Parcelable.Creator<T> c) {
+ assertNotRecycled();
int N = readInt();
if (N < 0) {
return null;
@@ -3859,6 +4056,7 @@
* @see #writeTypedList
*/
public final <T> void readTypedList(@NonNull List<T> list, @NonNull Parcelable.Creator<T> c) {
+ assertNotRecycled();
int M = list.size();
int N = readInt();
int i = 0;
@@ -3888,6 +4086,7 @@
*/
public final @Nullable <T extends Parcelable> SparseArray<T> createTypedSparseArray(
@NonNull Parcelable.Creator<T> creator) {
+ assertNotRecycled();
final int count = readInt();
if (count < 0) {
return null;
@@ -3917,6 +4116,7 @@
*/
public final @Nullable <T extends Parcelable> ArrayMap<String, T> createTypedArrayMap(
@NonNull Parcelable.Creator<T> creator) {
+ assertNotRecycled();
final int count = readInt();
if (count < 0) {
return null;
@@ -3944,6 +4144,7 @@
*/
@Nullable
public final ArrayList<String> createStringArrayList() {
+ assertNotRecycled();
int N = readInt();
if (N < 0) {
return null;
@@ -3970,6 +4171,7 @@
*/
@Nullable
public final ArrayList<IBinder> createBinderArrayList() {
+ assertNotRecycled();
int N = readInt();
if (N < 0) {
return null;
@@ -3997,6 +4199,7 @@
@Nullable
public final <T extends IInterface> ArrayList<T> createInterfaceArrayList(
@NonNull Function<IBinder, T> asInterface) {
+ assertNotRecycled();
int N = readInt();
if (N < 0) {
return null;
@@ -4017,6 +4220,7 @@
* @see #writeStringList
*/
public final void readStringList(@NonNull List<String> list) {
+ assertNotRecycled();
int M = list.size();
int N = readInt();
int i = 0;
@@ -4038,6 +4242,7 @@
* @see #writeBinderList
*/
public final void readBinderList(@NonNull List<IBinder> list) {
+ assertNotRecycled();
int M = list.size();
int N = readInt();
int i = 0;
@@ -4060,6 +4265,7 @@
*/
public final <T extends IInterface> void readInterfaceList(@NonNull List<T> list,
@NonNull Function<IBinder, T> asInterface) {
+ assertNotRecycled();
int M = list.size();
int N = readInt();
int i = 0;
@@ -4091,6 +4297,7 @@
@NonNull
public final <T extends Parcelable> List<T> readParcelableList(@NonNull List<T> list,
@Nullable ClassLoader cl) {
+ assertNotRecycled();
return readParcelableListInternal(list, cl, /*clazz*/ null);
}
@@ -4112,6 +4319,7 @@
@NonNull
public <T> List<T> readParcelableList(@NonNull List<T> list,
@Nullable ClassLoader cl, @NonNull Class<? extends T> clazz) {
+ assertNotRecycled();
Objects.requireNonNull(list);
Objects.requireNonNull(clazz);
return readParcelableListInternal(list, cl, clazz);
@@ -4157,6 +4365,7 @@
*/
@Nullable
public final <T> T[] createTypedArray(@NonNull Parcelable.Creator<T> c) {
+ assertNotRecycled();
int N = readInt();
if (N < 0) {
return null;
@@ -4170,6 +4379,7 @@
}
public final <T> void readTypedArray(@NonNull T[] val, @NonNull Parcelable.Creator<T> c) {
+ assertNotRecycled();
int N = readInt();
if (N == val.length) {
for (int i=0; i<N; i++) {
@@ -4186,6 +4396,7 @@
*/
@Deprecated
public final <T> T[] readTypedArray(Parcelable.Creator<T> c) {
+ assertNotRecycled();
return createTypedArray(c);
}
@@ -4202,6 +4413,7 @@
*/
@Nullable
public final <T> T readTypedObject(@NonNull Parcelable.Creator<T> c) {
+ assertNotRecycled();
if (readInt() != 0) {
return c.createFromParcel(this);
} else {
@@ -4228,6 +4440,7 @@
* @see #readTypedArray
*/
public <T> void readFixedArray(@NonNull T val) {
+ assertNotRecycled();
Class<?> componentType = val.getClass().getComponentType();
if (componentType == boolean.class) {
readBooleanArray((boolean[]) val);
@@ -4268,6 +4481,7 @@
*/
public <T, S extends IInterface> void readFixedArray(@NonNull T val,
@NonNull Function<IBinder, S> asInterface) {
+ assertNotRecycled();
Class<?> componentType = val.getClass().getComponentType();
if (IInterface.class.isAssignableFrom(componentType)) {
readInterfaceArray((S[]) val, asInterface);
@@ -4294,6 +4508,7 @@
*/
public <T, S extends Parcelable> void readFixedArray(@NonNull T val,
@NonNull Parcelable.Creator<S> c) {
+ assertNotRecycled();
Class<?> componentType = val.getClass().getComponentType();
if (Parcelable.class.isAssignableFrom(componentType)) {
readTypedArray((S[]) val, c);
@@ -4351,6 +4566,7 @@
*/
@Nullable
public <T> T createFixedArray(@NonNull Class<T> cls, @NonNull int... dimensions) {
+ assertNotRecycled();
// Check if type matches with dimensions
// If type is one-dimensional array, delegate to other creators
// Otherwise, create an multi-dimensional array at once and then fill it with readFixedArray
@@ -4424,6 +4640,7 @@
@Nullable
public <T, S extends IInterface> T createFixedArray(@NonNull Class<T> cls,
@NonNull Function<IBinder, S> asInterface, @NonNull int... dimensions) {
+ assertNotRecycled();
// Check if type matches with dimensions
// If type is one-dimensional array, delegate to other creators
// Otherwise, create an multi-dimensional array at once and then fill it with readFixedArray
@@ -4484,6 +4701,7 @@
@Nullable
public <T, S extends Parcelable> T createFixedArray(@NonNull Class<T> cls,
@NonNull Parcelable.Creator<S> c, @NonNull int... dimensions) {
+ assertNotRecycled();
// Check if type matches with dimensions
// If type is one-dimensional array, delegate to other creators
// Otherwise, create an multi-dimensional array at once and then fill it with readFixedArray
@@ -4547,6 +4765,7 @@
*/
public final <T extends Parcelable> void writeParcelableArray(@Nullable T[] value,
int parcelableFlags) {
+ assertNotRecycled();
if (value != null) {
int N = value.length;
writeInt(N);
@@ -4565,6 +4784,7 @@
*/
@Nullable
public final Object readValue(@Nullable ClassLoader loader) {
+ assertNotRecycled();
return readValue(loader, /* clazz */ null);
}
@@ -4620,6 +4840,7 @@
*/
@Nullable
public Object readLazyValue(@Nullable ClassLoader loader) {
+ assertNotRecycled();
int start = dataPosition();
int type = readInt();
if (isLengthPrefixed(type)) {
@@ -5022,6 +5243,7 @@
@Deprecated
@Nullable
public final <T extends Parcelable> T readParcelable(@Nullable ClassLoader loader) {
+ assertNotRecycled();
return readParcelableInternal(loader, /* clazz */ null);
}
@@ -5041,6 +5263,7 @@
*/
@Nullable
public <T> T readParcelable(@Nullable ClassLoader loader, @NonNull Class<T> clazz) {
+ assertNotRecycled();
Objects.requireNonNull(clazz);
return readParcelableInternal(loader, clazz);
}
@@ -5069,6 +5292,7 @@
@Nullable
public final <T extends Parcelable> T readCreator(@NonNull Parcelable.Creator<?> creator,
@Nullable ClassLoader loader) {
+ assertNotRecycled();
if (creator instanceof Parcelable.ClassLoaderCreator<?>) {
Parcelable.ClassLoaderCreator<?> classLoaderCreator =
(Parcelable.ClassLoaderCreator<?>) creator;
@@ -5096,6 +5320,7 @@
@Deprecated
@Nullable
public final Parcelable.Creator<?> readParcelableCreator(@Nullable ClassLoader loader) {
+ assertNotRecycled();
return readParcelableCreatorInternal(loader, /* clazz */ null);
}
@@ -5116,6 +5341,7 @@
@Nullable
public <T> Parcelable.Creator<T> readParcelableCreator(
@Nullable ClassLoader loader, @NonNull Class<T> clazz) {
+ assertNotRecycled();
Objects.requireNonNull(clazz);
return readParcelableCreatorInternal(loader, clazz);
}
@@ -5238,6 +5464,7 @@
@Deprecated
@Nullable
public Parcelable[] readParcelableArray(@Nullable ClassLoader loader) {
+ assertNotRecycled();
return readParcelableArrayInternal(loader, /* clazz */ null);
}
@@ -5258,6 +5485,7 @@
@SuppressLint({"ArrayReturn", "NullableCollection"})
@Nullable
public <T> T[] readParcelableArray(@Nullable ClassLoader loader, @NonNull Class<T> clazz) {
+ assertNotRecycled();
return readParcelableArrayInternal(loader, requireNonNull(clazz));
}
@@ -5291,6 +5519,7 @@
@Deprecated
@Nullable
public Serializable readSerializable() {
+ assertNotRecycled();
return readSerializableInternal(/* loader */ null, /* clazz */ null);
}
@@ -5307,6 +5536,7 @@
*/
@Nullable
public <T> T readSerializable(@Nullable ClassLoader loader, @NonNull Class<T> clazz) {
+ assertNotRecycled();
Objects.requireNonNull(clazz);
return readSerializableInternal(
loader == null ? getClass().getClassLoader() : loader, clazz);
@@ -5548,6 +5778,7 @@
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public void readArrayMap(@NonNull ArrayMap<? super String, Object> outVal,
@Nullable ClassLoader loader) {
+ assertNotRecycled();
final int N = readInt();
if (N < 0) {
return;
@@ -5564,6 +5795,7 @@
*/
@UnsupportedAppUsage
public @Nullable ArraySet<? extends Object> readArraySet(@Nullable ClassLoader loader) {
+ assertNotRecycled();
final int size = readInt();
if (size < 0) {
return null;
@@ -5703,6 +5935,7 @@
* @hide For testing
*/
public long getOpenAshmemSize() {
+ assertNotRecycled();
return nativeGetOpenAshmemSize(mNativePtr);
}