Android Ethernet Porting Guide

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zoosenpin/article/details/81902007

1 Android Ethernet Porting Guide
1.1 Usual Network Commands for Android
netstat, netcfg, ifconfig, ip route.

You can config ethernet ip address manually like as below:
ifconfig eth0 up
ifconfig eth0 192.168.0.2 netmask 255.255.255.0

1.2 Ethernet Configuration
In frameworks/base/core/res/res/values/config.xml, search networkAttributes, append the following line <item>"ethernet,9,9,0,-1,true"</item> , which is illustrated as below:
[Connection name],
[ConnectivityManager.TYPE_xxxx],
[associated radio-type],
[priority],
[restoral-timer(ms)],
[dependencyMet]

Then search radioAttributes, append the following line <item>”9,1”</item>, which is illustrated as below:
[ConnectivityManager connectionType],[simultaneous connection types]

For tethering, search config_tether_upstream_types,
Add <item>9</item>

Add two services device/qcom/common/rootdir/etc/init.qcom.rc like as below:
service dhcpcd_eth0 /system/bin/dhcpcd -ABKL
class main
disabled
oneshot

service iprenew_eth0 /system/bin/dhcpcd -n
class main
disabled
oneshot

In Android, EthernetNetworkFactory.java can be found under frameworks/opt/net/ethernet/java/com/android/server/ethernet/, please add logs in this file when debug android ethernet function.

Add Ethernet feature under device/qcom/msm8xxx/msm8xxx.mk as shown below:
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.ethernet.xml:system/etc/permissions/android.hardware.ethernet.xml

1.3 System Level Route Config
Firstly, open Windows command shell, please do shown as below:
adb shell
su
cat /proc/net/route
# add a route
ip route 192.168.0.1/32 dev eth0
# delete a route
ip route del 192.168.0.1/32
You should add ip as prefix in the route, which is not the same as general Linux release version, also you can typo ‘ip route help’ to get more helps

2 Abbreviations
config_tether_upstream_types:Android手机配置为ApCli(AP-Client)时,作为Client的一方
config_tether_usb_regexs:regular expressions,正则表达式

猜你喜欢

转载自blog.csdn.net/zoosenpin/article/details/81902007