java - Determining Android VPN Interface/IP? -
i'm trying determine name of pptp vpn interface in android can list bind-able interface in application. since there no vpn api in android -- figured use straight java find it.
when standard java list of interfaces, ie.
arraylist<networkinterface> allinterfaces = collections.list(networkinterface.getnetworkinterfaces());
i see few interesting things:
when phone on 802.11x wifi
- tiwlan0 (the wifi interface)
- ppp0 (the vpn)
when phone on verizon only
- ppp0 (the vpn, usually)
- ppp1 (the vz network, usually)
so - need way eliminate vz interface. can networkinfo objects android api this:
connectivitymanager conman = (connectivitymanager)this.getsystemservice(context.connectivity_service); networkinfo[] infolist = conman.getallnetworkinfo();
there few problems method:
- the vpn doesn't show up
- the names/fields in network info objects don't correspond in java networkinterface object
the way see there's few ways eliminate vz interface interfaces list:
- do name (ie. if android gave me list had "ppp1" in eliminate ppp1, since android list not ever contain vpn)
- do ip (ie. if figure out vz ip address, eliminate interface ip using java's networkinterface object.)
unfortunately, doesn't either of options possible since names don't match , can't figure out how vz ip android os.
so -- has else tried similar? there way ask android os interfaces have ip addresses?
thanks in advance -- appreciated.
dan
ps. i'm trying avoid forcing user input valid ip range (or specific ip) bind to.
edit: 1 possible option here jni system calll android native kit. read directory listing of /dev/ , grep ppp*. assume earliest 1 3g/4g connection , latter 1 vpn.
Comments
Post a Comment