variable to check if pin/password is set or not.

54 views
Skip to first unread message

Dustin Mundy

unread,
May 10, 2015, 2:15:02 AM5/10/15
to tas...@googlegroups.com
I had a perfect functioning lock/unlock toggle button at one point. Lost it when wiping my phone.

I want to have a "toggle lock" task:

If ( pin/password is set ) {
    unset pin
    change icon to unlocked icon
} else {
    set pin to xxxx
    change icon to locked icon
}

The problem is I don't think there's a variable to check if a pin is set. Ideas?

Juergen Gruen

unread,
May 10, 2015, 9:29:45 AM5/10/15
to tas...@googlegroups.com
Define your own global variable:

If ( %PinSet ~ true ) {
unset pin
%PinSet = false
change icon to unlocked icon
} else {
set pin to xxxx
%PinSet = true
change icon to locked icon
}

Juergen.

Hippo Man

unread,
May 10, 2015, 9:58:20 AM5/10/15
to tas...@googlegroups.com
On Sunday, May 10, 2015 at 9:29:45 AM UTC-4, Juergen Gruen wrote:
Define your own global variable:

Yes, but how would %PinSet be initialized to reflect the actual state of the pin being set or unset?
.
 

Juergen Gruen

unread,
May 10, 2015, 11:06:40 AM5/10/15
to tas...@googlegroups.com
Thanks for the comment. At first execution the task goes directly to "else" and the variable is then set to "true".

But  it is probably better to create and set the variable first in the "Vars"-tab (Switch off Beginner Mode).

Juergen.

Dustin Mundy

unread,
May 10, 2015, 11:11:42 AM5/10/15
to tas...@googlegroups.com
Using my own variable seems to be working fine. I'm worried about the state of my variable desyncronizing with the state of my lock if, for instance, I decide to password lock my phone instead of pin locking with my button.

Is there an event for pin/password set/unset that I can bind to set the variable?

Rich D

unread,
May 10, 2015, 11:26:09 AM5/10/15
to Tasker Google Groups Post

> Using my own variable seems to be working fine. I'm worried about the state of my variable desyncronizing with the state of my lock if, for instance, I decide to password lock my phone instead of pin locking with my button.
>
> Is there an event for pin/password set/unset that I can bind to set the variable?

Not as far as I know,  you could look into the shell dumpsys command.  The "device_policy" looks like it could help. 

You Could have a display on profile that checks the status with the 'dumpsys' command then and will set the variable to the correct state.

Robert Ryan

unread,
May 10, 2015, 12:20:42 PM5/10/15
to Support Forum


On May 10, 2015 12:15 AM, "Dustin Mundy" <dustin....@gmail.com> wrote:
>
> The problem is I don't think there's a variable to check if a pin is set. Ideas?

You can check via Java:

Test (69)
A1: Java Function [ Return:(KeyguardManager) key_manager Class Or Object:CONTEXT Function:getSystemService
{Object} (String) Param:"keyguard" Param: Param: Param: Param: Param: Param: ]
A2: Java Function [ Return:%secure Class Or Object:key_manager Function:isKeyguardSecure
{boolean} () Param: Param: Param: Param: Param: Param: Param: ]
A3: Flash [ Text:%secure Long:Off ]

Hippo Man

unread,
May 11, 2015, 9:52:49 PM5/11/15
to tas...@googlegroups.com
On Sunday, May 10, 2015 at 11:06:40 AM UTC-4, Juergen Gruen wrote:
Thanks for the comment. At first execution the task goes directly to "else" and the variable is then set to "true".

But  it is probably better to create and set the variable first in the "Vars"-tab (Switch off Beginner Mode).

I understand how the if-statement works. My question has to do with how can Tasker know the _actual_ state of the pin.

For example: suppose I go into Settings and set the pin; or suppose I go into settings and clear the pin. The %PinSet variable will not change in either case. Iwill have to manually (or indirectly via some task) set or clear %PinSet after making that change in Settings.

This means that %PinSet can get out of sync with the actual state of the pin.
.



Hippo Man

unread,
May 11, 2015, 9:56:17 PM5/11/15
to tas...@googlegroups.com

This means that %PinSet can get out of sync with the actual state of the pin.

... and I see from reading the subsequent messages that the state of the pin can be gotten via a Java Function or perhaps via dumpsys.

I should have read on before hastily posting my previous response.
.
 
Reply all
Reply to author
Forward
0 new messages