Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 15d809b9 authored by lesl's avatar lesl
Browse files

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
parent 72468611
Loading
Loading
Loading
Loading
+5 −9
Original line number Original line Diff line number Diff line
@@ -198,17 +198,13 @@ public class NetworkIdentity implements Comparable<NetworkIdentity> {
        final int oemManaged = getOemBitfield(snapshot.networkCapabilities);
        final int oemManaged = getOemBitfield(snapshot.networkCapabilities);


        if (legacyType == TYPE_WIFI) {
        if (legacyType == TYPE_WIFI) {
            if (snapshot.networkCapabilities.getSsid() != null) {
            networkId = snapshot.networkCapabilities.getSsid();
            networkId = snapshot.networkCapabilities.getSsid();
            if (networkId == null) {
            if (networkId == null) {
                    // TODO: Figure out if this code path never runs. If so, remove them.
                final WifiManager wifi = context.getSystemService(WifiManager.class);
                    final WifiManager wifi = (WifiManager) context.getSystemService(
                            Context.WIFI_SERVICE);
                final WifiInfo info = wifi.getConnectionInfo();
                final WifiInfo info = wifi.getConnectionInfo();
                networkId = info != null ? info.getSSID() : null;
                networkId = info != null ? info.getSSID() : null;
            }
            }
        }
        }
        }


        return new NetworkIdentity(legacyType, subType, subscriberId, networkId, roaming, metered,
        return new NetworkIdentity(legacyType, subType, subscriberId, networkId, roaming, metered,
                defaultNetwork, oemManaged);
                defaultNetwork, oemManaged);