Adb install progress bar

ぃ、小莉子 提交于 2019-12-05 00:53:55

Well, adb install apk.apk is just a glorified shortcut for:

adb push apk.apk /data/local/tmp
adb shell pm install /data/local/tmp/apk.apk
adb shell rm /data/local/tmp/apk.apk

So if you are so inclined to see the upload progress bar - just adb push -p your apk first and then adb shell pm install it either manually or with a simple script.

if you're not calling the push/install operation (for example, Android Studio is doing it for you), you can query the push status as follows (bash script):

function check_push_progress(){
     local push_to=$1 #path in the device
     local push_from=$2 #path to local file
     local current=0
     local complete=1
     while [ $current -ne $complete ]; do
        current=`adb shell ls -l $push_to | awk '{print $5}'`
        complete=`ls -l $push_from | awk '{print $5}'`
        echo pushed $current bytes, out of $complete bytes, $((100*$current/$complete))%
        sleep 1
    done
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!