2

I want to start and stop adb wireless from an app using a rooted phone. I managed to start adb wireless daemon with these commands:

            String cmds[] = {
                    "setprop service.adb.tcp.port 5555",
                    "stop adbd",
                    "start adbd"
            };
            Shell.su(cmds).exec();

But

            String cmds[] = {
                    "stop adbd"
            };
            Shell.su(cmds).exec();

or

            String cmds[] = {
                    "setprop service.adb.tcp.port 5555",
                    "stop adbd"
            };
            Shell.su(cmds).exec();

does not work to stop adb. At least it stops but I can't start it again with

setprop service.adb.tcp.port 5555
stop adbd
start adbd

How should I stop adb wireless properly from a rooted phone?

coolman
  • 109
  • 1
  • 8
  • tried `adb kill-server && start-server` ? – Blundell Mar 02 '20 at 12:59
  • I think there is a misunderstanding. I don't want to stop start adb from laptop. I want to stop and start adb wireless daemon at android phone. I edited my question to explain my question better. – coolman Mar 02 '20 at 13:15

1 Answers1

2

I'm just guessing, but try removing the 5555 as a parameter (maybe passing an empty string in quotes, or passing nothing at all).

It smells a lot as this answer (although it talks about persisting it or not, but the way to do it might be the same):

https://stackoverflow.com/a/34219466

Sergi Juanola
  • 6,531
  • 8
  • 56
  • 93