Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1371459
  • 博文数量: 198
  • 博客积分: 1629
  • 博客等级: 上尉
  • 技术积分: 2743
  • 用 户 组: 普通用户
  • 注册时间: 2011-08-01 15:41
文章分类
文章存档

2023年(6)

2022年(20)

2021年(8)

2020年(3)

2018年(17)

2017年(3)

2016年(3)

2015年(9)

2014年(13)

2013年(17)

2012年(77)

2011年(22)

分类: Android平台

2013-12-12 15:28:21


参照网上的移植过一次,有以下3个问题先需要注意:
一.  下载相应的android-x86版本代码,否则出错的几率很大
二.  如出现android.net.ethernet.ethernetstatetracker.cpp  stripped of.....这一错误时,大多是版本不对
三.  编译完成后,如出现以下错误,按照代码修改即可:
主要从android-x86中移植过来,分成3部分。
1. build/core/pathmap.mk
FRAMEWORKS_BASE_SUBDIRS := \
        $(addsuffix /java, \
            sax \
            telephony \
            ethernet \
2. packages/apps/Settings/中增加及修改
    参照android-x86中gingerbread-x86分支
3. frameworks/base/中增加及修改
    参照android-x86中gingerbread-x86分支

出现的问题:
1.现象:
# I/ActivityManager(  633): Starting: Intent { act=android.intent.action.MAIN cmp=com.android.settings/.EthernetSettings } from pid 1065
W/ApplicationContext( 1065): Error getting service name:ethernet
D/AndroidRuntime( 1065): Shutting down VM
W/dalvikvm( 1065): threadid=1: thread exiting with uncaught exception (group=0x40015560)
I/EthernetManager( 1065): Init Ethernet Manager, service: null
E/AndroidRuntime( 1065): FATAL EXCEPTION: main
E/AndroidRuntime( 1065): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.settings/com.android.settings.EthernetSettings}: java.lang.NullPointerException
E/AndroidRuntime( 1065):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
E/AndroidRuntime( 1065):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
E/AndroidRuntime( 1065):        at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 1065):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/AndroidRuntime( 1065):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1065):        at android.os.Looper.loop(Looper.java:130)
通过在frameworks/base/services/java/com/android/server/ConnectivityService.java中的函数
    private ConnectivityService(Context context) {
增加一些log信息,可以知道attributes有出现问题,并没有 public static final int TYPE_ETHERNET    = 9; 这个被找到。 log如下:
D/ConnectivityService(   87): netType:4 , mRadio:0
D/ConnectivityService(   87): netType:5 , mRadio:0
D/ConnectivityService(   87): netType:3 , mRadio:0
D/ConnectivityService(   87): netType:2 , mRadio:0
D/ConnectivityService(   87): netType:1 , mRadio:1
V/ConnectivityService(   87): Starting Wifi Service.
I/WifiService(   87): WifiService starting up with Wi-Fi enabled
D/ConnectivityService(   87): netType:0 , mRadio:0

中明明有增加
    "ethernet,9,9,1"
为什么就没了呢?  其实是在device/samsung/smdkv210/overlay目录下被
overlay了。
device/samsung/smdkv210/overlay/frameworks/base/core/res/res/values/config.xml
   
        "wifi,1,1,1"
        "mobile,0,0,0"
        "mobile_mms,2,0,2"
        "mobile_supl,3,0,2"
        "mobile_dun,4,0,4"
        "mobile_hipri,5,0,3"
        "ethernet,9,9,1"
   
在这里增加ethernet行后,上面的错误信息就没了。

2. 加入ethernet导致启动过程出错,进不了桌面,log:
W/dalvikvm(  390): No implementation found for native Landroid/net/ethernet/EthernetNative;.initEthernetNative ()I
W/dalvikvm(  390): threadid=27: thread exiting with uncaught exception (group=0x40015560)
D/ConnectivityService(  390): netType:9 , mRadio:9
V/ConnectivityService(  390): Starting Ethernet Service.
D/ConnectivityService(  390): Starting Ethernet Service.
V/EthernetStateTracker(  390): Starts...
E/AndroidRuntime(  390): *** FATAL EXCEPTION IN SYSTEM PROCESS: ConnectivityThread
E/AndroidRuntime(  390): java.lang.UnsatisfiedLinkError: initEthernetNative
E/AndroidRuntime(  390):        at android.net.ethernet.EthernetNative.initEthernetNative(Native Method)
E/AndroidRuntime(  390):        at android.net.ethernet.EthernetStateTracker.(EthernetStateTracker.java:83)
E/AndroidRuntime(  390):        at com.android.server.ConnectivityService.(ConnectivityService.java:413)
E/AndroidRuntime(  390):        at com.android.server.ConnectivityService.(ConnectivityService.java:66)
E/AndroidRuntime(  390):        at com.android.server.ConnectivityService$ConnectivityThread.run(ConnectivityService.java:230)
而在frameworks/base/core/jni/android_net_ethernet.cpp中明明是有
        {"initEthernetNative", "()I",
         (void *)android_net_ethernet_initEthernetNative},
jeff@translogic:~/android/adv-iputer/jeff-2.3.7_r1$ grep register_android_net_ethernet_EthernetManager frameworks/base/ -r --include=*.cpp
frameworks/base/core/jni/android_net_ethernet.cpp:    int register_android_net_ethernet_EthernetManager(JNIEnv* env)
jeff@translogic:~/android/adv-iputer/jeff-2.3.7_r1$ 
而在android-x86的frameworks/base目录搜索:
jeff@translogic:~/android/adv-iputer/jeff-2.3.7_r1$ grep register_android_net_ethernet_EthernetManager /common/android-x86/base/ -r --include=*.cpp
/common/android-x86/base/core/jni/android_net_ethernet.cpp:    int register_android_net_ethernet_EthernetManager(JNIEnv* env)
/common/android-x86/base/core/jni/AndroidRuntime.cpp:extern int register_android_net_ethernet_EthernetManager(JNIEnv* env);
/common/android-x86/base/core/jni/AndroidRuntime.cpp:    REG_JNI(register_android_net_ethernet_EthernetManager),
jeff@translogic:~/android/adv-iputer/jeff-2.3.7_r1$ 
所以是在 frameworks/base/core/jni/AndroidRuntime.cpp 中缺少了注册jni。 增加后就可以正常启动了。

好了,移植开始
一、准备工具:curl和repo 

yum install curl 
curl  > /bin/repo 
chmod a+x /bin/repo 

二、创建文件夹 
mkdir /opt/FriendlyARM/mini6410/ android /android-x86 
cd /opt/FriendlyARM/mini6410/ android /android-x86 

三、全部源码太大,只下载相关部分源码,gingerbread-x86代表2.3版本的源码 
repo init -u git://android-x86.git.sf.net/gitroot/android-x86/x86/platform/manifest.git -b gingerbread-x86 
repo sync platform/frameworks/base 
repo sync platform/packages/apps/Settings 

四、移植framework部分(+号的行代表增加的内容,-号的行代表删除的内容) 
源路径=/opt/FriendlyARM/mini6410/android/android-x86 
目标路径=/opt/FriendlyARM/mini6410/android/Android-2.3.4 
4.1.将源路径framework/base/ethernet 复制到目标路径的framework/base/目录下 

4.2.修改目标路径的framework/base目录下的Android.mk 
    vpn/java/android/net/vpn/IVpnService.aidl \ 
+    ethernet/java/android/net/ethernet/IEthernetManager.aidl \ 
    voip/java/android/net/sip/ISipSession.aidl \ 

4.3. 将源路径文件frameworks/base/services/java/com/android/server/EthernetService.java复制到目标路径frameworks/base/services/java/com/android/server/目录下 

4.4. 修改目标路径framework/base/service/java/com/android/server目录下的ConnectivityService.java文件 
import android.net.wifi.WifiStateTracker; 
+import android.net.ethernet.EthernetStateTracker; 
import android.net.wimax.WimaxManagerConstants; 
//----------------------------------------------------------------------------------------- 
if (mNetAttributes[n.mType] != null) { 
    Slog.e(TAG, "Error in networkAttributes - ignoring attempt to redefine type " + 
        n.mType); 
    continue; 

-if (mRadioAttributes[n.mRadio] == null) { 
+if ((n.mType != ConnectivityManager.TYPE_ETHERNET) && (mRadioAttributes[n.mRadio] == null)) { //by bjw 
    Slog.e(TAG, "Error in networkAttributes - ignoring attempt to use undefined " + 
        "radio " + n.mRadio + " in network type " + n.mType); 
    continue; 

mNetAttributes[n.mType] = n; 
mNetworksDefined++; 
} catch(Exception e) { 
+Slog.e(TAG, "wrong dev exception " + e); //by bjw 
// ignore it - leave the entry null 

//----------------------------------------------------------------------------------------- 
wifiService.startWifi(); 
mNetTrackers[ConnectivityManager.TYPE_WIFI] = wst; 
wst.startMonitoring(); 
break; 
+case ConnectivityManager.TYPE_ETHERNET: //by bjw 
+if (DBG) Slog.v(TAG, "#########Starting Ethernet Service.");  //by bjw 
+EthernetStateTracker est = new EthernetStateTracker(context, mHandler);  //by bjw 
+EthernetService ethService = new EthernetService(context, est);  //by bjw 
+ServiceManager.addService(Context.ETHERNET_SERVICE, ethService);  //by bjw 
+mNetTrackers[ConnectivityManager.TYPE_ETHERNET] = est;  //by bjw 
+est.startMonitoring(); //by bjw 
+break;//by bjw 
case ConnectivityManager.TYPE_MOBILE: 
//----------------------------------------------------------------------------------------- 
if (noMobileData) { 
    if (DBG) Slog.d(TAG, "tearing down WiMAX networks due to setting"); 
    mNetTrackers[netType].teardown(); 

break; 
default: 
// Slog.e(TAG, "Trying to create a DataStateTracker for an unknown radio type " + 
// mNetAttributes[netType].mRadio); 

4.5. 将源路径framework/base/core/jni/android_net_ethernet.cpp复制到目标路径framework/base/core/jni/目录下 

4.6. 修改目标路径framework/base/core/jni/AndroidRuntime.cpp文件 
extern int register_android_net_wifi_WifiManager(JNIEnv* env); 
+extern int register_android_net_ethernet_EthernetManager(JNIEnv* env); 
extern int register_android_security_Md5MessageDigest(JNIEnv *env); 
//----------------------------------------------------------------------------------------- 
REG_JNI(register_android_net_wifi_WifiManager), 
+REG_JNI(register_android_net_ethernet_EthernetManager), 
REG_JNI(register_android_nfc_NdefMessage), 

4.7. 修改目标路径framework/base/core/jni/Android.mk文件,添加ethernetJNI接口文件的编译项 
android_net_wifi_Wifi.cpp \ 
+android_net_ethernet.cpp \ 
android_nio_utils.cpp \ 

4.8. 修改目标路径framework/base/java/android/content/Context.java 
public static final String WIFI_SERVICE = "wifi"; 
+public static final String ETHERNET_SERVICE = "ethernet"; 

4.9. 修改目标路径frameworks/base/core/java/android/provider/Settings.java 
        public static final String WIFI_ON = "wifi_on"; 

+        /** 
+         * Ethernet related configurations 
+         */ 
+        public static final String ETHERNET_ON      = "ethernet_on"; 
+        public static final String ETHERNET_MODE    = "ethernet_mode"; 
+        public static final String ETHERNET_IP      = "ethernet_ip"; 
+        public static final String ETHERNET_MASK    = "ethernet_netmask"; 
+        public static final String ETHERNET_DNS     = "ethernet_dns"; 
+        public static final String ETHERNET_ROUTE   = "ethernet_iproute"; 
+        public static final String ETHERNET_CONF    = "ethernet_conf"; 
+        public static final String ETHERNET_IFNAME  = "ethernet_ifname"; 

4.10. 修改目标路径frameworks/base/core/java/android/app/ContextImpl.java 
import android.net.wifi.WifiManager; 
+import android.net.ethernet.IEthernetManager;//by bjw 
+import android.net.ethernet.EthernetManager; //by bjw 
import android.nfc.NfcManager; 
//----------------------------------------------------------------------------------------- 
private static WifiManager sWifiManager; 
+private static EthernetManager sEthernetManager; //by bjw 
private static LocationManager sLocationManager; 
//----------------------------------------------------------------------------------------- 
    } else if (WIFI_SERVICE.equals(name)) { 
        return getWifiManager(); 
+    } else if (ETHERNET_SERVICE.equals(name)) {  //by bjw 
+        return getEthernetManager();  //by bjw 
    } else if (NOTIFICATION_SERVICE.equals(name)) { 
        return getNotificationManager(); 
//----------------------------------------------------------------------------------------- 
return sWifiManager; 
    } 
+    private EthernetManager getEthernetManager()  //by bjw 
+    {   
+        synchronized (sSync) {   
+            if (sEthernetManager == null) {     
+                if (b == null) { 
+                        Log.w(TAG, "Error getting service name:" + ETHERNET_SERVICE); 
+                } 
+                IBinder b = ServiceManager.getService(ETHERNET_SERVICE);   
+                IEthernetManager service = IEthernetManager.Stub.asInterface(b);   
+                sEthernetManager = new EthernetManager(service, mMainThread.getHandler());   
+            }   
+        }   
+        return sEthernetManager;   
+    } 
private NotificationManager getNotificationManager() { 

4.11. 修改目标路径frameworks/base/core/res/res/values/config.xml 
wifi 
+ethernet 
cdma_eri 
//----------------------------------------------------------------------------------------- 
"mobile_hipri,5,0,3" 
+"ethernet,9,9,1" 
 

五、移植packages部分 
5.1.复制源路径packages/apps/Settings/src/com/android/settings/ethernet目录到目标路径packages/apps/Settings/src/com/android/settings/目录下; 

5.2.复制源路径packages/apps/Settings/src/com/android/settings/EthernetSettings.java到目标路径packages/apps/Settings/src/com/android/settings/目录下; 

5.3.复制源路径packages/apps/Settings/res/drawable-hdpi/ic_settings_ethernet.png到目标路径packages/apps/Settings/res/drawable-hdpi/目录下 

5.4.复制源路径packages/apps/Settings/res/drawable-mdpi/ic_settings_ethernet.png到目标路径packages/apps/Settings/res/drawable-mdpi/目录下 

5.5.复制源路径packages/apps/Settings/res/layout/eth_configure.xml到目标路径packages/apps/Settings/res/layout/目录下 

5.6.复制源路径packages/apps/Settings/res/xml/ethernet_settings.xml到目标路径packages/apps/Settings/res/xml/目录下 

5.7. 修改目标路径文件packages/apps/Settings/res/values/strings.xml 
Feedback 
+   
+Configure Ethernet device   
+Ethernet setting   
+Ethernet Devices:   
+Connection Type   
+DHCP   
+Static IP   
+DNS address   
+Default Gateway   
+IP address   
+Ethernet   
+Turn on Ethernet   
+Ethernet configuration   
+Ethernet configuration   
+Configure Ethernet devices   
+Netmask   
+Turn off Ethernet   
+Turn on Ethernet   

5.8.修改目标路径packages/apps/Settings/res/values/arrays.xml 
     
        15 seconds 
        30 seconds 
        1 minute 
        2 minutes 
        10 minutes 
        30 minutes 
+        Never Timeout 
     
//----------------------------------------------------------------------------------------- 
     
     
         
        15000 
         
        30000 
         
        60000 
         
        120000 
         
        600000 
         
        1800000 
+        
+       -1 
 

5.9.修改目标路径文件packages/apps/Settings/res/values-zh-rCN/arrays.xml 
   
    "15 秒" 
    "30 秒" 
    "1 分钟" 
    "2 分钟" 
    "10 分钟" 
    "30 分钟" 
+   "从不待机" 
   

5.10.修改目标路径文件packages/apps/Settings/res/ values-zh-rCN-nokeys/strings.xml 
"管理应用程序" 
+       
+    "设置以太网设备"   
+    "以太网设置"   
+    "以太网设置:"   
+    "连接类型"   
+    "Dhcp动态分配IP"   
+    "静态分配IP"   
+    "DNS地址"   
+    "网关"   
+    "IP地址"   
+    "以太网"   
+    "打开以太网设备"   
+    "以太网设置"   
+    "以太网设置"   
+    "设置以太网设备"   
+    "子网掩码"   
+    "关闭以太网设备"   
+    "打开以太网设备" 

5.11. 修改目标路径文件packages/apps/Settings/res/xml/settings.xml 

    android:title="@string/radio_controls_title" 
    settings:icon="@drawable/ic_settings_wireless"> 
    
    android:action="android.intent.action.MAIN" 
    android:targetPackage="com.android.settings" 
    android:targetClass="com.android.settings.WirelessSettings" /> 
 
+
+    android:title="@string/eth_radio_ctrl_title"   
+    settings:icon="@drawable/ic_settings_ethernet">   
+    
+    android:action="android.intent.action.MAIN"   
+    android:targetPackage="com.android.settings"   
+    android:targetClass="com.android.settings.EthernetSettings" />   


5.12. 修改目标路径文件packages/apps/Settings/AndroidManifest.xml 
+   
+
+    android:label="@string/eth_radio_ctrl_title"   
+    >   
+       
+           
+           
+           
+           
+       
+
   

+
+    android:clearTaskOnLaunch="true"   
+    >   
+       
+           
+           
+           
+           
+           
+       
+
   

+
+    android:clearTaskOnLaunch="true"   
+    >   
+       
+           
+           
+           
+           
+           
+       
+
   

 

六、接下来要增加Ethernet的状态栏图标 
6.1.复制源路径frameworks/base/packages/SystemUI/res/drawable-hdpi/connect_creating.png到目标路径对应目录下 

6.2.复制源路径frameworks/base/packages/SystemUI/res/drawable-hdpi/connect_established.png到目标路径对应目录下 

6.3.复制源路径frameworks/base/packages/SystemUI/res/drawable-hdpi/connect_no.png到目标路径对应目录下 

6.4.复制源路径frameworks/base/packages/SystemUI/res/drawable-mdpi/connect_creating.png到目标路径对应目录下 

6.5.复制源路径frameworks/base/packages/SystemUI/res/drawable-mdpi/connect_established.png到目标路径对应目录下 

6.6.复制源路径frameworks/base/packages/SystemUI/res/drawable-mdpi/connect_no.png到目标路径对应目录下 

6.7. 修改目标路径文件frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java 
import android.net.wifi.WifiManager; 
+import android.net.ethernet.EthernetManager; 
+import android.net.ethernet.EthernetStateTracker; 
import android.os.Binder; 
//----------------------------------------------------------------------------------------- 
import android.os.storage.StorageManager; 
+import android.os.SystemProperties; 
import android.provider.Settings; 
//----------------------------------------------------------------------------------------- 
private int mLastWifiSignalLevel = -1; 
private boolean mIsWifiConnected = false; 
// Ethernet 
+private static final int[] sEthImages = { 
+    R.drawable.connect_established, 
+    R.drawable.connect_no, 
+    R.drawable.connect_creating 
+}; 
//----------------------------------------------------------------------------------------- 
    else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION) || 
        action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION) || 
        action.equals(WifiManager.RSSI_CHANGED_ACTION)) { 
            updateWifi(intent); 
+    }  else if (action.equals(EthernetManager.ETHERNET_STATE_CHANGED_ACTION)) { 
+        updateEth(intent); 
    } 
    else if (action.equals(LocationManager.GPS_ENABLED_CHANGE_ACTION) || 
        action.equals(LocationManager.GPS_FIX_CHANGE_ACTION)) { 
            updateGps(intent); 
    } 
//----------------------------------------------------------------------------------------- 
//如果不要2G/3G信号图标可如此更改,设置图标属性Visibility为false 
mService.setIcon("phone_signal", mPhoneSignalIconId, 0);//在所有的这行下添加下面的一行,共4处 
+mService.setIconVisibility("phone_signal", false);//此处是添加的 
//----------------------------------------------------------------------------------------- 
// wifi will get updated by the sticky intents 
+// ethernet 
+mService.setIcon("ethernet", sEthImages[0], 0); 
+mService.setIconVisibility("ethernet", false); 
//----------------------------------------------------------------------------------------- 
filter.addAction(WifiManager.RSSI_CHANGED_ACTION); 
+filter.addAction(EthernetManager.ETHERNET_STATE_CHANGED_ACTION); 
filter.addAction(LocationManager.GPS_ENABLED_CHANGE_ACTION); 
//----------------------------------------------------------------------------------------- 
updateSignalStrength(); // apply any change in mInetCondition 
break; 
+case ConnectivityManager.TYPE_ETHERNET: 
+    if (info.isConnected()) { 
+        mService.setIcon("ethernet", sEthImages[0], 0); 
+        // Show the icon since ethernet is connected 
+        mService.setIconVisibility("ethernet", true); 
+    } else { 
+        mService.setIcon("ethernet", sEthImages[1], 0); 
+        // Hide the icon since we're not connected 
+        mService.setIconVisibility("ethernet", false); 
+    } 
+    break; 
case ConnectivityManager.TYPE_WIMAX: 
            mInetCondition = inetCondition; 
            if (info.isConnected()) { 
                mIsWimaxConnected = true; 
                mService.setIconVisibility("wimax", true); 
            } else { 
                mIsWimaxConnected = false; 
            } 
            updateWiMAX(intent); 
            break; 
//----------------------------------------------------------------------------------------- 
mService.setIconVisibility("bluetooth", mBluetoothEnabled); 
    } 
+private final void updateEth(Intent intent) { 
+    final int event = intent.getIntExtra(EthernetManager.EXTRA_ETHERNET_STATE, EthernetManager.ETHERNET_STATE_UNKNOWN); 
+    int iconId; 
+    switch (event) { 
+            case EthernetStateTracker.EVENT_HW_CONNECTED: 
+            case EthernetStateTracker.EVENT_INTERFACE_CONFIGURATION_SUCCEEDED: 
+                mService.setIconVisibility("ethernet", true); 
+                iconId = sEthImages[0]; 
+                break; 
+            case EthernetStateTracker.EVENT_HW_DISCONNECTED: 
+            case EthernetStateTracker.EVENT_INTERFACE_CONFIGURATION_FAILED: 
+                mService.setIconVisibility("ethernet", false); 
+                iconId = sEthImages[1]; 
+                return; 
+            default: 
+                iconId = sEthImages[2]; 
+    } 
+    mService.setIcon("ethernet", iconId, 0); 
+} 
private final void updateWifi(Intent intent) { 

6.8. 修改目标路径文件frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java 
//此步只是去除友善之臂添加的SeviceSocket服务而已,因为已经在系统中添加了Ethernet框架,所以SeviceSocket可以不要,但如果你还要使用友善提供的有线网络和3g网络的设置工具,那还是不要做此步骤以保留SeviceSocket服务。 
package com.android.systemui.statusbar; 
-import com.android.systemui.statusbar.SeviceSocket; 
-import android.content.ComponentName; 
-import android.app.Notification; 
-import android.app.NotificationManager; 
-import android.app.PendingIntent; 
-import java.io.File; 
-import java.io.FileReader; 
-import java.util.Timer; 
-import java.util.TimerTask; 
import android.app.Service; 
//----------------------------------------------------------------------------------------- 
// for disabling the status bar 
int mDisabled = 0; 
-//F/r/i/e/n/d/l/y/A/R/M 
-private static SeviceSocket seviceSocket = null; 
-private NotificationManager myNotiManager; 
//----------------------------------------------------------------------------------------- 
// Put up the view 
addStatusBarView(); 

// Lastly, call to the icon policy to install/update all the icons. 
mIconPolicy = new StatusBarPolicy(this); 

-//F/r/i/e/n/d/l/y/A/R/M 
-myNotiManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
-seviceSocket = new SeviceSocket(new SeviceSocket.RecvCallBack() { 
-    public void responseIncoming(String response) { 
-        processNETStatusResponse(response); 
-    } 
-}); 
-timerToConnService.schedule(taskConnectService,1,8000); 
-    } 


-    //{{F-r-i-e-n-d-l-y-A-R-M 
-    private void setStatusIcon(int iconId, String text) { 
-        Intent notifyIntent=new Intent(); 
-        notifyIntent.setComponent(new ComponentName("com.friendlyarm.net3gdialup", "com.friendlyarm.net3gdialup.ActivityMain")); 
-        notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
-        PendingIntent appIntent = PendingIntent.getActivity(this, 0, 
-            notifyIntent, 0); 
-        Notification myNoti = new Notification(); 
-        myNoti.icon = iconId; 
-        myNoti.tickerText = text; 
-        myNoti.defaults = Notification.DEFAULT_LIGHTS; 
-        myNoti.setLatestEventInfo(this, "3G Network Status",text, appIntent); 
-        myNotiManager.notify(0, myNoti); 
-    } 

-    private void removeStatusIcon() { 
-        myNotiManager.cancelAll(); 
-    } 

-    private int lastNetworkStatus = -1; 
-    private boolean isConnectService = false; 

-    private final int CONNECT_TO_SERVICE_MSG = 100; 
-    private final int REQUEST_NETSTATUS_MSG = 101; 

-    private Timer timerToConnService = new Timer(); 
-    private Timer timerToRequestStatus = new Timer(); 

-    private Handler handler = new Handler() { 
-        public void handleMessage(Message msg) { 
-            switch (msg.what) { 
-            case CONNECT_TO_SERVICE_MSG: 
-                timerToConnService.cancel(); 
-                seviceSocket.connectToService(); 
-                break; 
-            case REQUEST_NETSTATUS_MSG: 
-                seviceSocket.sendRequest("REQUEST NETSTATUS\n"); 
-                seviceSocket.recvResponse(); 
-                break; 
-            } 
-            super.handleMessage(msg); 
-        } 
-    }; 

-    private TimerTask taskConnectService = new TimerTask() { 
-        public void run() { 
-            Message message = new Message(); 
-            message.what = CONNECT_TO_SERVICE_MSG; 
-            handler.sendMessage(message); 
-        } 
-    }; 

-    private TimerTask taskRequestNetStatus = new TimerTask() { 
-        public void run() { 
-            Message message = new Message(); 
-            message.what = REQUEST_NETSTATUS_MSG; 
-            handler.sendMessage(message); 
-        } 
-    }; 

-    private void processNETStatusResponse(String response) { 
-        String[] results = response.split(" "); 

-        if (response.startsWith("RESPONSE CONNECT OK")) { 
-            seviceSocket.sendRequest("REQUEST 3GAUTOCONNECT GETSTATUS"); 
-            seviceSocket.recvResponse(); 
-        } else if (response.startsWith(new String("RESPONSE 3GAUTOCONNECT")) && results.length == 6) { 
-            if (Integer.parseInt(results[2]) == 1 && results[3].startsWith(new String("3GNET"))) { 
-                timerToRequestStatus.schedule(taskRequestNetStatus,1,3000); 
-            } else { 
-                seviceSocket.disconnect(); 
-            } 
-        } else if (response.startsWith(new String("RESPONSE NETSTATUS")) 
-            && results.length >= 5) { 
-                if (results[2].startsWith(new String("DOWN"))) { 
-                    if (lastNetworkStatus != 0) { 
-                        removeStatusIcon(); 
-                    } 
-                    lastNetworkStatus = 0; 
-                } else if (results[2].startsWith(new String("UP")) 
-                    && results.length == 8) { 
-                        if (lastNetworkStatus != 1) { 
-                            setStatusIcon(com.android.internal.R.drawable.net3g, "Connected. (FriendlyARM-3G)"); 
-                        } 
-                        lastNetworkStatus = 1; 
-                } 
-        } 
-    } 
-    //}} 
}//这边增加一个括号 
@Override 
public void onDestroy() { 
    // we're never destroyed 


七、修改目标路径文件build/core/pathmap.mk 
vpn \ 
+ethernet \ 
keystore \ 

八、编译并烧写 //如果编译出错,升级一下make程序:yum update make 
注意: 
如果对资源文件做了修改(添加/删除/修改),必须删掉临时编译文件,否则总是使用旧的临时文件编译; 
针对APP,资源文件需删除的临时文件路径如下: 
out/target/common/R/com/android; 
out/target/common/obj/APPS; 
out/target/product/tigger/obj/APPS; 
然后make update-api 
./build-android 
最后记得修改init.rc,在最后增加DHCP服务 
service dhcpcd_eth0 /system/bin/dhcpcd -ABKL 
    disabled 
oneshot 
制作ROM烧写 

九、使用 
在自己的程序中,可以使用如下语句来转到以太网设置页面 
Intent intent = new Intent("android.settings.ETHERNET_SETTINGS"); 
startActivity(intent); 




阅读(4708) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~