Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0c66b4bc authored by Bjorn Bringert's avatar Bjorn Bringert Committed by The Android Open Source Project
Browse files

am 9fc2e9c9: MemoryFile constructor and native methods throw IOExceptions.

Merge commit '9fc2e9c9'

* commit '9fc2e9c9':
  MemoryFile constructor and native methods throw IOExceptions.
parents a38201d8 9fc2e9c9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -96978,6 +96978,8 @@
</parameter>
<parameter name="length" type="int">
</parameter>
<exception name="IOException" type="java.io.IOException">
</exception>
</constructor>
<method name="allowPurging"
 return="boolean"
+10 −9
Original line number Diff line number Diff line
@@ -37,15 +37,15 @@ public class MemoryFile
    private static String TAG = "MemoryFile";
 
    // returns fd
    private native int native_open(String name, int length);
    private static native int native_open(String name, int length) throws IOException;
    // returns memory address for ashmem region
    private native int native_mmap(int fd, int length);
    private native void native_close(int fd);
    private native int native_read(int fd, int address, byte[] buffer, 
            int srcOffset, int destOffset, int count, boolean isUnpinned);
    private native void native_write(int fd, int address, byte[] buffer, 
            int srcOffset, int destOffset, int count, boolean isUnpinned);
    private native void native_pin(int fd, boolean pin);
    private static native int native_mmap(int fd, int length) throws IOException;
    private static native void native_close(int fd);
    private static native int native_read(int fd, int address, byte[] buffer,
            int srcOffset, int destOffset, int count, boolean isUnpinned) throws IOException;
    private static native void native_write(int fd, int address, byte[] buffer,
            int srcOffset, int destOffset, int count, boolean isUnpinned) throws IOException;
    private static native void native_pin(int fd, boolean pin) throws IOException;

    private int mFD;        // ashmem file descriptor
    private int mAddress;   // address of ashmem memory
@@ -57,8 +57,9 @@ public class MemoryFile
     *
     * @param name optional name for the file (can be null).
     * @param length of the memory file in bytes.
     * @throws IOException if the memory file could not be created.
     */
    public MemoryFile(String name, int length) {
    public MemoryFile(String name, int length) throws IOException {
        mLength = length;
        mFD = native_open(name, length);
        mAddress = native_mmap(mFD, length);