Class ShadowSharedMemory


  • @Implements(value=android.os.SharedMemory.class,
                minSdk=27,
                isInAndroidSdk=false)
    public class ShadowSharedMemory
    extends java.lang.Object
    A SharedMemory fake that uses a private temporary disk file for storage and Java's MappedByteBuffer for the memory mappings.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.nio.ByteBuffer map​(int prot, int offset, int length)
      Only works on SharedMemory instances from SharedMemory.create(java.lang.String, int).
      protected static java.io.FileDescriptor nCreate​(java.lang.String name, int size)  
      protected static int nGetSize​(java.io.FileDescriptor fd)  
      static void reset()  
      static void setCreateShouldThrow​(android.system.ErrnoException e)
      Causes subsequent calls to {@link SharedMemory#create)} to throw the specified exception, if non-null.
      protected static void unmap​(java.nio.ByteBuffer mappedBuf)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ShadowSharedMemory

        public ShadowSharedMemory()
    • Method Detail

      • reset

        @Resetter
        public static void reset()
      • map

        @Implementation
        protected java.nio.ByteBuffer map​(int prot,
                                          int offset,
                                          int length)
                                   throws android.system.ErrnoException
        Only works on SharedMemory instances from SharedMemory.create(java.lang.String, int).

        "prot" is ignored -- all mappings are read/write.

        Throws:
        android.system.ErrnoException
      • unmap

        @Implementation
        protected static void unmap​(java.nio.ByteBuffer mappedBuf)
                             throws android.system.ErrnoException
        Throws:
        android.system.ErrnoException
      • nCreate

        @Implementation
        protected static java.io.FileDescriptor nCreate​(java.lang.String name,
                                                        int size)
                                                 throws android.system.ErrnoException
        Throws:
        android.system.ErrnoException
      • nGetSize

        @Implementation
        protected static int nGetSize​(java.io.FileDescriptor fd)
      • setCreateShouldThrow

        public static void setCreateShouldThrow​(android.system.ErrnoException e)
        Causes subsequent calls to {@link SharedMemory#create)} to throw the specified exception, if non-null. Pass null to restore create to normal operation.