Skip to content

Instantly share code, notes, and snippets.

@TheMightyLlama
Last active September 18, 2021 02:19
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save TheMightyLlama/7801820 to your computer and use it in GitHub Desktop.
Save TheMightyLlama/7801820 to your computer and use it in GitHub Desktop.
List of ADB commands for obtaining information from an application
#Gets screen capture of device every 270 seconds and outputs screencap to timestamped png file in local directory
while true; do adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > ScreenCap.`date +%Y`.`date +%m`.`date +%d`-`date +%H`.`date +%M`.`date +%S`.png; sleep 270; done
#Gets logs from device and outputs them to a timestamped file in local directory
while true; do adb logcat -v time > logging`date +%Y`.`date +%m`.`date +%d`-`date +%H`.`date +%M`.`date +%S`.txt; done
#Gets PID of <packagename>
adb shell ps | grep <packagename>
#Outputs battery level to console
adb shell dumpsys battery | grep level
#Outputs battery usage for <packagename> to console every two seconds
while true; do adb shell dumpsys cpuinfo | grep <packagename>;adb shell dumpsys battery | grep level; sleep 2; done
#Gives permission to package to read logs
adb shell
su
pm grant <packagename> android.permission.READ_LOGS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment