Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,11 @@ private void onWifiChangeBroadcastReceived(Intent intent, WifiConfiguration conf
return;
}
SSID newlyConnectedSSID = SSID.from(wifiInfo);
log.i("Connected to: " + newlyConnectedSSID);
log.i("Connected to : " + newlyConnectedSSID);

if (newlyConnectedSSID.equals(SSID.from(config))) {
log.d("Trying to bind : " + newlyConnectedSSID);
wifiFacade.bindProcessToNetwork();
// FIXME: find a way to record success in memory in case this happens to happen
// during a config change (etc)?
client.onApConnectionSuccessful(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Build.VERSION_CODES;

import androidx.annotation.Nullable;
Expand Down Expand Up @@ -142,6 +143,17 @@ public boolean enableNetwork(int networkId, boolean disableOthers) {
return wifiManager.enableNetwork(networkId, disableOthers);
}

public void bindProcessToNetwork() {
if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
Network network = getNetworkObjectForCurrentWifiConnection();
if (Build.VERSION.SDK_INT >= VERSION_CODES.M) {
connectivityManager.bindProcessToNetwork(network);
} else {
ConnectivityManager.setProcessDefaultNetwork(network);
}
}
}

public WifiConfiguration getWifiConfiguration(SSID ssid) {
List<WifiConfiguration> wifiConfigurations = getConfiguredNetworks();
for (WifiConfiguration configuration : wifiConfigurations) {
Expand Down