添加网络ADB的方法(含以太网和无线)
将下面代码添加至packages/apps/Settings/src/com/android/settings/DevelopmentSettings.java
结合之前的添加wifi adb的博客
也要仿照着在xml文件中添加以太网相关的变量接口直接使用网络adb
else if (preference == mEnableWifiAdb) {
if (mEnableWifiAdb.isChecked()) {
Settings.Global.putInt(getActivity().getContentResolver(),ADB_WIFI_ENABLED_KEY, 1);
android.os.SystemProperties.set("sys.connect.adb.wifi","1");
EthernetManager mEthManager = (EthernetManager) getSystemService(Context.ETHERNET_SERVICE);
int Ethenable = mEthManager.getEthernetIfaceState();
if( Ethenable == EthernetManager.ETHER_IFACE_STATE_UP )
{
IpAssignment mode =mEthManager.getConfiguration().getIpAssignment();
String inetAddr;
if (mode== IpAssignment.STATIC){ // 如果是静态的
StaticIpConfiguration staticIpConfiguration=mEthManager.getConfiguration().getStaticIpConfiguration();
LinkAddress ipAddress = staticIpConfiguration.ipAddress;
inetAddr=ipAddress.getAddress().getHostAddress();
}
else{
String iface = "eth0";
inetAddr = SystemProperties.get("dhcp."+ iface +".ipaddress");
}
if ("0.0.0.0".equals(inetAddr)) {
mEnableWifiAdb.setSummary(getResources().getString(R.string.enable_wifi_adb_openwifi));
}else{
mEnableWifiAdb.setSummary(getResources().
getString(R.string.enable_wifi_adb_connected_summary,inetAddr));
}
}
else
{
WifiManager wifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int ipAddress = wifiInfo.getIpAddress();
String ipAddressString = (ipAddress & 0xFF ) + "." +((ipAddress >> 8 ) & 0xFF) + "." +
((ipAddress >> 16 ) & 0xFF) + "." +( ipAddress >> 24 & 0xFF) ;
Log.i(TAG, "ipAddress="+ipAddress);
Log.i(TAG, "ipAddressString="+ipAddressString);
if ("0.0.0.0".equals(ipAddressString)) {
mEnableWifiAdb.setSummary(getResources().getString(R.string.enable_wifi_adb_openwifi));
}else{
mEnableWifiAdb.setSummary(getResources().
getString(R.string.enable_wifi_adb_connected_summary,ipAddressString));
}
} } else {
Settings.Global.putInt(getActivity().getContentResolver(),ADB_WIFI_ENABLED_KEY, 0);
android.os.SystemProperties.set("sys.connect.adb.wifi","0");
mEnableWifiAdb.setSummary(getResources().getString(R.string.enable_wifi_adb_summary));
}
}
添加网络ADB的方法(含以太网和无线)的更多相关文章
- Android : 网络adb配置及有线端口占用解决方法
一.调试环境: Android Debug Bridge version 1.0.40: Nexus6P平板(Android 8.0系统): 二.网络ADB调试: 1. Android设备除了用有线u ...
- 排错-Loadrunner添加Windows Resource计数器提示“找不到网络路径”解决方法
Loadrunner添加Windows Resource计数器提示“找不到网络路径”解决方法 by:授客 QQ:1033553122 1.启动windows相关服务 win->services. ...
- Linux下多网卡同网段多IP网络分流设定方法
Linux下多网卡同网段多IP网络分流设定方法 -- :: 标签:Linux下多网卡同网段多IP网络分流设定方法 当服务器需要较高的网络流量时,在其它资源不造成瓶颈的情况下无疑会用到多网卡. 第1选项 ...
- iphone抓取移动网络报文的方法
iphone抓取移动网络报文的方法 对iPhone进行越狱,网上有很多教程,这里不做说明.越狱后会有cydia这个app,首先对用户身份进行设置,选用开发者身份.打开这个应用,搜索openssh,找到 ...
- Android 下使用tcpdump网络抓包方法
Android 下使用tcpdump网络抓包方法 抓包需要tcpdump以及Root权限,tcpdump在本文后有下载. 首先把tcpdump传进手机,用adb命令(放SD卡有时会有问题,我一次可以用 ...
- swift网络数据请求方法
搭建一个apache服务器,用php编写一个返回给客户端请求数据的脚本 <?php // header("Content-type:text/html;charset=utf-8&qu ...
- flask使用第三方云通讯平台时,出现{'172001':'网络错误'}解决方法
问题描述:flask使用第三方云通讯平台时,出现{'172001':'网络错误'} 解决方法: 在sms.py文件中添加如下代码 import ssl # 取消证书验证ssl._create_defa ...
- Linux添加永久路由的方法
通常我们使用route add -net添加临时路由.当系统重启,临时路由将丢失,重新配置路由带来了不必要的麻烦.可通过固化临时路由为永久路由的方法解决该问题. static-routes文件为路由固 ...
- 在html中添加script脚本的方法和注意事项
在html中添加script脚本有两种方法,直接将javascript代码添加到html中与添加外部js文件,这两种方法都比较常用,大家可以根据自己需要自由选择 在html中添加<script& ...
随机推荐
- PHP统计网站pv(访问量)
//首先判断有没有统计的文件 if(is_file("pv.txt")){//有 //取文件里面的值 $count=file_get_contents("pv.txt&q ...
- 为什么说windows会死机,Linux不会死机
通常所说的死机是指操作没有响应了,但是操作系统的核心仍然在工作.在windows中,由于只有一个界面,没有响应就是死机了:而在Linux中可有tty1-tty7,死了一个开另外一个把死了的那个杀掉就可 ...
- js的JSON
把任何JavaScript对象变成JSON,就是把这个对象序列化成一个JSON格式的字符串,这样才能够通过网络传递给其他计算机. 如果我们收到一个JSON格式的字符串,只需要把它反序列化成一个Java ...
- Taxi
/* After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to cele ...
- [Centos] ERROR: Could not find useradd in chroot, maybe the install failed?
[mockbuild at localhost ~]$ mock -r centos-5-x86_64-testdev.cfg initinitcleanprepThis may take a whi ...
- [转载]linux中sed的用法
转自:http://www.cnblogs.com/emanlee/archive/2013/09/07/3307642.html sed命令行格式为: sed [-nefri] ‘ ...
- spring+mybatis框架搭建时遇到Mapped Statements collection does not contain value for...的错误
http://your233.iteye.com/blog/1563240 上面的博客总结了4个可能出现的问题,如下: 1.mapper.xml中没有加入namespace 2.mapper.xml中 ...
- 无法将参数 1 从“WCHAR [256]”转换为“const char *”
https://blog.csdn.net/zhangxuechao_/article/details/81064037 字符集 修改为未设置 然后再修改回来unicode 居然好了
- sys安装
1.将SYS驱动文件放到系统目录的SYSTEM32目录中.2.按WIN+R组合键,在运行框中输入:regsvr32 sys所在全路径,点击确定即可.
- Tag file
JSP 2.0 引入 Tag file ,tag file 以 tag 或 tagx 为后缀,它们可以包含其他资源文件:一个被其他文件包含的 tag file 应该以 tagf 为后缀. 如同JSP页 ...