[FIX] Tasker and the pattern lock

Search This thread

terranim

Member
Nov 9, 2009
31
34
blog.teadriven.me.uk
One of the things that I wanted to use Tasker for was enable the pattern lock when I was away from home and then disable it at home. Unfortunately due to recent changes in the Android SDK that is no longer possible with Tasker directly.

With a bit of searching I discovered the Secure Settings plugin which can be installed to /system/app and thereby provide Tasker with the functionality. However, it seems that Secure Settings does not work on the Galaxy S2 because Samsung have their own pattern lock and method of controlling it.

I started doing a bit of digging (mainly using logcat to see what the system was doing when the pattern lock was enabled/disabled via the Location and security settings menu). I discovered that the Samsung lock system is controlled by some files in /efs and with a bit of experimentation I was able to enable/disable the pattern lock via a root shell. I contacted the author of Secure Settings who suggested I use the Locale Execute plugin to run shell commands via Tasker.

So I present here the commands I am now using on my phone and hopefully they will be of some use to others. The commands include a check that should ensure that it does not attempt to enable the pattern lock when no pattern has been set, but this has not been fully tested!

WARNING: These commands require root access and you use them at your own risk!

Make sure to install the Locale Execute plugin first and then to enable the pattern lock with a task simply add a new "Plugin/Execute" action and set the contents to:
Code:
@! if [ "`cat /efs/cryptprop_lockscreen.patterneverchosen`" = "true" ]; then echo -n true > /efs/cryptprop_lock_pattern_autolock; fi

To disable the pattern lock create an Execute action with the following contents:
Code:
@! if [ "`cat /efs/cryptprop_lockscreen.patterneverchosen`" = "true" ]; then echo -n false > /efs/cryptprop_lock_pattern_autolock; fi

These have been tested on rooted stock KE7 firmware.

Enjoy,
Dan
 

mljjlm

Senior Member
Mar 7, 2010
385
68
Copenhagen
Sorry for sounding stupid (I probably will)
But could you make a tasker-noob-proof-tutorial?
I couldn't find where to change, if it should be active inside or outside the given area (home or not home)..

Thanks in advance :)
 
  • Like
Reactions: xhepera

nightranger73

Senior Member
Oct 20, 2010
977
261
47
Reggio Emilia
Sorry for sounding stupid (I probably will)
But could you make a tasker-noob-proof-tutorial?
I couldn't find where to change, if it should be active inside or outside the given area (home or not home)..

Thanks in advance :)

He described the command action so you can apply your own rule... Google for tasker and you'll find a lot of howto

Sent from my Galaxy SII

If you find this post usefull please press the "Thanks" button
 

terranim

Member
Nov 9, 2009
31
34
blog.teadriven.me.uk
@mljjlm
I'm sorry but this is not a tutorial for Tasker, it simply provides the information necessary to configure your own profiles for toggling the pattern lock. Although the information at the end of this post may prove useful.

@bgx
No idea I'm afraid, I've not had a chance to look into those although I'm pretty sure it's not possible to switch 2G/3G or GPS in the same way that the pattern lock is toggled here.

@js931
My profile is based on location (using the "Cell Near" state) and so will not be much use for anyone else. However I basically configured the following:
  • Create profile called "Home".
  • Add a "Cell Near" state and configure for my local towers.
  • Add a task called "Home" and include the "Execute" action described above for disabling the pattern lock (I also turn off mobile data and turn on wifi here).
  • Add an exit task called "Away" which includes the "Execute" action to enable the pattern lock (I also turn on mobile data here).
 
  • Like
Reactions: rob_h

terranim

Member
Nov 9, 2009
31
34
blog.teadriven.me.uk
In your code for disabling the pattern, should the code read 'patternneverchosen' rather than 'patterneverchosen' as you have written? I haven't tested, but the spelling seemed odd.

If it's correct, ignore me ;)

It is actually correct (I double checked the first time I tested it out since it was an ambiguous name), it is supposed to be:
pattern-ever-chosen

