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

Commit 6c541f54 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

Fix NPE when reading SSID from WifiInfo

parent d347237c
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -24,9 +24,9 @@ internal fun ScanResult.toWifiDetails(): WifiDetails = WifiDetails(

@RequiresApi(31)
internal fun WifiInfo.toWifiDetails(): WifiDetails = WifiDetails(
    macAddress = bssid,
    ssid = ssid.takeIf { it != WifiManager.UNKNOWN_SSID && it.startsWith("\"") && it.endsWith("\"") }
        ?.let { it.substring(1, it.length - 1) },
    macAddress = bssid ?: "02:00:00:00:00:00",
    ssid = ssid?.removeSurrounding("\"")
        ?.takeIf { it.isNotEmpty() && it != WifiManager.UNKNOWN_SSID },
    timestamp = System.currentTimeMillis(),
    frequency = frequency,
    signalStrength = rssi,