Skip to content

Instantly share code, notes, and snippets.

@glutanimate
Last active October 14, 2021 03:12
Show Gist options
  • Save glutanimate/42ce2a327f32c744dc45 to your computer and use it in GitHub Desktop.
Save glutanimate/42ce2a327f32c744dc45 to your computer and use it in GitHub Desktop.
Toggle flashlight on Android via power button press sequence
<TaskerData sr="" dvi="1" tv="4.6u3m">
<Profile sr="prof92" ve="2">
<cdate>1426618335190</cdate>
<clp>true</clp>
<edate>1427251395506</edate>
<id>92</id>
<mid0>93</mid0>
<nme>FlashlightButton</nme>
<Event sr="con0" ve="2">
<code>208</code>
<pri>0</pri>
</Event>
<State sr="con1" ve="2">
<code>40</code>
<pin>true</pin>
<Int sr="arg0" val="2"/>
<Str sr="arg1" ve="3"/>
</State>
</Profile>
<Project sr="proj0" ve="2">
<cdate>1427144859127</cdate>
<name>Flashlight Button</name>
<pids>92</pids>
<tids>100,101,94,93</tids>
<Kid sr="Kid">
<launchID>93</launchID>
<pkg>com.glutanimate.flashlightbutton</pkg>
<vnme>1.0</vnme>
<vnum>2</vnum>
</Kid>
<Img sr="icon" ve="2">
<nme>hl_aaa_ext_bulb</nme>
</Img>
</Project>
<Task sr="task100">
<cdate>1351255597661</cdate>
<edate>1427498501108</edate>
<id>100</id>
<nme>FlashOn</nme>
<pri>10</pri>
<Action sr="act0" ve="7">
<code>664</code>
<Str sr="arg0" ve="3">pm</Str>
<Str sr="arg1" ve="3">CONTEXT</Str>
<Str sr="arg2" ve="3">getPackageManager
{PackageManager} ()</Str>
<Str sr="arg3" ve="3"/>
<Str sr="arg4" ve="3"/>
<Str sr="arg5" ve="3"/>
<Str sr="arg6" ve="3"/>
<Str sr="arg7" ve="3"/>
</Action>
<Action sr="act1" ve="7">
<code>664</code>
<Str sr="arg0" ve="3">%hasflash</Str>
<Str sr="arg1" ve="3">pm</Str>
<Str sr="arg2" ve="3">hasSystemFeature
{boolean} (String)</Str>
<Str sr="arg3" ve="3">android.hardware.camera.flash</Str>
<Str sr="arg4" ve="3"/>
<Str sr="arg5" ve="3"/>
<Str sr="arg6" ve="3"/>
<Str sr="arg7" ve="3"/>
</Action>
<Action sr="act10" ve="7">
<code>664</code>
<Str sr="arg0" ve="3"/>
<Str sr="arg1" ve="3">cam</Str>
<Str sr="arg2" ve="3">setParameters
{} (android.hardware.Camera$Parameters)</Str>
<Str sr="arg3" ve="3">params</Str>
<Str sr="arg4" ve="3"/>
<Str sr="arg5" ve="3"/>
<Str sr="arg6" ve="3"/>
<Str sr="arg7" ve="3"/>
</Action>
<Action sr="act11" ve="7">
<code>664</code>
<Str sr="arg0" ve="3"/>
<Str sr="arg1" ve="3">cam</Str>
<Str sr="arg2" ve="3">startPreview
{} ()</Str>
<Str sr="arg3" ve="3"/>
<Str sr="arg4" ve="3"/>
<Str sr="arg5" ve="3"/>
<Str sr="arg6" ve="3"/>
<Str sr="arg7" ve="3"/>
</Action>
<Action sr="act12" ve="7">
<code>130</code>
<Str sr="arg0" ve="3">FlashAutoOff</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="act13" ve="7">
<code>35</code>
<Int sr="arg0" val="0"/>
<Int sr="arg1" val="1"/>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
<Int sr="arg4" val="0"/>
<ConditionList sr="if">
<Condition sr="c0" ve="3">
<lhs>%FlashCtl</lhs>
<op>0</op>
<rhs>0</rhs>
</Condition>
</ConditionList>
</Action>
<Action sr="act14" ve="7">
<code>664</code>
<Str sr="arg0" ve="3"/>
<Str sr="arg1" ve="3">cam</Str>
<Str sr="arg2" ve="3">stopPreview
{} ()</Str>
<Str sr="arg3" ve="3"/>
<Str sr="arg4" ve="3"/>
<Str sr="arg5" ve="3"/>
<Str sr="arg6" ve="3"/>
<Str sr="arg7" ve="3"/>
</Action>
<Action sr="act15" ve="7">
<code>664</code>
<Str sr="arg0" ve="3"/>
<Str sr="arg1" ve="3">cam</Str>
<Str sr="arg2" ve="3">release
{} ()</Str>
<Str sr="arg3" ve="3"/>
<Str sr="arg4" ve="3"/>
<Str sr="arg5" ve="3"/>
<Str sr="arg6" ve="3"/>
<Str sr="arg7" ve="3"/>
</Action>
<Action sr="act16" ve="7">
<code>137</code>
<Int sr="arg0" val="0"/>
<Str sr="arg1" ve="3">FlashAutoOff</Str>
</Action>
<Action sr="act2" ve="7">
<code>37</code>
<ConditionList sr="if">
<Condition sr="c0" ve="3">
<lhs>%hasflash</lhs>
<op>1</op>
<rhs>true</rhs>
</Condition>
</ConditionList>
</Action>
<Action sr="act3" ve="7">
<code>548</code>
<Str sr="arg0" ve="3">Flash unavailable</Str>
<Int sr="arg1" val="0"/>
</Action>
<Action sr="act4" ve="7">
<code>137</code>
<Int sr="arg0" val="1"/>
<Str sr="arg1" ve="3"/>
</Action>
<Action sr="act5" ve="7">
<code>38</code>
</Action>
<Action sr="act6" ve="7">
<code>549</code>
<Str sr="arg0" ve="3">%FlashCtl</Str>
<Int sr="arg1" val="0"/>
</Action>
<Action sr="act7" ve="7">
<code>664</code>
<Str sr="arg0" ve="3">cam</Str>
<Str sr="arg1" ve="3">Camera</Str>
<Str sr="arg2" ve="3">open
{Camera} ()</Str>
<Str sr="arg3" ve="3"/>
<Str sr="arg4" ve="3"/>
<Str sr="arg5" ve="3"/>
<Str sr="arg6" ve="3"/>
<Str sr="arg7" ve="3"/>
</Action>
<Action sr="act8" ve="7">
<code>664</code>
<Str sr="arg0" ve="3">params</Str>
<Str sr="arg1" ve="3">cam</Str>
<Str sr="arg2" ve="3">getParameters
{android.hardware.Camera$Parameters} ()</Str>
<Str sr="arg3" ve="3"/>
<Str sr="arg4" ve="3"/>
<Str sr="arg5" ve="3"/>
<Str sr="arg6" ve="3"/>
<Str sr="arg7" ve="3"/>
</Action>
<Action sr="act9" ve="7">
<code>664</code>
<Str sr="arg0" ve="3"/>
<Str sr="arg1" ve="3">params</Str>
<Str sr="arg2" ve="3">setFlashMode
{} (String)</Str>
<Str sr="arg3" ve="3">torch</Str>
<Str sr="arg4" ve="3"/>
<Str sr="arg5" ve="3"/>
<Str sr="arg6" ve="3"/>
<Str sr="arg7" ve="3"/>
</Action>
</Task>
<Task sr="task101">
<cdate>1427145843081</cdate>
<edate>1427498503240</edate>
<id>101</id>
<nme>FlashOff</nme>
<pri>10</pri>
<Action sr="act0" ve="7">
<code>547</code>
<Str sr="arg0" ve="3">%FlashCtl</Str>
<Str sr="arg1" ve="3">0</Str>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
</Action>
</Task>
<Task sr="task93">
<cdate>1426618354356</cdate>
<edate>1427498494570</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>61</code>
<Int sr="arg0" val="25"/>
</Action>
<Action sr="act11" ve="7">
<code>130</code>
<Str sr="arg0" ve="3">FlashOff</Str>
<Int sr="arg1">
<var>%priority</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="act12" ve="7">
<code>547</code>
<Str sr="arg0" ve="3">%FlashStatus</Str>
<Str sr="arg1" ve="3">off</Str>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
</Action>
<Action sr="act13" ve="7">
<code>547</code>
<Str sr="arg0" ve="3">%FirstInvocation</Str>
<Str sr="arg1" ve="3">1</Str>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
</Action>
<Action sr="act14" ve="7">
<code>16</code>
</Action>
<Action sr="act15" ve="7">
<code>43</code>
<label>Make sure not to trigger twice in a row after 3 display toggles</label>
<ConditionList sr="if">
<Condition sr="c0" ve="3">
<lhs>%FirstInvocation</lhs>
<op>0</op>
<rhs>1</rhs>
</Condition>
</ConditionList>
</Action>
<Action sr="act16" ve="7">
<code>549</code>
<Str sr="arg0" ve="3">%FirstInvocation</Str>
<Int sr="arg1" val="0"/>
</Action>
<Action sr="act17" ve="7">
<code>38</code>
</Action>
<Action sr="act18" ve="7">
<code>38</code>
</Action>
<Action sr="act19" 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>
<bool1>And</bool1>
<Condition sr="c0" ve="3">
<lhs>%dScrActive</lhs>
<op>6</op>
<rhs>1500</rhs>
</Condition>
<Condition sr="c1" ve="3">
<lhs>%FlashStatus</lhs>
<op>1</op>
<rhs>on</rhs>
</Condition>
<Condition sr="c2" ve="3">
<lhs>%FirstInvocation</lhs>
<op>1</op>
<rhs>1</rhs>
</Condition>
</ConditionList>
</Action>
<Action sr="act4" ve="7">
<code>61</code>
<Int sr="arg0" val="25"/>
</Action>
<Action sr="act5" ve="7">
<code>130</code>
<Str sr="arg0" ve="3">FlashOn</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="act6" ve="7">
<code>547</code>
<Str sr="arg0" ve="3">%FlashStatus</Str>
<Str sr="arg1" ve="3">on</Str>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
</Action>
<Action sr="act7" ve="7">
<code>547</code>
<Str sr="arg0" ve="3">%FirstInvocation</Str>
<Str sr="arg1" ve="3">1</Str>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
</Action>
<Action sr="act8" ve="7">
<code>16</code>
<label>Turn off screen after flashlight toggle</label>
</Action>
<Action sr="act9" ve="7">
<code>43</code>
<ConditionList sr="if">
<bool0>And</bool0>
<Condition sr="c0" ve="3">
<lhs>%dScrActive</lhs>
<op>6</op>
<rhs>1500</rhs>
</Condition>
<Condition sr="c1" ve="3">
<lhs>%FirstInvocation</lhs>
<op>1</op>
<rhs>1</rhs>
</Condition>
</ConditionList>
</Action>
</Task>
<Task sr="task94">
<cdate>1426620544981</cdate>
<edate>1427498506490</edate>
<id>94</id>
<nme>FlashAutoOff</nme>
<pri>10</pri>
<Action sr="act0" ve="7">
<code>30</code>
<Int sr="arg0" val="0"/>
<Int sr="arg1" val="0"/>
<Int sr="arg2" val="1"/>
<Int sr="arg3" val="0"/>
<Int sr="arg4" val="0"/>
</Action>
<Action sr="act1" ve="7">
<code>130</code>
<Str sr="arg0" ve="3">FlashOff</Str>
<Int sr="arg1">
<var>%priority</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="act2" ve="7">
<code>547</code>
<Str sr="arg0" ve="3">%FlashStatus</Str>
<Str sr="arg1" ve="3">off</Str>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
</Action>
</Task>
</TaskerData>
@ProLoser
Copy link

ProLoser commented Nov 11, 2016

Any interest in submitting this here: https://github.com/ProLoser/Tasker-Presets/ ?

@marinegundoctor
Copy link

Just wanted to say that this is working great on my GS4 (SCH-i545PP). I imported as a project and it works. The only issue I thought I had turned out to be caused by my tapping the power key too quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment