How to stop adb wireless programmatically?

coolman :

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?

Korcholis :

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=19044&siteId=1