Android->Settings:add eth mac address in status
This commit is contained in:
@ -2,7 +2,7 @@ LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_JAVA_LIBRARIES := bouncycastle conscrypt telephony-common ims-common
|
||||
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 android-support-v13 jsr305
|
||||
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 android-support-v13 jsr305 lib-android-tool
|
||||
# $_rbox_$_modify_$_zhangxueguang_$_begin_$_20120426_$
|
||||
LOCAL_JAVA_LIBRARIES += services
|
||||
# $_rbox_$_modify_$_zhangxueguang_$_end_$_20120426_$
|
||||
@ -23,6 +23,10 @@ LOCAL_PROGUARD_FLAG_FILES := proguard.flags
|
||||
include frameworks/opt/setupwizard/navigationbar/common.mk
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := lib-android-tool:lib/android-tools.jar
|
||||
include $(BUILD_MULTI_PREBUILT)
|
||||
|
||||
# Use the following include to make our test apk.
|
||||
ifeq (,$(ONE_SHOT_MAKEFILE))
|
||||
|
||||
BIN
packages/apps/Settings/lib/android-tools.jar
Normal file
BIN
packages/apps/Settings/lib/android-tools.jar
Normal file
Binary file not shown.
@ -908,6 +908,7 @@
|
||||
<string name="status_operator" msgid="2274875196954742087">"网络"</string>
|
||||
<string name="status_wifi_mac_address" msgid="2202206684020765378">"WLANMAC 地址"</string>
|
||||
<string name="status_bt_address" msgid="4195174192087439720">"蓝牙地址"</string>
|
||||
<string name="status_eth_mac_address">"以太网MAC地址"</string>
|
||||
<string name="status_serial_number" msgid="2257111183374628137">"序列号"</string>
|
||||
<string name="status_unavailable" msgid="7862009036663793314">"不可用"</string>
|
||||
<string name="status_up_time" msgid="7294859476816760399">"已开机时间"</string>
|
||||
|
||||
@ -2222,6 +2222,8 @@
|
||||
<string name="status_bt_address">Bluetooth address</string>
|
||||
<!-- About phone, status item title. The hardware serial number. [CHAR LIMIT=30]-->
|
||||
<string name="status_serial_number">Serial number</string>
|
||||
<!-- About phone, status item title. The ethernet mac address. -->
|
||||
<string name="status_eth_mac_address">eth MAC address</string>
|
||||
<!-- About phone, status item value if the actual value is not available. -->
|
||||
<string name="status_unavailable">Unavailable</string>
|
||||
<!-- About phone, status item title. How long the device has been running since its last reboot. -->
|
||||
|
||||
@ -49,6 +49,11 @@
|
||||
android:title="@string/status_wifi_mac_address"
|
||||
android:summary="@string/device_info_not_available"
|
||||
android:persistent="false" />
|
||||
<Preference android:key="eth_mac_address"
|
||||
style="?android:attr/preferenceInformationStyle"
|
||||
android:title="@string/status_eth_mac_address"
|
||||
android:summary="@string/device_info_not_available"
|
||||
android:persistent="false" />
|
||||
<Preference android:key="bt_address"
|
||||
style="?android:attr/preferenceInformationStyle"
|
||||
android:title="@string/status_bt_address"
|
||||
|
||||
@ -48,6 +48,16 @@ import com.android.settings.Utils;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
|
||||
import android.net.EthernetManager;
|
||||
import android.net.LinkAddress;
|
||||
import android.net.LinkProperties;
|
||||
|
||||
import twinone.lib.androidtools.log.ALog;
|
||||
import twinone.lib.androidtools.shell.Command;
|
||||
import twinone.lib.androidtools.shell.Shell;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Display the following information
|
||||
* # Battery Strength : TODO
|
||||
@ -67,7 +77,7 @@ public class Status extends PreferenceActivity {
|
||||
private static final String KEY_WIMAX_MAC_ADDRESS = "wimax_mac_address";
|
||||
private static final String KEY_SIM_STATUS = "sim_status";
|
||||
private static final String KEY_IMEI_INFO = "imei_info";
|
||||
|
||||
private static final String KEY_ETH_MAC_ADDRESS = "eth_mac_address";
|
||||
// Broadcasts to listen to for connectivity changes.
|
||||
private static final String[] CONNECTIVITY_INTENTS = {
|
||||
BluetoothAdapter.ACTION_STATE_CHANGED,
|
||||
@ -82,7 +92,8 @@ public class Status extends PreferenceActivity {
|
||||
|
||||
private ConnectivityManager mCM;
|
||||
private WifiManager mWifiManager;
|
||||
|
||||
private EthernetManager mEthManager;
|
||||
|
||||
private Resources mRes;
|
||||
|
||||
private String mUnknown;
|
||||
@ -95,8 +106,10 @@ public class Status extends PreferenceActivity {
|
||||
private Preference mIpAddress;
|
||||
private Preference mWifiMacAddress;
|
||||
private Preference mWimaxMacAddress;
|
||||
private Preference mEthMacAddress;
|
||||
|
||||
private Handler mHandler;
|
||||
private Shell mShell;
|
||||
|
||||
private static class MyHandler extends Handler {
|
||||
private WeakReference<Status> mStatus;
|
||||
@ -161,9 +174,11 @@ public class Status extends PreferenceActivity {
|
||||
super.onCreate(icicle);
|
||||
|
||||
mHandler = new MyHandler(this);
|
||||
mShell = new Shell();
|
||||
|
||||
mCM = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
|
||||
mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
|
||||
mEthManager = (EthernetManager) getSystemService(Context.ETHERNET_SERVICE);
|
||||
|
||||
addPreferencesFromResource(R.xml.device_info_status);
|
||||
mBatteryLevel = findPreference(KEY_BATTERY_LEVEL);
|
||||
@ -172,6 +187,7 @@ public class Status extends PreferenceActivity {
|
||||
mWifiMacAddress = findPreference(KEY_WIFI_MAC_ADDRESS);
|
||||
mWimaxMacAddress = findPreference(KEY_WIMAX_MAC_ADDRESS);
|
||||
mIpAddress = findPreference(KEY_IP_ADDRESS);
|
||||
mEthMacAddress = findPreference(KEY_ETH_MAC_ADDRESS);
|
||||
|
||||
mRes = getResources();
|
||||
mUnknown = mRes.getString(R.string.device_info_default);
|
||||
@ -302,6 +318,21 @@ public class Status extends PreferenceActivity {
|
||||
mWifiMacAddress.setSummary(!TextUtils.isEmpty(macAddress) ? macAddress : mUnavailable);
|
||||
}
|
||||
|
||||
private void setEthStatus() {
|
||||
String macAddress = getMacAddress("eth0");
|
||||
mEthMacAddress.setSummary(!TextUtils.isEmpty(macAddress) ? macAddress : mUnavailable);
|
||||
}
|
||||
|
||||
private String getMacAddress(String iface) {
|
||||
String cmd = "busybox ifconfig "+iface+" | grep 'HWaddr' | busybox awk '{print $5}'";
|
||||
Command mCommand = mShell.execute(cmd);
|
||||
if(mCommand.exitStatus == 0 && mCommand.output != null && mCommand.output.length > 0)
|
||||
{
|
||||
return mCommand.output[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void setIpAddressStatus() {
|
||||
String ipAddress = Utils.getDefaultIpAddresses(this.mCM);
|
||||
if (ipAddress != null) {
|
||||
@ -327,6 +358,7 @@ public class Status extends PreferenceActivity {
|
||||
void updateConnectivity() {
|
||||
setWimaxStatus();
|
||||
setWifiStatus();
|
||||
setEthStatus();
|
||||
setBtStatus();
|
||||
setIpAddressStatus();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user