Permit p2pInterface to be null for whatever reasons

This commit is contained in:
Mygod
2018-04-27 17:38:14 -07:00
parent 04ddddeef0
commit 3b964e0537
2 changed files with 3 additions and 2 deletions

View File

@@ -89,7 +89,7 @@ class RepeaterFragment : Fragment(), ServiceConnection, Toolbar.OnMenuItemClickL
} }
inner class Client(p2p: WifiP2pDevice? = null, neighbour: IpNeighbour? = null) { inner class Client(p2p: WifiP2pDevice? = null, neighbour: IpNeighbour? = null) {
val iface = neighbour?.dev ?: p2pInterface!! val iface = neighbour?.dev ?: p2pInterface
val mac = p2p?.deviceAddress ?: neighbour?.lladdr!! val mac = p2p?.deviceAddress ?: neighbour?.lladdr!!
val ip = TreeMap<String, IpNeighbour.State>() val ip = TreeMap<String, IpNeighbour.State>()

View File

@@ -41,7 +41,8 @@ enum class TetherType {
.map { it.toPattern() } .map { it.toPattern() }
} }
fun ofInterface(iface: String, p2pDev: String? = null) = when { fun ofInterface(iface: String?, p2pDev: String? = null) = when {
iface == null -> NONE
iface == p2pDev -> WIFI_P2P iface == p2pDev -> WIFI_P2P
usbRegexes.any { it.matcher(iface).matches() } -> USB usbRegexes.any { it.matcher(iface).matches() } -> USB
wifiRegexes.any { it.matcher(iface).matches() } -> WIFI wifiRegexes.any { it.matcher(iface).matches() } -> WIFI