Android OOT STB set IP

//dhcp 动态 ip

ethManeger  = (EthernetManager)getSystemService(Context.ETHERNET_SERVICE);
ethManeger.setEthernetEnabled(false);
ethManeger.setEthernetDefaultConf();
ethManeger.setEthernetEnabled(true);


//静态IP

final DhcpInfoInternal dhcpInfo = new DhcpInfoInternal();
dhcpInfo.ipAddress = ip;
dhcpInfo.dns1 = dns;
if(dnsBak != null){
    dhcpInfo.dns2 = dnsBak;
}
dhcpInfo.addRoute(new RouteInfo(NetworkUtils.numericToInetAddress(gateway)));
dhcpInfo.prefixLength = NetworkUtils.netmaskIntToPrefixLength(NetworkUtils.inetAddressToInt(NetworkUtils.numericToInetAddress(mask)));
			  
new Thread() {
	public void run () {
		DhcpInfoInternal mDhcpInfoInternaltemp = new DhcpInfoInternal();
		mDhcpInfoInternaltemp.getFromDhcpInfo(ethManeger.getSavedEthernetIpInfo());
		ethManeger.saveEthernetIpInfo(dhcpInfo.makeDhcpInfo(), EthernetManager.ETHERNET_CONNECT_MODE_MANUAL);
	}
}.start();


注意 

1.代码要在源码中编译

2.app push /system/app





你可能感兴趣的:(Android OOT STB set IP)