1

I'm working with a chinese tablet which needs to be initialized every time after it's connected to a power source.

I'm using Tasker to do so. Problem is: this condition makes tasker execute the reboot command over and over, and it becomes a bootloop.

What should I do in order to initialize the tablet when a power source is attached, but avoid it from entering the bootloop?

Edit: TaskerProfile

<TaskerData sr="" dvi="1" tv="4.6u3">
<Profile sr="prof2" ve="2">
<cdate>1431370575080</cdate>
<edate>1431372456863</edate>
<id>2</id>
<mid0>4</mid0>
<State sr="con0" ve="2">
<code>10</code>
<pin>true</pin>
<Int sr="arg0" val="1"/>
</State>
</Profile>
<Profile sr="prof5" ve="2">
<cdate>1431370730220</cdate>
<edate>1431371684461</edate>
<flags>2</flags>
<id>5</id>
<mid0>6</mid0>
<State sr="con0" ve="2">
<code>10</code>
<Int sr="arg0" val="1"/>
</State>
</Profile>
<Project sr="proj0" ve="2">
<cdate>1431027887676</cdate>
<mdate>1431371133517</mdate>
<name>Base</name>
<pids>2,5</pids>
<tids>4,6,7</tids>
<Img sr="icon" ve="2">
<nme>hl_aaa_ext_home</nme>
</Img>
</Project>
<Task sr="task4">
<cdate>1431370589904</cdate>
<edate>1431372085383</edate>
<id>4</id>
<nme>Task1</nme>
<pri>10</pri>
<Action sr="act0" ve="7">
<code>410</code>
<Str sr="arg0" ve="3">Documents/sdcard.txt</Str>
<Str sr="arg1" ve="3">0</Str>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
</Action>
</Task>
<Task sr="task6">
<cdate>1431370741046</cdate>
<edate>1431372415674</edate>
<id>6</id>
<nme>Task2</nme>
<pri>10</pri>
<Action sr="act0" ve="7">
<code>417</code>
<Str sr="arg0" ve="3">Documents/sdcard.txt</Str>
<Str sr="arg1" ve="3">%True</Str>
</Action>
<Action sr="act1" ve="7">
<code>410</code>
<Str sr="arg0" ve="3">Documents/sdcard.txt</Str>
<Str sr="arg1" ve="3">1</Str>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
<ConditionList sr="if">
<Condition sr="c0" ve="3">
<lhs>%True</lhs>
<op>2</op>
<rhs>0</rhs>
</Condition>
</ConditionList>
</Action>
</Task>
<Task sr="task7">
<cdate>1431371028431</cdate>
<edate>1431372348654</edate>
<id>7</id>
<nme>runshell</nme>
<pri>10</pri>
<Action sr="act0" ve="7">
<code>123</code>
<Str sr="arg0" ve="3">reboot</Str>
<Int sr="arg1" val="0"/>
<Int sr="arg2" val="1"/>
<Str sr="arg3" ve="3"/>
<Str sr="arg4" ve="3"/>
<Str sr="arg5" ve="3"/>
<ConditionList sr="if">
<Condition sr="c0" ve="3">
<lhs>%True</lhs>
<op>2</op>
<rhs>0</rhs>
</Condition>
</ConditionList>
</Action>
</Task>
</TaskerData>

1 Answer 1

2

If I understood the question correctly, you want to connect the device to a power source which triggers Tasker to reboot the device (for initialization). But when the device reboots itself Tasker finds that the power source is connected so it repeats the task again. Your goal is to make Tasker reboot only once while power source remains connected. If the source is to be removed and re-inserted again, then Tasker should do the reboot again only for once.


Based on this understanding, I proposed the following solution:

The solution is very trivial. I'm using two profiles in Tasker, namely:

  1. Not power USB
  2. Power USB

These two profiles, as obvious, will be triggered by connecting/disconnecting the power source to the Android device. I'm using a file's content as a condition here to restrict boot-loop.

Note: For this answer, I chose my power source as USB only.

Instructions:

Regarding the file content:

  1. Create an empty file in your default storage. (I created a file named sdcard.txt in /sdcard. The location of this file is /sdcard/sdcard.txt.)
  2. Open this file in a text editor in Android and add 0 in it. (I used 920 Text Editor).
  3. Note that there is no logical reasoning in using 0 only. It will be used in a conditional statement only. You're at liberty to try an another number.

Regarding Profiles and Tasks in Tasker app:

  1. Launch Tasker.
  2. Under Profiles tab create a Profile by tapping +State → Power → Power.
  3. Under Source choose USB.
  4. Check Invert -- this will make Not power USB profile.
  5. Press Back key/button once and select New Task.
  6. Add a name for your task (persistent) or leave it blank (deleting profile will delete it as well).
  7. Under Tasks tab tap +FileWrite File.
  8. Under File field mention the location of your text file. In this case, it is /sdcard/sdcard.txt.
  9. Write 0 under Text field.
  10. Uncheck Append and Add Newline. -- we want to replace the content, so no appending should be done.
  11. Tap Back key/button twice to save this task.
  12. In order to create Power USB profile, repeat step 2,3,5 and 6, respectively.
  13. Under Tasks tab tap +FileRead File.
  14. Repeat step 8.
  15. Under To Var type %True -- You can change %True to any other name. Make sure that you capitalize at least one letter of your variable to make it non-local. See this to know more.
  16. Repeat step 11, 7 and 8.
  17. Type 1 under Text field.
  18. Repeat step 10.
  19. Tap + corresponding to If. Add %True and 0 in fields respectively. It should look like %True ~ 0.
  20. Repeat step 11.
  21. Under Tasks tab tap +CodeRun Shell.
  22. Type reboot under Command. (My device is rooted, so I provided root permissions to this step to avoid any hassle.) As a soft-reboot option, you can use killall zygote instead of reboot.
  23. Check Use Root if your device is rooted.
  24. Leave Store Output In and Store Errors In blank.
  25. Repeat step 19 and 20.
  26. Go to Profiles and enable both profiles. To save yourself from unnecessary trouble, disable any other power related profile other than the ones mentioned above.
  27. Tasker must be Enabled. You can check this by tapping Menu key/button once and amongst the options, Disable tasker would be visible. Also, if this app is running and you happen to minimize it, then as a default setting you would see its icon in the Status bar with the profile mentioned there (if activated).

We're good to go.

  • Go to Home Screen of your device.
  • Connect power source (we used USB only here).
  • Your device will reboot. Do not disconnect power source to verify that boot-loop vanished.
  • When the device comes back to Home Screen after reboot, you can see that Power USB profile is activated in tasker yet there is no boot-loop, not to mention that your initialization is also done. :)
  • Disconnect power source and the profile will switch to No power USB.
  • Connect power source again and device will reboot again for once.

Status: Objective Completed. Done!

11
  • It is switching between both profiles, but it doesn't execute the RunShell "reboot" task
    – Machado
    May 11, 2015 at 19:15
  • @Tardo I traced this issue. If I uncheck root option in this task, then the device doesn't reboot at all. Guess what, no error in logs of Tasker as well. I checked root option and it worked fine. I'm having this feeling that your device is un-rooted.
    – Firelord
    May 11, 2015 at 19:22
  • I'm using SuperSU from Chainfire to root the device
    – Machado
    May 11, 2015 at 19:23
  • If I execute (manually) the reboot task, it will reboot
    – Machado
    May 11, 2015 at 19:24
  • Can you send me the screen shots of all the profiles and tasks that you made using this answer in details? IDK how to export and restore tasker data.
    – Firelord
    May 11, 2015 at 19:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .