下载android-x86的Framework 和package 两个文件夹;
网址:http://www.android-x86.org/getsourcecode
我们要移植的是android-2.2的版本,所以我们必须得到android-x86在2.2版本上的源码。
mkdir android-x86
cd android-x86
repo init -u git://git.android-x86.org/manifest.git -b froyo-x86
前面初始化了android-x86,接下来你可以repo sync,只需要check out我们需要的几个文件夹,如下:
repo sync platform/build
repo sync platform/frameworks/base
repo sync platform/packages/apps/Settings
下面我们将ethernet部分内容移植到自己的android源码中:
1. 将framework/base/ethernet 复制到源码的framework/base/目录下:
2. 修改源码framework/base目录下的Android.mk
LOCAL_SRC_FILES += \
… \
/java/android/net//IVpnService.aidl \
185+:ethernet/java/android/net/ethernet/IEthernetManager.aidl
3. 将文件framework/base/service/java/com/android/server/EthernetService.java复制到 framework/base/service/java/com/android/server/目录下;
4. 修改framework/base/service/java/com/android/server目录下的ConnectivityService.java文件:
--- /home/thomas/android2.2/frameworks/base/services/java/com/android/server/ConnectivityService.java 2011-07-04 15:37:30.949468920 +0800
+++ ./frameworks/base/services/java/com/android/server/ConnectivityService.java 2011-09-08 11:02:01.927843001 +0800
@@ -28,6 +28,7 @@
import android.net.NetworkInfo;
import android.net.NetworkStateTracker;
import android.net.wifi.WifiStateTracker;
+import android.net.ethernet.EthernetStateTracker;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
@@ -235,7 +236,7 @@
n.mType);
continue;
}
- if (mRadioAttributes[n.mRadio] == null) {
+ if ((n.mType != ConnectivityManager.TYPE_ETHERNET) && (mRadioAttributes[n.mRadio] == null)) {
Slog.e(TAG, "Error in networkAttributes - ignoring attempt to use undefined " +
"radio " + n.mRadio + " in network type " + n.mType);
continue;
@@ -243,6 +244,7 @@
mNetAttributes[n.mType] = n;
mNetworksDefined++;
} catch(Exception e) {
+ Slog.e(TAG, "wrong dev exception " + e);
// ignore it - leave the entry null
}
}
@@ -299,8 +301,14 @@
wifiService.startWifi();
mNetTrackers[ConnectivityManager.TYPE_WIFI] = wst;
wst.startMonitoring();
-
break;
+ case ConnectivityManager.TYPE_ETHERNET:
+ if (DBG) Slog.v(TAG, "#########Starting Ethernet Service.");
+ EthernetStateTracker est = new EthernetStateTracker(context, mHandler);
+ EthernetService ethService = new EthernetService(context, est);
+ ServiceManager.addService(Context.ETHERNET_SERVICE, ethService);
+ mNetTrackers[ConnectivityManager.TYPE_ETHERNET] = est;
+ est.startMonitoring();
case ConnectivityManager.TYPE_MOBILE:
mNetTrackers[netType] = new MobileDataStateTracker(context, mHandler,
netType, mNetAttributes[netType].mName);
@@ -310,9 +318,23 @@
mNetTrackers[netType].teardown();
}
break;
+
default:
- Slog.e(TAG, "Trying to create a DataStateTracker for an unknown radio type " +
- mNetAttributes[netType].mRadio);
+ /*
+ * The ethernet is not a radio device, but we will still need to init
+ * it. check if this is the etherent device or not.
+
+ if (netType == ConnectivityManager.TYPE_ETHERNET) {
+ if (DBG) Slog.v(TAG, "Starting Ethernet Service.");
+ EthernetStateTracker est = new EthernetStateTracker(context, mHandler);
+ EthernetService ethService = new EthernetService(context, est);
+ ServiceManager.addService(Context.ETHERNET_SERVICE, ethService);
+ mNetTrackers[ConnectivityManager.TYPE_ETHERNET] = est;
+ est.startMonitoring();
+ } else {
+ Slog.e(TAG, "Trying to create a DataStateTracker for an unknown radio type " +
+ mNetAttributes[netType].mRadio);
+ }*/
continue;
}
}
JNI接口文件添加:android_net_ethernet.cpp
5. 将framework/base/core/jni/android_net_ethernet.cpp复制到源码目录framework/base/core/jni/目录下;
6. 修改framework/base/core/jni/AndroidRuntime.cpp文件,注册JNI接口文件:
--- /home/thomas/android2.2/frameworks/base/core/jni/AndroidRuntime.cpp 2011-07-04 15:37:30.109468920 +0800
+++ ./frameworks/base/core/jni/AndroidRuntime.cpp 2011-09-08 15:35:47.047843001 +0800
@@ -141,6 +141,7 @@
extern int register_android_net_NetworkUtils(JNIEnv* env);
extern int register_android_net_TrafficStats(JNIEnv* env);
extern int register_android_net_wifi_WifiManager(JNIEnv* env);
+extern int register_android_net_ethernet_EthernetManager(JNIEnv* env); //Added by TCL Thomas Yang Sep.08 2011
extern int register_android_security_Md5MessageDigest(JNIEnv *env);
extern int register_android_text_AndroidCharacter(JNIEnv *env);
extern int register_android_text_AndroidBidi(JNIEnv *env);
@@ -1259,6 +1260,7 @@
REG_JNI(register_android_net_NetworkUtils),
REG_JNI(register_android_net_TrafficStats),
REG_JNI(register_android_net_wifi_WifiManager),
+ REG_JNI(register_android_net_ethernet_EthernetManager),//Added by TCL Thomas Yang Sep.08 2011
REG_JNI(register_android_os_MemoryFile),
REG_JNI(register_com_android_internal_os_ZygoteInit),
REG_JNI(register_android_hardware_Camera),
7. 修改framework/base/core/jni/Android.mk文件,添加ethernetJNI接口文件的编译项:
--- /home/thomas/android2.2/frameworks/base/core/jni/Android.mk 2011-07-04 15:37:30.109468920 +0800
+++ ./frameworks/base/core/jni/Android.mk 2011-09-08 15:42:58.551843002 +0800
@@ -60,6 +60,7 @@
android_net_NetUtils.cpp \
android_net_TrafficStats.cpp \
android_net_wifi_Wifi.cpp \
+ android_net_ethernet.cpp \
android_nio_utils.cpp \
android_pim_EventRecurrence.cpp \
android_text_format_Time.cpp \
8. 修改framework/base/core/java/android/net/ConnectivityManager.java文件:
--- /home/thomas/android2.2/frameworks/base/core/java/android/net/ConnectivityManager.java 2011-07-04 15:37:30.017468920 +0800
+++ ./frameworks/base/core/java/android/net/ConnectivityManager.java 2011-09-07 11:29:30.185267002 +0800
@@ -190,10 +190,19 @@
* default connections.
*/
public static final int TYPE_WIMAX = 6;
+
+/**
+ * The Default Ethernet data connection. When active, all data traffic
+ * will use this connection by default. Should not coexist with other
+ * default connections.
+ */
+ public static final int TYPE_ETHERNET = 7; //Changed by TCL Thomas Yang Sep.07 2011
+
+
/** {@hide} TODO: Need to adjust this for WiMAX. */
public static final int MAX_RADIO_TYPE = TYPE_WIFI;
/** {@hide} TODO: Need to adjust this for WiMAX. */
- public static final int MAX_NETWORK_TYPE = TYPE_MOBILE_HIPRI;
+ public static final int MAX_NETWORK_TYPE = TYPE_ETHERNET; //Changed by TCL Thomas Yang Sep.07 2011
public static final int DEFAULT_NETWORK_PREFERENCE = TYPE_WIFI;
9. 修改framework/base/java/android/content/Context.java:
10. 修改文件frameworks/base/core/java/android/provider/Settings.java
11. 修改文件:frameworks/base/core/java/android/app/ContextImpl.java
12. 修改文件:frameworks/base/core/res/res/values/arrays.xml:
13. 修改文件:frameworks/base/core/res/res/values/config.xml:
下文待续------