• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Lock/Unlock function leaves phone active

Rob4077

Lurker
I used the Tasker function featured on this link (http://techaeris.com/2014/07/18/disable-androids-pin-code-home-tasker-android/) to create a Lock and Unlock function when in and out of a WiFi area. It works fine but when the Profile is Activated and the Task runs it leaves my phone active for the screen timeout duration which means the phone is illuminated and prone to random app launches or phone calls if the phone is bumped. I am therefore after suggestions to either introduce a safety lock or an alternative approach to achieve the desired result.

I am using a Samsung Galaxy Note 2 running Android 4.4.2
 
Welcome to Android Forums.

I am not sure what you are trying to do.

If the question is how to turn the screen off the answer is to use the standard Tasker action ... Screen Lock ... that will immediately turn the screen off.

... Thom
 
Have you made sure that Tasker is a device administrator? (Required for system lock)

In my phone this is under Settings > Security > Device Administrator
 
Yes that's the action.

Something I found out about after a year ...

The bottom of the screen says Filter. I thought it was a decoration. It Isn't. You can type on that line and Tasker will display the actions that contain that string in its name.You don;t have to memorize what Category each Action is in.

I don't know what "doesn't seem to work" means. Perhaps the suggestion from @sumotori is the answer.

... Thom
 
Where is the "Filter"? I only get " if" and "label".

Also, using system lock, the fingerprint sensor doesn't unlock my device and I get a prompt for me password.
 
Where is the "Filter"? I only get " if" and "label".

When you hit the + to pull up the Select Action Category screen there is a Filter line at the very bottom. Typing on that line will bring up actions from all categories that match. (Yes it was over a year before I found out about this one solving my biggest problem with Tasker in memorizing what category the action was in.)

... Thom
 
Oh, that! I've rarely used it because it would never show things properly.
Only much later I realized that the screen scaling has issues, and I needed to hide the keyboard to see the actions. :P
But indeed, it is very handy!
 
Yes my phone is set to give Tasker Administrator privileges. What happens is that when I get home the Task runs and removes the need for a PIN code. However it then leaves the screen illuminated and active. If I don't realise it then I end up opening apps etc. as the phone rubs against the side of the pocket. The Display>System Lock doesn't appear to have made any difference. I've now had to shorten the time the display stays active to reduce the risk of problems but it means I have to keep my finger on the screen whenever I try to read anything to stop it timing out.
 
Have you tried to run the "Display > System Lock" on its own and see what happens? Surely this should lock the phone while in Tasker?
Maybe you need a "Wait" before running that in your task? Also do a "Alert > Flash" some text to ensure the task reaches this point?

Export your task as a description (long press on the task > Export > Description in clipboard) and put it on here in case we can find something.
 
Ok, so I have tried creating the following Task. It beeps and both messages flash but it WON'Tt lock the Keypad.
When I go to Settings>Security>Device Administrator Tasker is ticked. If I long press on Tasker it said Administrator active. This allows Tasker to perform following operations: "Lock the screen" and the only options available are Cancel or Deactivate, so to me it appears everything is set up as it should be- but it just won't work

KeyguardOn (12)
A1: Flash [ Text:About to lock Long:Off ]
A2: Keyguard [ Set:On ]
A3: Beep [ Frequency:8000 Duration:1000 Amplitude:50 Stream:3 ]
A4: Flash [ Text:Locked Long:Off ]
 
Keyguard is likely not to work in recent Android versions due to changes in Android.
For me, running CM 13.0 (MM 6.0.1) the keyguard doesn't work either! Pent suggests to use "Secure Settings" instead of "Keyguard".

Try to use "System Lock" instead (not "Lock" but "System Lock"). This should lock your device. It is Located in "Display > System Lock".
 
I've been testing the suggested change for a week and it seems to have overcome the problem I was having, but has introduced a lesser nuisance. If I happen to be using the phone when the WiFi connection is going in and out, it locks my phone.

Is there a State that I can test to see if the phone is being used? It seems to me that if I save the state to a variable at the start of the Task that sets or removes the Password and then return to that state at the end of the Task it may overcome my new (lesser) problem.
 
It is not clear what you are saying you are currently running. Can you post it here?

One that I use is below. It dims the screen when the proximity sensor is triggered unless I am on a call ...

Profile: tlaProx (365)
State: Proximity Sensor
State: Not Call [ Type:Any Number:* ]
Enter: tlaProxEnter (293)
A1: System Lock

... Thom
 
Last edited:
What I've set up are Tasks that remove the requirement for a password when connected to WiFi and when not connected to WiFi the phone needs a password. What was happening was that when either Task ran it left the monitor active and the Keyguard command wasn't working. The help given above solved that problem by activating. system lock at the end of the Task. However now if I am say typing or reading a message, or surfing the net, when it runs, System Lock runs in the middle of my work
 
Ok so here's the WiFi Connected Profile. I set a couple of variables that will trigger an entry in my log. Then it runs the Task Unlock

WiFi Connected (38)
A1: Variable Set [ Name:%BluetoothTo To:Unknown Recurse Variables:Off Do Maths:Off Append:Off ]
A2: Variable Set [ Name:%TriggeredBy To:Wifi Connected Recurse Variables:Off Do Maths:Off Append:Off ]
A3: Perform Task [ Name:Unlock Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ]​


Following is the Unlock Task. It dims the screen for a second, Clears the password and locks the screen. Trouble is if I am working on the phone when this runs it locks the screen on me.

Unlock (11)
A1: Secure Settings [ Configuration:Screen Dim
1 Second Timeout (Seconds):0 ]
A2: Secure Settings [ Configuration:Clear Password Timeout (Seconds):0 ]
A3: System Lock​
 
On the Profiles screen you can long press on the profile name until it is highlighted.
You can then chose three-dots/export to export it. This will include the profile/entry task/exit task. Any called tasks would need to be exported separately.

If I had to guess ... my guess is that you need to do something like what I do in the following profile that monitors WiFi connection status ...

Profile: tlaWiFiState (690)
Enforce: no
State: Wifi Connected [ SSID:TLANET-2.4GHz/TLANET-5GHz MAC:* IP:* ]
Enter: tlaWiFiStateEnter (691)
A1: Wait [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ]
A2: Perform Task [ Name:tlaWiFiStateExitResult Priority:%priority Parameter 1 (%par1):WiFi - Enabled Parameter 2 (%par2):2 Return Value Variable: Stop:Off ]
Exit: tlaWiFiStateExit (692)
A1: Wait [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ]
A2: Perform Task [ Name:tlaWiFiStateExitResult Priority:%priority Parameter 1 (%par1):WiFi - Disabled Parameter 2 (%par2): Return Value Variable: Stop:Off ]

... Thom
 
Last edited:
Hi Thom, Thanks for the suggestion. How to I import your code so I can see what it looks like as I don't really see what your task is doing from the exported code?
 
You can;t import it from the description. It was an example and not a solution.

It would be helpful seeing how the Profile is defined that is involving the Tasks.

For my Profile you can see that it has an Entry Task and an Exit Task.

My GUESS is that you need a 2 sec wait.

... Thom
 
Hi Thom, sorry, I thought I had posted the Profile I use to trigger the task. Here it is. By way of explanation, first of all I set a few variables (%BluetoothTo; %TriggeredBy) that are then added to a log csv file whenever I connect or disconnect Bluetooth or WiFi and finally I Perform Task [ Name:Unlock

Profile: WiFi Connected (8)
Notification: no
State: Wifi Connected [ SSID:* MAC:* IP:* ]
Enter: WiFi Connected (38)
A1: Variable Set [ Name:%BluetoothTo To:Unknown Recurse Variables:Off Do Maths:Off Append:Off ]
A2: Variable Set [ Name:%TriggeredBy To:Wifi Connected Recurse Variables:Off Do Maths:Off Append:Off ]
A3: Perform Task [ Name:Unlock Priority:%priority Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: Stop:Off ]

The Tasm Unlock I perform is as follows.

Unlock (11)
A1: Secure Settings [ Configuration:Screen Dim
1 Second Timeout (Seconds):0 ]
A2: Secure Settings [ Configuration:Clear Password Timeout (Seconds):0 ]
A3: System Lock

As soon as I come home the Unlock task runs so I don't need to enter a PIN. Trouble is that e.g. if I walk in the front door while I am typing a message, all of a sudden the screen goes blank as the System Lock is executed. I can live with it because it's better than before I started this post, but it would be better if it didn't run System Lock if I the screen was unlocked when the task started
 
Notice that mine starts with a dumb 2 sec wait. Give it a try. Try even longer. This allows all the elements to have chance to sync before a decision is made.

This is the most counterintuitive area that I ever played with.

I have a profile that disables WiFi on my phone when I am out of range of my router. When I come back into range it enables WiFi for an automatic sync. That one uses a 1 min wait.

... Thom
 
What Tasker plug-in are you using ...
Screen Dim
Clear Password Timeout

I installed the Secure Settings plug-in and could not find either of them.

... Thom
 
Last edited:
I do not follow what your profile is doing. To help (I hope) I suggest you install the following Profile and enable it. Then toggle Airplane Mode a few times. It will demonstrate when the Tasks are being executed.

Profile: BeepBeep (775)
State: Wifi Connected [ SSID:* MAC:* IP:* ]
Enter: Anon (776)
A1: Beep [ Frequency:8000 Duration:1000 Amplitude:50 Stream:3 ]
Exit: Anon (777)
A1: Beep [ Frequency:8000 Duration:1000 Amplitude:50 Stream:3 ]
A2: Beep [ Frequency:8000 Duration:1000 Amplitude:50 Stream:3 ]

... Thom
 
Back
Top Bottom