summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/wifi
diff options
context:
space:
mode:
authorRicardo Cerqueira <cyanogenmod@cerqueira.org>2013-02-13 13:54:58 +0000
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2013-02-15 00:07:30 +0000
commit20a2aaa9595e9ab958d27eb430af6560e24ba78c (patch)
treed810cc69bfa5db15a0d8833cfc73a4618a0eee73 /src/com/android/settings/wifi
parentf0ad93f3b99b9fd7c5191dc9fa91c59809d48870 (diff)
parent29a4eb7a33da12a957b3305138ada69140d8ab75 (diff)
downloadpackages_apps_settings-20a2aaa9595e9ab958d27eb430af6560e24ba78c.zip
packages_apps_settings-20a2aaa9595e9ab958d27eb430af6560e24ba78c.tar.gz
packages_apps_settings-20a2aaa9595e9ab958d27eb430af6560e24ba78c.tar.bz2
Merge commit 'android-4.2.2_r1' into mr1.1-staging
Conflicts: AndroidManifest.xml res/values-de/strings.xml res/values-el/strings.xml res/values-es/strings.xml res/values-fi/strings.xml res/values-hu/strings.xml res/values-it/strings.xml res/values-iw/strings.xml res/values-nl/strings.xml res/values-ru/strings.xml res/values-zh-rCN/strings.xml res/values/strings.xml src/com/android/settings/ChooseLockGeneric.java src/com/android/settings/ChooseLockPatternTutorial.java src/com/android/settings/DeviceInfoSettings.java src/com/android/settings/Settings.java Change-Id: I275be467a401ad6dcc7966924358a5adb0773b75
Diffstat (limited to 'src/com/android/settings/wifi')
-rw-r--r--src/com/android/settings/wifi/AccessPoint.java36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/com/android/settings/wifi/AccessPoint.java b/src/com/android/settings/wifi/AccessPoint.java
index 5a7a768..f6581a5 100644
--- a/src/com/android/settings/wifi/AccessPoint.java
+++ b/src/com/android/settings/wifi/AccessPoint.java
@@ -224,17 +224,19 @@ class AccessPoint extends Preference {
}
AccessPoint other = (AccessPoint) preference;
// Active one goes first.
- if (mInfo != other.mInfo) {
- return (mInfo != null) ? -1 : 1;
- }
+ if (mInfo != null && other.mInfo == null) return -1;
+ if (mInfo == null && other.mInfo != null) return 1;
+
// Reachable one goes before unreachable one.
- if ((mRssi ^ other.mRssi) < 0) {
- return (mRssi != Integer.MAX_VALUE) ? -1 : 1;
- }
+ if (mRssi != Integer.MAX_VALUE && other.mRssi == Integer.MAX_VALUE) return -1;
+ if (mRssi == Integer.MAX_VALUE && other.mRssi != Integer.MAX_VALUE) return 1;
+
// Configured one goes before unconfigured one.
- if ((networkId ^ other.networkId) < 0) {
- return (networkId != -1) ? -1 : 1;
- }
+ if (networkId != WifiConfiguration.INVALID_NETWORK_ID
+ && other.networkId == WifiConfiguration.INVALID_NETWORK_ID) return -1;
+ if (networkId == WifiConfiguration.INVALID_NETWORK_ID
+ && other.networkId != WifiConfiguration.INVALID_NETWORK_ID) return 1;
+
// Sort by signal strength.
int difference = WifiManager.compareSignalLevel(other.mRssi, mRssi);
if (difference != 0) {
@@ -244,6 +246,22 @@ class AccessPoint extends Preference {
return ssid.compareToIgnoreCase(other.ssid);
}
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof AccessPoint)) return false;
+ return (this.compareTo((AccessPoint) other) == 0);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 0;
+ if (mInfo != null) result += 13 * mInfo.hashCode();
+ result += 19 * mRssi;
+ result += 23 * networkId;
+ result += 29 * ssid.hashCode();
+ return result;
+ }
+
boolean update(ScanResult result) {
if (ssid.equals(result.SSID) && security == getSecurity(result)) {
if (WifiManager.compareSignalLevel(result.level, mRssi) > 0) {