Fix Wi-Fi SSID null handling
When Wi-Fi SSID is null in NetworkCapabilities, get Wi-Fi SSID from connection info (WifiInfo) which is non-null design. Bug: 176396812 Test: FrameworksNetTests NetworkPolicyManagerServiceTest Change-Id: I59c7d8f7e176d0c6bb100721269f3f6165f0ca21
This commit is contained in:
@@ -198,15 +198,11 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> {
|
||||
final int oemManaged = getOemBitfield(snapshot.networkCapabilities);
|
||||
|
||||
if (legacyType == TYPE_WIFI) {
|
||||
if (snapshot.networkCapabilities.getSsid() != null) {
|
||||
networkId = snapshot.networkCapabilities.getSsid();
|
||||
if (networkId == null) {
|
||||
// TODO: Figure out if this code path never runs. If so, remove them.
|
||||
final WifiManager wifi = (WifiManager) context.getSystemService(
|
||||
Context.WIFI_SERVICE);
|
||||
final WifiInfo info = wifi.getConnectionInfo();
|
||||
networkId = info != null ? info.getSSID() : null;
|
||||
}
|
||||
networkId = snapshot.networkCapabilities.getSsid();
|
||||
if (networkId == null) {
|
||||
final WifiManager wifi = context.getSystemService(WifiManager.class);
|
||||
final WifiInfo info = wifi.getConnectionInfo();
|
||||
networkId = info != null ? info.getSSID() : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user