【Android】在build/envsetup.sh中添加自己的命令(函数)

由于测试的需要,经常需要手动刷入boot.img和system.img,把它写到envsetup.sh就可以每次使用一行命令来代替了;

function flashtestimage(){
    if [[ "$(fastboot devices | grep \"fastboot\")" == "" ]]; then
        adb -s 0123456789ABCDEF reboot bootloader
    fi
    fastboot flash boot $OUT/boot.img
    fastboot flash system $OUT/system.img
    fastboot reboot
}

function flashallimage(){
    fastboot flash boot $OUT/boot.img
    fastboot flash system $OUT/system.img
    fastboot -w
    fastboot reboot
}

function cdevice(){
    croot
    if [[ "$TARGET_PRODUCT" != "" ]]; then
        cd $(find device/ -maxdepth 2 -type d | grep $(echo $TARGET_PRODUCT | awk -F'_|-' '{print $2}'))
    else
        echo "\$TARGET_PRODUCT NO SET!"
    fi
}

cdevice是用于切换至device/厂商/型号/目录下;

posted @ 2013-06-30 02:41  scue  阅读(506)  评论(0编辑  收藏  举报