use of cc.mvdan.accesspoint.WifiApControl in project fdroidclient by f-droid.
the class WifiStateChangeService method setSsid.
private void setSsid(WifiInfo wifiInfo) {
Context context = getApplicationContext();
if (wifiInfo != null && wifiInfo.getBSSID() != null) {
String ssid = wifiInfo.getSSID();
Utils.debugLog(TAG, "Have wifi info, connected to " + ssid);
if (ssid == null) {
FDroidApp.ssid = context.getString(R.string.swap_blank_wifi_ssid);
} else {
FDroidApp.ssid = ssid.replaceAll("^\"(.*)\"$", "$1");
}
FDroidApp.bssid = wifiInfo.getBSSID();
} else {
WifiApControl wifiApControl = null;
try {
wifiApControl = WifiApControl.getInstance(context);
wifiApControl.isEnabled();
} catch (NullPointerException e) {
wifiApControl = null;
}
Utils.debugLog(TAG, "WifiApControl: " + wifiApControl);
if (wifiApControl == null && FDroidApp.ipAddressString != null) {
wifiInfo = wifiManager.getConnectionInfo();
if (wifiInfo != null && wifiInfo.getBSSID() != null) {
setSsid(wifiInfo);
} else {
FDroidApp.ssid = context.getString(R.string.swap_active_hotspot, "");
}
} else if (wifiApControl != null && wifiApControl.isEnabled()) {
WifiConfiguration wifiConfiguration = wifiApControl.getConfiguration();
Utils.debugLog(TAG, "WifiConfiguration: " + wifiConfiguration);
if (wifiConfiguration == null) {
FDroidApp.ssid = context.getString(R.string.swap_active_hotspot, "");
FDroidApp.bssid = "";
return;
}
if (wifiConfiguration.hiddenSSID) {
FDroidApp.ssid = context.getString(R.string.swap_hidden_wifi_ssid);
} else {
FDroidApp.ssid = wifiConfiguration.SSID;
}
FDroidApp.bssid = wifiConfiguration.BSSID;
}
}
}
Aggregations