diff options
author | Irfan Sheriff <isheriff@google.com> | 2011-08-25 14:04:03 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-08-25 14:04:03 -0700 |
commit | de58555d25cd38b4ed0dfa5d2baf444f85ab7742 (patch) | |
tree | 90cc962d88c9110b94e82fb65e424e2624384d4d /src/com/android | |
parent | 06285deb669a43020adef4517bceb35618a7f8ee (diff) | |
parent | e2c6e7520b5002573bf76bcdee909281514eabb0 (diff) | |
download | packages_apps_settings-de58555d25cd38b4ed0dfa5d2baf444f85ab7742.zip packages_apps_settings-de58555d25cd38b4ed0dfa5d2baf444f85ab7742.tar.gz packages_apps_settings-de58555d25cd38b4ed0dfa5d2baf444f85ab7742.tar.bz2 |
Merge "Fixed wifi refresh bug, b/5021754"
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/settings/wifi/AccessPoint.java | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/com/android/settings/wifi/AccessPoint.java b/src/com/android/settings/wifi/AccessPoint.java index 03e7ba4..5a7a768 100644 --- a/src/com/android/settings/wifi/AccessPoint.java +++ b/src/com/android/settings/wifi/AccessPoint.java @@ -71,7 +71,6 @@ class AccessPoint extends Preference { private int mRssi; private WifiInfo mInfo; private DetailedState mState; - private ImageView mSignal; static int getSecurity(WifiConfiguration config) { if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK)) { @@ -145,12 +144,14 @@ class AccessPoint extends Preference { super(context); setWidgetLayoutResource(R.layout.preference_widget_wifi_signal); loadConfig(config); + refresh(); } AccessPoint(Context context, ScanResult result) { super(context); setWidgetLayoutResource(R.layout.preference_widget_wifi_signal); loadResult(result); + refresh(); } AccessPoint(Context context, Bundle savedState) { @@ -204,17 +205,16 @@ class AccessPoint extends Preference { @Override protected void onBindView(View view) { - setTitle(ssid); - mSignal = (ImageView) view.findViewById(R.id.signal); + super.onBindView(view); + ImageView signal = (ImageView) view.findViewById(R.id.signal); if (mRssi == Integer.MAX_VALUE) { - mSignal.setImageDrawable(null); + signal.setImageDrawable(null); } else { - mSignal.setImageResource(R.drawable.wifi_signal); - mSignal.setImageState((security != SECURITY_NONE) ? + signal.setImageLevel(getLevel()); + signal.setImageResource(R.drawable.wifi_signal); + signal.setImageState((security != SECURITY_NONE) ? STATE_SECURED : STATE_NONE, true); } - refresh(); - super.onBindView(view); } @Override @@ -245,14 +245,19 @@ class AccessPoint extends Preference { } boolean update(ScanResult result) { - // We do not call refresh() since this is called before onBindView(). if (ssid.equals(result.SSID) && security == getSecurity(result)) { if (WifiManager.compareSignalLevel(result.level, mRssi) > 0) { + int oldLevel = getLevel(); mRssi = result.level; + if (getLevel() != oldLevel) { + notifyChanged(); + } } // This flag only comes from scans, is not easily saved in config - if (security == SECURITY_PSK) + if (security == SECURITY_PSK) { pskType = getPskType(result); + } + refresh(); return true; } return false; @@ -260,7 +265,8 @@ class AccessPoint extends Preference { void update(WifiInfo info, DetailedState state) { boolean reorder = false; - if (info != null && networkId != -1 && networkId == info.getNetworkId()) { + if (info != null && networkId != WifiConfiguration.INVALID_NETWORK_ID + && networkId == info.getNetworkId()) { reorder = (mInfo == null); mRssi = info.getRssi(); mInfo = info; @@ -309,13 +315,11 @@ class AccessPoint extends Preference { return "\"" + string + "\""; } + /** Updates the title and summary; may indirectly call notifyChanged() */ private void refresh() { - if (mSignal == null) { - return; - } - Context context = getContext(); - mSignal.setImageLevel(getLevel()); + setTitle(ssid); + Context context = getContext(); if (mState != null) { // This is the active connection setSummary(Summary.get(context, mState)); } else if (mRssi == Integer.MAX_VALUE) { // Wifi out of range |