Wifi ADB debug mode lost on restart?

Twski

New member
I haven't been following the replies on this thread, so I have no idea what's going on anymore. I switched to using root on all my devices for the past few years and didn't really need the adb tcpip 5555 method anymore.

However, I recently bought a device that I can't root because it'll break a few things, such as Widevine L1 for Netflix, among other things. So I've decided to revisit the adb tcpip 5555 method once more.

I ended up creating another solution that is pretty consistent and easy to use. It's currently working on my Redmi K60 running MIUI 14, Android 13. You need Termux and Termux Tasker plugin for this to work.

Basically, I just need to open the Wireless Debugging page under Developer Settings. Then, read the screen contents and grab the values under "IP address and Port". Note that at this step, I don't need to pair my device and enter the pairing code. It's not required.

Once I have the IP address and port (e.g. 192.168.0.140:34551), I then pass this into Termux via the Termux Tasker plugin. It will do a adb connect 192.168.0.140:34551 and then once connected, it will do adb tcpip 5555 and voila, it's working now.

I've uploaded my macro to the template store. Macro id is 21169 and the name is "Switch ADB Mode".

My macro includes the things I've discussed above but also does other things as well. You can ignore those extra stuff if you don't need them. The macro basically uses a MacroDroid quick tile and I can toggle it to turn on ADB USB mode or ADB TCPIP 5555 mode. When ADB TCPIP 5555 mode is toggled, it'll execute the actions described above.

UPDATE:

Found an even better method. You'll need the Wirebug app from F-Droid store. You can then use another macro that I've created (id = 21171) to get it running. You just need the IP to use adb connect, you don't even need the port. It's very easy to get the IP (it'll show on the Wirebug app and you can do a Read Screen Contents and then extract it), or use the builtin Macrodroid magic text {ip} to get the current IP.

Note that during my testing, turning on Wireless Debugging and using adb connect IP_address is not enough. I needed to use Wirebug to enable wireless debugging from the app, then I can use adb connect IP_address and after that I can run adb tcpip 5555. I'm not sure what Wirebug is doing in the background after you enable debugging in the app, but hey it works.
I'm used your template as a base, but used some termux scripts instead of Wirebug.

But I have one problem (that I don't know if it's solvable)... is ADB pver TCPIP only supposed to work if you are connected to an wifi network and have wireless debugging turned on?

I currently need to re-run the macro for activating adb over tcpip 5555 not only after I reboot the hpine, but even after I disconnect the wi-fi and later connect again.

It would be fine if only the first activation after reboot needed wifi. Or am I doing something wrong?

btw I'm not rooted, and I'm using termux-adb instead of regular adb from android-tools package
 

chaoscreater

Active member
I'm used your template as a base, but used some termux scripts instead of Wirebug.

But I have one problem (that I don't know if it's solvable)... is ADB pver TCPIP only supposed to work if you are connected to an wifi network and have wireless debugging turned on?

I currently need to re-run the macro for activating adb over tcpip 5555 not only after I reboot the hpine, but even after I disconnect the wi-fi and later connect again.

It would be fine if only the first activation after reboot needed wifi. Or am I doing something wrong?

btw I'm not rooted, and I'm using termux-adb instead of regular adb from android-tools package
Only the first connection on phone boot-up is required for me. On my Xiaomi phone (rooted) and Lenovo tablet (non-rooted but runs MacroDroid and Shizuku), I can get ADB over TCP on first bootup even after I disconnect my wifi. I'm not using Wirebug on my Lenovo tablet because Wirebug requires root.
 

Endercraft

Moderator (& bug finder :D)
I had problems with adb tcpip not working if I tried to connect on data instead of wifi, but launching it on wifi and connecting at that point works (I found that adb stop-server && adb devices helped quite a bit).
 

Twski

New member
Only the first connection on phone boot-up is required for me. On my Xiaomi phone (rooted) and Lenovo tablet (non-rooted but runs MacroDroid and Shizuku), I can get ADB over TCP on first bootup even after I disconnect my wifi. I'm not using Wirebug on my Lenovo tablet because Wirebug requires root.
Does "wireless debugging" stay turned on for you when you disconnect the wifi?

When I disconnect the wifi, the setting key adb_wifi_enabled is set to 0, and there is no way to set it to 1 unless I connect to a wifi again.

When that is off, I can't use ADB Shell Command plugin or even manually connect to localhost:5555 in termux.

I just figured that, if I disconnect to wifi and later connect again, I can just enable adb_wifi_enabled again, no need to do the whole tcpip 5555 script. But still, I can't find a way to use adb while not connected to a wifi.

Maybe it's a Samsung thing? I'm using a S23U and a S20FE. I'll test in a Motorola I have laying around when I have some free time, and see if it's any different
 

chaoscreater

Active member
Does "wireless debugging" stay turned on for you when you disconnect the wifi?

When I disconnect the wifi, the setting key adb_wifi_enabled is set to 0, and there is no way to set it to 1 unless I connect to a wifi again.

When that is off, I can't use ADB Shell Command plugin or even manually connect to localhost:5555 in termux.

I just figured that, if I disconnect to wifi and later connect again, I can just enable adb_wifi_enabled again, no need to do the whole tcpip 5555 script. But still, I can't find a way to use adb while not connected to a wifi.

Maybe it's a Samsung thing? I'm using a S23U and a S20FE. I'll test in a Motorola I have laying around when I have some free time, and see if it's any different
Wireless debugging requires wifi to be on. When I turn off my wifi, wireless debugging is off as well. However, ADB TCPIP 5555 should still stay on and so it doesn't actually impact me if I leave my wifi turned off, otherwise it would have bugged me to hell if I had to re-do this whole thing all over again (even if it's automated).

I've just done a test on my Lenovo Xiaoxin Pad tablet, running on Android 13. This device isn't rooted, but runs MacroDroid and Shizuku. When my tablet boots up, it'll use Macrodroid to run the automation for turning on wireless debugging - which then allows Shizuku to use ADB. At this point, I can turn off wifi (which also turns off wireless debugging) and Shizuku will still work. Apps that rely on Shizuku, such as Swift Backup, can perform elevated tasks using ADB (via Shizuku). I only need to run my Macrodroid automation just once on every boot.

On my tablet, I'm not using Wirebug. I'm using Wirebug only on my rooted devices, because Wirebug requires root.
 

Twski

New member
I have found the solution!

I just had to leave "USB debugging" turned on. If it's off, the whole thing will just work if connected to wifi.

Thanks for the help @chaoscreater
 

chaoscreater

Active member
I have found the solution!

I just had to leave "USB debugging" turned on. If it's off, the whole thing will just work if connected to wifi.

Thanks for the help @chaoscreater
Oh lol. Yeah you'd need that on for sure. I never turn it off because it's useful all the time.

On some phones, you need to also disable the authorization timeout and some other settings. They're all found under Developer Settings.
 
Top