完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
测试平台
Platform: RK3399/RK3328 OS: Android 10.0 现象 设置中设置以太网为静态ip,设置后使用ifconfig查看ip显示正常。然后重启,极大概率出现开机后设备没有获取到ip. 分析解决 测试后发现了几点规律: 设置静态ip会开机获取不到ip,但是设置动态ip无问题 没有获取到ip时,使用ifconfig查看,发现网卡设备连接正常。此时拔插网线,或者使用ifconfig eth0 down + ifconfig eth0 up 来开关一次设备后,就能正常获取到ip 根据测试结果采取了如下的解决方案,在开机的时候在Ethernet服务中进行一次ifconfig eth0 down + ifconfig eth0 up的操作来解决. 修改补丁如下,测试20次后无问题,提交给到客户 diff --git a/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetTracker.java b/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetTracker.java index 308e328..919edc6 100644 --- a/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetTracker.java +++ b/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetTracker.java @@ -252,12 +254,41 @@ final class EthernetTracker { } } - private void maybeTrackInterface(String iface) { + private boolean maybeTrackInterface(String iface) { if (DBG) Log.i(TAG, "maybeTrackInterface " + iface); // If we don't already track this interface, and if this interface matches // our regex, start tracking it. if (!iface.matches(mIfaceMatch) || mFactory.hasInterface(iface)) { - return; + return false; } if (mIpConfigForDefaultInterface != null) { @@ -266,13 +297,31 @@ final class EthernetTracker { } addInterface(iface); + return true; } private void trackAvailableInterfaces() { try { final String[] ifaces = mNMService.listInterfaces(); for (String iface : ifaces) { - maybeTrackInterface(iface); + if (maybeTrackInterface(iface)) { + String mIfaceTmp = iface; + new Thread(new Runnable() { + public void run() { + // carrier is always 1 when kernel boot up no matter RJ45 plugin or not, + // sleep a little time to wait kernel's correct carrier status + try { + Thread.sleep(3000); + } catch (InterruptedException ignore) { + } + if(isEthernetInterfaceActive()){ + IpConfiguration config = getIpConfiguration(mIfaceTmp); + if(config != null && IpAssignment.STATIC == config.getIpAssignment()) + { + updateInterfaceState(mIfaceTmp, false); + updateInterfaceState(mIfaceTmp, true); + } + }else{ + updateInterfaceState(mIfaceTmp, false); + } + } + }).start(); + break; + } } } catch (RemoteException | IllegalStateException e) { Log.e(TAG, "Could not get list of interfaces " + e); 注:其实这是种治标不治本的解决办法,但是由于客户追的比较紧先采取这种解决方案,后续有时间再去查一下根本所在(根据测试log等,我猜想这是个由于加载顺序和获取ip的时机导致的随机问题)。 |
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
谁有3566+电池+POE充电的方案,有个项目需要用该功能的主板
437 浏览 0 评论
RK3588的GMAC0与PHY的参考时钟电平匹配问题??????
4425 浏览 1 评论
请问各位大佬,如何解决,瑞芯微 RV1126B 使用 mpp 自带工具 调试时,内核直接报错崩溃!
1802 浏览 0 评论
使用rk3568开发板,核0\\1\\3运行linux,核2运行hal,在核0中怎么关闭核2
2359 浏览 0 评论
2363 浏览 0 评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 13:30 , Processed in 1.255881 second(s), Total 74, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1193