Created
July 14, 2022 14:50
-
-
Save leonschreuder/4e52daffe78129b801b5d3daf4773ba3 to your computer and use it in GitHub Desktop.
aosp helper script for syncing files built using mm
This file contains 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
#!/bin/bash | |
# little application | |
main() { | |
assertCorrectAdb | |
assertAdbConnected | |
remountAsRootIfRequired | |
echo "# syncing..." | |
adb sync | |
echo "# restarting..." | |
adb shell 'stop; start' | |
echo "# DONE" | |
} | |
assertCorrectAdb() { | |
if [[ "$(which adb)" == "/usr/bin/adb" ]]; then | |
exitWithError "it doesn't seem like you've had lunch yet" | |
fi | |
} | |
assertAdbConnected() { | |
if ! adb get-state 1>/dev/null 2>&1; then | |
exitWithError "no device connected" | |
fi | |
} | |
remountAsRootIfRequired() { | |
result="$(adb shell 'getprop service.adb.root')" | |
if [[ $result != 1 ]];then | |
echo "# getting root..." | |
adb root | |
sleep 1 | |
fi | |
if ! adb shell 'test -w /product/etc/selinux/'; then | |
echo "# remounting..." | |
adb remount | |
sleep 2 | |
fi | |
} | |
exitWithError() { | |
echo "ERROR: $*" >&2 | |
exit 1 | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment