简体   繁体   English

将计算机和手机与 USB 电缆配对一次,然后始终通过 WiFi 使用 ADB,即使在重新启动后也是如此

[英]Pair computer and phone with USB cable once, and then always use ADB over WiFi, even after reboot

I'm using scrcpy to mirror the phone screen to computer, which uses adb .我正在使用scrcpy将手机屏幕镜像到使用adb的计算机。 I've followed the steps and it works:我已按照步骤操作,并且有效:

# connect via USB
adb devices
adb tcpip 5555
# now unplug USB, and the following will work over WiFi
adb connect 192.168.1.14:5555
scrcpy

But when you reboot the phone or computer, doing adb connect 192.168.1.14:5555 and scrcpy doesn't work anymore (NB: the phone IP hasn't changed, it's fixed).但是当您重新启动手机或计算机时,执行adb connect 192.168.1.14:5555并且scrcpy不再起作用(注意:电话 IP 没有改变,它已修复)。

Reading the answers from Run/install/debug Android applications over Wi-Fi? 通过 Wi-Fi 从运行/安装/调试 Android 应用程序中读取答案? , I see 3 options: ,我看到 3 个选项:

  • plug the USB cable each time before doing a wireless connection, but this is annoying, and somehow reduces the interest of wireless...每次进行无线连接前都要插入 USB 电缆,但这很烦人,并且不知何故降低了无线的兴趣......

  • Use "ADB over network" (main answer's screenshot), but as noted by many people in comments: "i do not have the "ADB over network" option in debugging option" ;使用“ADB over network”(主要答案的屏幕截图),但正如许多人在评论中指出的那样: “我在调试选项中没有“ADB over network”选项” so this option doesn't work for me所以这个选项对我不起作用

  • other techniques that need root (not possible for me)其他需要root的技术(对我来说不可能)

Question: how to pair the phone and computer with a USB cable only once , and then be able to use adb between them without having to use a USB connection first, after each reboot?问题:如何将手机和电脑与 USB 电缆配对一次,然后能够在它们之间使用adb而无需先使用 USB 连接,每次重启后?

Note: I don't use Android Studio, but only scrcpy .注意:我不使用 Android Studio,而只使用scrcpy

Based on all the information I have the next conclusion.根据所有信息,我得出了下一个结论。 Just for reference, how a low-level setup with changing add routes works inside, described here .仅供参考,更改add路由的低级设置如何在内部工作, 在此处描述 It comes up, there is a pretty straight thing inside changing navigation with adb tcpip <port> .它出现了,用adb tcpip <port>改变导航有一个非常直接的事情。

  1. The first thing we need to do, it's setup system property with tcp port with name setprop service.adb.tcp.port (and values with a port number) By default, there is not such property.我们需要做的第一件事是使用名称为setprop service.adb.tcp.port的 tcp 端口设置系统属性(以及带有端口号的值)默认情况下,没有这样的属性。

  2. And then just restart adb with few commands.然后用几个命令重新启动adb stop adbd and start adbd on a device in order to debug bridge listen new port. stop adbd并在设备上start adbd以调试桥接侦听新端口。 What is the trick here, that you don't have access to this service and stop/start it without root.这里的诀窍是什么,您无权访问此服务并在没有 root 的情况下停止/启动它。 But it could be easily done, via Developer setting with stop/start debugging.但它可以很容易地完成,通过开发人员设置停止/开始调试。

This few simple action hidden inside adb tcpip <port> .这几个简单的动作隐藏在adb tcpip <port>中。 And the problem, that you cannot change system properties (point 1).问题是您无法更改系统属性(第 1 点)。 That is why all application requires root access, it's just to change the single option.这就是为什么所有应用程序都需要 root 访问权限,这只是更改单个选项。 That is why, we need to connect with USB to debug bridge, which can change properties with his sepolicy.这就是为什么我们需要连接USB来调试桥接器,它可以用他的sepolicy改变属性。

So answering your question.所以回答你的问题。 I don't understand either, what is the problem or enabling this small setup in Developer options.我也不明白,有什么问题或在开发人员选项中启用这个小设置。 But right now, it's possible to do so on some Roms, or devices with root access.但是现在,可以在某些 Rom 或具有 root 访问权限的设备上这样做。

It's not possible without root the phone.没有root手机是不可能的。 If your phone has rooted.如果你的手机已经root了。 You can use this app.你可以使用这个应用程序。 https://play.google.com/store/apps/details?id=com.ttxapps.wifiadb&hl=en . https://play.google.com/store/apps/details?id=com.ttxapps.wifiadb&hl=en With this app you can easily debugs android apps with only wifi.使用此应用程序,您可以轻松调试仅使用 wifi 的 android 应用程序。 Don't want USB cable even only first time.即使只是第一次也不想要 USB 电缆。

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

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