Loading core/java/android/os/MemoryFile.java +6 −7 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ public class MemoryFile private static native void native_write(FileDescriptor fd, int address, byte[] buffer, int srcOffset, int destOffset, int count, boolean isUnpinned) throws IOException; private static native void native_pin(FileDescriptor fd, boolean pin) throws IOException; private static native int native_get_mapped_size(FileDescriptor fd) throws IOException; private static native int native_get_size(FileDescriptor fd) throws IOException; private FileDescriptor mFD; // ashmem file descriptor private int mAddress; // address of ashmem memory Loading Loading @@ -300,20 +300,19 @@ public class MemoryFile * @hide */ public static boolean isMemoryFile(FileDescriptor fd) throws IOException { return (native_get_mapped_size(fd) >= 0); return (native_get_size(fd) >= 0); } /** * Returns the size of the memory file, rounded up to a page boundary, that * the file descriptor refers to, or -1 if the file descriptor does not * refer to a memory file. * Returns the size of the memory file that the file descriptor refers to, * or -1 if the file descriptor does not refer to a memory file. * * @throws IOException If <code>fd</code> is not a valid file descriptor. * * @hide */ public static int getMappedSize(FileDescriptor fd) throws IOException { return native_get_mapped_size(fd); public static int getSize(FileDescriptor fd) throws IOException { return native_get_size(fd); } /** Loading core/jni/android_os_MemoryFile.cpp +3 −5 Original line number Diff line number Diff line Loading @@ -30,8 +30,6 @@ static jobject android_os_MemoryFile_open(JNIEnv* env, jobject clazz, jstring na { const char* namestr = (name ? env->GetStringUTFChars(name, NULL) : NULL); // round up length to page boundary length = (((length - 1) / getpagesize()) + 1) * getpagesize(); int result = ashmem_create_region(namestr, length); if (name) Loading Loading @@ -118,7 +116,7 @@ static void android_os_MemoryFile_pin(JNIEnv* env, jobject clazz, jobject fileDe } } static jint android_os_MemoryFile_get_mapped_size(JNIEnv* env, jobject clazz, static jint android_os_MemoryFile_get_size(JNIEnv* env, jobject clazz, jobject fileDescriptor) { int fd = jniGetFDFromFileDescriptor(env, fileDescriptor); // Use ASHMEM_GET_SIZE to find out if the fd refers to an ashmem region. Loading Loading @@ -146,8 +144,8 @@ static const JNINativeMethod methods[] = { {"native_read", "(Ljava/io/FileDescriptor;I[BIIIZ)I", (void*)android_os_MemoryFile_read}, {"native_write", "(Ljava/io/FileDescriptor;I[BIIIZ)V", (void*)android_os_MemoryFile_write}, {"native_pin", "(Ljava/io/FileDescriptor;Z)V", (void*)android_os_MemoryFile_pin}, {"native_get_mapped_size", "(Ljava/io/FileDescriptor;)I", (void*)android_os_MemoryFile_get_mapped_size} {"native_get_size", "(Ljava/io/FileDescriptor;)I", (void*)android_os_MemoryFile_get_size} }; static const char* const kClassPathName = "android/os/MemoryFile"; Loading graphics/java/android/graphics/BitmapFactory.java +1 −1 Original line number Diff line number Diff line Loading @@ -532,7 +532,7 @@ public class BitmapFactory { public static Bitmap decodeFileDescriptor(FileDescriptor fd, Rect outPadding, Options opts) { try { if (MemoryFile.isMemoryFile(fd)) { int mappedlength = MemoryFile.getMappedSize(fd); int mappedlength = MemoryFile.getSize(fd); MemoryFile file = new MemoryFile(fd, mappedlength, "r"); InputStream is = file.getInputStream(); Bitmap bm = decodeStream(is, outPadding, opts); Loading Loading
core/java/android/os/MemoryFile.java +6 −7 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ public class MemoryFile private static native void native_write(FileDescriptor fd, int address, byte[] buffer, int srcOffset, int destOffset, int count, boolean isUnpinned) throws IOException; private static native void native_pin(FileDescriptor fd, boolean pin) throws IOException; private static native int native_get_mapped_size(FileDescriptor fd) throws IOException; private static native int native_get_size(FileDescriptor fd) throws IOException; private FileDescriptor mFD; // ashmem file descriptor private int mAddress; // address of ashmem memory Loading Loading @@ -300,20 +300,19 @@ public class MemoryFile * @hide */ public static boolean isMemoryFile(FileDescriptor fd) throws IOException { return (native_get_mapped_size(fd) >= 0); return (native_get_size(fd) >= 0); } /** * Returns the size of the memory file, rounded up to a page boundary, that * the file descriptor refers to, or -1 if the file descriptor does not * refer to a memory file. * Returns the size of the memory file that the file descriptor refers to, * or -1 if the file descriptor does not refer to a memory file. * * @throws IOException If <code>fd</code> is not a valid file descriptor. * * @hide */ public static int getMappedSize(FileDescriptor fd) throws IOException { return native_get_mapped_size(fd); public static int getSize(FileDescriptor fd) throws IOException { return native_get_size(fd); } /** Loading
core/jni/android_os_MemoryFile.cpp +3 −5 Original line number Diff line number Diff line Loading @@ -30,8 +30,6 @@ static jobject android_os_MemoryFile_open(JNIEnv* env, jobject clazz, jstring na { const char* namestr = (name ? env->GetStringUTFChars(name, NULL) : NULL); // round up length to page boundary length = (((length - 1) / getpagesize()) + 1) * getpagesize(); int result = ashmem_create_region(namestr, length); if (name) Loading Loading @@ -118,7 +116,7 @@ static void android_os_MemoryFile_pin(JNIEnv* env, jobject clazz, jobject fileDe } } static jint android_os_MemoryFile_get_mapped_size(JNIEnv* env, jobject clazz, static jint android_os_MemoryFile_get_size(JNIEnv* env, jobject clazz, jobject fileDescriptor) { int fd = jniGetFDFromFileDescriptor(env, fileDescriptor); // Use ASHMEM_GET_SIZE to find out if the fd refers to an ashmem region. Loading Loading @@ -146,8 +144,8 @@ static const JNINativeMethod methods[] = { {"native_read", "(Ljava/io/FileDescriptor;I[BIIIZ)I", (void*)android_os_MemoryFile_read}, {"native_write", "(Ljava/io/FileDescriptor;I[BIIIZ)V", (void*)android_os_MemoryFile_write}, {"native_pin", "(Ljava/io/FileDescriptor;Z)V", (void*)android_os_MemoryFile_pin}, {"native_get_mapped_size", "(Ljava/io/FileDescriptor;)I", (void*)android_os_MemoryFile_get_mapped_size} {"native_get_size", "(Ljava/io/FileDescriptor;)I", (void*)android_os_MemoryFile_get_size} }; static const char* const kClassPathName = "android/os/MemoryFile"; Loading
graphics/java/android/graphics/BitmapFactory.java +1 −1 Original line number Diff line number Diff line Loading @@ -532,7 +532,7 @@ public class BitmapFactory { public static Bitmap decodeFileDescriptor(FileDescriptor fd, Rect outPadding, Options opts) { try { if (MemoryFile.isMemoryFile(fd)) { int mappedlength = MemoryFile.getMappedSize(fd); int mappedlength = MemoryFile.getSize(fd); MemoryFile file = new MemoryFile(fd, mappedlength, "r"); InputStream is = file.getInputStream(); Bitmap bm = decodeStream(is, outPadding, opts); Loading