@Implements(value=android.os.SharedMemory.class, minSdk=27, isInAndroidSdk=false) public class ShadowSharedMemory extends Object
A SharedMemory
fake that uses a private temporary disk file for storage and Java’s MappedByteBuffer
for the memory mappings.
Constructor and Description |
---|
ShadowSharedMemory() |
Modifier and Type | Method and Description |
---|---|
protected ByteBuffer |
map(int prot,
int offset,
int length)
Only works on
SharedMemory instances from SharedMemory.create(java.lang.String, int) . |
protected static FileDescriptor |
nCreate(String name,
int size) |
protected static int |
nGetSize(FileDescriptor fd) |
static void |
setCreateShouldThrow(ErrnoException e)
Causes subsequent calls to
SharedMemory#create) to throw the specified exception, if non-null. |
protected static void |
unmap(ByteBuffer mappedBuf) |
@Implementation protected ByteBuffer map(int prot, int offset, int length) throws ErrnoException
Only works on SharedMemory
instances from SharedMemory.create(java.lang.String, int)
.
“prot” is ignored – all mappings are read/write.
ErrnoException
@Implementation protected static void unmap(ByteBuffer mappedBuf) throws ErrnoException
ErrnoException
@Implementation protected static FileDescriptor nCreate(String name, int size) throws ErrnoException
ErrnoException
@Implementation protected static int nGetSize(FileDescriptor fd)
public static void setCreateShouldThrow(ErrnoException e)
Causes subsequent calls to SharedMemory#create)
to throw the specified exception, if non-null. Pass null to restore create to normal operation.