morganestes
6/10/2014 - 9:23 PM

Android command-line tools for OS X.

Android command-line tools for OS X.

# Android helpers
alias phonescreencap="adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png"

# Creates a full backup using adb.
function phonebackup(){
	local timestamp=$(date "+%Y%m%dT%H%M%S")
	local phoneserial=$(adb get-serialno)
	
	adb backup -apk -shared -all -f "${HOME}/temp/villebackup/${phoneserial}-backup-${timestamp}.ab"
}

# Uses Android Backup Extractor to extract the .ab file created by phonebackup
# Requires JRE 1.7 or greater.
# abe.jar built from source at https://github.com/nelenkov/android-backup-extractor
# I put mine in ~/bin, and I'm using the homebrew cask java7 package.
# This works on my HTC One S (ville) running CyanogenMod (CM11).
function phonebackupextract(){
	local backup=$1

	java -jar ~/bin/abe.jar unpack "$backup" "$backup.tar"
}