Package org.robolectric.shadows
Class ShadowParcel
java.lang.Object
org.robolectric.shadows.ShadowParcel
@Implements(value=android.os.Parcel.class, looseSignatures=true) public class ShadowParcel extends Object
Robolectric's
Parcel pretends to be backed by a byte buffer, closely matching Parcel's position, size, and capacity behavior. However, its internal pure-Java representation
is strongly typed, to detect non-portable code and common testing mistakes. It may throw IllegalArgumentException or IllegalStateException for error-prone behavior normal Parcel tolerates.-
Field Summary
-
Constructor Summary
Constructors Constructor Description ShadowParcel() -
Method Summary
Modifier and Type Method Description static voidnativeAppendFrom(int thisNativePtr, int otherNativePtr, int offset, int length)protected static voidnativeAppendFrom(long thisNativePtr, long otherNativePtr, int offset, int length)static NumbernativeCreate()static byte[]nativeCreateByteArray(int nativePtr)protected static byte[]nativeCreateByteArray(long nativePtr)static intnativeDataAvail(int nativePtr)protected static intnativeDataAvail(long nativePtr)static intnativeDataCapacity(int nativePtr)protected static intnativeDataCapacity(long nativePtr)static intnativeDataPosition(int nativePtr)protected static intnativeDataPosition(long nativePtr)static intnativeDataSize(int nativePtr)protected static intnativeDataSize(long nativePtr)static voidnativeDestroy(int nativePtr)protected static voidnativeDestroy(long nativePtr)static voidnativeEnforceInterface(int nativePtr, String interfaceName)protected static voidnativeEnforceInterface(long nativePtr, String interfaceName)static voidnativeFreeBuffer(int nativePtr)protected static voidnativeFreeBuffer(long nativePtr)static byte[]nativeMarshall(int nativePtr)protected static byte[]nativeMarshall(long nativePtr)protected static byte[]nativeReadBlob(long nativePtr)protected static booleannativeReadByteArray(long nativePtr, byte[] dest, int destLen)static doublenativeReadDouble(int nativePtr)protected static doublenativeReadDouble(long nativePtr)protected static FileDescriptornativeReadFileDescriptor(long nativePtr)static floatnativeReadFloat(int nativePtr)protected static floatnativeReadFloat(long nativePtr)static intnativeReadInt(int nativePtr)protected static intnativeReadInt(long nativePtr)static longnativeReadLong(int nativePtr)protected static longnativeReadLong(long nativePtr)static StringnativeReadString(int nativePtr)protected static StringnativeReadString(long nativePtr)protected static StringnativeReadString16(long nativePtr)protected static StringnativeReadString8(long nativePtr)protected static IBindernativeReadStrongBinder(int nativePtr)protected static IBindernativeReadStrongBinder(long nativePtr)static voidnativeSetDataCapacity(int nativePtr, int size)protected static voidnativeSetDataCapacity(long nativePtr, int size)static voidnativeSetDataPosition(int nativePtr, int pos)protected static voidnativeSetDataPosition(long nativePtr, int pos)static voidnativeSetDataSize(int nativePtr, int size)protected static voidnativeSetDataSize(long nativePtr, int size)static voidnativeUnmarshall(int nativePtr, byte[] data, int offset, int length)protected static voidnativeUnmarshall(long nativePtr, byte[] data, int offset, int length)protected static voidnativeWriteBlob(long nativePtr, byte[] b, int offset, int len)static voidnativeWriteByteArray(int nativePtr, byte[] b, int offset, int len)protected static voidnativeWriteByteArray(long nativePtr, byte[] b, int offset, int len)static voidnativeWriteDouble(int nativePtr, double val)protected static voidnativeWriteDouble(long nativePtr, double val)protected static intnativeWriteDouble(Object nativePtr, Object val)protected static longnativeWriteFileDescriptor(long nativePtr, FileDescriptor val)protected static voidnativeWriteFileDescriptor(Object nativePtr, Object val)static voidnativeWriteFloat(int nativePtr, float val)protected static voidnativeWriteFloat(long nativePtr, float val)protected static intnativeWriteFloat(Object nativePtr, Object val)static voidnativeWriteInt(int nativePtr, int val)protected static voidnativeWriteInt(long nativePtr, int val)protected static intnativeWriteInt(Object nativePtr, Object val)static voidnativeWriteInterfaceToken(int nativePtr, String interfaceName)protected static voidnativeWriteInterfaceToken(long nativePtr, String interfaceName)static voidnativeWriteLong(int nativePtr, long val)protected static voidnativeWriteLong(long nativePtr, long val)protected static intnativeWriteLong(Object nativePtr, Object val)static voidnativeWriteString(int nativePtr, String val)protected static voidnativeWriteString(long nativePtr, String val)protected static voidnativeWriteString16(long nativePtr, String val)protected static voidnativeWriteString8(long nativePtr, String val)protected static voidnativeWriteStrongBinder(int nativePtr, IBinder val)protected static voidnativeWriteStrongBinder(long nativePtr, IBinder val)protected static FileDescriptoropenFileDescriptor(String file, int mode)protected <T extends Parcelable>
TreadParcelable(ClassLoader loader)Parcelable.Creator<?>readParcelableCreator(ClassLoader loader)protected <T> Parcelable.Creator<T>readParcelableCreatorInternal(ClassLoader loader, Class<T> clazz)The goal of this shadow method is to workaround a JVM/ART incompatibility.static voidreset()protected voidwriteBlob(byte[] b, int offset, int len)protected voidwriteByteArray(byte[] b, int offset, int len)
-
Field Details
-
TAG
- See Also:
- Constant Field Values
-
-
Constructor Details
-
ShadowParcel
public ShadowParcel()
-
-
Method Details
-
readParcelable
-
readParcelableCreator
@HiddenApi @Implementation(minSdk=18) public Parcelable.Creator<?> readParcelableCreator(ClassLoader loader) -
readParcelableCreatorInternal
@Implementation(minSdk=33) protected <T> Parcelable.Creator<T> readParcelableCreatorInternal(ClassLoader loader, Class<T> clazz)The goal of this shadow method is to workaround a JVM/ART incompatibility.In ART, a public field is visible regardless whether or not the enclosing class is public. On the JVM, this is not the case. For compatibility, we need to use
Field.setAccessible(boolean)to simulate the same behavior. -
writeByteArray
-
nativeDataSize
-
nativeDataSize
-
nativeDataAvail
-
nativeDataAvail
-
nativeDataPosition
-
nativeDataPosition
-
nativeDataCapacity
-
nativeDataCapacity
-
nativeSetDataSize
@HiddenApi @Implementation(maxSdk=20) public static void nativeSetDataSize(int nativePtr, int size) -
nativeSetDataSize
-
nativeSetDataPosition
@HiddenApi @Implementation(maxSdk=20) public static void nativeSetDataPosition(int nativePtr, int pos) -
nativeSetDataPosition
-
nativeSetDataCapacity
@HiddenApi @Implementation(maxSdk=20) public static void nativeSetDataCapacity(int nativePtr, int size) -
nativeSetDataCapacity
-
nativeWriteByteArray
@HiddenApi @Implementation(maxSdk=20) public static void nativeWriteByteArray(int nativePtr, byte[] b, int offset, int len) -
nativeWriteByteArray
@Implementation(minSdk=21) protected static void nativeWriteByteArray(long nativePtr, byte[] b, int offset, int len) -
writeBlob
-
nativeWriteBlob
@Implementation(minSdk=21) protected static void nativeWriteBlob(long nativePtr, byte[] b, int offset, int len) -
nativeWriteInt
-
nativeWriteInt
@Implementation(minSdk=21, maxSdk=30) protected static void nativeWriteInt(long nativePtr, int val) -
nativeWriteLong
-
nativeWriteLong
@Implementation(minSdk=21, maxSdk=30) protected static void nativeWriteLong(long nativePtr, long val) -
nativeWriteFloat
@HiddenApi @Implementation(maxSdk=20) public static void nativeWriteFloat(int nativePtr, float val) -
nativeWriteFloat
@Implementation(minSdk=21, maxSdk=30) protected static void nativeWriteFloat(long nativePtr, float val) -
nativeWriteDouble
@HiddenApi @Implementation(maxSdk=20) public static void nativeWriteDouble(int nativePtr, double val) -
nativeWriteDouble
@Implementation(minSdk=21, maxSdk=30) protected static void nativeWriteDouble(long nativePtr, double val) -
nativeWriteString
@HiddenApi @Implementation(maxSdk=20) public static void nativeWriteString(int nativePtr, String val) -
nativeWriteString
@Implementation(minSdk=21, maxSdk=29) protected static void nativeWriteString(long nativePtr, String val) -
nativeWriteStrongBinder
@HiddenApi @Implementation(maxSdk=20) protected static void nativeWriteStrongBinder(int nativePtr, IBinder val) -
nativeWriteStrongBinder
@Implementation(minSdk=21) protected static void nativeWriteStrongBinder(long nativePtr, IBinder val) -
nativeCreateByteArray
-
nativeCreateByteArray
-
nativeReadBlob
-
nativeReadByteArray
@Implementation(minSdk=27) protected static boolean nativeReadByteArray(long nativePtr, byte[] dest, int destLen) -
nativeReadInt
-
nativeReadInt
-
nativeReadLong
-
nativeReadLong
-
nativeReadFloat
-
nativeReadFloat
-
nativeReadDouble
-
nativeReadDouble
-
nativeReadString
-
nativeReadString
-
nativeReadStrongBinder
@HiddenApi @Implementation(maxSdk=20) protected static IBinder nativeReadStrongBinder(int nativePtr) -
nativeReadStrongBinder
-
nativeCreate
-
nativeFreeBuffer
-
nativeFreeBuffer
-
nativeDestroy
-
nativeDestroy
-
nativeMarshall
-
nativeMarshall
-
nativeUnmarshall
@HiddenApi @Implementation(maxSdk=20) public static void nativeUnmarshall(int nativePtr, byte[] data, int offset, int length) -
nativeUnmarshall
@Implementation(minSdk=21) protected static void nativeUnmarshall(long nativePtr, byte[] data, int offset, int length) -
nativeAppendFrom
@HiddenApi @Implementation(maxSdk=20) public static void nativeAppendFrom(int thisNativePtr, int otherNativePtr, int offset, int length) -
nativeAppendFrom
@Implementation(minSdk=21) protected static void nativeAppendFrom(long thisNativePtr, long otherNativePtr, int offset, int length) -
nativeWriteInterfaceToken
@HiddenApi @Implementation(maxSdk=20) public static void nativeWriteInterfaceToken(int nativePtr, String interfaceName) -
nativeWriteInterfaceToken
@Implementation(minSdk=21) protected static void nativeWriteInterfaceToken(long nativePtr, String interfaceName) -
nativeEnforceInterface
@HiddenApi @Implementation(maxSdk=20) public static void nativeEnforceInterface(int nativePtr, String interfaceName) -
nativeEnforceInterface
@Implementation(minSdk=21) protected static void nativeEnforceInterface(long nativePtr, String interfaceName) -
openFileDescriptor
@Implementation(maxSdk=28) protected static FileDescriptor openFileDescriptor(String file, int mode) throws IOException- Throws:
IOException
-
nativeWriteFileDescriptor
@Implementation(minSdk=23, maxSdk=30) protected static long nativeWriteFileDescriptor(long nativePtr, FileDescriptor val) -
nativeReadFileDescriptor
@Implementation(minSdk=23) protected static FileDescriptor nativeReadFileDescriptor(long nativePtr) -
nativeWriteString8
-
nativeWriteString16
-
nativeReadString8
-
nativeReadString16
-
nativeWriteInt
-
nativeWriteLong
-
nativeWriteFloat
-
nativeWriteDouble
-
nativeWriteFileDescriptor
@Implementation(minSdk=31) protected static void nativeWriteFileDescriptor(Object nativePtr, Object val) -
reset
-