本文主要是介绍为Tiny6410Android2.3.4系统添加Ethernet框架支持(含去除状态栏信号图标及增加屏幕超时“永不关屏”选项),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
http://www.arm9home.net/read.php?tid-17117.html
先分享一下修改后的图片
1.增加状态栏网络图标(有连接时才显示),去除信号图标2. 增加设置“以太网设置”选项
3. 增加“从不待机”选项,对应的实际值是-1
友善之臂有提供了1个软件用于设置开发板的有线网络。如果你因某些原因不想使用或不方便使用这个软件,本文讲述如何移植让系统框架支持以太网的设置(DHCP动态分配IP或手动静态设置IP)
主要是利用android-x86现成的Ethernet框架,添加到Tiny6410的android源码中,增加系统对Ethernet的支持。
本文所用的是友善Tiny6410 2011-11-16版本的Android源代码。所有的修改都是基于此版本进行的。
如果你懒得修改,可以直接用附件中改好的代码直接覆盖,当然前提是你使用的开发板型号、源代码版本一样才行。附件的内容仅供参考,除了增加Ethernet框架之外,还更改了一些默认设置。
==========================================================================================
先把友善android源代码解压放好
一、准备工具:curl和repo
yum install curl
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > /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
<item><xliff:g id="id">wifi</xliff:g></item>
+<item><xliff:g id="id">ethernet</xliff:g></item>
<item><xliff:g id="id">cdma_eri</xliff:g></item>
//-----------------------------------------------------------------------------------------
<item>"mobile_hipri,5,0,3"</item>
+<item>"ethernet,9,9,1"</item>
</string-array>
五、移植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
<string name="sound_category_feedback_title">Feedback</string>
+<!-- Ethernet configuration dialog -->
+<string name="eth_config_title">Configure Ethernet device</string>
+<string name="eth_setting">Ethernet setting</string>
+<string name="eth_dev_list">Ethernet Devices:</string>
+<string name="eth_con_type">Connection Type</string>
+<string name="eth_con_type_dhcp">DHCP</string>
+<string name="eth_con_type_manual">Static IP</string>
+<string name="eth_dns">DNS address</string>
+<string name="eth_gw">Default Gateway</string>
+<string name="eth_ipaddr">IP address</string>
+<string name="eth_quick_toggle_title">Ethernet</string>
+<string name="eth_quick_toggle_summary">Turn on Ethernet</string>
+<string name="eth_radio_ctrl_title">Ethernet configuration</string>
+<string name="eth_conf_perf_title">Ethernet configuration</string>
+<string name="eth_conf_summary">Configure Ethernet devices</string>
+<string name="eth_mask">Netmask</string>
+<string name="eth_toggle_summary_off">Turn off Ethernet</string>
+<string name="eth_toggle_summary_on">Turn on Ethernet</string>
5.8.修改目标路径packages/apps/Settings/res/values/arrays.xml
<string-array name="screen_timeout_entries">
<item>15 seconds</item>
<item>30 seconds</item>
<item>1 minute</item>
<item>2 minutes</item>
<item>10 minutes</item>
<item>30 minutes</item>
+ <item>Never Timeout</item>
</string-array>
//-----------------------------------------------------------------------------------------
<!-- Do not translate. -->
<string-array name="screen_timeout_values" translatable="false">
<!-- Do not translate. -->
<item>15000</item>
<!-- Do not translate. -->
<item>30000</item>
<!-- Do not translate. -->
<item>60000</item>
<!-- Do not translate. -->
<item>120000</item>
<!-- Do not translate. -->
<item>600000</item>
<!-- Do not translate. -->
<item>1800000</item>
+ <!-- Do not translate. -->
+ <item>-1</item>
</string-array>
5.9.修改目标路径文件packages/apps/Settings/res/values-zh-rCN/arrays.xml
<string-array name="screen_timeout_entries">
<item msgid="3342301044271143016">"15 秒"</item>
<item msgid="8881760709354815449">"30 秒"</item>
<item msgid="7589406073232279088">"1 分钟"</item>
<item msgid="7001195990902244174">"2 分钟"</item>
<item msgid="5721688686241190620">"10 分钟"</item>
<item msgid="7156442995039264948">"30 分钟"</item>
+ <item msgid="1781492122915870416">"从不待机"</item>
</string-array>
5.10.修改目标路径文件packages/apps/Settings/res/ values-zh-rCN-nokeys/strings.xml
<string name="applications_settings_summary" msgid="6616938758022986257">"管理应用程序"</string>
+ <!-- Ethernet configuration dialog -->
+ <string name="eth_config_title">"设置以太网设备"</string>
+ <string name="eth_setting">"以太网设置"</string>
+ <string name="eth_dev_list">"以太网设置:"</string>
+ <string name="eth_con_type">"连接类型"</string>
+ <string name="eth_con_type_dhcp">"Dhcp动态分配IP"</string>
+ <string name="eth_con_type_manual">"静态分配IP"</string>
+ <string name="eth_dns">"DNS地址"</string>
+ <string name="eth_gw">"网关"</string>
+ <string name="eth_ipaddr">"IP地址"</string>
+ <string name="eth_quick_toggle_title">"以太网"</string>
+ <string name="eth_quick_toggle_summary">"打开以太网设备"</string>
+ <string name="eth_radio_ctrl_title">"以太网设置"</string>
+ <string name="eth_conf_perf_title">"以太网设置"</string>
+ <string name="eth_conf_summary">"设置以太网设备"</string>
+ <string name="eth_mask">"子网掩码"</string>
+ <string name="eth_toggle_summary_off">"关闭以太网设备"</string>
+ <string name="eth_toggle_summary_on">"打开以太网设备"</string>
5.11. 修改目标路径文件packages/apps/Settings/res/xml/settings.xml
<com.android.settings.IconPreferenceScreen
android:title="@string/radio_controls_title"
settings:icon="@drawable/ic_settings_wireless">
<intent
android:action="android.intent.action.MAIN"
android:targetPackage="com.android.settings"
android:targetClass="com.android.settings.WirelessSettings" />
</com.android.settings.IconPreferenceScreen>
+<com.android.settings.IconPreferenceScreen
+ android:title="@string/eth_radio_ctrl_title"
+ settings:icon="@drawable/ic_settings_ethernet">
+ <intent
+ android:action="android.intent.action.MAIN"
+ android:targetPackage="com.android.settings"
+ android:targetClass="com.android.settings.EthernetSettings" />
+</com.android.settings.IconPreferenceScreen>
5.12. 修改目标路径文件packages/apps/Settings/AndroidManifest.xml
+<!-- Ethernet controls -->
+<activity android:name="EthernetSettings"
+ android:label="@string/eth_radio_ctrl_title"
+ >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <action android:name="android.settings.ETHERNET_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.VOICE_LAUNCH" />
+ </intent-filter>
+</activity>
+<activity android:name=".ethernet.EthernetEnabler" android:label="@string/eth_setting"
+ android:clearTaskOnLaunch="true"
+ >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <action android:name="android.settings.ETHERNET_ENABLER_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.VOICE_LAUNCH" />
+ <category android:name="com.android.settings.SHORTCUT" />
+ </intent-filter>
+</activity>
+<activity android:name=".ethernet.EthernetConfigure" android:label="@string/eth_conf_perf_title"
+ android:clearTaskOnLaunch="true"
+ >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <action android:name="android.settings.ETHERNET_CONFIGURE_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.VOICE_LAUNCH" />
+ <category android:name="com.android.settings.SHORTCUT" />
+ </intent-filter>
+</activity>
<!-- Wireless Controls -->
六、接下来要增加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);
这篇关于为Tiny6410Android2.3.4系统添加Ethernet框架支持(含去除状态栏信号图标及增加屏幕超时“永不关屏”选项)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!