Created
June 26, 2018 11:22
-
-
Save trevd/ccf3446554d7eadf1c674216a48cb1a0 to your computer and use it in GitHub Desktop.
Bash Functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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