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
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
nativeAppendFrom
(int thisNativePtr, int otherNativePtr, int offset, int length) protected static void
nativeAppendFrom
(long thisNativePtr, long otherNativePtr, int offset, int length) static Number
static byte[]
nativeCreateByteArray
(int nativePtr) protected static byte[]
nativeCreateByteArray
(long nativePtr) static int
nativeDataAvail
(int nativePtr) protected static int
nativeDataAvail
(long nativePtr) static int
nativeDataCapacity
(int nativePtr) protected static int
nativeDataCapacity
(long nativePtr) static int
nativeDataPosition
(int nativePtr) protected static int
nativeDataPosition
(long nativePtr) static int
nativeDataSize
(int nativePtr) protected static int
nativeDataSize
(long nativePtr) static void
nativeDestroy
(int nativePtr) protected static void
nativeDestroy
(long nativePtr) static void
nativeEnforceInterface
(int nativePtr, String interfaceName) protected static void
nativeEnforceInterface
(long nativePtr, String interfaceName) static void
nativeFreeBuffer
(int nativePtr) protected static void
nativeFreeBuffer
(long nativePtr) static byte[]
nativeMarshall
(int nativePtr) protected static byte[]
nativeMarshall
(long nativePtr) protected static byte[]
nativeReadBlob
(long nativePtr) protected static boolean
nativeReadByteArray
(long nativePtr, byte[] dest, int destLen) static double
nativeReadDouble
(int nativePtr) protected static double
nativeReadDouble
(long nativePtr) protected static FileDescriptor
nativeReadFileDescriptor
(long nativePtr) static float
nativeReadFloat
(int nativePtr) protected static float
nativeReadFloat
(long nativePtr) static int
nativeReadInt
(int nativePtr) protected static int
nativeReadInt
(long nativePtr) static long
nativeReadLong
(int nativePtr) protected static long
nativeReadLong
(long nativePtr) static String
nativeReadString
(int nativePtr) protected static String
nativeReadString
(long nativePtr) protected static String
nativeReadString16
(long nativePtr) protected static String
nativeReadString8
(long nativePtr) protected static IBinder
nativeReadStrongBinder
(int nativePtr) protected static IBinder
nativeReadStrongBinder
(long nativePtr) static void
nativeSetDataCapacity
(int nativePtr, int size) protected static void
nativeSetDataCapacity
(long nativePtr, int size) static void
nativeSetDataPosition
(int nativePtr, int pos) protected static void
nativeSetDataPosition
(long nativePtr, int pos) static void
nativeSetDataSize
(int nativePtr, int size) protected static void
nativeSetDataSize
(long nativePtr, int size) static void
nativeUnmarshall
(int nativePtr, byte[] data, int offset, int length) protected static void
nativeUnmarshall
(long nativePtr, byte[] data, int offset, int length) protected static void
nativeWriteBlob
(long nativePtr, byte[] b, int offset, int len) static void
nativeWriteByteArray
(int nativePtr, byte[] b, int offset, int len) protected static void
nativeWriteByteArray
(long nativePtr, byte[] b, int offset, int len) static void
nativeWriteDouble
(int nativePtr, double val) protected static void
nativeWriteDouble
(long nativePtr, double val) protected static int
nativeWriteDouble
(Object nativePtr, Object val) protected static long
nativeWriteFileDescriptor
(long nativePtr, FileDescriptor val) protected static void
nativeWriteFileDescriptor
(Object nativePtr, Object val) static void
nativeWriteFloat
(int nativePtr, float val) protected static void
nativeWriteFloat
(long nativePtr, float val) protected static int
nativeWriteFloat
(Object nativePtr, Object val) static void
nativeWriteInt
(int nativePtr, int val) protected static void
nativeWriteInt
(long nativePtr, int val) protected static int
nativeWriteInt
(Object nativePtr, Object val) static void
nativeWriteInterfaceToken
(int nativePtr, String interfaceName) protected static void
nativeWriteInterfaceToken
(long nativePtr, String interfaceName) static void
nativeWriteLong
(int nativePtr, long val) protected static void
nativeWriteLong
(long nativePtr, long val) protected static int
nativeWriteLong
(Object nativePtr, Object val) static void
nativeWriteString
(int nativePtr, String val) protected static void
nativeWriteString
(long nativePtr, String val) protected static void
nativeWriteString16
(long nativePtr, String val) protected static void
nativeWriteString8
(long nativePtr, String val) protected static void
nativeWriteStrongBinder
(int nativePtr, IBinder val) protected static void
nativeWriteStrongBinder
(long nativePtr, IBinder val) protected static FileDescriptor
openFileDescriptor
(String file, int mode) protected <T extends Parcelable>
TreadParcelable
(ClassLoader loader) 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 void
reset()
protected void
writeBlob
(byte[] b, int offset, int len) protected void
writeByteArray
(byte[] b, int offset, int len)
-
Field Details
-
TAG
- See Also:
-
-
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
-
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
-
nativeWriteLong
-
nativeWriteLong
@Implementation(minSdk=21, maxSdk=30) protected static void nativeWriteLong(long nativePtr, long val) -
nativeWriteFloat
-
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
-
nativeWriteString8
-
nativeWriteString16
-
nativeReadString8
-
nativeReadString16
-
nativeWriteInt
-
nativeWriteLong
-
nativeWriteFloat
-
nativeWriteDouble
-
nativeWriteFileDescriptor
@Implementation(minSdk=31) protected static void nativeWriteFileDescriptor(Object nativePtr, Object val) -
reset
-