Android 2.2下实现Ethernet
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
(android-x86下需要修改的文件源码包,基于Android 2.2版本)下载地址在安科网的1号FTP服务器里,下载地址:
密码:www.muu.cc
相关推荐
IT之家 2020-03-11
graseed 2020-10-28
zbkyumlei 2020-10-12
SXIAOYI 2020-09-16
jinhao 2020-09-07
impress 2020-08-26
liuqipao 2020-07-07
淡风wisdon大大 2020-06-06
yoohsummer 2020-06-01
chenjia00 2020-05-29
baike 2020-05-19
扭来不叫牛奶 2020-05-08
hxmilyy 2020-05-11
黎豆子 2020-05-07
xiongweiwei00 2020-04-29
Cypress 2020-04-25
冰蝶 2020-04-20