Adb install progress bar

2020-08-13 04:40发布

问题:

I'm a beginner at this so just mind me if I ask anything obvious. I'm trying to install an apk to my device using adb install apk.apk however, the apk is around a few hundred MB big and it takes some time. Is there some sort of progress bar that I could implement in the command window to show the progress? I've seen stuff for adb push/pull . I'm not sure if it's the same. I'm running this in Windows 8.1. I also have an adb environment variable set up.

Thanks so much.

回答1:

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.



回答2:

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
}