diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2010-04-21 09:51:01 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-04-21 09:51:01 -0700 |
commit | 1795d18f815568c15b6fc1b1d3cf29b1c193f030 (patch) | |
tree | e72d67f222f1bd000e9493922815e22be6b74434 /src | |
parent | e7879010e3dbfd2db193055c60c9825004a3a51a (diff) | |
parent | 2c3265af7419c35c1084fd5c1e4726abcdd90f40 (diff) | |
download | packages_apps_Settings-1795d18f815568c15b6fc1b1d3cf29b1c193f030.zip packages_apps_Settings-1795d18f815568c15b6fc1b1d3cf29b1c193f030.tar.gz packages_apps_Settings-1795d18f815568c15b6fc1b1d3cf29b1c193f030.tar.bz2 |
am 2c3265af: merge from open-source master
Merge commit '2c3265af7419c35c1084fd5c1e4726abcdd90f40' into kraken
* commit '2c3265af7419c35c1084fd5c1e4726abcdd90f40':
Display current IP address in advanced Wifi settings screen
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/wifi/AdvancedSettings.java | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/com/android/settings/wifi/AdvancedSettings.java b/src/com/android/settings/wifi/AdvancedSettings.java index 7d62f8e..636e1df 100644 --- a/src/com/android/settings/wifi/AdvancedSettings.java +++ b/src/com/android/settings/wifi/AdvancedSettings.java @@ -40,6 +40,7 @@ public class AdvancedSettings extends PreferenceActivity implements Preference.OnPreferenceChangeListener { private static final String KEY_MAC_ADDRESS = "mac_address"; + private static final String KEY_CURRENT_IP_ADDRESS = "current_ip_address"; private static final String KEY_USE_STATIC_IP = "use_static_ip"; private static final String KEY_NUM_CHANNELS = "num_channels"; private static final String KEY_SLEEP_POLICY = "sleep_policy"; @@ -109,7 +110,7 @@ public class AdvancedSettings extends PreferenceActivity initNumChannelsPreference(); } initSleepPolicyPreference(); - refreshMacAddress(); + refreshWifiInfo(); } private void initNumChannelsPreference() { @@ -307,7 +308,7 @@ public class AdvancedSettings extends PreferenceActivity } } - private void refreshMacAddress() { + private void refreshWifiInfo() { WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); @@ -315,6 +316,20 @@ public class AdvancedSettings extends PreferenceActivity String macAddress = wifiInfo == null ? null : wifiInfo.getMacAddress(); wifiMacAddressPref.setSummary(!TextUtils.isEmpty(macAddress) ? macAddress : getString(R.string.status_unavailable)); + + Preference wifiIpAddressPref = findPreference(KEY_CURRENT_IP_ADDRESS); + String ipAddress = null; + if (wifiInfo != null) { + long addr = wifiInfo.getIpAddress(); + if (addr != 0) { + // handle negative values whe first octet > 127 + if (addr < 0) addr += 0x100000000L; + ipAddress = String.format("%d.%d.%d.%d", + addr & 0xFF, (addr >> 8) & 0xFF, (addr >> 16) & 0xFF, (addr >> 24) & 0xFF); + } + } + wifiIpAddressPref.setSummary(ipAddress == null ? + getString(R.string.status_unavailable) : ipAddress); } - + } |