Skip to content

RF Sentinel (RFSentinel): free, open-source police detector app for Android. Spots police body cams, Flock ALPR cameras, AirTag trackers, Remote ID drones, smart glasses and fake cell towers from Bluetooth LE and WiFi. No root.

Better TV and console detection, hidden router networks under Routers, Apple and Computers categories

CIS-C0385539481ed7
diff --git a/app/src/main/java/com/rfsentinel/app/detect/DeviceIntel.kt b/app/src/main/java/com/rfsentinel/app/detect/DeviceIntel.kt
index f320513..10a5ef0 100644
--- a/app/src/main/java/com/rfsentinel/app/detect/DeviceIntel.kt
+++ b/app/src/main/java/com/rfsentinel/app/detect/DeviceIntel.kt
@@ -107,11 +107,16 @@ object DeviceIntel {
"^70mai|^viofo|^blackvue|^thinkware|^nextbase|^vantrue|^rexing|^garmin ?dash|^dashcam|^dash ?cam|^roav|^redtiger|^azdome" to "Dashcam",
"^gopro|^gp[0-9]{8}$|^hero\\d+|^insta360|^osmo ?action|^akaso" to "Action camera",
"^tello-|^dji[-_ ]|^mavic|^spark-|^phantom|^anafi|^skycontroller|^autel|^evo ?ii|^skydio|^parrot" to "Drone / controller",
- "\\[tv\\]|^direct-[0-9a-z]{2}-(\\[tv\\]|samsung|lg|bravia|tcl|hisense|vizio)|^bravia|^lg[_ ]?(webos)?[_ ]?tv|^vizio|^roku-|^androidtv|^chromecast" to "Smart TV / streaming device",
+ // TVs and streaming sticks: their screen-mirroring / setup networks and default names.
+ "\\[tv\\]|\\[lg\\]|^direct-[0-9a-z]{2}-(\\[tv\\]|\\[lg\\]|samsung|lg|bravia|sony|tcl|hisense|vizio|philips|panasonic|sharp|toshiba|" +
+ "insignia|xiaomi|mi tv|fire ?tv|roku|skyworth|grundig|metz|loewe)|^(sony[ _-]?)?bravia|^lg[_ ]?(webos)?[_ ]?tv|^webos|^vizio|" +
+ "^roku-|^roku ?(tv|ultra|express|stick)|^android[_ ]?tv|^google[_ ]?tv|^chromecast|^fire ?tv|^shield[ _-]?(tv|android)|" +
+ "^mi[_ ]?box|^tivo|^apple ?tv|samsung ?(smart ?)?tv|^philips ?tv|^hisense ?tv|^tcl ?(smart ?)?tv" to "Smart TV / streaming device",
"^esp[-_][0-9a-f]{4,6}$|^esp32|^esp8266|^tasmota-|^shelly|^sonoff|^espressif|^wled-|^openmqttgateway" to "IoT board (ESP / smart-home firmware)",
"^tp-?link_smart|^kasa_|^tapo_|^wemo\\.|^meross_|^smartlife-|^smart ?life|^tuya|^gosund|^govee|^wiz_|^hue-" to "Smart plug / bulb waiting to be set up",
"^ring setup|^ring-[0-9a-f]{4}|^nest-|^arlo|^blink-|^wyze|^eufy|^reolink|^ipc[-_]|^ezviz|^hikvision|^imou" to "Security camera / doorbell",
- "^nintendo|^switch_|^ps[45]-|^xbox" to "Game console"
+ "^nintendo|^switch_|^ps[345]-|^ps ?vita|^xbox|^steam ?deck|^rog ?ally|^legion ?go" to "Game console",
+ "^meta ?quest|^quest[ _-]?([23]|pro)|^oculus" to "VR headset"
).map { (re, type) -> Regex(re, RegexOption.IGNORE_CASE) to type }
private val PHONE_TYPE = Regex("^(iphone|apple watch|phone hotspot|phone / computer|apple device \\(iphone|samsung device|google device|phone$|phone -)", RegexOption.IGNORE_CASE)
@@ -119,6 +124,14 @@ object DeviceIntel {
/** A phone maker's other gear, named after the phone ("Galaxy Buds", "Pixel Watch", "Galaxy Tab"). */
private val NOT_PHONE_NAME = Regex("buds|watch|\\btab\\b|book|\\bfit\\b|band|\\bring\\b|smarttag|\\btag\\b|\\btv\\b|tablet|\\bear", RegexOption.IGNORE_CASE)
+ private val ROUTER_TYPE = Regex("^(home router|wifi access point|vehicle / cellular router|mesh router)|access point$", RegexOption.IGNORE_CASE)
+
+ /** True when a type is a router or a home / plain access point (the Routers chip); business access points aren't. */
+ fun isRouter(type: String): Boolean = ROUTER_TYPE.containsMatchIn(type)
+
+ /** The type of a hidden network another network of the same access point names: "<that type> (hidden network)". */
+ fun hiddenOnType(siblingType: String) = "$siblingType (hidden network)"
+
/** True when a device's type (from [identify]) or broadcast name says it's a phone (or a phone's hotspot). */
fun isPhone(type: String?, name: String?): Boolean =
type?.let { PHONE_TYPE.containsMatchIn(it) } == true ||
@@ -141,7 +154,13 @@ object DeviceIntel {
Regex("meshtastic|^meshcore", RegexOption.IGNORE_CASE) to MESH_NODE,
Regex("airpods|beats|buds|earbud|headphone|headset|jbl|bose|sony w[hf]-|soundcore|jabra|sennheiser|skullcandy", RegexOption.IGNORE_CASE) to "Headphones / earbuds",
Regex("watch|fitbit|garmin|amazfit|mi band|galaxy fit|whoop|polar|suunto|oura", RegexOption.IGNORE_CASE) to "Wearable",
- Regex("\\b(tv|bravia|roku|chromecast|fire ?tv|shield)\\b|\\[tv\\]", RegexOption.IGNORE_CASE) to "TV / streaming device",
+ // Game gear before TVs and the generic peripherals ("Xbox Wireless Controller" is a controller, not a console).
+ Regex("xbox (wireless )?controller|dualsense|dualshock|wireless controller|pro controller|joy-con|8bitdo|gamesir|" +
+ "backbone one|razer kishi|stadia controller|luna controller", RegexOption.IGNORE_CASE) to "Game controller",
+ Regex("\\b(playstation|ps[345]|xbox( series [xs]| one)?|nintendo switch|steam ?deck|rog ally|legion go)\\b", RegexOption.IGNORE_CASE) to "Game console",
+ Regex("meta quest|oculus|\\bquest ([23]|pro)\\b|htc vive|\\bpico [34]\\b|psvr", RegexOption.IGNORE_CASE) to "VR headset",
+ Regex("\\b(tv|bravia|roku|chromecast|fire ?tv|shield|google tv|android ?tv|apple tv|webos|tizen|oled\\d{2}|qled|the frame|" +
+ "mi box|tivo)\\b|\\[tv\\]|\\[lg\\]", RegexOption.IGNORE_CASE) to "TV / streaming device",
// Car makers and their infotainment systems' Bluetooth names (whole words: "audi" is in "audio").
Regex("tesla|model [3sxy]\\b|\\bbmw\\b|mercedes|\\baudi\\b|volkswagen|\\bvw\\b|toyota|lexus|honda|acura|hyundai|genesis|\\bkia\\b|\\bford\\b|lincoln|" +
"chevrolet|\\bchevy\\b|cadillac|\\bgmc\\b|buick|nissan|infiniti|subaru|volvo|polestar|rivian|mazda|jeep|dodge|chrysler|porsche|land rover|" +
@@ -152,7 +171,9 @@ object DeviceIntel {
Regex("keyboard|mouse|\\bmx \\w+|trackpad|controller|xbox|dualsense|dualshock|joy-con", RegexOption.IGNORE_CASE) to "Peripheral / controller",
Regex("gopro|insta360|osmo|dash ?cam|doorbell|\\bcam\\b|camera|arlo|wyze ?cam|eufy ?cam|blink", RegexOption.IGNORE_CASE) to "Camera",
Regex("\\bnest\\b|\\bring\\b|echo|alexa|google home|\\bhue\\b|govee|wiz|kasa|tapo|switchbot|\\block\\b|august|yale", RegexOption.IGNORE_CASE) to "Smart-home device",
- Regex("iphone|ipad|macbook|imac|galaxy|pixel|oneplus|xiaomi|redmi|motorola|moto g", RegexOption.IGNORE_CASE) to "Phone / computer",
+ Regex("macbook|\\bimac\\b|mac mini|mac studio|thinkpad|chromebook|surface (pro|laptop|book)|\\blaptop\\b|^(desktop|laptop)-[0-9a-z]{7,8}$",
+ RegexOption.IGNORE_CASE) to "Computer",
+ Regex("iphone|ipad|galaxy|pixel|oneplus|xiaomi|redmi|motorola|moto g", RegexOption.IGNORE_CASE) to "Phone / computer",
Regex("speaker|soundbar|sonos|boom|flip \\d|charge \\d", RegexOption.IGNORE_CASE) to "Speaker"
)
@@ -236,6 +257,9 @@ object DeviceIntel {
Regex("motorola solutions|harris corp|kenwood", RegexOption.IGNORE_CASE) to "Two-way radio / public-safety gear",
Regex("axon", RegexOption.IGNORE_CASE) to "Axon body cam / TASER",
Regex("zepcam", RegexOption.IGNORE_CASE) to "Zepcam body camera",
+ // TV, streaming and console makers (not their parents' phone and appliance arms).
+ Regex("^roku|^vizio|^tivo|hisense electric|hisense broadband|tcl king|shenzhen tcl new|skyworth digital|^vestel|^funai", RegexOption.IGNORE_CASE) to "Smart TV / streaming device",
+ Regex("sony interactive|^nintendo|^valve corp", RegexOption.IGNORE_CASE) to "Game console",
Regex("apple", RegexOption.IGNORE_CASE) to "Apple device",
Regex("samsung", RegexOption.IGNORE_CASE) to "Samsung device",
Regex("sonos|bose|harman|jbl|sennheiser|jabra|gn audio", RegexOption.IGNORE_CASE) to "Audio device",
@@ -402,7 +426,7 @@ object DeviceIntel {
private val WIFI_VENDOR_KINDS = setOf(
"Vehicle / cellular router", "IoT / smart-home module", "Two-way radio / public-safety gear",
"Axon body cam / TASER", "Vehicle system", "Drone / controller", "Smart-home / camera device", "Rugged scanner / printer",
- "Security camera / doorbell"
+ "Security camera / doorbell", "Smart TV / streaming device", "Game console"
)
private fun identifyWifi(a: Advert, macVendor: String?): Identity {
diff --git a/app/src/main/java/com/rfsentinel/app/service/DeviceRegistry.kt b/app/src/main/java/com/rfsentinel/app/service/DeviceRegistry.kt
index 0318236..d47c66b 100644
--- a/app/src/main/java/com/rfsentinel/app/service/DeviceRegistry.kt
+++ b/app/src/main/java/com/rfsentinel/app/service/DeviceRegistry.kt
@@ -466,7 +466,7 @@ object DeviceRegistry {
sources = t.sources.toSet(),
name = t.name,
vendor = t.vendor,
- deviceType = t.identity.type,
+ deviceType = hiddenRouterType(t) ?: t.identity.type,
facts = t.identity.facts +
listOfNotNull(
t.linkedFrom?.let { "Previous address" to "$it (address rotated, same advert fingerprint)" },
@@ -491,6 +491,20 @@ object DeviceRegistry {
broadcast = t.broadcast
)
+ /**
+ * A hidden network broadcast by the same access point as a router is that router's: it takes the router's
+ * type ("Home router - Sagemcom (hidden network)"), so it sorts, groups and filters with it. Null otherwise.
+ */
+ private fun hiddenRouterType(t: Track): String? {
+ if (Advert.Source.WIFI !in t.sources || !t.name.isNullOrEmpty() || t.advert?.wifi?.client == true) return null
+ if (DeviceIntel.isRouter(t.identity.type)) return null
+ return tracks.values.firstNotNullOfOrNull { o ->
+ if (o === t || !WifiFingerprint.sameAccessPoint(t.mac, o.mac)) null
+ // Read without locking [o]: this runs under [t]'s lock, and the sibling facts lock the other way round.
+ else o.identity.type.takeIf { !o.name.isNullOrEmpty() && o.advert?.isWifi == true && DeviceIntel.isRouter(it) }
+ }?.let { DeviceIntel.hiddenOnType(it) }
+ }
+
/**
* Other networks broadcast by the same access point (see
* [WifiFingerprint.sameAccessPoint]). For a hidden network this usually
diff --git a/app/src/main/java/com/rfsentinel/app/ui/DeviceFilter.kt b/app/src/main/java/com/rfsentinel/app/ui/DeviceFilter.kt
index 87dee0f..833880d 100644
--- a/app/src/main/java/com/rfsentinel/app/ui/DeviceFilter.kt
+++ b/app/src/main/java/com/rfsentinel/app/ui/DeviceFilter.kt
@@ -42,7 +42,10 @@ enum class DeviceFilter(val label: String, val liveOnly: Boolean = false) {
ROUTERS("Routers"),
HOTSPOTS("Hotspots"),
TVS("TVs & consoles"),
- SMART_HOME("Smart home");
+ SMART_HOME("Smart home"),
+ COMPUTERS("Computers"),
+ /** Made by Apple, whatever kind (iPhone, Mac, AirPods, AirTag...). */
+ APPLE("Apple");
/**
* What a filter looks at, the same for a device heard now and one saved in a snapshot or a trace,
@@ -57,7 +60,9 @@ enum class DeviceFilter(val label: String, val liveOnly: Boolean = false) {
val flagged: Boolean,
val facts: List<Pair<String, String>> = emptyList(),
val isNew: Boolean = false,
- val remoteId: Boolean = false
+ val remoteId: Boolean = false,
+ /** The address registrant, when the address is a fixed one. */
+ val vendor: String? = null
)
fun matches(s: DeviceRegistry.Snapshot): Boolean = matches(seen(s))
@@ -84,10 +89,13 @@ enum class DeviceFilter(val label: String, val liveOnly: Boolean = false) {
AUDIO -> (AUDIO_TYPE.containsMatchIn(s.type) || s.facts.contains("Identified by" to "Fast Pair model ID")) &&
s.hits.none { it.category == Category.AUDIO_SENSOR }
CAMERAS -> CAMERA_TYPE.containsMatchIn(s.type) || s.hits.any { it.category in CAMERA_CATEGORIES }
- ROUTERS -> ROUTER_TYPE.containsMatchIn(s.type)
+ ROUTERS -> DeviceIntel.isRouter(s.type)
HOTSPOTS -> HOTSPOT_TYPE.containsMatchIn(s.type)
TVS -> TV_TYPE.containsMatchIn(s.type)
SMART_HOME -> SMART_HOME_TYPE.containsMatchIn(s.type) && !VEHICLE_TYPE.containsMatchIn(s.type)
+ COMPUTERS -> COMPUTER_TYPE.containsMatchIn(s.type) || s.name?.let { COMPUTER_NAME.containsMatchIn(it) } == true
+ APPLE -> APPLE_TYPE.containsMatchIn(s.type) || s.vendor?.startsWith("Apple", ignoreCase = true) == true ||
+ s.hits.any { com.rfsentinel.app.detect.SignatureEngine.isAppleFindMy(it) }
}
companion object {
@@ -95,39 +103,45 @@ enum class DeviceFilter(val label: String, val liveOnly: Boolean = false) {
@Volatile var excludeAirTags = false
/** The device-kind filters (from the device's type), after the main ones. */
- val KINDS = listOf(VEHICLES, PHONES, AUDIO, CAMERAS, ROUTERS, HOTSPOTS, TVS, SMART_HOME)
+ val KINDS = listOf(VEHICLES, PHONES, COMPUTERS, AUDIO, CAMERAS, ROUTERS, HOTSPOTS, TVS, SMART_HOME, APPLE)
// Each kind from the types DeviceIntel gives (its own names, the Bluetooth appearance names and
// older versions' names, so saved snapshots and traces sort the same way).
private fun kind(re: String) = Regex(re, RegexOption.IGNORE_CASE)
private val TRACKER_TYPE = kind("tracker|find my|airtag|key finder|^tag$|^keyring")
private val VEHICLE_TYPE = kind("^vehicle|^motorized vehicle|^train wifi|tire pressure")
- private val AUDIO_TYPE = kind("headphone|earbud|airpods|beats|speaker|soundbar|\\bbuds\\b|audio|headset|hearing aid|" +
+ private val AUDIO_TYPE = kind("headphone|earbud|airpods|beats|speaker|soundbar|\\bbuds\\b|audio|(?<!vr )headset|hearing aid|" +
"bose|jbl|jabra|sennheiser|soundcore|skullcandy|sonos")
private val CAMERA_TYPE = kind("^(dashcam|action camera|security camera|camera)|body cam|\\bcam(era)?\\b")
/** Detection categories that are cameras (police, home security, action / hidden, recording glasses). */
private val CAMERA_CATEGORIES = setOf(Category.BODY_CAM, Category.ALPR, Category.NETWORK_CAMERA, Category.OTHER_CAMERA, Category.GLASSES)
- private val ROUTER_TYPE = kind("^(home router|wifi access point|vehicle / cellular router|mesh router)|access point$")
// Business access points and account sign-in WiFi stay off both: they're neither.
private val HOTSPOT_TYPE = kind("^(public wifi hotspot|mobile hotspot box|phone hotspot|train wifi|open wifi)")
- private val TV_TYPE = kind("^(smart tv|tv / streaming|game console|apple tv)|television|set-top|media player|^gaming")
+ private val TV_TYPE = kind("^(smart tv|tv / streaming|game console|game controller|vr headset|apple tv)|television|set-top|media player|^gaming|gamepad|joystick")
private val SMART_HOME_TYPE = kind("smart-home|smart home|^iot|smart plug|bthome|^sensor|environmental sensor|light|" +
"thermostat|^hvac|^heating|air conditioning|humidifier|^fan\\b|access control|door lock|power device|domestic appliance|" +
"window covering|motorized device")
+ // Macs, PCs and laptops (not "phone or computer" guesses, nor a WiFi client that may be either).
+ private val COMPUTER_TYPE = kind("^(computer|mac|imac|laptop|desktop|notebook|chromebook|windows pc)\\b|" +
+ "\\bmac (mini|pro|studio)\\b|macbook|personal computer")
+ /** Windows' default computer names (DESKTOP-1A2B3C4, LAPTOP-1A2B3C4D) and named laptops. */
+ private val COMPUTER_NAME = kind("^(desktop|laptop)-[0-9a-z]{7,8}$|macbook|\\bimac\\b|thinkpad|chromebook|surface (pro|laptop|book)")
+ private val APPLE_TYPE = kind("^apple|iphone|\\bipad|macbook|\\bimac\\b|^mac\\b|airpods|airtag|homepod|apple tv|find my|airplay|vision pro|^beats")
+
private fun isAppleFindMy(s: Seen) =
s.type.contains("Find My", true) || s.type.contains("AirTag", true) ||
s.hits.any { com.rfsentinel.app.detect.SignatureEngine.isAppleFindMy(it) }
fun seen(s: DeviceRegistry.Snapshot) = Seen(
s.mac, s.deviceType, s.name, s.hits, s.sources, s.best != null && !WhitelistCache.contains(s.mac),
- s.facts, s.isNew, s.remoteId != null
+ s.facts, s.isNew, s.remoteId != null, s.vendor
)
fun seen(d: TripDeviceEntity) = Seen(
d.mac, DeviceIntel.savedType(d.deviceType, d.vendor, d.mac).orEmpty(), d.name,
listOfNotNull(Category.parse(d.category)?.let { Hit(it, d.label, d.confidence, d.evidence.orEmpty(), "") }),
- setOfNotNull(Advert.Source.entries.firstOrNull { it.name == d.source }), d.flagged
+ setOfNotNull(Advert.Source.entries.firstOrNull { it.name == d.source }), d.flagged, vendor = d.vendor
)
fun parse(name: String?) = entries.firstOrNull { it.name == name } ?: ALL
diff --git a/app/src/main/java/com/rfsentinel/app/ui/DeviceOrder.kt b/app/src/main/java/com/rfsentinel/app/ui/DeviceOrder.kt
index f9853fc..50b6b33 100644
--- a/app/src/main/java/com/rfsentinel/app/ui/DeviceOrder.kt
+++ b/app/src/main/java/com/rfsentinel/app/ui/DeviceOrder.kt
@@ -50,7 +50,8 @@ object DeviceOrder {
/** Category groups, in the filter chips' spirit: what matters most first. */
private val CATEGORY_ORDER = listOf(
DeviceFilter.TRACKERS, DeviceFilter.DRONES, DeviceFilter.CAMERAS, DeviceFilter.VEHICLES, DeviceFilter.PHONES,
- DeviceFilter.AUDIO, DeviceFilter.ROUTERS, DeviceFilter.HOTSPOTS, DeviceFilter.TVS, DeviceFilter.SMART_HOME
+ DeviceFilter.COMPUTERS, DeviceFilter.AUDIO, DeviceFilter.ROUTERS, DeviceFilter.HOTSPOTS, DeviceFilter.TVS,
+ DeviceFilter.SMART_HOME, DeviceFilter.APPLE
)
/** The group of flagged devices, first when grouped. */
const val ALERTS = "Alerts"
diff --git a/app/src/test/java/com/rfsentinel/app/detect/IdentifyMoreTest.kt b/app/src/test/java/com/rfsentinel/app/detect/IdentifyMoreTest.kt
index a60ed59..d893a95 100644
--- a/app/src/test/java/com/rfsentinel/app/detect/IdentifyMoreTest.kt
+++ b/app/src/test/java/com/rfsentinel/app/detect/IdentifyMoreTest.kt
@@ -280,4 +280,73 @@ class IdentifyMoreTest {
assertEquals(listOf("Alerts", "eero", "Samsung", "Unknown maker"),
ids(DeviceOrder.Sort.SIGNAL, DeviceOrder.Group.MAKER).map { it.first }.map { if (it.startsWith("Samsung")) "Samsung" else it })
}
+
+ @Test
+ fun tvsAndGameGear() {
+ fun wifiType(ssid: String, mac: String = "06:00:00:00:00:61") = DeviceIntel.identify(
+ Advert(mac, Advert.Source.WIFI, -60, ssid, wifi = Advert.WifiInfo(2437, "[WPA2-PSK-CCMP]", null, emptyList())),
+ VendorDb.macVendor(mac)).type
+ fun bleType(name: String) = DeviceIntel.identify(Advert("C1:22:33:44:55:61", Advert.Source.BLE, -60, name)).type
+ listOf("DIRECT-4F-Philips TV", "[LG] webOS TV OLED55C1", "Samsung Smart TV", "Fire TV Stick-1A2B", "Roku Ultra 4K",
+ "AndroidTV-4F2A", "Google TV 3B", "SHIELD-TV", "MiBox_4S").forEach { assertEquals(it, "Smart TV / streaming device", wifiType(it)) }
+ listOf("PS5-123456", "steamdeck", "ROG Ally").forEach { assertEquals(it, "Game console", wifiType(it)) }
+ assertEquals("VR headset", wifiType("Meta Quest 3"))
+ // By maker, whatever the network is called: a Roku and a Nintendo console.
+ assertEquals("Smart TV / streaming device (WiFi)", wifiType("Living room", "D8:31:34:00:00:62"))
+ assertEquals("Game console (WiFi)", wifiType("plain", "00:09:BF:00:00:63"))
+
+ assertEquals("Game controller", bleType("Xbox Wireless Controller"))
+ assertEquals("Game controller", bleType("DualSense Wireless Controller"))
+ assertEquals("Game console", bleType("Steam Deck"))
+ assertEquals("VR headset", bleType("Meta Quest 3"))
+ assertEquals("TV / streaming device", bleType("[TV] Samsung Q70 Series"))
+ assertEquals("TV / streaming device", bleType("LG webOS TV OLED65"))
+
+ fun kinds(type: String) = DeviceFilter.KINDS.filter { it.matches(DeviceFilter.Seen("02:00:00:00:00:64", type, null, emptyList(), emptySet(), false)) }
+ listOf("Game controller", "VR headset", "Game console (WiFi)", "Smart TV / streaming device (WiFi)", "Gamepad")
+ .forEach { assertEquals(it, listOf(DeviceFilter.TVS), kinds(it)) }
+ }
+
+ @Test
+ fun hiddenNetworkOfARouterIsARouter() {
+ DeviceRegistry.clear(); DeviceRegistry.startSession()
+ fun report(mac: String, ssid: String?) {
+ val a = Advert(mac, Advert.Source.WIFI, -60, ssid, wifi = Advert.WifiInfo(2437, "[WPA2-PSK-CCMP]", null, emptyList()))
+ DeviceRegistry.report(a, emptyList(), DeviceIntel.identify(a, VendorDb.macVendor(mac)), null, null, null)
+ }
+ report("00:0E:59:12:34:50", "Smith house")
+ report("02:0E:59:12:34:52", null) // the same router's hidden network (virtual BSSID)
+ report("06:AA:BB:CC:DD:10", null) // a hidden network of no known router
+ val now = System.currentTimeMillis()
+ val byMac = DeviceRegistry.snapshot(now).associateBy { it.mac }
+ assertEquals("Home router (internet provider's) - Sagemcom (hidden network)", byMac.getValue("02:0E:59:12:34:52").deviceType)
+ assertTrue(DeviceFilter.ROUTERS.matches(byMac.getValue("02:0E:59:12:34:52")))
+ assertEquals("Hidden WiFi network", byMac.getValue("06:AA:BB:CC:DD:10").deviceType)
+ DeviceRegistry.clear()
+ }
+
+ @Test
+ fun appleAndComputers() {
+ fun bleType(name: String) = DeviceIntel.identify(Advert("C1:22:33:44:55:71", Advert.Source.BLE, -60, name)).type
+ assertEquals("Computer", bleType("Jane's MacBook Pro"))
+ assertEquals("Computer", bleType("DESKTOP-4F2A9QK"))
+ assertEquals("Computer", bleType("ThinkPad X1"))
+ assertEquals("Phone / computer", bleType("Jane's iPhone"))
+
+ fun kinds(type: String, name: String? = null, vendor: String? = null) = DeviceFilter.KINDS.filter {
+ it.matches(DeviceFilter.Seen("02:00:00:00:00:72", type, name, emptyList(), emptySet(), false, vendor = vendor))
+ }
+ assertEquals(listOf(DeviceFilter.COMPUTERS, DeviceFilter.APPLE), kinds("MacBook Pro"))
+ assertEquals(listOf(DeviceFilter.COMPUTERS), kinds("Computer"))
+ assertEquals(listOf(DeviceFilter.COMPUTERS), kinds("Windows PC (Connected Devices beacon)"))
+ assertTrue(DeviceFilter.COMPUTERS in kinds("WiFi device (laptop, phone or camera on a network)", "LAPTOP-1A2B3C4D"))
+ assertEquals(listOf(DeviceFilter.PHONES, DeviceFilter.APPLE), kinds("iPhone or cellular iPad"))
+ assertTrue(DeviceFilter.APPLE in kinds("AirPods Pro"))
+ assertTrue(DeviceFilter.APPLE in kinds("Apple TV / AirPlay speaker"))
+ assertEquals(listOf(DeviceFilter.APPLE), kinds("Bluetooth device", vendor = "Apple, Inc."))
+ // Not computers: a guess that may be a phone, a plain WiFi client, a machine-like word.
+ assertTrue(DeviceFilter.COMPUTERS !in kinds("Apple device (iPhone, iPad, Mac or Watch)"))
+ assertTrue(DeviceFilter.COMPUTERS !in kinds("WiFi device (laptop, phone or camera on a network)"))
+ assertTrue(DeviceFilter.COMPUTERS !in kinds("Machine sensor"))
+ }
}