Android源码本身是不支持Ethernet上网,主要因为它针对手机设计,而手机上一般不会带有RJ45模块,因此要想在Android上实现Ethernet功能就要增加Framework层和App层代码,工作量还是很大。还好网络上有基于上网本开发的开源项目android-x86,它已经实现了Ethernet功能,我们只要参考它的源码修改。下面将介绍下如何实现Ethernet功能:
1.linux驱动的修改
我所使用的RJ45芯片是MCS7830,linux kernel源码中已包含了它的驱动,只要在配置时选中它
- make memuconfig:
- [*] Network device support --->
- USB Network Adapters --->
- <*> Multi-purpose USB Networking Framework
- <*> MosChip MCS7830 based Ethernet adapters
2.Android源码的修改
下面只列出Android2.2需要修改的源码文件,包括所在的文件夹位置
- 1.frameworks/base/Android.mk
- 2.3.frameworks/base/core/java/Android/app/ContextImpl.java
- 4.5.frameworks/base/core/java/Android/content/Context.java
- 6.7.frameworks/base/core/java/Android/net/ConnectivityManager.java
- 8.9.frameworks/base/core/java/Android/provider/Settings.java
- 10.11.frameworks/base/core/jni/Android.mk
- 12.13.frameworks/base/core/jni/AndroidRuntime.cpp
- 14.15.frameworks/base/core/jni/Android_net_ethernet.cpp (增加)
- 16.17.frameworks/base/core/res/res/drawable/connect_creating.png (增加)
- 18.19.frameworks/base/core/res/res/drawable/connect_established.png (增加)
- 20.21.frameworks/base/core/res/res/drawable/connect_no.png (增加)
- 22.23.frameworks/base/core/res/res/values/arrays.xml
- 24.25.frameworks/base/core/res/res/values/config.xml
- 26.27.frameworks/base/ethernet/java/Android/net/ethernet/EthernetDevInfo.aidl (增加)
- 28.29.frameworks/base/ethernet/java/Android/net/ethernet/EthernetDevInfo.java (增加)
- 30.31.frameworks/base/ethernet/java/Android/net/ethernet/EthernetManager.java (增加)
- 32.33.frameworks/base/ethernet/java/Android/net/ethernet/EthernetMonitor.java (增加)
- 34.35.frameworks/base/ethernet/java/Android/net/ethernet/EthernetNative.java (增加)
- 36.37.frameworks/base/ethernet/java/Android/net/ethernet/EthernetStateTracker.java (增加)
- 38.39.frameworks/base/ethernet/java/Android/net/ethernet/IEthernetManager.aidl (增加)
- 40.41.frameworks/base/services/java/com/Android/server/status/StatusBarPolicy.java
- 42.43.frameworks/base/services/java/com/Android/server/ConnectivityService.java
- 44.45.frameworks/base/services/java/com/Android/server/EthernetService.java (增加)
- 46.47.frameworks/base/wifi/java/Android/net/wifi/WifiStateTracker.java
- 48.49.packages/apps/Settings/res/drawable-hdpi/ic_settings_ethernet.png (增加)
- 50.51.packages/apps/Settings/res/drawable-mdpi/ic_settings_ethernet.png (增加)
- 52.53.packages/apps/Settings/res/layout/eth_configure.xml (增加)
- 54.55.packages/apps/Settings/res/values/strings.xml
- 56.57.packages/apps/Settings/res/xml/ethernet_settings.xml (增加)
- 58.59.packages/apps/Settings/res/xml/settings.xml
- 60.61.packages/apps/Settings/src/com/Android/settings/ethernet/EthernetConfigDialog.java (增加)
- 62.63.packages/apps/Settings/src/com/Android/settings/ethernet/EthernetEnabler.java (增加)
- 64.65.packages/apps/Settings/src/com/Android/settings/ethernet/EthernetLayer.java (增加)
- 66.67.packages/apps/Settings/src/com/Android/settings/EthernetSettings.java (增加)
- 68.69.packages/apps/Settings/AndroidManifest.xml
- 70.71.build/core/pathmap.mk
3.init.rc的修改
增加以下代码
- + mkdir /data/misc/dhcp 0777 dhcp dhcp
- + chown dhcp dhcp /data/misc/dhcp
- +service dhcpcd /system/bin/dhcpcd -o domain_name_servers -ABKL
- + disabled
- + oneshot
以上全完成后,在Setting中就可以看到Ethernet Setting的选项,RJ45接上网线就可以上网了。
阅读(2769) | 评论(0) | 转发(0) |