debracey
debracey

Reputation: 6597

Determining Android VPN Interface/IP?

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:

  1. Do it by name (ie. if Android gave me a list that had "ppp1" in it I could eliminate ppp1, since the Android list does not ever contain the VPN)
  2. Do it by IP (ie. if I could figure out the VZ IP address, I could eliminate the interface with that IP using Java's NetworkInterface object.)

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.

Upvotes: 5

Views: 8105

Answers (2)

ajpyles
ajpyles

Reputation: 628

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.

Upvotes: 1

debracey
debracey

Reputation: 6597

Found out this is not possible using the current API (10). Bug Report/Feature Request:

http://code.google.com/p/android/issues/detail?id=15082

Upvotes: 0

Related Questions