简体   繁体   English

使用一些 ADB 命令(拉/推)随机返回

[英]Random returns with some ADB command (Pull/Push)

I'm facing some problems with adb commands pull/push.我在使用 adb 命令拉/推时遇到了一些问题。

Sometimes, the command work well, I launch it, I get the percent and the result at the end:).有时,该命令运行良好,我启动它,最后得到百分比和结果:)。 Like this:像这样:

在此处输入图像描述 在此处输入图像描述

But sometimes the command doesn't return anything until it's finished.但有时该命令在完成之前不会返回任何内容。 So instead of getting the progress I get nothing but an empty line:/因此,除了一个空行,我什么也没得到,而不是取得进展:/

在此处输入图像描述

And the result at the end最后的结果

在此处输入图像描述

Of course, both behaviors are obtained with exactly the same environment.当然,这两种行为都是在完全相同的环境下获得的。 Same device, same powershell window, same cable... But with an interval of 5 minutes...相同的设备,相同的 powershell window,相同的电缆……但间隔为 5 分钟……

I tried to reproduce the behavior many times, by changing the usb connection type of the device, killing and restarting the adb server, unplugging and replugging the device, changing adb server port, checking TCP connexion, use another command line tool... But I never found anything tangible我尝试多次重现该行为,通过更改设备的 usb 连接类型,杀死并重新启动 adb 服务器,拔下并重新插入设备,更改 adb 服务器端口,检查 TCP 连接,使用另一个命令行工具......但是我从未发现任何有形的东西

My final goal is to have a software that launches the pull/push and displays the progress during the process.我的最终目标是拥有一个软件来启动拉/推并在此过程中显示进度。 Everything works fine, but obviously only when the adb command returns the right things一切正常,但显然只有当 adb 命令返回正确的东西时

Is there some options that I'm missing?有一些我缺少的选项吗? Can I force the behavior?我可以强迫这种行为吗?

I'm using ADB version 31.0.3 and differents Android phone (Samsung/Huawei and Oppo)我正在使用 ADB 版本 31.0.3 和不同的 Android 手机(三星/华为和 Oppo)

This is interesting, For me, it's seems like the command you are executing should run as a background job eg - a task that may execute for a while and you wish to run in the background in order to avoid it to block your current session这很有趣,对我来说,您正在执行的命令似乎应该作为background job运行,例如 - 一个可能执行一段时间的任务并且您希望在后台运行以避免它阻止您当前的 session

Following this answer which direct us to the official documentation , it seems we need to do something like this:按照这个将我们引导到官方文档答案,我们似乎需要做这样的事情:

$job = Start-Job adb pull -a "some_video-file.mp4"
Wait-Job $job
Receive-Job $job

It should wait until the job is completed (regardless to the overall files size, which in our case - impacts how long the operation will take) and only then return the output (signaling that the upload process is completed)它应该等到作业完成(不管整体文件大小,在我们的例子中,这会影响操作需要多长时间),然后才返回 output(表示上传过程已完成)

The only question remains - will it work?唯一的问题是——它会起作用吗? Please try this and share your findings with us.请试试这个并与我们分享您的发现。 tnx tnx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM