查网上的资料得到修改的方法如下所示:
frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetServiceImpl.java
/**
* Set Ethernet configuration
*/
@Override
public void setConfiguration(String iface, IpConfiguration config) {
if (!mStarted.get()) {
Log.w(TAG, "System isn't ready enough to change ethernet configuration");
}
enforceConnectivityInternalPermission();
if (mTracker.isRestrictedInterface(iface)) {
enforceUseRestrictedNetworksPermission();
}
// TODO: this does not check proxy settings, gateways, etc.
// Fix this by making IpConfiguration a complete representation of static configuration.
mTracker.updateIpConfiguration(iface, new IpConfiguration(config));
+ mTracker.removeInterface(iface);// 清除当前端口
+ mTracker.start(); // 启动以太网
}
但经过实际测试发现没有效果。再修改一下:
+++ b/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetServiceImpl.java
@@ -194,6 +194,7 @@ public class EthernetServiceImpl extends IEthernetManager.Stub {
mTracker.updateIpConfiguration(iface, new IpConfiguration(config));
//add
mTracker.removeInterface(iface);
+ mTracker.stop(); // 把以太网关闭
mTracker.start();
}
在启动前关闭一下以太网网口,经测试成功解决网线插拔一下才能上网的问题。