So far:
I found the following solutions
The broadcast receiver is deprecated from ICS
It's definitely going to take lots of time and its not efficient
Polling for DNS server changes
It's definitely going to take lots of time and its not efficient
Even though it won't take much time depending on the network connection it may vary
My conclusion:
So far all the solutions I found are either not efficient or not so reliable.
My questions:
If VPN is connected in android device then android OS must be aware of it.
Are there any public android framework APIs to read it because finding it locally is most efficient and reliable solution ?
Are there any other efficient and reliable ways to achieve it (like integrating a C or C plus plus library with NDK)?
Note:
I couldn't find any custom broadcast senders/AIDL from OpenVPN for Android as well
You can try to check for tun0 INTERFACE, It is being start afther the establish command.
try {
for( NetworkInterface intf : Collections.list(NetworkInterface.getNetworkInterfaces())) {
// Pass over dormant interfaces
if(!intf.isUp() || intf.getInterfaceAddresses().size() == 0)
continue;
if ("tun0".equals(intf.getName())){
// The VPN is up
break;
}
}
}
this also might work:
(Collections.list(NetworkInterface.getByName("tun0")