autojs


切换adbd服务(root)

<pre><code class="language-js">function 启动adbd(port) { if (port) { var adbPort = port; shell("setprop service.adb.tcp.port "+ adbPort); } else { var adbPort = "5555"; shell("setprop service.adb.tcp.port "+ adbPort); } var res = shell("netstat -tunlp |grep ':::'"+adbPort); if (res.code == 0) { toastLog("adbd服务正在运行!"); return true; } else { let info = shell("start adbd", true); if (info.code == 0) { toastLog("启动了adbd服务"); return true; } else { toastLog('code='+info.code+'\nerror='+info.error); return false; } } } function 关闭adbd() { var adbPort = shell("getprop service.adb.tcp.port").result; if (adbPort == "") { toastLog("adbd服务未运行!"); return true; } var res = shell("netstat -tunlp |grep ':::'"+adbPort); if (res.code != 0) { toastLog("adbd服务未运行!"); return true; } else { let info = shell("stop adbd", true); if (info.code == 0) { toastLog("关闭了adbd服务"); return true; } else { toastLog('code='+info.code+'\nerror='+info.error); return false; } } }</code></pre>

页面列表

ITEM_HTML