@@ -6,9 +6,13 @@ Invoke ". build/envsetup.sh" from your shell to add the following functions to y
66- croot: Changes directory to the top of the tree.
77- m: Makes from the top of the tree.
88- mm: Builds all of the modules in the current directory, but not their dependencies.
9+ - mmp: Builds all of the modules in the current directory and pushes them to the device.
910- mmm: Builds all of the modules in the supplied directories, but not their dependencies.
11+ - mmmp: Builds all of the modules in the supplied directories and pushes them to the device.
1012- mma: Builds all of the modules in the current directory, and their dependencies.
1113- mmma: Builds all of the modules in the supplied directories, and their dependencies.
14+ - mfwk: Build frameworks/base projects
15+ - mfwkp: Build frameworks/base projects and pushes them to the device
1216- cgrep: Greps on all local C/C++ files.
1317- jgrep: Greps on all local Java files.
1418- resgrep: Greps on all local res/*.xml files.
2529 echo $A
2630}
2731
32+ alias mmp=' dopush mm'
33+ alias mmmp=' dopush mmm'
34+ alias mfwk=' mmm frameworks/base/core/res frameworks/base frameworks/base/services/java frameworks/base/packages/SystemUI'
35+ alias mfwkp=' dopush mmm frameworks/base/core/res frameworks/base frameworks/base/services/java frameworks/base/packages/SystemUI'
36+
2837# Get the value of a build variable as an absolute path.
2938function get_abs_build_var()
3039{
@@ -760,6 +769,70 @@ function mmma()
760769 fi
761770}
762771
772+ # Credit for color strip sed: http://goo.gl/BoIcm
773+ # Original implementation was taken from CyanogenMod's envsetup.sh
774+ function dopush()
775+ {
776+ local func=$1
777+ shift
778+
779+ adb start-server # Prevent unexpected starting server message from adb get-state in the next line
780+ if [ " $( adb get-state) " != device -a " $( adb shell busybox test -e /sbin/recovery 2> /dev/null; echo $? ) " != 0 ] ; then
781+ echo " No device is online. Waiting for one..."
782+ echo " Please connect USB and/or enable USB debugging"
783+ until [ " $( adb get-state) " = device -o " $( adb shell busybox test -e /sbin/recovery 2> /dev/null; echo $? ) " = 0 ]; do
784+ sleep 1
785+ done
786+ echo " Device Found."
787+ fi
788+
789+ # retrieve IP and PORT info if we're using a TCP connection
790+ TCPIPPORT=$( adb devices | egrep ' ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+[^0-9]+' \
791+ | head -1 | awk ' {print $1}' )
792+ adb root & > /dev/null
793+ sleep 0.3
794+ if [ -n " $TCPIPPORT " ]
795+ then
796+ # adb root just killed our connection
797+ # so reconnect...
798+ adb connect " $TCPIPPORT "
799+ fi
800+ adb wait-for-device & > /dev/null
801+ sleep 0.3
802+ adb remount & > /dev/null
803+
804+ # Running the function we planned on running
805+ $func $*
806+
807+ # Running adb sync, to sync all the changed modules to the device.
808+ # Since ADB writes to stderr, we'll redirect it to stdout and also to the .log file
809+ adb sync 2>&1 | tee $OUT /.log
810+
811+ # Looking for rows with this structure: "push: <local file> -> <remote file>"
812+ LOC=$( cat $OUT /.log | sed -r ' s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | grep ' push:' | cut -d ' ' -f 4)
813+
814+ if [ ! -z " $LOC " -a " $LOC " != " " ]; then
815+ echo -e " \n ** Number of files synced - $( echo $LOC | wc -l) **\n"
816+ else
817+ echo -e " \n ** No files were synced to the device **\n"
818+ fi
819+
820+ # If one of the synced files require restarting the shell - do that
821+ while read -r file; do
822+ case $file in
823+ * /SystemUI.apk|/system/framework/* )
824+ echo -e " ** Restarting the shell **\n"
825+ adb shell stop
826+ adb shell start
827+ break
828+ ;;
829+ esac
830+ done <<< " $LOC"
831+
832+ rm -f $OUT /.log
833+ return 0
834+ }
835+
763836function croot()
764837{
765838 T=$( gettop)
0 commit comments