which is why I check for it being true in my command since we want a pattern to have been set.

Edit:

It has actually been properly tested today, I was away from home and the pattern lock was enabled, when I got back home the pattern lock was disabled.

One thing to be aware of, when setting up the Tasker profile, is that each "Execute" command requires its own root permission, so you have to make sure that these have been allowed before it will work quietly in the background (you should be able to trigger them by testing the task).
 
Last edited:
  • Like
Reactions: t00dy

julien.me

Senior Member
Jul 22, 2010
218
36
Perth
It works great, however when the Lock Pattern is disabled, I still get the "slide to unlock" type of screen when waking the phone up. Any command for that?
I am running the stock SGS2 ROM (rooted obviously)

Thanks !
 

Lennyuk

Inactive Recognized Developer
Jan 26, 2010
6,273
1,743
Essex, England
www.villainrom.co.uk
I am new to tasker and would like some help/advice

I want to save power a bit so want my gps to only turn on in certain cell tower locations (in order to aid more specific tasks when in those cell locations). my issue is not setting this up, it is in the fact that taskers default gps toggle settings do not work on the sgs2. Can anyone help with this, rather than me having to keep it checking gps all the time (which I have currently delayed to 10 minute checking slots).

Edit: Also not sure if it is me just being dumb, but I cannot see that plugin on that link in the OP..?
 
Last edited:

terranim

Member
Nov 9, 2009
31
34
blog.teadriven.me.uk
@julien.me
The slide to unlock keyguard is handled differently to the pattern lock, but you should be able to enable/disable it using Tasker without any hacking. I use Tasker to disable the keyguard when it is plugged in.

@Lennyuk
I mentioned in an earlier post that I have no idea how the 3G or GPS is enabled disabled, but I am fairly sure it cannot be achieved using a method like this.

@m.shafik
The original Galaxy S handles the pattern lock differently so this solution will not work, but the Secure Settings plugin may be of use.

Regards,
Dan
 

xerxes

Member
Nov 14, 2005
24
0
Excellent work, do you know if this will work with the original Galaxy S as well?

I used Tasker to do the same thing on my Galaxy S last night coincidentally - only in a somewhat more simplistic way as I am not as technically strong as most people here.

I have a simple Tasker profile that checks my location and if I am at home it executes an action to turn "Keyguard Off". Keyguard is under "Display" in the Action categories. Setting Keyguard to Off disables both the pattern lock and the slide lock.

My case is actually a little more complex because I want to disable the keyguard in two situations, when I am at home or when I am driving in the car. I did this by creating two profiles, the first of which checks to see if the GS is connected to my home wifi, and the second of which checks whether I am connected to my car Bluetooth. If either case is found to be true the relevant profile sets a variable. When the case become untrue (ie. I leave the house or turn the car off) the profile will clear the variable (via an exit action). I then have a third profile that simply turns off the keyguard when the variable is set.

I appreciate that there are probably cleverer and better ways to achieve the objective but I only installed Tasker last night so I am only just lifting the lid.
 
Last edited:

hotsync100

Senior Member
Jun 27, 2009
360
81
Caracas
Hi terranim, I was using your script several days and it worked like a charm, but now I updated to 2.3.4 and it does not work anymore. Any advice ?

Sent from my GT-I9100 using Tapatalk
 

Beowulf_pt

Senior Member
Jul 29, 2010
303
25
Lisbon
I can't get it to work well on my SGS2 2.3.3 stock unrooted. I enabled admin and set Tasker to disable the keylock in a profile (when I'm at home and the wifi ssid is visible). The profile activates but I always get the lock.

And I mean the stock lock screen with the pin (not the pattern one which I read that requires rooting and the method explained in this thread)

