Android May Soon Restrict On-Device ADB
Android May Soon Restrict On-Device ADB
Android 或将限制设备端 ADB 连接
Early Warning
预警
Before we dive in, please note that this is not an official Google announcement. Instead, this is based on a recent, ongoing feature request on Google IssueTracker, in which a comment by one of the core ADB maintainers (Google employee) talked about restricting On-Device ADB connections to protect from “bad actors”. 在深入探讨之前,请注意这并非 Google 的官方公告。本文基于 Google IssueTracker 上近期的一项功能请求,其中一位核心 ADB 维护者(Google 员工)在评论中提到,为了防范“恶意行为者”,可能会限制设备端的 ADB 连接。
Before you stop what you are doing to head over to that IssueTracker thread, please read this carefully: If you plan to visit the issue tracker just to post low-quality comments (such as “Hey, don’t do this, I need Shizuku!”), complaints about monopoly, or insults, I highly recommend that you refrain from doing so. Spamming the thread will only cause Google developers to lock the issue, ignore valuable community feedback, or stop sharing public updates about this change entirely. 在您放下手头工作前往该 IssueTracker 讨论串之前,请仔细阅读以下内容:如果您打算访问该页面仅仅是为了发布低质量评论(例如“嘿,别这么做,我需要 Shizuku!”)、抱怨垄断或进行人身攻击,我强烈建议您不要这样做。在讨论串中刷屏只会导致 Google 开发人员锁定该议题,从而忽略有价值的社区反馈,甚至完全停止分享关于此项变更的公开更新。
Introduction
引言
Hi! I’m Kitsumed, developer of ShizuCallRecorder, a Shizuku based application. As you may have guessed by now, I would be affected by this change. Obviously, I would really like it if they do not proceed with it in a way that prevent loopback connections. 大家好!我是 Kitsumed,ShizuCallRecorder(一款基于 Shizuku 的应用)的开发者。正如你们可能已经猜到的,我会受到此项变更的影响。显然,我非常希望他们不要以阻止回环(loopback)连接的方式来推进这项变更。
To talk briefly about myself, I made ShizuCallRecorder to help with some of my own disabilities. I can get by without it, but it’s much easier with it. You could say I have a very unique use case, and I keep discovering other unusual ones, like this person on Reddit, who used my application to preserve the voicemail of a deceased loved one. 简单介绍一下我自己,我开发 ShizuCallRecorder 是为了帮助应对我自身的一些残障问题。没有它我也可以生活,但有了它会方便得多。可以说我的使用场景非常独特,而且我不断发现其他不寻常的案例,比如 Reddit 上有位用户使用我的应用保存了已故亲人的语音留言。
What’s ADB?
什么是 ADB?
ADB, also called Android Debug Bridge, is protocol created by Google to let developers do developer things on Android devices… Basically, it grant us a high level of privileges, give us access to a lot of sensible commands to tests how the phone and application behave. Useful stuff for any developers or power-users. ADB,全称 Android Debug Bridge(安卓调试桥),是 Google 创建的一种协议,旨在让开发者在 Android 设备上执行开发任务……基本上,它赋予了我们很高的权限,让我们能够访问许多敏感命令,以测试手机和应用程序的行为。这对任何开发者或高级用户来说都是非常有用的工具。
ADB was originally designed to work over a USB connection, but later expanded how it could works: ADB 最初设计为通过 USB 连接工作,但后来扩展了其工作方式:
- USB: The original way. ADB communicates directly over a USB cable. USB: 最初的方式。ADB 直接通过 USB 线进行通信。
- TCP/IP: Introduced as a way to run ADB over a network using an IP address and port (typically port 5555). The connection carries ADB traffic in plain text and provides a YES/NO prompt as authentication. Can only be enabled once you already have an active ADB connection. TCP/IP: 引入该方式是为了通过网络使用 IP 地址和端口(通常为 5555 端口)运行 ADB。该连接以明文传输 ADB 流量,并提供“是/否”提示作为身份验证。只有在已经建立有效的 ADB 连接后才能启用。
- Wireless Debugging (Wifi 1.0/2.0): Introduced in Android 11, it aims to improve the legacy TCP/IP workflow. It requires pairing the computer with the device using a pairing code or QR code, then establishes an authenticated and encrypted connection for subsequent ADB sessions. It does not require an active ADB connection to be enabled. 无线调试 (Wifi 1.0/2.0): Android 11 中引入,旨在改进传统的 TCP/IP 工作流程。它需要使用配对码或二维码将计算机与设备配对,然后为后续的 ADB 会话建立经过身份验证和加密的连接。它不需要预先建立有效的 ADB 连接即可启用。
What’s a On-Device ADB connection?
什么是设备端 ADB 连接?
ADB was originally intended to be used with two devices: the Android device being debugged run the ADB Daemon (ADBD) and a separate developer machine run the ADB client. In practice, however, this setup is not always convenient. Some developers work directly from their Android device and do not have access to a second machine. ADB 最初旨在配合两台设备使用:被调试的 Android 设备运行 ADB 守护进程 (ADBD),而另一台开发者机器运行 ADB 客户端。然而在实践中,这种设置并不总是方便。有些开发者直接在 Android 设备上工作,无法使用第二台机器。
This led to usage of On-Device ADB (this is not a official term). By using a terminal emulator such as Termux, developers can run an ADB client directly on their phone and establish a connection to the local daemon (ADBD) server using either ADB TCP/IP or Wireless Debugging. Since both the client and server are running on the same device, the connection is made through the loopback address (127.0.0.1). That’s what I call On-Device ADB. 这导致了“设备端 ADB”(这不是官方术语)的使用。通过使用 Termux 等终端模拟器,开发者可以直接在手机上运行 ADB 客户端,并使用 ADB TCP/IP 或无线调试连接到本地守护进程 (ADBD) 服务器。由于客户端和服务器都在同一台设备上运行,连接是通过回环地址 (127.0.0.1) 建立的。这就是我所说的设备端 ADB。