diff options
author | Mike Lockwood <lockwood@android.com> | 2010-04-20 11:53:49 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2010-04-20 13:52:38 -0400 |
commit | 68b8069862314a26dbacd28d13dd4c6bea8b6141 (patch) | |
tree | d9015424aac338d3327ffc3828c20a403f8c62a2 /src | |
parent | 9f78ffb27e8f6a9de6a9db1d04887cf1eedfff81 (diff) | |
download | packages_apps_Settings-68b8069862314a26dbacd28d13dd4c6bea8b6141.zip packages_apps_Settings-68b8069862314a26dbacd28d13dd4c6bea8b6141.tar.gz packages_apps_Settings-68b8069862314a26dbacd28d13dd4c6bea8b6141.tar.bz2 |
Display current IP address in advanced Wifi settings screen
Change-Id: I47c6eece376e712b73add72057462926f7b2349f
Signed-off-by: Mike Lockwood <lockwood@android.com>
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 ff485de..cca10da 100644 --- a/src/com/android/settings/wifi/AdvancedSettings.java +++ b/src/com/android/settings/wifi/AdvancedSettings.java @@ -39,6 +39,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"; @@ -98,7 +99,7 @@ public class AdvancedSettings extends PreferenceActivity */ //initNumChannelsPreference(); initSleepPolicyPreference(); - refreshMacAddress(); + refreshWifiInfo(); } private void initNumChannelsPreference() { @@ -296,7 +297,7 @@ public class AdvancedSettings extends PreferenceActivity } } - private void refreshMacAddress() { + private void refreshWifiInfo() { WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); @@ -304,6 +305,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); } - + } |