adb 连接黑盒(未知端口号) 您所在的位置:网站首页 小米手表端口号 adb 连接黑盒(未知端口号)

adb 连接黑盒(未知端口号)

2024-07-05 08:25| 来源: 网络整理| 查看: 265

我们知道android 默认adb tcp 连接端口为5555(电脑端adb 服务默认端口为5037),但很多rom厂商会定义一个自己的端口号,避免被他人通过adb随意连接.可通过setprop servcie.adb.tcp.prot xxxx设置。

有时需要连接一个未知adb 端口的 android设置就比较麻烦了。我最近就碰到这种情况,最后是通过最笨的方法,脚本轮询端口(最大65535)才连上。很耗时。不过1024之前一般不用考虑。

下面是bat脚本,轮询连接adb

@echo off setlocal enabledelayedexpansion set /a a=5000 //定义端口号变量 for /l %%c in (5000 1 65535) do ( //循环,从5000开始,每次递增1,到65535为止 set /a a+=1 //端口号值递增 adb connect 192.168.0.75:!a! >> log.txt //连接adb connect ip:port Wscript sleep.vbs //调用延时脚本 adb remount echo !a! //打印端口值 ) echo %a% pause

sleep.vbs 内容如下:

WScript.sleep 500 //间隔500毫秒轮询一次

从输出日志内容查看是否连接成功:

unable to connect to 192.168.0.75:6765:6765 unable to connect to 192.168.0.75:6766:6766 unable to connect to 192.168.0.75:6767:6767 unable to connect to 192.168.0.75:6768:6768 unable to connect to 192.168.0.75:6769:6769 unable to connect to 192.168.0.75:6770:6770 unable to connect to 192.168.0.75:6771:6771 unable to connect to 192.168.0.75:6772:6772 unable to connect to 192.168.0.75:6773:6773 unable to connect to 192.168.0.75:6774:6774 unable to connect to 192.168.0.75:6775:6775 unable to connect to 192.168.0.75:6776:6776 unable to connect to 192.168.0.75:6777:6777 unable to connect to 192.168.0.75:6778:6778 unable to connect to 192.168.0.75:6779:6779 unable to connect to 192.168.0.75:6780:6780 unable to connect to 192.168.0.75:6781:6781 unable to connect to 192.168.0.75:6782:6782 unable to connect to 192.168.0.75:6783:6783 unable to connect to 192.168.0.75:6784:6784 unable to connect to 192.168.0.75:6785:6785 unable to connect to 192.168.0.75:6786:6786 unable to connect to 192.168.0.75:6787:6787 unable to connect to 192.168.0.75:6788:6788 connected to 192.168.0.75:6789 //连接成功,正确端口号为 6789 unable to connect to 192.168.0.75:6790:6790 unable to connect to 192.168.0.75:6791:6791 unable to connect to 192.168.0.75:6792:6792 unable to connect to 192.168.0.75:6793:6793 unable to connect to 192.168.0.75:6794:6794 unable to connect to 192.168.0.75:6795:6795

方法二:

通过打印串口重置adb 端口号:

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

没有权限的话先执行一下:su



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有