import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
+import android.support.annotation.NonNull;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
private static final int PSK_WPA2 = 2;
private static final int PSK_WPA_WPA2 = 3;
- private static final int VISIBILITY_OUTDATED_AGE_IN_MILLI = 20000;
+ public static final int SIGNAL_LEVELS = 4;
+
private final Context mContext;
private String ssid;
}
@Override
- public int compareTo(AccessPoint other) {
+ public int compareTo(@NonNull AccessPoint other) {
// Active one goes first.
if (isActive() && !other.isActive()) return -1;
if (!isActive() && other.isActive()) 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);
+ // Sort by signal strength, bucketed by level
+ int difference = WifiManager.calculateSignalLevel(other.mRssi, SIGNAL_LEVELS)
+ - WifiManager.calculateSignalLevel(mRssi, SIGNAL_LEVELS);
if (difference != 0) {
return difference;
}
if (mRssi == Integer.MAX_VALUE) {
return -1;
}
- return WifiManager.calculateSignalLevel(mRssi, 4);
+ return WifiManager.calculateSignalLevel(mRssi, SIGNAL_LEVELS);
}
public int getRssi() {