File descriptor file descriptor FileDescriptor (as int) in Android

Is there a way to get a system file descriptor (socket or file number as int) from an Android FileDescriptor object? I would like to access the file descriptor directly in the JNI code without using any Java wrappers.

Edit: I found getParcelFileDescriptorFD and that FileDescriptor has an int field named "handle", an example of use is in media/jni/android_media_MediaPlayer.cpp, the definition of func is in frameworks/base/core/jni/android_util_Binder.cpp, the field itself is inlibcore/luni/src/main/java/java/io/FileDescriptor.java

But this is not part of the official documentary API. Is there a documented “right” way to do this?

+3
source share
1 answer

dalvik/libcore/ jniGetFDFromFileDescriptor java_io_FileDescriptor.c, , API. , , . JNI - , !

:

  • - Java, .

  • - ( -), - : open (2) - , fd int, FileDescriptor, - Java, int ( -, ).

Android, .

+5

Source: https://habr.com/ru/post/1729701/


All Articles