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_SETTINGSBut 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
taskerpermissions to usetermux, you’ll find this intasker’s additional permissions section. - After that you’ll need to use the program called
termux-camera-photowhich requirestermuxto 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 installtermux-apiinsidetermuxwhich will have you installedtermux-camera-photoand other programs which will use theTermux:API. - At this point you’re all set to take photos using
termux. Seetermux-camea-photo -h
Setting up storage
- But by default
termuxdoes not have shared storage on. What I intended to do is take photograph and upload it to google drive, this requirestermuxto have shared storage access so that it can store the photo. See Internal and external storage - Termux Wiki. You simply have to runtermux-setup-storageand you’ll be good to go.
Execution from tasker to tmux
- Now I need to setup
taskerto usetermuxto capture the photo. This requires setting theallow-external-appstotruein~/.termux/termux.properties. (Basically uncommenting a line). I had issues with this approach - The approach I used is just creating bash scripts inside
~/.termux/taskerand using them from thetermuxplugin insidetasker. Works great :)