ADB推/拉进度条 [英] adb push/pull with progress bar

查看:3462
本文介绍了ADB推/拉进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这实在是烦人,如果你ADB推/拉大文件到设备上,有没有办法到现在多长时间了它。是否有可能运行ADB推或拉,亚行并获得使用棒工具的进度条?

It is really annoying if you adb push/pull large files to the device that there's no way to now how far along it is. Is it possible to run adb push or adb pull and get a progress bar using the 'bar' utility?

这里的主要问题是,我认为,亚行预计,两个文件名,如果输入文件可以通过标准输入来代替你可以通过栏工具管道,并得到一个进度条。到目前为止,我还没有做得很成功,但我不是一个真正的外壳大师这就是为什么我在这里问:)

The main issue here is I think that adb expects two file names, if the input file could be replaced by stdin you could pipe through the 'bar' utility and get a progress bar. So far I haven't succeeded in doing so, but I'm not really a shell guru which is why I'm asking here :)

请注意,我在使用bash的Linux。

Note that I'm on Linux using bash.

推荐答案

它看起来像最新的亚行进步的支持。

It looks like the latest adb has progress support.

Android Debug Bridge version 1.0.32
device commands:
adb push [-p] <local> <remote>
    - copy file/dir to device
    ('-p' to display the transfer progress)

然而,上面还答案工作'亚行安装,这不具有进步选项。我修改了第一个答案的脚本,以这种方式工作:

However, the answers above also work for 'adb install' which do not have a progress option. I modified the first answer's script to work this way:

创建adb-install.sh在系统的路径,并运行adb-install.sh,而不是亚行安装-f

Create "adb-install.sh" somewhere in your PATH and run "adb-install.sh " instead of "adb install -f "

#!/bin/bash
# adb install with progressbar displayed
# usage: <adb-install.sh> <file.apk>
# original code from: http://stackoverflow.com/questions/6595374/adb-push-pull-with-progress-bar

function usage()
{
    echo "$0 <apk to install>"
    exit 1
}

function progressbar()
{
    bar="================================================================================"
    barlength=${#bar}
    n=$(($1*barlength/100))
    printf "\r[%-${barlength}s] %d%%" "${bar:0:n}" "$1"
    # echo -ne "\b$1"
}

export -f progressbar

[[ $# < 1 ]] && usage

SRC=$1

[ ! -f $SRC ] && { \
    echo "source file not found"; \
    exit 2; \
}

which adb >/dev/null 2>&1 || { \
    echo "adb doesn't exist in your path"; \
    exit 3; \
}

SIZE=$(ls -l $SRC | awk '{print $5}')
export ADB_TRACE=all

adb install -r $SRC 2>&1 \
    | sed -n '/DATA/p' \
    | awk -v T=$SIZE 'BEGIN{FS="[=:]"}{t+=$7;system("progressbar " sprintf("%d\n", t/T*100))}'

export ADB_TRACE=

echo

echo 'press any key'
read n

这篇关于ADB推/拉进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