I'm trying to determine the name of a PPTP VPN interface in android so I can list it as a bind-able interface in my application. Since there is no VPN API to do that in Android -- I figured I could use straight Java to find it.
When I do your standard Java to get the list of interfaces, ie.
ArrayList<NetworkInterface> allInterfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
I see a few interesting things:
When phone is on 802.11X Wifi
When the phone is on Verizon Only
So - I need a way to eliminate the VZ interface. You can get NetworkInfo objects from the Android API like this:
ConnectivityManager conMan = (ConnectivityManager)this.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo[] infoList = conMan.getAllNetworkInfo();
There are a few problems with that method:
The way I see it there's a few ways to eliminate the VZ interface from the all interfaces list:
Unfortunately, it doesn't look like either of those options are possible since the names don't match up and I can't figure out how to get the VZ IP from the Android OS.
So -- has anyone else tried something similar? Is there some way to ask the android OS what interfaces have IP addresses?
Thanks in advance -- all help is appreciated.
Dan
PS. I'm trying to avoid forcing the user to input a valid IP range (or specific IP) to bind to.
EDIT: One possible option here is to do a JNI system calll with the android native kit. Read the directory listing of /dev/ and grep for ppp*. Assume the earliest one is the 3G/4g connection and the latter one is the VPN.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With