Setting up camera capture on locked phone

I have tasker pro and after a number of attempts I was unable to get my phone to capture a photograph remotely through an SMS. I have given tasker required permissions through:

adb shell pm grant net.dinglisch.android.taskerm android.permission.WRITE_SECURE_SETTINGS

But it seems like it just doesn’t work, as mentioned here: Locked screen photo help : tasker

So I really need this functionality and decided to go the tasker + termux route.

Installing dependencies

  • First you need Termux:Tasker which will bridge tasker and termux. You’ll need to grant tasker permissions to use termux, you’ll find this in tasker’s additional permissions section.
  • After that you’ll need to use the program called termux-camera-photo which requires termux to have access to your phone api. For this you’ll have to install Termux:API(This will grant you the required permissions) once done you’ll have to install termux-api inside termux which will have you installed termux-camera-photo and other programs which will use the Termux:API.
  • At this point you’re all set to take photos using termux. See termux-camea-photo -h

Setting up storage

  • But by default termux does not have shared storage on. What I intended to do is take photograph and upload it to google drive, this requires termux to have shared storage access so that it can store the photo. See Internal and external storage - Termux Wiki. You simply have to run termux-setup-storage and you’ll be good to go.

Execution from tasker to tmux

  • Now I need to setup tasker to use termux to capture the photo. This requires setting the allow-external-apps to true in ~/.termux/termux.properties. (Basically uncommenting a line). I had issues with this approach
  • The approach I used is just creating bash scripts inside ~/.termux/tasker and using them from the termux plugin inside tasker. Works great :)