more reliably set WiFi SSID in nearby/swap interfaces
Often times, the WiFi is properly setup, the IP address is showing, but the SSID is showing as "No network yet".
This commit is contained in:
parent
11e0c1926c
commit
5b610798c2
@ -127,6 +127,7 @@ public class WifiStateChangeService extends IntentService {
|
|||||||
if (wifiState == WifiManager.WIFI_STATE_ENABLED) {
|
if (wifiState == WifiManager.WIFI_STATE_ENABLED) {
|
||||||
wifiInfo = wifiManager.getConnectionInfo();
|
wifiInfo = wifiManager.getConnectionInfo();
|
||||||
FDroidApp.ipAddressString = formatIpAddress(wifiInfo.getIpAddress());
|
FDroidApp.ipAddressString = formatIpAddress(wifiInfo.getIpAddress());
|
||||||
|
setSsidFromWifiInfo(wifiInfo);
|
||||||
DhcpInfo dhcpInfo = wifiManager.getDhcpInfo();
|
DhcpInfo dhcpInfo = wifiManager.getDhcpInfo();
|
||||||
if (dhcpInfo != null) {
|
if (dhcpInfo != null) {
|
||||||
String netmask = formatIpAddress(dhcpInfo.netmask);
|
String netmask = formatIpAddress(dhcpInfo.netmask);
|
||||||
@ -168,17 +169,7 @@ public class WifiStateChangeService extends IntentService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wifiInfo != null) {
|
setSsidFromWifiInfo(wifiInfo);
|
||||||
String ssid = wifiInfo.getSSID();
|
|
||||||
Utils.debugLog(TAG, "Have wifi info, connected to " + ssid);
|
|
||||||
if (ssid != null) {
|
|
||||||
FDroidApp.ssid = ssid.replaceAll("^\"(.*)\"$", "$1");
|
|
||||||
}
|
|
||||||
String bssid = wifiInfo.getBSSID();
|
|
||||||
if (bssid != null) {
|
|
||||||
FDroidApp.bssid = bssid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String scheme;
|
String scheme;
|
||||||
if (Preferences.get().isLocalRepoHttpsEnabled()) {
|
if (Preferences.get().isLocalRepoHttpsEnabled()) {
|
||||||
@ -232,6 +223,20 @@ public class WifiStateChangeService extends IntentService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setSsidFromWifiInfo(WifiInfo wifiInfo) {
|
||||||
|
if (wifiInfo != null) {
|
||||||
|
String ssid = wifiInfo.getSSID();
|
||||||
|
Utils.debugLog(TAG, "Have wifi info, connected to " + ssid);
|
||||||
|
if (ssid != null) {
|
||||||
|
FDroidApp.ssid = ssid.replaceAll("^\"(.*)\"$", "$1");
|
||||||
|
}
|
||||||
|
String bssid = wifiInfo.getBSSID();
|
||||||
|
if (bssid != null) {
|
||||||
|
FDroidApp.bssid = bssid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for known Wi-Fi, Hotspot, and local network interfaces and get
|
* Search for known Wi-Fi, Hotspot, and local network interfaces and get
|
||||||
* the IP Address info from it. This is necessary because network
|
* the IP Address info from it. This is necessary because network
|
||||||
|
Loading…
x
Reference in New Issue
Block a user