DIY-Actions: Execute Command, Execute Root Command
Moderator: Martin
DIY-Actions: Execute Command, Execute Root Command
Hi,
Many interesting features available on Android can be accessed on the command line respectively by using the actions Execute Command and Execute Root Command.
The goal of this post is to collect interesting commands that extend the capabilities of Automagic (it is not the goal to create a complete Android command line reference).
Feel free to add more commands and variations of already listed commands by replying to this post. Optionally also include a link to a published flow that shows how the feature can be used.
Thanks!
Martin
Not all commands work on all devices/Android versions.
Action Execute Command
Command: ps
Report a snapshot of the current processes running on the device. Use variable stdout to access the output.
Command: am bug-report
Developer options and USB debugging must be enabled. Create a bug report using all kind of system data including a screenshot and allows the data to be sent by mail after a few seconds. Device vibrates when the bug report is created and ready to be sent. This method might be useful to create a screenshot without root. The screenshot is stored in /mnt/sdcard/Pictures/Screenshot/Screnshot_<timestamp>.png
Action Execute Root Command use at your own risk and have a backup ready
Command: screencap -p /mnt/sdcard/test.png
Create a screenshot and store in the specified file.
Command: input text <text>
Enters the specified text into the currently focused text field or component.
Command: input keyevent <keyevent>
Newer Android devices (Android 4+) can use the name of the key event, older Android devices have to use the numeric value of the key event.
Simulates the specified keyevent. Keyevent values are available here: API doc KeyEvent and here: Simulating keypress events on Android
Simulate DPAD:
input keyevent DPAD_UP resp. input keyevent 19
input keyevent DPAD_DOWN resp. input keyevent 20
input keyevent DPAD_LEFT resp. input keyevent 21
input keyevent DPAD_RIGHT resp. input keyevent 22
input keyevent DPAD_CENTER resp. input keyevent 23
Press the Power button to turn off the display: input keyevent POWER resp. input keyevent 26
Press the menu key to pass the slide to unlock keyguard: input keyevent MENU resp. input keyevent 82
Enter a pin/pass in the keyguard and press enter: input text 1234, input keyevent ENTER resp. input keyevent 66
Command: reboot
Reboot the device. Be careful, seems a little bit too fast for a regular shutdown.
Command: reboot -p
Shutdown the device. Be careful, seems a little bit too fast for a regular shutdown.
Command: pm disable <package name>
Disable an app/package and also stops services and processes of the specified package.
Command: pm enable <package name>
Enable a disabled app/package again.
Command: am force-stop <package name>
Force-stop an app/package. Might be an alternative way to kill an app.
Command: service call activity 42 s16 com.android.systemui
Remove/Stop the statusbar/buttonbar (back, home, recents) to gain screen real estate.
Command: am startservice -n com.android.systemui/.SystemUIService
Show/Restart the statusbar/buttonbar (back, home, recents). You might need to reset your wallpaper.
Many interesting features available on Android can be accessed on the command line respectively by using the actions Execute Command and Execute Root Command.
The goal of this post is to collect interesting commands that extend the capabilities of Automagic (it is not the goal to create a complete Android command line reference).
Feel free to add more commands and variations of already listed commands by replying to this post. Optionally also include a link to a published flow that shows how the feature can be used.
Thanks!
Martin
Not all commands work on all devices/Android versions.
Action Execute Command
Command: ps
Report a snapshot of the current processes running on the device. Use variable stdout to access the output.
Command: am bug-report
Developer options and USB debugging must be enabled. Create a bug report using all kind of system data including a screenshot and allows the data to be sent by mail after a few seconds. Device vibrates when the bug report is created and ready to be sent. This method might be useful to create a screenshot without root. The screenshot is stored in /mnt/sdcard/Pictures/Screenshot/Screnshot_<timestamp>.png
Action Execute Root Command use at your own risk and have a backup ready
Command: screencap -p /mnt/sdcard/test.png
Create a screenshot and store in the specified file.
Command: input text <text>
Enters the specified text into the currently focused text field or component.
Command: input keyevent <keyevent>
Newer Android devices (Android 4+) can use the name of the key event, older Android devices have to use the numeric value of the key event.
Simulates the specified keyevent. Keyevent values are available here: API doc KeyEvent and here: Simulating keypress events on Android
Simulate DPAD:
input keyevent DPAD_UP resp. input keyevent 19
input keyevent DPAD_DOWN resp. input keyevent 20
input keyevent DPAD_LEFT resp. input keyevent 21
input keyevent DPAD_RIGHT resp. input keyevent 22
input keyevent DPAD_CENTER resp. input keyevent 23
Press the Power button to turn off the display: input keyevent POWER resp. input keyevent 26
Press the menu key to pass the slide to unlock keyguard: input keyevent MENU resp. input keyevent 82
Enter a pin/pass in the keyguard and press enter: input text 1234, input keyevent ENTER resp. input keyevent 66
Command: reboot
Reboot the device. Be careful, seems a little bit too fast for a regular shutdown.
Command: reboot -p
Shutdown the device. Be careful, seems a little bit too fast for a regular shutdown.
Command: pm disable <package name>
Disable an app/package and also stops services and processes of the specified package.
Command: pm enable <package name>
Enable a disabled app/package again.
Command: am force-stop <package name>
Force-stop an app/package. Might be an alternative way to kill an app.
Command: service call activity 42 s16 com.android.systemui
Remove/Stop the statusbar/buttonbar (back, home, recents) to gain screen real estate.
Command: am startservice -n com.android.systemui/.SystemUIService
Show/Restart the statusbar/buttonbar (back, home, recents). You might need to reset your wallpaper.
Re: DIY-Actions: Execute Command, Execute Root Command
Execute Root command example:
dumpsys is a very detailed command which gives info about service infos:
first, try this in console:
dumpsys | grep DUMP
you'll get services list that you can diagnose.. examples:
dumpsys battery : to get voltage and temperature
dumpsys appwidget : (better use this command like this at first = dumpsys appwidget > /mnt/sdcard/1.txt) and you can examine 1.txt
all available widgets, and which commands are executed on those widgets..
dumpsys statusbar : read the status bar and status bar notifications !
dumpsys is a very detailed command which gives info about service infos:
first, try this in console:
dumpsys | grep DUMP
you'll get services list that you can diagnose.. examples:
dumpsys battery : to get voltage and temperature
dumpsys appwidget : (better use this command like this at first = dumpsys appwidget > /mnt/sdcard/1.txt) and you can examine 1.txt
all available widgets, and which commands are executed on those widgets..
dumpsys statusbar : read the status bar and status bar notifications !
Re: DIY-Actions: Execute Command, Execute Root Command
Hi,
For older versions of Android (I have checked with 2.3.6), keyevent with event name as text is not working, like
input keyevent DPAD_DOWN
instead you should pass numeric values, like
input keyevent 20
You can find the list of numeric values associted with the corresponding texts here:
http://thecodeartist.blogspot.in/2011/0 ... evice.html
For older versions of Android (I have checked with 2.3.6), keyevent with event name as text is not working, like
input keyevent DPAD_DOWN
instead you should pass numeric values, like
input keyevent 20
You can find the list of numeric values associted with the corresponding texts here:
http://thecodeartist.blogspot.in/2011/0 ... evice.html
Samsung Galaxy Note 8
Android 9.
Non-rooted
Android 9.
Non-rooted
Re: DIY-Actions: Execute Command, Execute Root Command
Hi pilusona,
Thanks for the note, updated the post.
Regards,
Martin
Thanks for the note, updated the post.
Regards,
Martin
Re: DIY-Actions: Execute Command, Execute Root Command
Hi,
is there any way to switch the logging off? I use a password in the command string and i don't want to see it in the log.
Thanks Rene
is there any way to switch the logging off? I use a password in the command string and i don't want to see it in the log.
Thanks Rene
Re: DIY-Actions: Execute Command, Execute Root Command
I've found a workaround: At the end of my flow i kill(9) the Automagic process itself by an action.
Not nice but the log is cleared in the app.
Rene
Not nice but the log is cleared in the app.
Rene
Re: DIY-Actions: Execute Command, Execute Root Command
Hi,
No sorry, the logging can not be turned off.
You could also move the command to a shell script and execute the script from within Automagic.
Regards,
Martin
No sorry, the logging can not be turned off.
You could also move the command to a shell script and execute the script from within Automagic.
Regards,
Martin
Re: DIY-Actions: Execute Command, Execute Root Command
Thanks for your hint. But i ask for the password by an input action in AM and have to send it to the shell. And this will be always logged by the command action, isn't it.
P.S.: The disadvantage of killing AM in the workaround is that no global variables are stored at the end of the flow.
Regards
Rene
P.S.: The disadvantage of killing AM in the workaround is that no global variables are stored at the end of the flow.
Regards
Rene
Re: DIY-Actions: Execute Command, Execute Root Command
Yes, it's probably not possible to suppress the log in this case.
I will add an entry to my todo-list to create a new action to clear the log in a future release.
Regards
Martin
I will add an entry to my todo-list to create a new action to clear the log in a future release.
Regards
Martin
Re: DIY-Actions: Execute Command, Execute Root Command
I'm trying to create a flow when the smartphone is shaked it will take a screenshot.
execute root command
screencap -p /mnt/sdcard/screencap.png
after I trying to rename this file to
mv /mnt/sdcard/screencap.png /mnt/sdcard/screencap_{date_hour}.png
if I don't use the variable, it works, but with the variable doesn't work....
Someone can help me?
I just try to get the trigger time from the clipboard, but no success.
execute root command
screencap -p /mnt/sdcard/screencap.png
after I trying to rename this file to
mv /mnt/sdcard/screencap.png /mnt/sdcard/screencap_{date_hour}.png
if I don't use the variable, it works, but with the variable doesn't work....
Someone can help me?
I just try to get the trigger time from the clipboard, but no success.