当前位置: 首页 > 工具软件 > oot > 使用案例 >

android stb源代码,Android OOT STB set IP

樊浩初
2023-12-01

//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

 类似资料: