biotinker / LibreTasks

An updated form of Omnidroid
Apache License 2.0
82 stars 22 forks source link

Add PowerOffAction #212

Closed bilboquet closed 7 years ago

bilboquet commented 7 years ago

Hi,

I've made few adjustment to the project (mostly fix some lint warnings and fix package declaration so that eclipse is happy) then I've added an action to power off the device. It requires ROOT which is a limitation but AFAIK it is mandatory for such an action. I hope you find this useful and merge it.

Regards,

biotinker commented 7 years ago

Thanks for the pull request! I looked over it briefly and all looks well, I'll merge it in after I have some time to build the app and test it out (hopefully this weekend).

I haven't tried it so I'm not 100% sure what the behavior here will be, but is it not the case that the first root request will come on the first trigger, which may well be at a time when the user cannot interact with the phone to approve it? If so, I may or may not delay the merge so that I can implement a menu option which will request root access, so the action will always work.

bilboquet commented 7 years ago

Thanks for your reply. You're right root access is requested the first time the action is triggered, so the user may not accept it if he's not in front of the phone. If I have some time I'll try to solve this issue and send you another merge request. Let me know if you solved it before me :)

bilboquet commented 7 years ago

Just added a function that should do the trick. On start-up, it tries to run "su" which trigger the authorisation (or not). The function return a bool which is actually not used. I imagine it can be used to hide or gray the actions or rules that require ROOT but it was too complicate for now. Only tested on rooted devices.

biotinker commented 7 years ago

Sounds good. I have an unrooted device, I'll test it out and barring any unforeseen problems try to make a new release by the end of the weekend

biotinker commented 7 years ago

It didn't appear to break anything on my unrooted device, so I'll merge this in to master and the new version should be out in the next day or two!