adb 

Send to Kindle
home » snippets » android » adb



Snippets

Listing packages

adb shell pm list packages | grep -i chrome

# package:com.android.chrome
# package:com.google.android.apps.chrome_dev
# package:com.google.android.apps.chrometophone

# So now you can use intents, like
NAME=com.google.android.apps.chrome_dev
adb shell am start \
  -a android.intent.action.VIEW \
  -n $NAME \
  -c android.intent.category.LAUNCHER \
  -d http://www.google.com

Tethering

From: answer at askubuntu.com

# Interface with the default route on the Android device.
android_gw_if=$(adb shell ip route list 0.0.0.0/0 | sed -n -e 's/^.* dev  *\([^ ]*\).*/\1/p' -e 'T' -e 'q')
adb ppp "shell:pppd nodetach noauth noipdefault /dev/tty" nodetach noauth noipdefault notty 192.168.254.2:192.168.254.1
adb shell "echo 1 >/proc/sys/net/ipv4/ip_forward"
adb shell "iptables -P FORWARD ACCEPT"
adb shell "iptables -t nat -I POSTROUTING -s 192.168.254.2 -j MASQUERADE -o $android_gw_if"
sleep 1 # give the ppp connection time to establish itself
route add -net default gw 192.168.254.1