Skip to content

Instantly share code, notes, and snippets.

@radixdev
Last active August 23, 2017 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radixdev/8d8def1011a68a36ecfa710ccf4392e7 to your computer and use it in GitHub Desktop.
Save radixdev/8d8def1011a68a36ecfa710ccf4392e7 to your computer and use it in GitHub Desktop.
Assorted android scripts
#!/bin/bash
# Modified from http://androiddevcorner.blogspot.ca/2014/08/automating-adb-over-wi-fi-for-multiple.html
#Modify this with your IP range
MY_IP_RANGE="192\.168\.1"
#You usually wouldn't have to modify this
PORT_BASE=5555
#List the devices on the screen for your viewing pleasure
adb devices
echo
#Find USB devices only (no emulators, genymotion or connected devices
declare -a deviceArray=(`adb devices -l | grep -v emulator | grep -v vbox | grep -v "${MY_IP_RANGE}" | grep " device " | awk '{print $1}'`)
echo "found ${#deviceArray[@]} device(s)"
echo
for index in ${!deviceArray[*]}
do
echo "finding IP address for device ${deviceArray[index]}"
echo "ifconfig wlan output:" "$(adb -s ${deviceArray[index]} shell ifconfig wlan0)"
IP_ADDRESS=$(adb -s ${deviceArray[index]} shell ifconfig wlan0 | grep 'inet addr:' | grep -o '\(\d\{1,3\}\.\)\{1,4\}\d\{1,3\}' | head -n 1)
echo "IP address found : \"$IP_ADDRESS\""
echo "Connecting..."
adb -s ${deviceArray[index]} tcpip $PORT_BASE
adb -s ${deviceArray[index]} connect "$IP_ADDRESS"
echo
echo
done
adb devices -l
echo
#exit
#!/bin/sh
package=$1
echo "Using package $package"
# if the package is null, JFI
if [ -z $package ]
then
echo "Package name is null. It's the first argument btw."
exit 1
fi
adb logcat | grep `adb shell ps | grep $package | cut -c10-15`
#!/bin/sh
package=$1
echo "Using package $package"
# if the package is null, JFI
if [ -z $package ]
then
echo "Package name is null. It's the first argument btw."
exit 1
fi
folder_name=appboy_dump_$package
# delete any previous dumps
rm -rf appboy_dump_$package
# pull the dump from the device
# adb shell "run-as com.appboy.sample cp -vr ./ /sdcard/Download/appboy_sample_dump"
adb -d shell "run-as $package cp -vr ./ /sdcard/Download/$folder_name"
adb -d pull /sdcard/Download/$folder_name
open $folder_name
atom $folder_name
# delete the temp folder
adb -d shell "rm -rf /sdcard/Download/$folder_name"
#!/bin/sh
package=$1
echo "Using package $package"
# if the package is null, JFI
if [ -z $package ]
then
echo "Package name is null. It's the first argument btw."
exit 1
fi
# this folder should exist in "."
folder_name_host=appboy_dump_$package
folder_name_device=/sdcard/Download/$folder_name_host
# sd card push
adb -d push $folder_name_host $folder_name_device
# pull from sd card
adb -d shell "run-as $package cp -vr $folder_name_device/. ."
# delete the temp folder
adb -d shell "rm -rf /sdcard/Download/$folder_name_device"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment