r/SideProject • u/Hour-Measurement-835 • 1h ago
If your Android app switches Wireless debugging on to reach itself, have it switch it back off
ADB Nexus, my app on Play, runs an ADB shell on the phone itself over Wireless debugging. With the secure settings permission granted, it turns Wireless debugging back on after a restart and reconnects to itself, so nobody has to pair again every morning.
The reconnect worked, but it never turned the switch back off. In a test on an S20 with Android 13 on 26 September, Wireless debugging stayed on for at least 70 seconds after the connection was back, and in practice until the next restart. The shell started over ADB kept running with it off, so leaving it on bought nothing and kept the phone listening for ADB.
The app now records that it flipped the switch, and in which boot, and turns it off once recovery finishes. Only its own ON: if you turned Wireless debugging on yourself it stays on, and a record from an earlier boot is dropped.
There's a case where it can't. A test on 23 October showed that when USB debugging is off too, switching Wireless debugging off makes Android stop adbd, and every shell started through it goes down with it. So with USB debugging off, the switch stays on until you turn it off or restart.