有线Ethernet流程
2021-11-12 17:18:16 3 举报
基于Android 10的有线Ethernet框架流程
作者其他创作
大纲/内容
updateLinkProperties()
mNMService.setInterfaceUp(iface);打开ethernet 接口
2. 系统运行到阶段PHASE_SYSTEM_SERVICES_READY时,系统会调用EthernetService.java 的onBootPhase()函数,运行EthernetServiceImpl服务
AIDL
EthernetNetworkFactory.java
start()
retstart()
network.setIpConfig(ipConfiguration);
updateIpConfiguration()
跟踪以太网接口并管理接口配置
mImpl.start()
EthernetNetworkFactory.NetworkInterfaceState
当ethernet cable接入或拔掉或eth0 接口up/down时
EthernetService.java
EthernetTracker()
reconnectEthernet()
读取ethernet db:/data/misc/ethernet/ipconfig.txt
ConnectivityService服务
EthernetTracker.java
network.stop();
onIpClientCreated()
iface = new NetworkInterfaceState()创建对象NetworkInterfaceState,于保存一些network info:NetworkInfo、NetworkAgent、IpConfiguration、IIpClient等
EthernetNetworkFactory.IpClientCallbacksImpl
onBootPhase()
addInterface(iface)
trackAvailableInterfaces()
EthernetServiceImpl mImpl = new EthernetServiceImpl(context)
stop()清除对象NetworkInfo、NetworkAgent、IpConfiguration、IIpClient等
Ethernet Framework框图
config = mNMService.getInterfaceConfig(iface);读取配置
EthernetConfigStore
EthernetManager.java
AOSP Ethernet 目录:/frameworks/opt/net/ethernet/java/com/android/server/ethernet/
NetworkStack服务中通过注册监听器IpClientLinkObserver 来获得Ethernet接口 ip变化消息,然后发送消息EVENT_NETLINK_LINKPROPERTIES_CHANGED,最终回调对象EthernetNetworkFactory.IpClientCallbacksImpl 对应的callbak函数。目录:NetworkStack/src/android/net/ip/IpClient.java
mNMService.registerObserver(new InterfaceObserver())作用: 当ethernet cable接入或拔掉,由NMservice通知并调用InterfaceObserver的callback
start()
mHandler.post(this::trackAvailableInterfaces);打开enable ethernet 接口
EthernetService/EthernetServiceImpl
EthernetTracker
setConfiguration()
onProvisioningSuccess()ip分配成功,报告给ConnectivitySerivce
class NetworkInterfaceState in EthernetNetworkFactory.java
mTracker.start() 1. 读db2. 注册ethernet接口InterfaceObserver()用于监听接口变化3. 打开ethernet interface
startProvisioning()
IpClientManager.java
1. 系统启动时,系统会调用EthernetService.java 的onStart()函数,注册服务Context.ETHERNET_SERVICE到系统
mIpClient.startProvisioning(prov.toStableParcelable());
EthernetServiceImpl.java
Ethernet ip变化,frameworks 如何知道?
onStart()
IIpClient.aidl
创建对象EthernetTracker时1. 创建对象EthernetConfigStore2. 创建对象EthernetNetworkFactory
addInterface(ipConfiguration)
NetworkStack是app、是服务。TODO:流程
NetworkInterfaceState.setIpConfig(ipConfiguration);主要是在DHCP 与static mode切换时执行此函数
EthernetNetworkFactory
有线Ethernet切换DHCP与Static模式
onIpLayerStarted()
maybeTrackInterface()
ConnectivityService服务。TODO:流程
AIDL: IpClient.aidl
mHandler.post(() -> mFactory.reconnectEthernet(iface));
network.start();
interfaceLinkStateChanged(false或true)
ethernet cable接入或拔掉跟踪代码入口
class EthernetNetworkFactory.IpClientCallbacksImpl
start();
mNetworkAgent.sendLinkProperties(linkProperties)
mConfigStore = new EthernetConfigStore();创建对象EthernetConfigStore
EthernetService()
IpClient.java 位于:/packages/modules/NetworkStack/src/android/net/ip/IpClient.java
EthernetConfigStore.read();
NetworkStack进程
onLinkPropertiesChange()更新LinkProperties信息到ConnectivitySerivce
收藏
收藏
0 条评论
下一页