Skip to content

Instantly share code, notes, and snippets.

@riansanderson
Last active April 13, 2017 07:14
Show Gist options
  • Select an option

  • Save riansanderson/7324563 to your computer and use it in GitHub Desktop.

Select an option

Save riansanderson/7324563 to your computer and use it in GitHub Desktop.
# capture a screen shot over adb first works in linux, second works mac+windows
adb shell screencap -p | sed 's/\r$//' > screen.png
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png
# samsung reload firmware on demand
*#2663#
# samsung test mode app
*#0*#
# switch the android tag your repo is building against
repo init -b android-5.0.0_r7; repo sync
# get adb to recognize a new device (needs testing, but you get the idea)
$ lsusb
Bus 001 Device 002: ID 0fce:6156 Sony Ericsson Mobile
$ echo 0x0fce > /tmp/adb-tmp && cat /tmp/adb-tmp >> ~/.android/adb_usb.ini
$ echo SUBSYSTEM=="usb", SYSFS{idVendor}=="0fec", MODE="0666" > /tmp/adb-tmp && cat /tmp/adb-tmp >> /etc/udev/rules.d/51-android.rules
$ adb kill-server
$ #unplug device, and replug in
$ adb devices
# remount partitions when adb remount won't work
su; mount -o rw,remount / /system /data
#send back/home/ keys via adb
## use KEY_CODE_XXX from http://developer.android.com/reference/android/view/KeyEvent.html
adb shell input keyevent 4 # send back key to target
adb shell input keyevent 3 # send home key to target
adb shell input keyevent 26 # send power on key
adb shell input keyevent 82 # send key to login past entry screen
# soft keys via keyboard
ESC => back
CTRL+ESC => menu
ALT+ESC => home
ALT+TAB => apps
# pull an installed APK off a device
adb shell pm list package
adb shell pm path com.something.interesting
adb pull /data/app/com.something.interesting-1.apk
# or
adb shell ls /data/app/ | awk '/step/ {system("adb pull /data/app/" $1)}'
# start android apps from the command line (substitude the pakacge and main activity name appropriately!)
adb shell am start -n com.fivasim.androsensor/.SensorActivity
# reflash the data partion using fastboot
adb reboot bootloader
fastboot devices
fastboot flash userdata userdata.img
fastboot reboot
# reflash commands for all the important bits
fastboot flash xloader MLO
fastboot flash bootloader u-boot.bin
fastboot flash boot boot.img
fastboot flash system system.img
fastboot flash cache cache.img
fastboot flash userdata userdata.img
fastboot reboot
# push all the .so files to a device
find . -name '*.so' -exec adb push {} /system/lib/ \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment