Skip to content

Instantly share code, notes, and snippets.

@trevd
Created June 26, 2018 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trevd/ccf3446554d7eadf1c674216a48cb1a0 to your computer and use it in GitHub Desktop.
Save trevd/ccf3446554d7eadf1c674216a48cb1a0 to your computer and use it in GitHub Desktop.
Bash Functions
function keyevent ()
{
KEYSRC=/build/master/frameworks/base/core/java/android/view/KeyEvent.java
echo "count $# "
if [[ $# -eq 0 ]]; then
echo "No keycode specified - Printing List"
grep "int KEYCODE.*" $KEYSRC | cut -d' ' -f9 | sort
return 1;
fi
echo "I=$OPTIND"
NEWKEY=$( echo keycode_$1 | sed 's/pip/window/g' | tr '[:lower:]' '[:upper:]'; )
F=$( grep --word-regex --only-matching $NEWKEY $KEYSRC | echo $? )
echo "F=$F"
if [[ $F -eq 1 ]]; then
echo "adb shell input keyevent $NEWKEY"
adb shell input keyevent $NEWKEY
return 1;
else
echo "KEYCODE $NEWKEY not found Did you mean"
grep --line--only-matching "$NEWKEY.*=" $KEYSRC
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment