I would like to understand the nature of the hazard we face if we ignored the developer’s warning and manipulated the keyguard without meeting requirement that display is on and unlocked.
Of course, the basic desire for most people I think is to turn their keyguard off at known locations (home, work) and then turn it back on when they leave these locations, but if triggered by typical location contexts, the change might occur when the display is off or on/locked.
I assume the concern is that phone can become disabled requiring something like a factory reset to recover, is that correct?
If that’s the case, it is intimidating to even experiment.
Does the caution apply to turning Keyguard "on" or to turning Keyguard "off", or to both?
Does this arise from Android system thinking there is unwanted tampering going on? Or just some unpredictable behavior?
Is there some failsafe we might be able to build into our code to be able to reverse unwanted changes? (for example on next reboot, put the keyguard back to previous state).
Note, I’m a Froyo user.
For info, here are some of the warnings posted.
Keyguard
Whether the keyguard is enabled or disabled.
The keyguard is the dialog requiring some sort of unlock action when the device is turned on.
Note: while keyguard is disabled, your SIM pin unlock screen may disappear after a few seconds after a reboot.
WARNING: while keyguard is disabled, the 'lock pattern' mechanism is also disabled, so your phone is unprotected if it is lost. There is also the possibility of interference with other applications that manipulate the keyguard.
On Android 2.2+, this action should probably only be used when the device is on and unlocked, unless the unlock method in Android settings is set to None.
Side-effect: coming out of Airplane Mode with Keyguard disabled may leave the SIM unrecognized until Keyguard is toggled again.
http://tasker.wikidot.com/disable-keyguard-when-at-home
The above was posted by Bruton on 14th January 2012, and whilst this may work well for some, others WILL experience problems with the Keyguard being activated whilst the display is off. For these people, I would suggest you install the Secure Settings plugin from the Market and, in the second profile, create an action that calls the 'Screen Dim, for 5 seconds' function in Secure Settings BEFORE setting the Keyguard on. You can then create a third action to Lock the screen, which will turn the display off again:
Is there some failsafe we might be able to build into our code to be able to reverse unwanted changes? (for example on next reboot, put the keyguard back to previous state).
I have now downloaded/ installed “security settings” from the market.
I looked around in tasker and here’s what’s
new after that installation:
State / Plugin / Secure Settings / Configuration / Edit / .... then choices for failed login attempts and secret code
Task / Plugin / Secure Settings / Configuration / Edit / then choices:
Actions: Keyguard . Mobile Data, Run Command, Wake Device
Dev Admin Actions: Lock Device, Password Pin
Custom Rom Actions: LTE
I don’t see anything like Dim that was mentioned by sayling. Also, there is a lot written about admin permissions that I don’t understand. Any suggestions what to do with this? Maybe I can use the keyguard command direct from Security Settings... is it supposed to be safer?
Thanks again for the insights you guys have shared.
I think I have success. I haven’t invented anything new, but for me it is an achievement because the logic to meet my requirements is complex (for me anyway). But through all my testing so far (manipulating the variables to simulate leaving/arriving etc in all combinations I could think of), it works exactly as intended. . I will report results after a few weeks of real world use
Unfortunately, despite my best efforts at documentation, it probably looks like spaghetti code (I wonder if I’ll be able to understand it six months from now). I’m sharing it with the forum for what little it’s worth. Feel free to ignore it (my feelings won’t be hurt). If it triggers any thoughts of better ways to do things or to document things, please let me know.
(By the way, is there a way to get rid of those label numbers added during export of tasks and profiles?)
Requirements:
Trick for resetting or cancelling timer:
The heart of the code is task KGTimeoutTask including a timer which will enable keyguard when it finishes counting down. This collision handling for this KGTimeout task is specified as “abort existing task” which means any new call to the task wipes out all the old timer tasks. This enables us to reset the timer (when occurs when %par1=KgTimerEnable is passed to the task) or to simply get rid of the timer (when @par1 = KgTimerAbort is passed to the task). .
Special Variables:
%DISPLAYSTATUS (on or off) is managed by the continuously-running profiles DispOn and DispOff. Just a conventient way to convert the available Display on/off events into a DISPLAYSTATUS on/off state.
%AtHome (1 or 0) is managed by the continuously-running profile “Home”. There are many ways to test for being at home/away of course and this is just one that works for me. There are a few extra steps included in profile home (beyond toggling %AtHome variable) that support this KG management (for example Home Exit task activates the timer routine).
Profiles:
Home, DispOn, DispOff all discussed above under “Special Variables”
CheckFirstUnlockHome – Normally this profile is disabled. Enabled only when HomeProfile senses arrival at home. Looks for first Unlocking to occur at home and when it does, the KG is unlocked, all timers cancelled, and the profile disables itself (it is only active during the time it needs to be).
CheckDispDuringWait – Normally this profile is disabled. Enabled only when KgTimerTask starts it’s timer. It looks for display turnon during this countdown period, in which case it resets the timer and disables itself. If no turn-on occurs, this profile will be disabled when the timer times out (it is only active during the time it needs to be).
Tasks:
Task KgTimeoutTask – discussed above under “trick for resetting/cancelling the timer. Note also the timer does not ever begin until the display is sensed as off (“wait until” statement depending on the value of DISPLAYSTATUS). Just before the 15-minute timer is activated, the CheckDispDuringWait is activated to check for display coming on during counting (which means we need to re-enter the counter routine and wait for the display to go off). Most importantly, the suggestions from Sayling are used to successfully enable Keyguard with display initially off.
Task KGWidget is very similar to the “Keyboard Toggle Widget” shown in the wiki stepthroughs, with extra steps to abort any timer tasks when KG is toggled to on (you’re safe, who needs a timer) and to start a timer when KG is toggled to off while on the road.
Code:
Profile: DispOn (75)
Event: Display On
Enter: Anon (76)
<Variable used by kg>
A1: Variable Set [ Name:%DISPLAYSTATUS To:on Do Maths:Off Append:Off ]
Profile: DispOff (77)
Event: Display Off
Enter: Anon (78)
<Variable used by kg>
A1: Variable Set [ Name:%DISPLAYSTATUS To:off Do Maths:Off Append:Off ]
Profile: Home (21)
State: Cell Near [ Cell Tower / Last Signal:GSM:XXXXX.YYYZZZZZ / 6
GSM:XXXXX.YYYZZZZZ / 0
GSM:XXXXX.YYYZZZZZ / 0
GSM:XXXXX.YYYZZZZZ / 0 ]
Enter: Anon (61)
A1: Mobile Data [ Set:Off ]
A2: Notify [ Title:Home-data off Text: Icon:<icon> Number:0 Permanent:Off ]
A3: Variable Set [ Name:%AtHome To:1 Do Maths:Off Append:Off ]
<Kill any old timer>
A4: Perform Task [ Name:KgTimeoutTask Stop:Off Priority:5 Parameter 1 (%par1):KgTimerAbort Parameter 2 (%par2): Return Value Variable: ]
<enable monitoring for first unlock>
A5: Profile Status [ Name:CheckFirstUnlockHome Set:On ]
Exit: Anon (62)
<If avoids false leave-home triggers due to cell signal. wifii is always out of range before leave home>
A1: If [ %WIFII !~ *connect* ]
A2: WiFi [ Set:Off ]
A3: Notify [ Title:Lv Home Wifi Off Text: Icon:<icon> Number:0 Permanent:Off ]
A4: Variable Set [ Name:%AtHome To:0 Do Maths:Off Append:Off ]
A5: Perform Task [ Name:KgTimeoutTask Stop:Off Priority:5 Parameter 1 (%par1):KgTimerEnable Parameter 2 (%par2): Return Value Variable: ]
A6: End If
Profile: CheckDispDuringWait (54)
Event: Display On
Enter: Anon (55)
<Reset timer>
A1: Perform Task [ Name:KgTimeoutTask Stop:Off Priority:5 Parameter 1 (%par1):KgTimerEnable Parameter 2 (%par2): Return Value Variable: ]
<Disable myself>
A2: Profile Status [ Name:CheckDispDuringWait Set:Off ]
Profile: CheckFirstUnlockHome (57)
Event: Display Unlocked
Enter: Anon (60)
<Abort any timer>
A1: Perform Task [ Name:KgTimeoutTask Stop:Off Priority:5 Parameter 1 (%par1):KgTimerAbort Parameter 2 (%par2): Return Value Variable: ]
<Icon unlocked>
A2: Set Widget Icon [ Name:KGWIDGET Icon:<icon> ]
A3: Keyguard [ Set:Off ]
<disable myself>
A4: Profile Status [ Name:CheckFirstUnlockHome Set:Off ]
Task: KgTimeoutTask (67)
A1: If [ %par1 ~ *abort* ]
<abort if signaled by caller...deletes any previous timer>
A2: Stop [ With Error:Off ]
A3: End If
<Wait for display udf condition, checking every minute>
A4: Wait Until [ MS:0 Seconds:0 Minutes:1 Hours:0 Days:0 ] If [ %DISPLAYSTATUS ~ off ]
<Enable profile which will interrupt the wait if display goes back on.>
A5: Profile Status [ Name:CheckDispDuringWait Set:On ]
<Variable for debug check only, can delete>
A6: Variable Set [ Name:%LAST_KG_TIMERSET To:%DATE %TIME Do Maths:Off Append:Off ]
<this is the timer wait period>
A7: Wait [ MS:0 Seconds:0 Minutes:15 Hours:0 Days:0 ]
<On timer completion, check display still off (should be)>
A8: If [ %DISPLAYSTATUS ~ off ]
A9: Secure Settings [ Configuration:Screen Dim
2 Seconds ]
A10: Keyguard [ Set:On ]
A11: Turn On
<Icon,locked>
A12: Set Widget Icon [ Name:KGWIDGET Icon:<icon> ]
A13: System Lock
<Only if somehow display on at end of timer (should not occur)>
A14: Else
<start timer all over again>
A15: Perform Task [ Name:KgTimeoutTask Stop:Off Priority:5 Parameter 1 (%par1):KgTimerEnabled Parameter 2 (%par2): Return Value Variable: ]
A16: End If
<cleanup added after exporting:>
A17: Profile Status [ Name:CheckDispDuringWait Set:Off ]
Task: KGWIDGET (73)
A1: Keyguard [ Set:Toggle ]
<may not be necessary, but wait a second>
A2: Wait [ MS:0 Seconds:1 Minutes:0 Hours:0 Days:0 ]
<Toggled from on to off>
A3: If [ %KEYG ~ off ]
<Show unlocked icon>
A4: Set Widget Icon [ Name:KGWIDGET Icon:<icon> ]
<If not home then set timer>
A5: If [ %AtHome !~ 1 ]
<Call timer, enabled>
A6: Perform Task [ Name:KgTimeoutTask Stop:Off Priority:5 Parameter 1 (%par1):KgTimerEnabled Parameter 2 (%par2): Return Value Variable: ]
A7: End If
<Toggled from off to on>
A8: Else
<Show locked icon>
A9: Set Widget Icon [ Name:KGWIDGET Icon:<icon> ]
<Abort any timer>
A10: Perform Task [ Name:KgTimeoutTask Stop:Off Priority:5 Parameter 1 (%par1):KgTimerAbort Parameter 2 (%par2): Return Value Variable: ]
A11: End If
You all probably should not waste a lot of time reviewing what I posted below. Let me make any changes during my two weak trial period and report back.
Here are a few things I’ll change:
1 – (editorical) I was a little sloppy on terminology (used locked/unlocked many places where I meant KG on/off).
2 - The order of the two tasks within CheckDispDuringWait profile needs to be reversed from what was posted below.
In the old way, the CheckDispDuringWait profile would sit and wait for the timer task to finish. Results seem unpredictable and the timer was not being reset when I expected.
In the new way, the profile completes as soon as it passes control to the Timer task and is ready to be re-enabled immediately if necessary. It also gives more of the results I expected.
Matt
Matt,
There was no reason at all except I didn't know about that variable...was looking for a
built-in variable called “DISPLAY” and it never occurred to me to look for a
variable called “SCREEN”.
But I will certainly make that change now that I know. That will save some juice from monitoring stuff I don’t need to, and also reduce the clutter of unneeded extra variables.
Thanks for the suggestion.
By the way, I also added an important extra line to disable the CheckDispDuringWait profile in task KgTimeoutTask after step A8. Also a few minor tweaks (ongoing) to try to make sure I have covered all possibilities of what the program might see. Will post those in a week or two.
Same here. The app author acknowledges they can't deal with pattern unlocks under ICS, sadly.
Where does one report problems to Google anyway?
Same here. The app author acknowledges they can't deal with pattern unlocks under ICS, sadly.
Where does one report problems to Google anyway?
Same here. The app author acknowledges they can't deal with pattern unlocks under ICS, sadly.
Where does one report problems to Google anyway?
On Jul 8, 2012 4:50 PM, "Steve Millsrote:
Stock and non-rooted, unfortunately - and stuck like that :(
Not strictly true, as there are some functions in Secure Settings that don't require root and Tasker doesn't do (screen on, for example) - but that's just minor semantics and nothing for us to argue about ;)
RudeboyX, you legend. I've been trying all over the internet to find a solution, and the setting 'None' before whatever security procedure, worked perfectly.Cheers