Page 1 of 1
status vpn verbunden abfragen ?
Posted: 02 Aug 2018 11:15
by joeko
hallo,
kann ich den Status der vpn Verbindung abfragen um davon weitere flows ausführen zu lassen ?
Re: status vpn verbunden abfragen ?
Posted: 29 Dec 2019 12:57
by schuster666
Ich würde mich da anschließen wollen.
Durch ein Datenleck (bei Win10) bin ich auf dieses Thema aufmerksam geworden und würde gerne checken ob das VPN (Android) in Betrieb ist oder nicht.
Könnte man alternativ abfragen welche Symbole in der Statusleiste angezeigt werden?
Re: status vpn verbunden abfragen ?
Posted: 01 Jan 2020 12:58
by Desmanto
It seems somehow I missed this post from 2018. Maybe because translation failed at that time.
You can detect the network config and check if tunneling interface is in use. use action execute command
If the stdout show something, then tunneling is in use, VPN is connected. But if blank, then no VPN connected. Check it using expression
If true, then stdout not blank, VPN Connected. If false, stdout is empty, tunneling interface not detected, VPN is not connected.
Re: status vpn verbunden abfragen ?
Posted: 01 Jan 2020 14:18
by anuraag
anuraag wrote: ↑13 Apr 2019 08:38
Below code works on my oreo. vpnconnected will return true or false
Code: Select all
ctx=getContext();
cm=callJavaMethod(ctx, "android.content.Context", "getSystemService(java.lang.String)", "connectivity");
vpnconnected=callJavaMethod(callJavaMethod(cm, "android.net.ConnectivityManager", "getNetworkInfo(int)", getJavaStaticField("android.net.ConnectivityManager", "TYPE_VPN")), "android.net.NetworkInfo", "isConnectedOrConnecting()");
Re: status vpn verbunden abfragen ?
Posted: 04 Jan 2020 01:22
by Horschte
Thank you for both approaches Desmanto and anuraag.
But in my tests the java way is much faster than the execute command action:
java: about 5 ms
execute command: about 100 ms
Re: status vpn verbunden abfragen ?
Posted: 04 Jan 2020 12:36
by Desmanto
@anuraag : Thank you always for the java code. I wish i really spent my time to learn java properly.
@Horschte : Thanks for the testing. So in most cases, when speed is important, calling java method is always preferred than using terminal emulator command. But this seems only happen in Automagic, as maybe for the action execute command (and root command), Automagic need to setup the environment first before executing the command. While script is already built-in.
Re: status vpn verbunden abfragen ?
Posted: 06 Jan 2020 05:38
by schuster666
Thank you all.
With this script/code all of my flows working perfekt.
Coding Java is next on my todo List.
I'm always very impressed about the possibilitys.
In hope that my mind will do the trick…..