### Function declare ###
function _stdOut() {
echo -e "\033[32m"; #Green output
echo $1;
echo -e "\e[0m"; #Normal output
}
function _stdErr() {
echo -e "\033[31m"; #Red output
echo $1;
echo -e "\e[0m"; #Normal ouput
}
### Step 1: Retrieve the module from console ###
if [ $1 != "" -a $2 != "" ]
then
PRODUCT=$1;
MODULE=$2;
echo "Product is ${PRODUCT}, Module is ${MODULE}";
else
_stdErr "Usage: $0 product_name module_name";
exit;
fi
### Step 2: Change Diretory to current and set environment ###
CUR_DIR=$(pwd);
cd ${CUR_DIR};
source build/envsetup.sh > /dev/null;
### Step 3: Compile ###
rm -rf out/target/product/${PRODUCT}/system/app/${MODULE}.apk;
#./makeMtk -t far2 mm packages/apps/${MODULE};
mmm packages/apps/$MODULE | grep "Install";
if [ $? != 0 ]
then
_stdErr "Make error.";
exit;
fi
### Step 4: Uninstall ###
ls -al out/target/product/${PRODUCT}/system/app/${MODULE}.apk | \
egrep -o "([0-9]{4})-([0-1][0-9])-([0-9]{2}) ([0-9]{2}):([0-9]{2})";
if [ $? != 0 ]
then
_stdErr "ERROR";
exit;
fi
adb root > /dev/null;
adb remount > /dev/null;
adb shell rm /system/app/${MODULE}.apk;
adb uninstall com.android.mms > /dev/null;
### Step 5: Install ###
adb push out/target/product/${PRODUCT}/system/app/${MODULE}.apk /system/app/;
_stdOut "${MODULE} has been pushed to ${PRODUCT}.";