mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-30 00:01:19 +00:00
Merge pull request #621 from capi/fix-620
Add checks for null-SSID (fix for #620)
This commit is contained in:
commit
24edfc8364
1 changed files with 8 additions and 3 deletions
|
@ -91,11 +91,13 @@ public class WifiSsidPreference extends MultiSelectListPreference {
|
||||||
private CharSequence[] extractSsid(WifiConfiguration[] configs, boolean stripQuotes) {
|
private CharSequence[] extractSsid(WifiConfiguration[] configs, boolean stripQuotes) {
|
||||||
CharSequence[] result = new CharSequence[configs.length];
|
CharSequence[] result = new CharSequence[configs.length];
|
||||||
for (int i = 0; i < configs.length; i++) {
|
for (int i = 0; i < configs.length; i++) {
|
||||||
|
// See #620: there may be null-SSIDs
|
||||||
|
String ssid = configs[i].SSID != null ? configs[i].SSID : "";
|
||||||
// WiFi SSIDs can either be UTF-8 (encapsulated in '"') or hex-strings
|
// WiFi SSIDs can either be UTF-8 (encapsulated in '"') or hex-strings
|
||||||
if (stripQuotes)
|
if (stripQuotes)
|
||||||
result[i] = configs[i].SSID.replaceFirst("^\"", "").replaceFirst("\"$", "");
|
result[i] = ssid.replaceFirst("^\"", "").replaceFirst("\"$", "");
|
||||||
else
|
else
|
||||||
result[i] = configs[i].SSID;
|
result[i] = ssid;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +117,10 @@ public class WifiSsidPreference extends MultiSelectListPreference {
|
||||||
Arrays.sort(result, new Comparator<WifiConfiguration>() {
|
Arrays.sort(result, new Comparator<WifiConfiguration>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(WifiConfiguration lhs, WifiConfiguration rhs) {
|
public int compare(WifiConfiguration lhs, WifiConfiguration rhs) {
|
||||||
return lhs.SSID.compareToIgnoreCase(rhs.SSID);
|
// See #620: There may be null-SSIDs
|
||||||
|
String l = lhs.SSID != null ? lhs.SSID : "";
|
||||||
|
String r = rhs.SSID != null ? rhs.SSID : "";
|
||||||
|
return l.compareToIgnoreCase(r);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in a new issue