Remove the main thread blocking call to get SSID

WifiManager#getConfiguredNetworks is a blocking call which may cause
main thread ANR, and the platform team also confirmed it is no longer
necessary to retrieve the SSID.

Bug: 183202291
Test: Unit tests
Change-Id: I089148cdb9900d7dc292dc8fc6d6f17302088e43
This commit is contained in:
yinxu
2021-03-31 13:31:23 -07:00
parent fa873e1cc8
commit eb3d14651e

View File

@@ -26,7 +26,6 @@ import android.net.NetworkKey;
import android.net.NetworkRequest;
import android.net.NetworkScoreManager;
import android.net.ScoredNetwork;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiNetworkScoreCache;
@@ -346,14 +345,6 @@ public class WifiStatusTracker {
if (ssid != null && !WifiManager.UNKNOWN_SSID.equals(ssid)) {
return ssid;
}
// OK, it's not in the connectionInfo; we have to go hunting for it
List<WifiConfiguration> networks = mWifiManager.getConfiguredNetworks();
int length = networks.size();
for (int i = 0; i < length; i++) {
if (networks.get(i).networkId == info.getNetworkId()) {
return networks.get(i).SSID;
}
}
return null;
}