Skip to content

Instantly share code, notes, and snippets.

@ShaunPlummer
Last active November 14, 2023 11:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShaunPlummer/1678c8f2dd67d7600f671b194adeabf5 to your computer and use it in GitHub Desktop.
Save ShaunPlummer/1678c8f2dd67d7600f671b194adeabf5 to your computer and use it in GitHub Desktop.
# A series of bash functions to make working with adb commnads easier
# Add the following to your .bashrc
#if [ -f ~/.adb_functions ]; then
# . ~/.adb_functions
#fi
# List all apps installed on the mobile device
alias installed='adb shell pm list packages'
# Turn on the show layout bound debug setting
# https://stackoverflow.com/questions/23799848/how-to-easily-show-layout-bounds-for-android-debugging
showLayoutBounds() {
adb shell setprop debug.layout true
adb shell service call activity 1599295570
}
# Turn off the show layout bound debug setting
hideLayoutBounds() {
adb shell setprop debug.layout false
adb shell service call activity 1599295570
}
# Usage: 'wifiDebugging 192.168.1.5' to set make the device available for wireless debugging
wifiDebugging() {
adb tcpip 5555
adb connect $1
}
# Usage: 'setBattery 49' to set android device battery level to some value
setBattery() {
adb shell dumpsys battery set level $1
}
# Reset battery information to actual device values
alias resetBattery='adb shell dumpsys battery reset'
# Usage: 'runJobTask id' where 'id' is the JobScheduler ID
runJobTask() {
adb shell cmd jobscheduler run -f com.foo.bar.application $1
}
# Usage: 'backgroundRequirements com.example' Enforce Android O backgroud limits to be applied.
backgroundRequirements() {
adb shell cmd appops set $1 RUN_IN_BACKGROUND deny
}
# Usage: 'backgroundNormal com.example' Remove Android O backgroud restrictions
alias backgroundNormal='adb shell cmd appops set com.bowers_wilkins.headphones RUN_IN_BACKGROUND deny`'
backgroudNormal() {
adb shell cmd appops set $1 RUN_IN_BACKGROUND allowó
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment