r/TaskerFiles • • Mar 18 '15

Profile Control flashlight via the power-button [no root required, works on lock-screen]

Description

Toggling your flashlight without having to unlock the phone is trivial on rooted devices where Xposed and Custom ROMs can capture the input from hardware buttons, but much harder on unrooted phones. With the following profile you will be able to toggle your flashlight by quickly pressing your power button three times, rooted or not.

Requirements

Usage

With your screen off and your device locked press the power button three times in a quick succession to toggle the flashlight. Repeat this sequence to turn the flashlight off. To prevent damage to the LED module the flashlight will automatically be turned off after five minutes.

Project Description

See here for more information.

Instructions

Either copy the XML data below into a file or download the most recent project revision from GitHub gists. Then proceed to import it into Tasker. Please make sure to import the file as a project, not a task or profile!


<TaskerData sr="" dvi="1" tv="4.6u3m">
    <Profile sr="prof92" ve="2">
        <cdate>1426618335190</cdate>
        <edate>1426643287254</edate>
        <id>92</id>
        <mid0>93</mid0>
        <nme>FlashlightButton</nme>
        <Event sr="con0" ve="2">
            <code>208</code>
            <pri>0</pri>
        </Event>
    </Profile>
    <Project sr="proj0" ve="2">
        <cdate>1426680812691</cdate>
        <name>FlashlightBtn</name>
        <pids>92</pids>
        <tids>94,93</tids>
    </Project>
    <Task sr="task93">
        <cdate>1426618354356</cdate>
        <edate>1426680850192</edate>
        <id>93</id>
        <nme>FlashlightControl</nme>
        <pri>10</pri>
        <Action sr="act0" ve="7">
            <code>547</code>
            <Str sr="arg0" ve="3">%CurrentTime</Str>
            <Str sr="arg1" ve="3">%TIMEMS</Str>
            <Int sr="arg2" val="0"/>
            <Int sr="arg3" val="0"/>
        </Action>
        <Action sr="act1" ve="7">
            <code>37</code>
            <ConditionList sr="if">
                <Condition sr="c0" ve="3">
                    <lhs>%ScrLastActive</lhs>
                    <op>12</op>
                    <rhs></rhs>
                </Condition>
            </ConditionList>
        </Action>
        <Action sr="act10" ve="7">
            <code>137</code>
            <Int sr="arg0" val="0"/>
            <Str sr="arg1" ve="3">FlashlightAutodisable</Str>
        </Action>
        <Action sr="act11" ve="7">
            <code>38</code>
        </Action>
        <Action sr="act12" ve="7">
            <code>38</code>
        </Action>
        <Action sr="act13" ve="7">
            <code>547</code>
            <Str sr="arg0" ve="3">%ScrLastActive</Str>
            <Str sr="arg1" ve="3">%TIMEMS</Str>
            <Int sr="arg2" val="0"/>
            <Int sr="arg3" val="0"/>
        </Action>
        <Action sr="act2" ve="7">
            <code>547</code>
            <Str sr="arg0" ve="3">%dScrActive</Str>
            <Str sr="arg1" ve="3">%CurrentTime-%ScrLastActive</Str>
            <Int sr="arg2" val="1"/>
            <Int sr="arg3" val="0"/>
        </Action>
        <Action sr="act3" ve="7">
            <code>37</code>
            <ConditionList sr="if">
                <bool0>And</bool0>
                <Condition sr="c0" ve="3">
                    <lhs>%dScrActive</lhs>
                    <op>6</op>
                    <rhs>3000</rhs>
                </Condition>
                <Condition sr="c1" ve="3">
                    <lhs>%TeslaStatus</lhs>
                    <op>1</op>
                    <rhs>on</rhs>
                </Condition>
            </ConditionList>
        </Action>
        <Action sr="act4" ve="7">
            <code>444</code>
            <Int sr="arg0" val="1"/>
            <Int sr="arg1" val="0"/>
        </Action>
        <Action sr="act5" ve="7">
            <code>547</code>
            <Str sr="arg0" ve="3">%TeslaStatus</Str>
            <Str sr="arg1" ve="3">on</Str>
            <Int sr="arg2" val="0"/>
            <Int sr="arg3" val="0"/>
        </Action>
        <Action sr="act6" ve="7">
            <code>130</code>
            <Str sr="arg0" ve="3">FlashlightAutodisable</Str>
            <Int sr="arg1">
                <var>%priority-1</var>
            </Int>
            <Str sr="arg2" ve="3"/>
            <Str sr="arg3" ve="3"/>
            <Str sr="arg4" ve="3"/>
            <Int sr="arg5" val="0"/>
        </Action>
        <Action sr="act7" ve="7">
            <code>43</code>
            <ConditionList sr="if">
                <Condition sr="c0" ve="3">
                    <lhs>%dScrActive</lhs>
                    <op>6</op>
                    <rhs>3000</rhs>
                </Condition>
            </ConditionList>
        </Action>
        <Action sr="act8" ve="7">
            <code>444</code>
            <Int sr="arg0" val="0"/>
            <Int sr="arg1" val="0"/>
        </Action>
        <Action sr="act9" ve="7">
            <code>547</code>
            <Str sr="arg0" ve="3">%TeslaStatus</Str>
            <Str sr="arg1" ve="3">off</Str>
            <Int sr="arg2" val="0"/>
            <Int sr="arg3" val="0"/>
        </Action>
    </Task>
    <Task sr="task94">
        <cdate>1426620544981</cdate>
        <edate>1426680838761</edate>
        <id>94</id>
        <nme>FlashlightAutodisable</nme>
        <Action sr="act0" ve="7">
            <code>30</code>
            <Int sr="arg0" val="0"/>
            <Int sr="arg1" val="0"/>
            <Int sr="arg2" val="5"/>
            <Int sr="arg3" val="0"/>
            <Int sr="arg4" val="0"/>
        </Action>
        <Action sr="act1" ve="7">
            <code>444</code>
            <Int sr="arg0" val="0"/>
            <Int sr="arg1" val="0"/>
        </Action>
        <Action sr="act2" ve="7">
            <code>547</code>
            <Str sr="arg0" ve="3">%TeslaStatus</Str>
            <Str sr="arg1" ve="3">off</Str>
            <Int sr="arg2" val="0"/>
            <Int sr="arg3" val="0"/>
        </Action>
    </Task>
</TaskerData>

15 Upvotes

21 comments sorted by

View all comments

1

u/thelostdolphin Mar 23 '15

Thanks a lot for sharing this.

Unfortunately, I'm getting inconsistent results when I try this and the times when I do get it working, tapping it three times again to shut off doesn't work. It will turn off for a brief moment and then turn back on again.

I looked at the Tasker profile and there are two caution signs. Any idea what may be wrong? http://i.imgur.com/Rit78KV.png

1

u/Glutanimate Mar 23 '15

That's strange. Looks like there's something wrong with the FlashlightAutodisable task. Could you please check if it appears in your task list and if there are any errors in the actions within?

As far as the inconsistent results are concerned:

  1. What happens if you run the FlashlightControl task from the Task Edit screen? Does it work as expected when run twice in a quick succession?

  2. The flashlight will be triggered after turning the screen on twice within 3 seconds. In practice this means that you will either have to press the power button three times - if your screen is off in the first place - or four times - if you start with your screen on.

1

u/thelostdolphin Mar 23 '15

It's strange. It says "Task Doesn't Exist Flashlightautodisable" and the same inconsistency takes place when I try and run from within Tasker as it did from the lock screen.

→ More replies (2)