Let's make sure I understand the flow of what you are trying to do:
1. Android device connects to a WiFi network, whether it is secure or not.
2. Upon connect, a Tasker profile fires.
3. The child task checks if the new WiFi connection is secure.
3a. If no, the task connects to a VPN.
3b. If yes, Tasker retains the connection without further action.
Do I have that correct?
I haven't forgotten you.
For the life of me, I can't figure out why this is so hard without using just a couple of activities, but, alas it is.
I'm currently working on a task for you. The task will --
(1) Grab the name (ssid) of the network you are on.
(2) Determine if the network implements either WAP and/or WAP2.
(3) Return a variable telling you if the network is secure or not. (If you need, I can include the the network's other available security protocols.)
One thing I'm not understanding, tho. If you are connected to a secure network, doesn't that mean you know its secure because you had to set up the connection?
If that is the case, do you really need this task to throw a warning when connected to an unsecure network rather than just telling you if your current network is / isn't secure? (Android does that natively whenever you connect to an unsecured neywork.) If so, how would you like the task to execute, (1) via a profile that fires when you connect to a wifi network or (2) when you call the task internally from another task?
Think of the two options this way.
Option 1
Profile -- Connect to a Wifi Network
Run Task: Check Network Security
--or --
Option 2
A1: <<Perform an activity>>
A2: <<Perform the next activity>>
A3: Perform Task - Check Network Security
A4: <<Perform another activity>>
I'm happy to set it any way you want it.
As for the reason I'm not done with this yet, I am trying to sort through a quirk in the data pulled by one of the addons I am using - AutoTools.
Subtle hint, there - you'll want to go download AutoTools from the app store, if you don't already have it. You'll need it to run the task I am building.
And when I get this thing all worked out, I promise to walk you through it.
Any tips?
Nice idea, it could be a useful addition to a project I have been working on.
After testing I found the best way to determine if a networks secure is to use key management on a device configured network.
Java - getConfigNets - isSecure (555)
A1: Test Net [ Type:Wifi SSID Data: Store Result In:%conssid ]
A2: If [ %conssid !~ <*> & %conssid Set ]
A3: Java Function [ Return:wifiser Class Or Object:CONTEXT Function:getSystemService
{Object} (String) Param:wifi Param: Param: Param: Param: Param: Param: Continue Task After Error:On ]
A4: Java Function [ Return:configlist Class Or Object:wifiser Function:getConfiguredNetworks
{List}() Param: Param: Param: Param: Param: Param: Param: ]
A5: Java Function [ Return:%size Class Or Object:configlist Function:size
{int} () Param:ssid Param: Param: Param: Param: Param: Param: ]
A6: Variable Subtract [ Name:%size Value:1 Wrap Around:0 ]
A7: For [ Variable:%idx Items:0:%size ]
A8: Java Function [ Return:network Class Or Object:configlist Function:get
{Object} (int) Param:%idx Param: Param: Param: Param: Param: Param: ]
A9: Java Function [ Return:%ssid Class Or Object:network.SSID Function:toString
{String} () Param: Param: Param: Param: Param: Param: Param: ]
A10: If [ %ssid eq "%conssid" ]
<allowedKeyManagement>
A11: Java Function [ Return:%allwdkeymgmt Class Or Object:network.allowedKeyManagement Function:toString
{String} () Param: Param: Param: Param: Param: Param: Param: ]
A12: End If
A13: End For
A14: If [ %allwdkeymgmt ~ *0* ]
A15: Flash [ Text:Network Not Secure Long:Off ]
A16: Else
A17: Flash [ Text:Network Secure Long:Off ]
A18: End If
A19: Else
A20: Flash [ Text:Wifi SSID Unavailable Long:Off ]
A21: End If
The task will display not secure if there is no security or only WEP (likely due to wep being cracked). Otherwise it will return secure.
You should run the code once the network is connected, so in your 'connected' enter Task.
The pattern match on the integer is because my device returns the value in curly brackets {}.
Thanks a lot for the task you created. Now I have a total n00b
question: Is there a way to import that task into Tasker? Or do I need
it in XML format? If so, could you send me the XML?
I'll post the xml (need to be at my computer).
PS: How did you create the task? Seems very tedious to manually create
those Java Functions. Is there a simpler/better way than typing them
into Tasker's UI?
Not that I know of. It's a short task after a bit of practice you'll be upto speed!
How you connect to VPN? Is it work VPN or something else like OpenVPN.
This could be quite helpful.
The ScanResult object exposes the capabilities field which should contain all of these. Adding a regex match field for this to the WiFi related dialogues will also make this easier to use.