Closed black-binary closed 3 years ago
The way Android creates the tun device is different from Linux. The app developer needs to pop up a window (VpnService.prepare()
) asking users for permissions. And then invoke VpnService.Builder.establish()
to request ART to create a tun device and obtain the fd.
The process of creating tun in Android needs to be written in Java instead of native code. Creating a tun device directly, like what linux::new
does, will result in an error. So I prefer to implement a new module for Android. :)
Makes sense! Just need to verify the note I left then.
AsyncDevice supported?
I added a module
android
by simply copying the code and renaming the structs from theios
module, and it works well on my Android 10 device.VpnService.builder
in Android works like iOS (#21). The tunnel device's file descriptor can be created in Java code and then be passed to the native Rust code.