I made a simple shell (actually windows batch) script that automates a task on android phone. It can be ran on any computer. I thought that if I convert the batch to linux sh
script, I could issue the commands without adb shell
before them.
So this (.exe
added for clarity):
adb.exe shell sleep 1
becomes this:
sleep 1
Well it works with sleep
in particular, but not with sendevent
. I made a script to press and release focus button:
#!/bin/sh
# Simply send two key events to see if it works (spoiler: it doesn't)
sendevent /dev/input/event0 1 212 1
sendevent /dev/input/event0 0 0 0
sleep 1
sendevent /dev/input/event0 1 212 0
sendevent /dev/input/event0 0 0 0
But I cannot execute the sendevent
commands:
That's ridiculous. Obviously my phone is capable of executing the commands from external source, so why the hell not from itself? Am I going to need a computer to work with the shell?
What can I do to issue adb commands to my own phone? (I am not using rooted device. Android developers made it too much painful to achieve.)
event0
device file. This has nothing to do with whether or not you can execute a command. This is special to that single command and can be solved by requesting appropriate permissions (root permissions in that case).su
) or by flashing a custom kernel compiled for permissive mode (most of which root your device or need root for management anyway). There might be another way around your issue, if so, please open a new question stating what you want to achieve.