[Atrix 4G Android Development] sendust7:
JB/ICS ROMs allow you to take a screenshot by long-pressing the Power and Volume Down simultaneously. But you may get unwanted screen artifacts or other strange behavior if you don’t press them exactly at the same time.

But my new Atrix4g Screen Shot (A4G SS) tool overcomes by invoking virtual key presses for Power and Volume Down using the “sendevent” command. Basically it’s remote control.

And it has a self-timer with adjustable delay. So among other things, you can run it with your built-in camera to take family/group portraits --- though the camera buttons will show :o.

Flashable zip (0.2 MB): http://www.mediafire.com/?18h1bzqcca3g15u

A4GG SS is tested working on CM10 SuperLite. I was going to try it on other JB/ICS ROMs but I ran out of time.

There are many ways to launch A4G SS. Examples:

Root Explorer (very simple once you set home directory to /system/bin)

Script Manager (not as simple at first, but easily configurable and settings are retained)

Terminal Emulator (not as simple but geeky)

ADB (remote operation)

Instructions on how to configure A4GG with Script Manager are given further below.

Key legends reside in the /system/usr/keylayout directory. Those of interest here are documented in my A4GG SS launch code:

#!/system/bin/sh

echo
echo "Atrix4g Screen Shot With Self-Timer!"
echo "Usage: sh a4g-screencap.sh [timer delay (sec)]"
echo "Default delay: 10 sec"
echo
echo "Initial Release: 11 May 2013"
echo "sendust7 @ xda developers"

#Atrix4g key map legends (decimal):

#/dev/input/event0
#key 107 POWER WAKE
#key 26 POWER WAKE
#key 226 HEADSETHOOK WAKE

#/dev/input/event1
#key 102 HOME WAKE
#key 139 MENU WAKE_DROPPED
#key 158 BACK WAKE_DROPPED
#key 211 FOCUS
#key 212 CAMERA
#key 115 VOLUME_UP WAKE
#key 114 VOLUME_DOWN WAKE
#key 217 SEARCH WAKE_DROPPED

echo
if grep -qs $EXTERNAL_STORAGE /proc/mounts; then
echo "$EXTERNAL_STORAGE mounted"
elif grep -qs $SECONDARY_STORAGE /proc/mounts; then
echo "$SECONDARY_STORAGE mounted"
else
echo "Phone storage not mounted. Exiting..."
exit 1
fi

echo
if [ $# -eq 0 ]; then
echo "Taking screen shot in 10 seconds..."
sleep 10
else
echo "Taking screen shot in $1 seconds..."
sleep $1
fi

#Long press POWER and VOL Down simultaneously
/system/bin/sendevent /dev/input/event0 1 107 1
/system/bin/sendevent /dev/input/event1 1 114 1

sleep 2

#Release POWER and VOL Down simultaneously
/system/bin/sendevent /dev/input/event0 1 107 0
/system/bin/sendevent /dev/input/event1 1 114 0

echo
echo "Done! Can exit now..."

exit 0

Instructions

Simply flash zip, reboot and optionally install/configure Script Manager (SManager): Go to Settings > Advanced > Configuration > Home directory. Navigate to /system/bin and “Select this directory” at bottom.

SManager: https://play.google.com/store/apps/details?id=os.tools.scriptmanager&hl=en

Make sure USB storage is turned off to save your screenshot. A4G SS includes logic to exit unless internal storage, external storage or both are mounted.

Then re-launch SManager, navigate to “/system/bin/atrix4g-ss-v1.0.sh” and tap:

“Su” (run as root --- setting is retained for later)
“Run”
“Home” (navigate to screen of interest)

Wait for the timeout. A message: “Saving screenshot” will appear at top. To view your screenshot, simply drag the pull down menu, tap the “Screenshot captured” bar and complete the action.

After screenshot, A4G SS exits gracefully. To re-launch from SManager, tap HOME > “Run Again”. To exit, tap the Back button on your Atrix.

If you want to change the default 10-second timeout, simply enter a different (positive) number in SManager’s argument box and re-launch. This setting is also retained.

Things go pretty fast after initial setup.

I understand many screenshot apps are available, and Screenshot UX is my favorite. But the trial version expires after 14 rounds  --- not because I don’t like to pay for a good app. I just don’t like Google having my credit card number.

My A4G SS tool is free, and the maximum allowable number of screenshots is limited only by available storage ;)

You can also run A4G SS from ADB-enabled remote device:

adb shell /system/bin/atrix4g-ss-v1.0.sh [N]

where N = delay time (sec).

This is how I took demo shots of A4G SS in action ;) I just set N=0 for an instant shot.

And you can spin your Atrix beauty into an efficient "still-moving" security cam using a delayed while loop and camera ON/shoot/OFF commands at fixed intervals. Something like this…

#Wait two hours
sleep 7200

#Start monitoring
while :
do

/system/bin/sendevent /dev/input/event1 1 212 1

sleep 2

#Long press POWER and VOL Down simultaneously
/system/bin/sendevent /dev/input/event0 1 107 1
/system/bin/sendevent /dev/input/event1 1 114 1

sleep 2

#Release POWER and VOL Down simultaneously
/system/bin/sendevent /dev/input/event0 1 107 0
/system/bin/sendevent /dev/input/event1 1 114 0

sleep 2

/system/bin/sendevent /dev/input/event1 1 158 0

#Wait 5 minutes until next picture
sleep 300

done

The companion “getevent” command is also very useful. For example it helps you learn the various key legends or to capture a time stamped history of sendevent commands.

Usage: getevent [-t] [-n] [-s switchmask] [-S] [-v [mask]] [-d] [-p] [-i] [-l] [-q] [-c count] [-r] [device]
-t: show time stamps
-n: don't print newlines
-s: print switch states for given bits
-S: print all switch states
-v: verbosity mask (errs=1, dev=2, name=4, info=8, vers=16, pos. events=32, props=64)
-d: show HID descriptor, if available
-p: show possible events (errs, dev, name, pos. events)
-i: show all device info and possible events
-l: label event types and names in plain text
-q: quiet (clear verbosity mask)
-c: print given number of events then exit
-r: print rate events are received
1|root@android:/ #

Screenshots

Blessings... Enjoy!

Disclaimer: Standard disclaimers apply.

References:

http://android.stackexchange.com/questions/26261/documentation-for-adb-shell-getevent-sendevent

http://source.android.com/tech/input/getevent.html

http://fangmobile.com/2012/11/06/an...lick-on-screen-for-ics-and-may-be-jelly-bean/

https://groups.google.com/forum/?fromgroups=#!topic/android-beginners/il2PqSKRFNI