简体   繁体   English

如何以编程方式停止 adb wireless?

[英]How to stop adb wireless programmatically?

I want to start and stop adb wireless from an app using a rooted phone.我想使用 root 手机从应用程序启动和停止 adb wireless。 I managed to start adb wireless daemon with these commands:我设法使用以下命令启动 adb wireless 守护进程:

            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.无法停止 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?我应该如何从有根电话中正确停止 adb wireless?

I'm just guessing, but try removing the 5555 as a parameter (maybe passing an empty string in quotes, or passing nothing at all).我只是猜测,但尝试删除 5555 作为参数(可能在引号中传递一个空字符串,或者根本不传递任何内容)。

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 https://stackoverflow.com/a/34219466

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM