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需要修改的源码文件,包括所在的文件夹位置
- frameworks/base/Android.mk
- frameworks/base/core/java/android/app/ContextImpl.java
- frameworks/base/core/java/android/content/Context.java
- frameworks/base/core/java/android/net/ConnectivityManager.java
- frameworks/base/core/java/android/provider/Settings.java
- frameworks/base/core/jni/Android.mk
- frameworks/base/core/jni/AndroidRuntime.cpp
- frameworks/base/core/jni/android_net_ethernet.cpp (增加)
- frameworks/base/core/res/res/drawable/connect_creating.png (增加)
- frameworks/base/core/res/res/drawable/connect_established.png (增加)
- frameworks/base/core/res/res/drawable/connect_no.png (增加)
- frameworks/base/core/res/res/values/arrays.xml
- frameworks/base/core/res/res/values/config.xml
- frameworks/base/ethernet/java/android/net/ethernet/EthernetDevInfo.aidl (增加)
- frameworks/base/ethernet/java/android/net/ethernet/EthernetDevInfo.java (增加)
- frameworks/base/ethernet/java/android/net/ethernet/EthernetManager.java (增加)
- frameworks/base/ethernet/java/android/net/ethernet/EthernetMonitor.java (增加)
- frameworks/base/ethernet/java/android/net/ethernet/EthernetNative.java (增加)
- frameworks/base/ethernet/java/android/net/ethernet/EthernetStateTracker.java (增加)
- frameworks/base/ethernet/java/android/net/ethernet/IEthernetManager.aidl (增加)
- frameworks/base/services/java/com/android/server/status/StatusBarPolicy.java
- frameworks/base/services/java/com/android/server/ConnectivityService.java
- frameworks/base/services/java/com/android/server/EthernetService.java (增加)
- frameworks/base/wifi/java/android/net/wifi/WifiStateTracker.java
- packages/apps/Settings/res/drawable-hdpi/ic_settings_ethernet.png (增加)
- packages/apps/Settings/res/drawable-mdpi/ic_settings_ethernet.png (增加)
- packages/apps/Settings/res/layout/eth_configure.xml (增加)
- packages/apps/Settings/res/values/strings.xml
- packages/apps/Settings/res/xml/ethernet_settings.xml (增加)
- packages/apps/Settings/res/xml/settings.xml
- packages/apps/Settings/src/com/android/settings/ethernet/EthernetConfigDialog.java (增加)
- packages/apps/Settings/src/com/android/settings/ethernet/EthernetEnabler.java (增加)
- packages/apps/Settings/src/com/android/settings/ethernet/EthernetLayer.java (增加)
- packages/apps/Settings/src/com/android/settings/EthernetSettings.java (增加)
- packages/apps/Settings/AndroidManifest.xml
- 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接上网线就可以上网了。
(附上android-x86下需要修改的文件源码包,基于Android2.2版本)
android2.2_ethernet.tar.zip
PS:后面还将介绍android2.1下的Ethernet实现
阅读(2175) | 评论(0) | 转发(0) |