Missing something?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 17
    One of the things that I wanted to use Tasker for was enable the pattern lock when I was away from home and then disable it at home. Unfortunately due to recent changes in the Android SDK that is no longer possible with Tasker directly.

    With a bit of searching I discovered the Secure Settings plugin which can be installed to /system/app and thereby provide Tasker with the functionality. However, it seems that Secure Settings does not work on the Galaxy S2 because Samsung have their own pattern lock and method of controlling it.

    I started doing a bit of digging (mainly using logcat to see what the system was doing when the pattern lock was enabled/disabled via the Location and security settings menu). I discovered that the Samsung lock system is controlled by some files in /efs and with a bit of experimentation I was able to enable/disable the pattern lock via a root shell. I contacted the author of Secure Settings who suggested I use the Locale Execute plugin to run shell commands via Tasker.

    So I present here the commands I am now using on my phone and hopefully they will be of some use to others. The commands include a check that should ensure that it does not attempt to enable the pattern lock when no pattern has been set, but this has not been fully tested!

    WARNING: These commands require root access and you use them at your own risk!

    Make sure to install the Locale Execute plugin first and then to enable the pattern lock with a task simply add a new "Plugin/Execute" action and set the contents to:
    Code:
    @! if [ "`cat /efs/cryptprop_lockscreen.patterneverchosen`" = "true" ]; then echo -n true > /efs/cryptprop_lock_pattern_autolock; fi

    To disable the pattern lock create an Execute action with the following contents:
    Code:
    @! if [ "`cat /efs/cryptprop_lockscreen.patterneverchosen`" = "true" ]; then echo -n false > /efs/cryptprop_lock_pattern_autolock; fi

    These have been tested on rooted stock KE7 firmware.

    Enjoy,
    Dan
    2
    sort of worked

    I have the AT&T SGS2 and couldn't get this to work.

    It seems that
    cat /efs/cryptprop_lockscreen.patterneverchosen
    always outputs "true" on my phone, no matter how many times I set up a pattern.

    I took out the conditional and it works just using this command disable the pattern:
    echo -n false > /efs/cryptprop_lock_pattern_autolock;

    and this command to enable it:
    echo -n true > /efs/cryptprop_lock_pattern_autolock;

    Also, this command wouldn't run using the Locale execute plugin. I had to use the "Secure Settings" plugin and the "run command" option as root.
    1
    Sorry for sounding stupid (I probably will)
    But could you make a tasker-noob-proof-tutorial?
    I couldn't find where to change, if it should be active inside or outside the given area (home or not home)..

    Thanks in advance :)
    1
    @mljjlm
    I'm sorry but this is not a tutorial for Tasker, it simply provides the information necessary to configure your own profiles for toggling the pattern lock. Although the information at the end of this post may prove useful.

    @bgx
    No idea I'm afraid, I've not had a chance to look into those although I'm pretty sure it's not possible to switch 2G/3G or GPS in the same way that the pattern lock is toggled here.

    @js931
    My profile is based on location (using the "Cell Near" state) and so will not be much use for anyone else. However I basically configured the following:
    • Create profile called "Home".
    • Add a "Cell Near" state and configure for my local towers.
    • Add a task called "Home" and include the "Execute" action described above for disabling the pattern lock (I also turn off mobile data and turn on wifi here).
    • Add an exit task called "Away" which includes the "Execute" action to enable the pattern lock (I also turn on mobile data here).
    1
    In your code for disabling the pattern, should the code read 'patternneverchosen' rather than 'patterneverchosen' as you have written? I haven't tested, but the spelling seemed odd.

    If it's correct, ignore me ;)

    It is actually correct (I double checked the first time I tested it out since it was an ambiguous name), it is supposed to be:
    pattern-ever-chosen

    which is why I check for it being true in my command since we want a pattern to have been set.

    Edit:

    It has actually been properly tested today, I was away from home and the pattern lock was enabled, when I got back home the pattern lock was disabled.

    One thing to be aware of, when setting up the Tasker profile, is that each "Execute" command requires its own root permission, so you have to make sure that these have been allowed before it will work quietly in the background (you should be able to trigger them by testing the task).
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone