Form an "intent" to disconnect/connect to specific profile
-
- OpenVpn Newbie
- Posts: 1
- Joined: Mon Jun 10, 2013 12:31 pm
Form an "intent" to disconnect/connect to specific profile
Through Tasker/Llama it's possible to craft an intent that basically can mimic the Shortcut that the OpenVPN app can create on the home screen. However, looking here http://android.stackexchange.com/questi ... internally the best answer to find out these intents really is to ask the developer. Or users.
To that end - does anybody know offhand the class/intents/actions needed to:
[*]connect to a profile, and
[*]disconnect
Llama (I'm sure Tasker is similar) asks for:
[*]Package name
[*]Class name
[*]Action
[*]Categories
[*]Data
[*]Data type
[*]Any extras...
This will then be used to connect/disconnect based on the wifi network connected.
Thanks for any help offered!
To that end - does anybody know offhand the class/intents/actions needed to:
[*]connect to a profile, and
[*]disconnect
Llama (I'm sure Tasker is similar) asks for:
[*]Package name
[*]Class name
[*]Action
[*]Categories
[*]Data
[*]Data type
[*]Any extras...
This will then be used to connect/disconnect based on the wifi network connected.
Thanks for any help offered!
-
- OpenVpn Newbie
- Posts: 3
- Joined: Mon Aug 12, 2013 2:53 pm
Re: Form an "intent" to disconnect/connect to specific profi
If you use Tasker's AutoShortcut plugin (separate install from the Play Store) or if your launcher supports shortcuts from "activities" (like Nova Launcher). You can see that there are 3 intents built into the OpenVPN Connect app: OpenVPNClient, OpenVPNAttachmentReceiver, and OpenVPNDisconnect.
OpenVPNDisconnect works just like the Disconnect homescreen shortcut you can make from inside the OpenVPN Connect app. But I don't know how to use the Client and AttachmentReceiver intents. They just seem to open the OpenVPN Connect app.
I really wish I could get Tasker to start a specific profile like the homescreen shortcut that the OpenVPN Connect app is capable of making. But I don't know how to build the intent like the shortcut, or even inspect the shortcut to copy its target. And Tasker doesn't seem capable of using already made shortcuts.
Hopefully some one with more knowledge chimes in and gives with more details.
OpenVPNDisconnect works just like the Disconnect homescreen shortcut you can make from inside the OpenVPN Connect app. But I don't know how to use the Client and AttachmentReceiver intents. They just seem to open the OpenVPN Connect app.
I really wish I could get Tasker to start a specific profile like the homescreen shortcut that the OpenVPN Connect app is capable of making. But I don't know how to build the intent like the shortcut, or even inspect the shortcut to copy its target. And Tasker doesn't seem capable of using already made shortcuts.
Hopefully some one with more knowledge chimes in and gives with more details.
-
- OpenVpn Newbie
- Posts: 3
- Joined: Mon Aug 12, 2013 2:53 pm
Re: Form an "intent" to disconnect/connect to specific profi
Here is the (sanitized) corresponding logcat when I start the OpenVPN Connect homescreen shortcut for the "my.server.com [My Server]" connection. There's more, but its D/OpenVPNService stuff, nothing more from D/OpenVPNClient.
I tried building a Send Intent in Tasker from the first android.intent.action.VIEW line, but it didn't work. I don't know what extras need to get sent.
Code: Select all
08-12 11:18:17.004 I/ActivityManager(334): START u0 {act=android.intent.action.VIEW flg=0x10800000 cmp=net.openvpn.openvpn/.OpenVPNClient bnds=[999,999][999,999] (has extras)} from pid 10534
08-12 11:18:17.308 D/OpenVPNClient(27152): CLI: onCreate intent=Intent { act=android.intent.action.VIEW flg=0x10800000 cmp=net.openvpn.openvpn/.OpenVPNClient bnds=[999,999][999,999] (has extras) }
08-12 11:18:17.511 D/OpenVPNClient(27152): CLI: onStart
08-12 11:18:17.527 D/OpenVPNClientBase(27152): CLIBASE: onServiceConnected: net.openvpn.openvpn.OpenVPNService@99999a99
08-12 11:18:17.527 D/OpenVPNService(27152): SERV: client attach n_clients=1
08-12 11:18:17.527 D/OpenVPNClient(27152): CLI: post bind
08-12 11:18:17.527 D/OpenVPNClient(27152): CLI: autostart: my.server.com [My Server]
08-12 11:18:17.547 D/PrefUtil(27152): get_string: vpn_proto='adaptive'
08-12 11:18:17.547 D/OpenVPNService(27152): SERV: client attach n_clients=1
08-12 11:18:17.550 D/OpenVPNClientBase(27152): CLI: submitConnectIntent: my.server.com [My Server]
08-12 11:18:17.652 D/OpenVPNService(27152): SERV: onStartCommand action=net.openvpn.openvpn.CONNECT
-
- OpenVpn Newbie
- Posts: 2
- Joined: Sun Sep 22, 2013 12:28 pm
Re: Form an "intent" to disconnect/connect to specific profi
Has any progress been made on this?
I too have been able to make the client disconnect and open, but unable to find the extras needed to actually make it auto-connect.
I too have been able to make the client disconnect and open, but unable to find the extras needed to actually make it auto-connect.
-
- OpenVpn Newbie
- Posts: 2
- Joined: Sun Sep 22, 2013 12:28 pm
Re: Form an "intent" to disconnect/connect to specific profi
Well, this is typical... I spend over an hour looking for a solution, to then find it almost immediately after posting here...
The extras column needs to be thus:
net.openvpn.openvpn.AUTOSTART_PROFILE_NAME: yourserver.com [clientname]
for example:
net.openvpn.openvpn.AUTOSTART_PROFILE_NAME: me.example.com [client123]
I now have tasker automatically connect to my OpenVPN server when I need it to, and the OpenVPN app gets out of the way when it's all done. Perfect.
The extras column needs to be thus:
net.openvpn.openvpn.AUTOSTART_PROFILE_NAME: yourserver.com [clientname]
for example:
net.openvpn.openvpn.AUTOSTART_PROFILE_NAME: me.example.com [client123]
I now have tasker automatically connect to my OpenVPN server when I need it to, and the OpenVPN app gets out of the way when it's all done. Perfect.
- 99AirBalloons
- OpenVpn Newbie
- Posts: 4
- Joined: Tue Feb 05, 2013 8:01 pm
Re: Form an "intent" to disconnect/connect to specific profi
Ribs - could you provide (sanitised) screen captures or similar of your working config. That would help a lot.
Thanks
Thanks
-
- OpenVpn Newbie
- Posts: 1
- Joined: Wed Oct 09, 2013 8:57 am
Re: Form an "intent" to disconnect/connect to specific profi
I thank you all for the information. This is the only search result I could find on the topic as of 2013/10/08. I'm definitely a noob to Android internals. The main issue I had is that I kept using the short class names rather than the fully-qualified class names, e.g. OpenVPNDisconnect instead of net.openvpn.openvpn.OpenVPNDisconnect.
Here is what I figured out with Tasker after several hours of attention deficit-afflicted fiddling, searching, etc...
VPN profile name, as shown in OpenVPN Connect: example.com/autologin
In the steps below, replace this with your own profile name.
For fields with no listed value here, leave the Tasker field blank (shows as "Optional").
In the first Extra field in the "To Connect" procedure below, the colon and everything in bold is written as intended.
To Connect:
* Misc > Send Intent
* Misc > Send Intent
OpenVPN Connect version: 1.1.12
Tasker version: 4.1u3
Android version: 4.1.2
Utilities involved in figuring this out (not required; not an endorsement):
Here is what I figured out with Tasker after several hours of attention deficit-afflicted fiddling, searching, etc...
VPN profile name, as shown in OpenVPN Connect: example.com/autologin
In the steps below, replace this with your own profile name.
For fields with no listed value here, leave the Tasker field blank (shows as "Optional").
In the first Extra field in the "To Connect" procedure below, the colon and everything in bold is written as intended.
To Connect:
* Misc > Send Intent
- * Action: android.intent.action.VIEW
* Cat: None
* Mime Type:
* Data:
* Extra: net.openvpn.openvpn.AUTOSTART_PROFILE_NAME: example.com/autologin
* Extra:
* Package: net.openvpn.openvpn
* Class: net.openvpn.openvpn.OpenVPNClient
* Target: Activity
* Misc > Send Intent
- * Action: android.intent.action.VIEW
* Cat: None
* Mime Type:
* Data:
* Extra:
* Extra:
* Package: net.openvpn.openvpn
* Class: net.openvpn.openvpn.OpenVPNDisconnect
* Target: Activity

OpenVPN Connect version: 1.1.12
Tasker version: 4.1u3
Android version: 4.1.2
Utilities involved in figuring this out (not required; not an endorsement):
- xShortcut Free reminded me about using fully-qualified class names, which was very helpful for me, but other than that, it wasn't necessary.
aLogcat would have been even more helpful if starting from scratch. It let me know some basic information about intents, all of which is listed in this thread, once I used TitaniumBackup to convert it to a system app. (Until then, it didn't really work.)
aapt, a PC utility, through a procedure described on Tasker's Intents page (http://tasker.dinglisch.net/userguide/en/intents.html), allowed me to process the OpenVPN Connect .apk to dig deeper into these things, but I didn't gain any useful insight from it in this case. It is part of android-apktool and is available here: https://code.google.com/p/android-apktool/
- 99AirBalloons
- OpenVpn Newbie
- Posts: 4
- Joined: Tue Feb 05, 2013 8:01 pm
Re: Form an "intent" to disconnect/connect to specific profi
Thanks tw, that was exactly what I needed.
-
- OpenVpn Newbie
- Posts: 3
- Joined: Mon Aug 12, 2013 2:53 pm
Re: Form an "intent" to disconnect/connect to specific profi
Thanks so much to you guys that solved this for me. I FINALLY got it working!
-
- OpenVpn Newbie
- Posts: 5
- Joined: Fri Feb 28, 2014 5:06 pm
Re: AW: Form an "intent" to disconnect/connect to specific p
Could somebody please tell me how to do so for Llama? I can't figure it out unfortunately :/
-
- OpenVpn Newbie
- Posts: 1
- Joined: Mon May 26, 2014 7:16 am
Re: Form an "intent" to disconnect/connect to specific profi
Hi Guys,
I've tried to use the configuration from tw to build an intent which should be fired from my own app. Funnily the approach with xShortcut Free did't worked for me, too.
Here's the Code that only opens the OpenVPN app without autoconnect...
Thanks for all help!
I've tried to use the configuration from tw to build an intent which should be fired from my own app. Funnily the approach with xShortcut Free did't worked for me, too.
Here's the Code that only opens the OpenVPN app without autoconnect...
Code: Select all
Intent openVPN = new Intent("android.intent.action.VIEW");
openVPN.setPackage("net.openvpn.openvpn");
openVPN.putExtra("net.openvpn.openvpn.AUTOSTART_PROFILE_NAME", "myServer/autologin");
startActivityForResult(openVPN, 0);
-
- OpenVpn Newbie
- Posts: 3
- Joined: Mon Oct 05, 2015 4:54 pm
Re: Form an "intent" to disconnect/connect to specific profi
I am attempting to use this approach on my phone, but while I was able to get the disconnect to work I am failing with the connect case. I am using Private Tunnel with OpenVPN Connect, so I am working with an ovpn file and the name shows in the OpenVPN Connect app as "Private Tunnel[New York]" with my username noted below it. In the profile I see an entry similar to the above example, "OVPN_ACCESS_SERVER_PROFILE={my_email_address}@us-ny-ny-001.privatetunnel.com/AUTOLOGIN" and I tried entering this starting with my email address in the extra field with no success. I also tried leaving out the extra field and nothing happens.tw wrote:I thank you all for the information. This is the only search result I could find on the topic as of 2013/10/08. I'm definitely a noob to Android internals. The main issue I had is that I kept using the short class names rather than the fully-qualified class names, e.g. OpenVPNDisconnect instead of net.openvpn.openvpn.OpenVPNDisconnect.
Here is what I figured out with Tasker after several hours of attention deficit-afflicted fiddling, searching, etc...
VPN profile name, as shown in OpenVPN Connect: example.com/autologin
In the steps below, replace this with your own profile name.
For fields with no listed value here, leave the Tasker field blank (shows as "Optional").
In the first Extra field in the "To Connect" procedure below, the colon and everything in bold is written as intended.
To Connect:
* Misc > Send IntentTo Disconnect:
- * Action: android.intent.action.VIEW
* Cat: None
* Mime Type:
* Data:
* Extra: net.openvpn.openvpn.AUTOSTART_PROFILE_NAME: example.com/autologin
* Extra:
* Package: net.openvpn.openvpn
* Class: net.openvpn.openvpn.OpenVPNClient
* Target: Activity
* Misc > Send IntentNow, I have a profile set up to connect to my VPN when *not* connected to my home WiFi, and otherwise, to disconnect.
- * Action: android.intent.action.VIEW
* Cat: None
* Mime Type:
* Data:
* Extra:
* Extra:
* Package: net.openvpn.openvpn
* Class: net.openvpn.openvpn.OpenVPNDisconnect
* Target: Activity
OpenVPN Connect version: 1.1.12
Tasker version: 4.1u3
Android version: 4.1.2
Utilities involved in figuring this out (not required; not an endorsement):
- xShortcut Free reminded me about using fully-qualified class names, which was very helpful for me, but other than that, it wasn't necessary.
aLogcat would have been even more helpful if starting from scratch. It let me know some basic information about intents, all of which is listed in this thread, once I used TitaniumBackup to convert it to a system app. (Until then, it didn't really work.)
aapt, a PC utility, through a procedure described on Tasker's Intents page (http://tasker.dinglisch.net/userguide/en/intents.html), allowed me to process the OpenVPN Connect .apk to dig deeper into these things, but I didn't gain any useful insight from it in this case. It is part of android-apktool and is available here: https://code.google.com/p/android-apktool/
Does anyone else have this working with Private Tunnel? This is on an LG Intuition VS-950 Jelly Bean phone with the current OpenVPN Connect app and the current Tasker app.
Dave