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.
Kotlin airtagalprandroidandroid-autoanti-surveillancebluetooth-low-energybody-cameracounter-surveillancedrone-detectionflock-safetyimsi-catcher-detectorpolice-detectorpolice-scannerprivacyremote-idrtl-sdrsdrsurveillance-detectiontracker-detectionwifi
Add detection and alert controls, pager frequencies, Sweden preset
CIS-C0e64372aafe84
diff --git a/app/src/main/assets/oui_presets/sweden.json b/app/src/main/assets/oui_presets/sweden.jsonnew file mode 100644index 0000000..8296844--- /dev/null+++ b/app/src/main/assets/oui_presets/sweden.json@@ -0,0 +1,26 @@+[+ {+ "prefix": "00:25:DF",+ "label": "Axon body camera (Swedish police)",+ "source": "IEEE MA-L registry (Axon Enterprise, Inc.); the Swedish Police Authority announced 1,000 Axon body cameras in 2019 after a field trial",+ "confidence": "confirmed",+ "score": 75,+ "category": "BODY_CAM"+ },+ {+ "prefix": "00:1E:96",+ "label": "Sepura radio (Rakel network)",+ "source": "IEEE MA-L registry (Sepura Limited); TETRA radios, the technology of the Swedish public-safety network Rakel",+ "confidence": "candidate",+ "score": 45,+ "category": "PUBLIC_SAFETY"+ },+ {+ "prefix": "00:23:B9",+ "label": "Airbus radio (Rakel network)",+ "source": "IEEE MA-L registry (Airbus Defence and Space Deutschland GmbH); maker of the TETRA network behind the Swedish public-safety network Rakel",+ "confidence": "candidate",+ "score": 40,+ "category": "PUBLIC_SAFETY"+ }+]diff --git a/app/src/main/java/com/rfsentinel/app/MainActivity.kt b/app/src/main/java/com/rfsentinel/app/MainActivity.ktindex 5c5517d..5e5b525 100644--- a/app/src/main/java/com/rfsentinel/app/MainActivity.kt+++ b/app/src/main/java/com/rfsentinel/app/MainActivity.kt@@ -43,6 +43,8 @@ class MainActivity : AppCompatActivity() {/** Row id prefix of the live cell tower rows (not devices). */private const val CELL_ROW = "cell:"private const val WAZE_ROW = "waze:"+ /** All clear closed with its X: alerts still show, and it comes back when the app restarts. */+ private var allClearClosed = falseprivate const val RADIO_ROW = "radio:"private const val AIRCRAFT_ROW = "air:"private const val TG_ROW = "tg:"@@ -911,7 +913,7 @@ class MainActivity : AppCompatActivity() {*/private fun currentWaze(now: Long): List<com.rfsentinel.app.online.WazePolice.Shown> {if (!ScanForegroundService.isRunning) return emptyList()- val alertM = Prefs.wazeAlertM(this).toDouble()+ val alertM = com.rfsentinel.app.online.WazeStatus.alertM(this)return com.rfsentinel.app.online.WazePolice.forList(com.rfsentinel.app.online.WazePolice.latest, alertM,Prefs.wazeAheadOnly(this), Prefs.wazeHideOffWay(this)).filter { !hidden(WAZE_ROW + it.report.id, now) }}@@ -1344,6 +1346,7 @@ class MainActivity : AppCompatActivity() {val banner = binding.threatBannerif (!ScanForegroundService.isRunning && flagged.isEmpty()) {banner.visibility = View.GONE+ showBannerClose(false)return}banner.visibility = View.VISIBLE@@ -1360,6 +1363,12 @@ class MainActivity : AppCompatActivity() {else -> WEAK_COLOR})slimBanner(false)+ showBannerClose(false)+ return+ }+ if (flagged.isEmpty() && allClearClosed) {+ banner.visibility = View.GONE+ showBannerClose(false)return}val (color, text) = when {@@ -1372,6 +1381,18 @@ class MainActivity : AppCompatActivity() {banner.text = if (flagged.size > 1 && following == null) "$text (+${flagged.size - 1} more)" else textbanner.background.mutate().setTint(color)slimBanner(top == null && following == null)+ showBannerClose(flagged.isEmpty())+ }++ /** The X on the All clear bar, with room kept for it at the end of the text. */+ private fun showBannerClose(show: Boolean) {+ val close = binding.bannerClose+ if ((close.visibility == View.VISIBLE) == show) return+ close.visibility = if (show) View.VISIBLE else View.GONE+ close.setOnClickListener { allClearClosed = true; binding.threatBanner.visibility = View.GONE; showBannerClose(false) }+ val banner = binding.threatBanner+ val dp = resources.displayMetrics.density+ banner.setPaddingRelative(banner.paddingStart, banner.paddingTop, ((if (show) 44 else 12) * dp).toInt(), banner.paddingBottom)}/** Visual style: "All clear" is a slim bar, so the map and list get the room; an alert gets the full size. */@@ -1382,7 +1403,7 @@ class MainActivity : AppCompatActivity() {banner.setTag(R.id.visual_chip_color, slim)val dp = resources.displayMetrics.densityval v = ((if (slim) 2 else 6) * dp).toInt()- banner.setPadding((12 * dp).toInt(), v, (12 * dp).toInt(), v)+ banner.setPaddingRelative((12 * dp).toInt(), v, banner.paddingEnd, v)banner.textSize = if (slim) 12f else 14f}diff --git a/app/src/main/java/com/rfsentinel/app/detect/FlockNoise.kt b/app/src/main/java/com/rfsentinel/app/detect/FlockNoise.ktindex 245c88c..498cd29 100644--- a/app/src/main/java/com/rfsentinel/app/detect/FlockNoise.kt+++ b/app/src/main/java/com/rfsentinel/app/detect/FlockNoise.kt@@ -7,7 +7,9 @@ package com.rfsentinel.app.detect* - a module-prefix match is dropped when the device names itself as something else* (a Flock module has no name or a Flock-style one);* - outside Flock's market (a European preset on, United States off) every Flock match is dropped, strong- * signatures included: Flock isn't used there.+ * signatures included: Flock isn't used there;+ * - with Flock cameras switched off (What to detect), every Flock plate camera match is dropped. Other plate+ * cameras and Flock's Raven audio sensor have their own switches.* In Flock's market, strong signatures (Penguin / Falcon / Raven names, Flock's own service, the* battery name, XUNTONG ID) are never touched.*/@@ -25,11 +27,12 @@ object FlockNoise {private fun isFlock(h: Hit) = h.label.contains("Flock", ignoreCase = true) || isGenericFsName(h)- fun filter(hits: List<Hit>, name: String?, flockRegion: Boolean): List<Hit> {+ fun filter(hits: List<Hit>, name: String?, flockRegion: Boolean, flockCameras: Boolean = true): List<Hit> {val named = name?.trim()?.takeIf { it.isNotEmpty() }return hits.filterNot { h ->when {!flockRegion -> isFlock(h)+ !flockCameras && h.category == Category.ALPR && isFlock(h) -> trueisCommunityPrefix(h) -> named != null && !FLOCK_NAME.containsMatchIn(named)else -> false}diff --git a/app/src/main/java/com/rfsentinel/app/online/AmbientThreats.kt b/app/src/main/java/com/rfsentinel/app/online/AmbientThreats.ktindex 003cfdb..0012285 100644--- a/app/src/main/java/com/rfsentinel/app/online/AmbientThreats.kt+++ b/app/src/main/java/com/rfsentinel/app/online/AmbientThreats.kt@@ -39,7 +39,7 @@ object AmbientThreats {).filter { it.score >= 40 }.maxByOrNull { it.score }private fun camera(context: Context): Threat? {- if (!ScanForegroundService.isRunning || !Prefs.categoryEnabled(context, Category.ALPR)) return null+ if (!ScanForegroundService.isRunning || !Prefs.mappedCameras(context)) return nullval loc = ScanForegroundService.lastFix ?: return nullval cams = AlprStore.cameras.takeIf { it.isNotEmpty() } ?: return nullval (cam, d) = KnownCameras.near(cams, loc.latitude, loc.longitude, 500.0).firstOrNull { (c, _) ->diff --git a/app/src/main/java/com/rfsentinel/app/online/OnlineWatch.kt b/app/src/main/java/com/rfsentinel/app/online/OnlineWatch.ktindex 9a77ef4..39bf37f 100644--- a/app/src/main/java/com/rfsentinel/app/online/OnlineWatch.kt+++ b/app/src/main/java/com/rfsentinel/app/online/OnlineWatch.kt@@ -90,7 +90,7 @@ class OnlineWatch(for (p in planes) {val circling = loiter.update(p, now)val distanceM = PoliceAircraft.distance(p, me.latitude, me.longitude)- val hit = PoliceAircraft.classify(p, registry, circling, distanceM)+ val hit = PoliceAircraft.classify(p, registry, circling, distanceM, alertM = Prefs.aircraftAlertKm(context) * 1000.0)seen += PoliceAircraft.Seen(p, hit)if (hit == null) continueval loud = PoliceAircraft.alerts(hit, distanceM, Prefs.aircraftCircling(context), Prefs.aircraftAlertKm(context) * 1000.0)@@ -123,7 +123,7 @@ class OnlineWatch(for (p in planes) {val circling = loiter.update(p, now)val distanceM = me?.let { PoliceAircraft.distance(p, it.latitude, it.longitude) }- val hit = PoliceAircraft.classify(p, registry, circling, distanceM, PoliceAircraft.VIA_LOCAL)+ val hit = PoliceAircraft.classify(p, registry, circling, distanceM, PoliceAircraft.VIA_LOCAL, Prefs.aircraftAlertKm(context) * 1000.0)seen += PoliceAircraft.Seen(p, hit)if (hit == null) continueval loud = PoliceAircraft.alerts(hit, distanceM, Prefs.aircraftCircling(context), Prefs.aircraftAlertKm(context) * 1000.0)diff --git a/app/src/main/java/com/rfsentinel/app/online/PoliceAircraft.kt b/app/src/main/java/com/rfsentinel/app/online/PoliceAircraft.ktindex 2ec3615..8c1cd07 100644--- a/app/src/main/java/com/rfsentinel/app/online/PoliceAircraft.kt+++ b/app/src/main/java/com/rfsentinel/app/online/PoliceAircraft.kt@@ -103,22 +103,24 @@ object PoliceAircraft {* What an aircraft is, or null when it's ordinary traffic. [circling] comes from* [LoiterTracker]; [distanceM] is the ground distance from you.*/- fun classify(p: Plane, registry: Map<String, Entry>, circling: Boolean, distanceM: Double?, via: String = VIA_ONLINE): Hit? {+ fun classify(p: Plane, registry: Map<String, Entry>, circling: Boolean, distanceM: Double?, via: String = VIA_ONLINE, alertM: Double = ALERT_M): Hit? {val where = describe(p, distanceM)+ // One 40 km away is listed, but it isn't overhead.+ val over = if (distanceM != null && distanceM <= alertM) " overhead" else ""registry[p.hex]?.let { e ->- return Hit(Category.AIRCRAFT, "Police aircraft overhead: ${titleCase(e.owner)}", if (circling) 90 else 85,+ return Hit(Category.AIRCRAFT, "Police aircraft$over: ${titleCase(e.owner)}", if (circling) 90 else 85,"${e.registration} (${e.model.ifBlank { p.type ?: "aircraft" }}), registered to ${titleCase(e.owner)}. $where" +if (circling) " It is circling." else "","FAA / Transport Canada aircraft registry; $via")}p.owner?.takeIf { LE_OWNER.containsMatchIn(it) }?.let { owner ->- return Hit(Category.AIRCRAFT, "Police aircraft overhead: ${titleCase(owner)}", if (circling) 85 else 80,+ return Hit(Category.AIRCRAFT, "Police aircraft$over: ${titleCase(owner)}", if (circling) 85 else 80,"${p.registration ?: p.hex.uppercase()} (${p.type ?: "aircraft"}), operated by ${titleCase(owner)}. $where" +if (circling) " It is circling." else "","ADS-B owner / operator (adsb.fi)")}p.owner?.takeIf { GOV_OWNER.containsMatchIn(it) }?.let { owner ->- return Hit(Category.AIRCRAFT, "Government aircraft overhead: ${titleCase(owner)}", if (circling) 85 else 80,+ return Hit(Category.AIRCRAFT, "Government aircraft$over: ${titleCase(owner)}", if (circling) 85 else 80,"${p.registration ?: p.hex.uppercase()} (${p.type ?: "aircraft"}), operated by ${titleCase(owner)}. $where" +(if (circling) " It is circling." else "") + " A government owner isn't always police - verify.","ADS-B owner / operator (adsb.fi)")diff --git a/app/src/main/java/com/rfsentinel/app/online/WazeWatch.kt b/app/src/main/java/com/rfsentinel/app/online/WazeWatch.ktindex 6f37624..7389ff4 100644--- a/app/src/main/java/com/rfsentinel/app/online/WazeWatch.kt+++ b/app/src/main/java/com/rfsentinel/app/online/WazeWatch.kt@@ -24,6 +24,9 @@ object WazeStatus {@Volatile var baseS = 0@Volatile var everyS = 0@Volatile var motion = MotionTracker.State.MOVING+ /** How close a report must be to alert right now: the highway distance on a fast road. */+ fun alertM(context: android.content.Context): Double =+ (if (motion == MotionTracker.State.FAST) Prefs.wazeFastAlertM(context) else Prefs.wazeAlertM(context)).toDouble()@Volatile var nextCheckAt = 0L@Volatile var lastCheckAt = 0L@Volatile var lastCheckMs = 0L@@ -177,7 +180,7 @@ class WazeWatch(if (key.isNullOrBlank()) { OnlineWatch.wazeStatus = "Add your OpenWeb Ninja API key"; return false }val me = location() ?: run { OnlineWatch.wazeStatus = "Waiting for a GPS fix"; return false }val types = WazePolice.Type.parse(Prefs.wazeTypes(context)).ifEmpty { setOf(WazePolice.Type.POLICE) }- val reach = maxOf(Prefs.wazeViewKm(context) * 1000.0, Prefs.wazeAlertM(context).toDouble())+ val reach = Prefs.wazeReachM(context).toDouble()val json = try {OnlineWatch.httpGet(WazePolice.url(me.latitude, me.longitude, reach, types), mapOf("x-api-key" to key))} catch (e: OnlineWatch.HttpError) {@@ -210,7 +213,7 @@ class WazeWatch(private fun pollDirect(): Boolean {val me = location() ?: run { OnlineWatch.wazeStatus = "Waiting for a GPS fix"; return false }val types = WazePolice.Type.parse(Prefs.wazeTypes(context)).ifEmpty { setOf(WazePolice.Type.POLICE) }- val reach = maxOf(Prefs.wazeViewKm(context) * 1000.0, Prefs.wazeAlertM(context).toDouble())+ val reach = Prefs.wazeReachM(context).toDouble()val alerts = try {// A box wider than the view range, so reports ahead of you are already loaded.fetcherFor(wazeRegion(me.latitude, me.longitude))@@ -244,7 +247,8 @@ class WazeWatch(// Failing checks for a long while: better to show nothing than reports that may be long gone.if (known.isNotEmpty() && now - lastOkAt > staleAfterMs(now)) known = emptyMap()val me = location() ?: return- val alertM = Prefs.wazeAlertM(context).toDouble()+ WazeStatus.motion = motion.state(now)+ val alertM = WazeStatus.alertM(context)val viewM = maxOf(Prefs.wazeViewKm(context) * 1000.0, alertM) // never narrower than the alert rangeval aheadOnly = Prefs.wazeAheadOnly(context)val approachOn = Prefs.wazeApproach(context)diff --git a/app/src/main/java/com/rfsentinel/app/oui/OuiWatchlist.kt b/app/src/main/java/com/rfsentinel/app/oui/OuiWatchlist.ktindex 7bdf71c..085e4ef 100644--- a/app/src/main/java/com/rfsentinel/app/oui/OuiWatchlist.kt+++ b/app/src/main/java/com/rfsentinel/app/oui/OuiWatchlist.kt@@ -63,10 +63,10 @@ object OuiWatchlist {private var state = State(emptyMap(), emptyList(), emptyList(), emptyList(), emptyMap(), emptyMap(), emptyMap(), emptyList(), emptyList())/** Load order: regional presets after "global", so their labels win for shared prefixes. */- val availablePresets = listOf("global", "canada", "us", "france", "uk", "portugal", "germany", "spain", "italy", "netherlands")+ val availablePresets = listOf("global", "canada", "us", "france", "uk", "portugal", "germany", "spain", "italy", "netherlands", "sweden")/** Regions where Flock isn't deployed: their presets turn Flock detection off (FlockNoise). */- private val NON_FLOCK_REGIONS = setOf("france", "uk", "portugal", "germany", "spain", "italy", "netherlands")+ private val NON_FLOCK_REGIONS = setOf("france", "uk", "portugal", "germany", "spain", "italy", "netherlands", "sweden")@Synchronizedfun load(context: Context) {diff --git a/app/src/main/java/com/rfsentinel/app/sdr/RadioReference.kt b/app/src/main/java/com/rfsentinel/app/sdr/RadioReference.ktindex 9c2153d..267fc2b 100644--- a/app/src/main/java/com/rfsentinel/app/sdr/RadioReference.kt+++ b/app/src/main/java/com/rfsentinel/app/sdr/RadioReference.kt@@ -70,7 +70,8 @@ object RadioReference {}FreqNames.nearby = nameslastArea = area; lastAreaAt = System.currentTimeMillis()- status = "RadioReference: ${calls.size} licences, ${names.size} frequencies near you"+ status = if (calls.isEmpty()) "RadioReference: no FCC licences within $RANGE_KM km. It only covers the United States."+ else "RadioReference: ${calls.size} licences, ${names.size} frequencies near you"}} catch (e: Exception) {status = "RadioReference: " + (e.message ?: "lookup failed")@@ -82,8 +83,11 @@ object RadioReference {/** Settings "Test login": one small query; returns a human answer. */suspend fun test(context: Context): String = withContext(Dispatchers.IO) {val a = auth(context) ?: return@withContext "Enter the username, password and developer key first"- // Any position checks the login; 0,0 sends nothing about where you are.- runCatching { proxCallsigns(a, 0.0, 0.0); "Login works" }.getOrElse { it.message ?: "Failed" }+ // Its own small call: sends nothing about where you are, and a proximity search can take too long to answer.+ runCatching {+ val until = parseExpiry(call("getUserData", "", a))+ if (until == null) "Login works" else "Login works, subscription until $until"+ }.getOrElse { it.message ?: "Failed" }}data class Callsign(val callsign: String, val licensee: String, val km: Double)@@ -121,6 +125,8 @@ object RadioReference {val text = stream.use { String(it.readBytes(), Charsets.UTF_8) }fault(text)?.let { throw java.io.IOException(it) }return text+ } catch (e: java.net.SocketTimeoutException) {+ throw java.io.IOException("RadioReference didn't answer in time. Try again.", e)} finally {conn.disconnect()}@@ -128,6 +134,10 @@ object RadioReference {// ---- response parsing (pure; unit-tested) ----+ /** When the Premium subscription ends, from a getUserData answer. */+ fun parseExpiry(xml: String): String? =+ Regex("<subExpireDate[^>]*>([^<]+)</subExpireDate>").find(xml)?.groupValues?.get(1)?.trim()?.takeIf { it.isNotEmpty() }+/** The faultstring of a SOAP fault, or null. */fun fault(xml: String): String? {if (!xml.contains("Fault")) return nulldiff --git a/app/src/main/java/com/rfsentinel/app/sdr/SdrRadio.kt b/app/src/main/java/com/rfsentinel/app/sdr/SdrRadio.ktindex 58edea8..bbc8b10 100644--- a/app/src/main/java/com/rfsentinel/app/sdr/SdrRadio.kt+++ b/app/src/main/java/com/rfsentinel/app/sdr/SdrRadio.kt@@ -672,7 +672,18 @@ object SdrRadio {halted || sdr.lost || away || !keeps(Mode.PAGER)}val onPage = { page: PagerLog.Page, hz: Long -> pagerLog.add(page, hz, System.currentTimeMillis()) }+ var next = 0while (!stop()) {+ // Frequencies typed in Settings: listen to those in turn, no scan.+ val mine = appContext?.let { c -> RadioSettings.targets(com.rfsentinel.app.util.Prefs.pagerFreqs(c)).map { it.freqHz } }.orEmpty()+ if (mine.isNotEmpty()) {+ val hz = mine[next++ % mine.size]+ status = "$deviceLabel · pagers · listening on %.4f MHz".format(java.util.Locale.US, hz / 1e6) + turnNote()+ val from = System.currentTimeMillis()+ hunt.listen(hz, stop, onPage)+ if (System.currentTimeMillis() - from < 1_000L) Thread.sleep(1_000L) // the tuner didn't lock: don't spin+ continue+ }val known = pagerHzif (known == null) status = "$deviceLabel · pagers · looking for a paging channel…" + turnNote()val hz = known ?: hunt.hunt(stop, onPage)diff --git a/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt b/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.ktindex c138762..84fa066 100644--- a/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt+++ b/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt@@ -609,6 +609,7 @@ class ScanForegroundService : Service() {holdAwake()val interval = Prefs.scanIntervalMs(this@ScanForegroundService)com.rfsentinel.app.ui.LiveWindow.wifiScanMs = interval+ com.rfsentinel.app.ui.LiveWindow.usbQuickClear = Prefs.usbQuickClear(this@ScanForegroundService)com.rfsentinel.app.ui.LiveWindow.wifiScanAt = System.currentTimeMillis()wifiEngine.requestScan()delay(interval)@@ -1159,7 +1160,7 @@ class ScanForegroundService : Service() {probeHits[a.mac]?.takeIf { now - it.first < ESP_HIT_TTL_MS }?.second.orEmpty() +extraval noAirTags = Prefs.excludeAirTags(this)- val kept = DeviceIntel.dropTrainRouter(com.rfsentinel.app.detect.FlockNoise.filter(raw, a.name, OuiWatchlist.flockRegion), a)+ val kept = DeviceIntel.dropTrainRouter(com.rfsentinel.app.detect.FlockNoise.filter(raw, a.name, OuiWatchlist.flockRegion, Prefs.flockCameras(this)), a)// Non-stop probing backs up a fixed-camera match that survived the noise filters (never alone).val sifted = kept + listOfNotNull(com.rfsentinel.app.detect.ProbeBehaviour.supportHit(a, kept))val (on, off) = sifted.filter { !(noAirTags && SignatureEngine.isAppleFindMy(it)) }@@ -1225,7 +1226,7 @@ class ScanForegroundService : Service() {}private fun knownAlprActive() = (Prefs.knownAlprAlerts(this) || Prefs.speedCameraAlerts(this)) &&- Prefs.categoryEnabled(this, Category.ALPR) && AlprStore.cameras.isNotEmpty()+ Prefs.mappedCameras(this) && AlprStore.cameras.isNotEmpty()private fun wantsAlert(kind: com.rfsentinel.app.alpr.KnownCamera.Kind) =if (kind == com.rfsentinel.app.alpr.KnownCamera.Kind.ALPR) Prefs.knownAlprAlerts(this) else Prefs.speedCameraAlerts(this)diff --git a/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt b/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.ktindex fe0f41f..f100367 100644--- a/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt+++ b/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt@@ -50,7 +50,8 @@ class SettingsActivity : AppCompatActivity() {"Germany: Motorola VB400 body cams, Motorola and Sepura BOS digital radios.\n" +"Spain: Axon body cams of the Policia Nacional, Teltronic radios.\n" +"Italy: Leonardo / Selex police radios, Selea and Elsag plate readers.\n" +- "Netherlands: Zepcam body cams."+ "Netherlands: Zepcam body cams.\n" ++ "Sweden: Axon body cams of the Swedish police, Sepura and Airbus Rakel radios."const val WAZE_WARNING_SHORT = "Use at your own risk. Reports come from third-party services RF Sentinel doesn't run or endorse " +"(OpenWeb Ninja with your own key, or Waze itself); your account, your responsibility."const val WAZE_WARNING = "Waze police reports are read through OpenWeb Ninja's Waze API with your own API key.\n\n" +@@ -92,6 +93,8 @@ class SettingsActivity : AppCompatActivity() {list += f}private var airTagSwitch: SwitchMaterial? = null+ private var flockSwitch: SwitchMaterial? = null+ private var mappedCamerasSwitch: SwitchMaterial? = nullprivate var wazeKeyInput: android.widget.EditText? = nullprivate var aircraftStatusText: android.widget.TextView? = nullprivate var wazeStatusText: android.widget.TextView? = null@@ -304,7 +307,8 @@ class SettingsActivity : AppCompatActivity() {"global" to binding.presetGlobal, "canada" to binding.presetCanada, "us" to binding.presetUs,"france" to binding.presetFrance, "uk" to binding.presetUk, "portugal" to binding.presetPortugal,"germany" to binding.presetGermany, "spain" to binding.presetSpain, "italy" to binding.presetItaly,- "netherlands" to binding.presetNetherlands+ "netherlands" to binding.presetNetherlands,+ "sweden" to binding.presetSweden)/** ESP32 boards on USB (OUI-Spy / GhostESP / Marauder) and an OUI-SPY board over Bluetooth. */@@ -738,6 +742,7 @@ class SettingsActivity : AppCompatActivity() {"• Spain: Axon body cams of the Policia Nacional, Teltronic TETRA radios.\n" +"• Italy: Leonardo / Selex TETRA radios of the Polizia di Stato, Selea and Elsag plate readers.\n" +"• Netherlands: Zepcam body cams.\n" ++ "• Sweden: Axon body cams of the Swedish police, Sepura and Airbus Rakel radios.\n" +"French drone electronic IDs are decoded in every region. With a European preset on (and not United States), " +"Flock detection is off: Flock isn't used there."),Section("alerts", binding.headerAlerts, binding.sectionAlerts,@@ -1026,6 +1031,25 @@ class SettingsActivity : AppCompatActivity() {* A What to detect row: the label with its ⓘ ([info]) right after the text, then the switch and its ▾ ([fold]).* A row with no ▾ keeps the slot empty, so every switch in the list lines up.*/+ /** Under plate cameras: Flock on its own, and mapped cameras, which don't depend on the detected ones. */+ private fun addCameraControls(detected: SwitchMaterial) {+ flockSwitch = SwitchMaterial(this).apply {+ text = "Flock cameras"+ isChecked = Prefs.flockCameras(this@SettingsActivity)+ isEnabled = detected.isChecked+ }+ detected.onToggle { on -> flockSwitch?.isEnabled = on }+ binding.categoryContainer.addView(detectRow(flockSwitch!!, "Off: detected Flock cameras stop alerting. Other plate cameras still alert.").apply {+ setPadding((24 * resources.displayMetrics.density).toInt(), 0, 0, 0)+ })+ mappedCamerasSwitch = SwitchMaterial(this).apply {+ text = "Mapped cameras"+ isChecked = Prefs.mappedCameras(this@SettingsActivity)+ }+ binding.categoryContainer.addView(detectRow(mappedCamerasSwitch!!,+ "Alerts for cameras mapped in OpenStreetMap, whether or not detected cameras are on. Choose which kinds under Known cameras."))+ }+private fun detectRow(sw: SwitchMaterial, info: String? = null, title: String? = null, fold: View? = null): View {val slot = fold ?: foldIcon().apply { visibility = View.INVISIBLE; importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO }if (info == null) return android.widget.LinearLayout(this).apply {@@ -1154,6 +1178,7 @@ class SettingsActivity : AppCompatActivity() {info(binding.radarTopLabel, "The way you face: the radar turns with the phone, like a compass, so N moves. North: N stays at the top.")info(binding.radarDotsLabel, "Most dots have no real direction (one antenna can't tell). Stay in place keeps them still; turn with north moves them with the compass.")info(binding.radarBeepSwitch, "Beeps faster as a flagged device gets closer, like a radar detector.")+ info(binding.usbQuickClearSwitch, "A USB WiFi adapter goes through every channel in seconds. When a sweep no longer hears a device, its alert and beeps end right away instead of after the next phone scan.")info(binding.detectorSoundSwitch, "Alerts use radar-detector tones (Ka, K and X) and say \"GPS connected\" when the first GPS fix comes in.")info(binding.gpsVoiceSwitch, "With the radar-detector sound: says \"GPS connected\" when the GPS locks, and again when it comes back after losing the fix.")info(binding.dedupeLabel, "The same device won't alert again until this many minutes have passed.")@@ -1561,6 +1586,11 @@ class SettingsActivity : AppCompatActivity() {"Time for ${m.label}")ticked to listOf(box.getChildAt(box.childCount - 2), box.getChildAt(box.childCount - 1))}+ val pagerFrom = box.childCount+ lines("Pager frequencies", "466.075", Prefs.pagerFreqs(this),+ "Leave empty to scan for paging channels. If you know yours, enter it in MHz, one per line: the SDR listens there and " ++ "doesn't scan, so a quiet channel isn't missed.") { Prefs.setPagerFreqs(this, it) }+ val pagerViews = (pagerFrom until box.childCount).map { box.getChildAt(it) }lines("Watch these talkgroups", "1234 Sheriff dispatch\n2001", Prefs.p25Talkgroups(this),"P25: alerts when a call starts on one of them, and names them on the P25 talkgroups screen. One per line: the " +"talkgroup number, with an optional name. 23* watches every talkgroup starting with 23 (2300, 2301, 2307...), and * every " +@@ -1606,9 +1636,10 @@ class SettingsActivity : AppCompatActivity() {val talkgroupViews = (box.childCount - 11 until box.childCount).map { box.getChildAt(it) }var sweepViews = emptyList<View>() // the sweep's own settings, belowshowSdrOptions = {- val ticked = listOf(sweepBox, adsbBox, p25Box).count { it.isChecked }+ val ticked = listOf(sweepBox, adsbBox, p25Box, pagerBox).count { it.isChecked }turnViews.forEach { (scan, views) -> views.forEach { it.shownIf(ticked > 1 && scan.isChecked) } }talkgroupViews.forEach { it.shownIf(p25Box.isChecked) }+ pagerViews.forEach { it.shownIf(pagerBox.isChecked) }sweepViews.forEach { it.shownIf(sweepBox.isChecked) }}val sweepFrom = box.childCount@@ -2299,11 +2330,27 @@ class SettingsActivity : AppCompatActivity() {val alertNow = Prefs.wazeAlertM(this)showAlert(alertNow)box.addView(alertText)+ val fastText = android.widget.TextView(this).apply { textSize = 12f; alpha = 0.75f }+ fun showFast(m: Int) { fastText.text = "On highways, alert within ${Prefs.formatRange(m)}" }+ lateinit var fastSlider: Sliderbox.addView(slider(0, steps.lastIndex, steps.indexOf(alertNow).coerceAtLeast(0), description = "Waze alert distance",format = { Prefs.formatRange(steps[it]) }) {Prefs.setWazeAlertM(this, steps[it])showAlert(steps[it])+ // Follows this one until it is set on its own.+ val fast = Prefs.wazeFastAlertM(this)+ fastSlider.value = steps.indexOf(fast).coerceAtLeast(0).toFloat()+ showFast(fast)})+ val fastNow = Prefs.wazeFastAlertM(this)+ showFast(fastNow)+ box.addView(infoRow(fastText, "At highway speed a report comes up sooner, so a longer distance gives more warning.", "Highway distance"))+ fastSlider = slider(0, steps.lastIndex, steps.indexOf(fastNow).coerceAtLeast(0), description = "Waze alert distance on highways",+ format = { Prefs.formatRange(steps[it]) }) {+ Prefs.setWazeFastAlertM(this, steps[it])+ showFast(steps[it])+ }+ box.addView(fastSlider)val viewText = TextView(this).apply { textSize = 12f; alpha = 0.75f }fun showView(km: Int) { viewText.text = "Show reports on the map within ${com.rfsentinel.app.util.Units.km(km)}" }showView(Prefs.wazeViewKm(this))@@ -2674,6 +2721,7 @@ class SettingsActivity : AppCompatActivity() {setPadding((24 * resources.displayMetrics.density).toInt(), 0, 0, 0)})}+ if (c == Category.ALPR) addCameraControls(sw)if (c == Category.AIRCRAFT) addAircraftControls(sw)if (c == Category.POLICE_REPORT) addWazeControls(sw)}@@ -2706,6 +2754,7 @@ class SettingsActivity : AppCompatActivity() {binding.vibrateSwitch.isChecked = Prefs.vibrateEnabled(this)setupSnoozeLength()binding.radarBeepSwitch.isChecked = Prefs.radarBeep(this)+ binding.usbQuickClearSwitch.isChecked = Prefs.usbQuickClear(this)binding.detectorSoundSwitch.isChecked = Prefs.detectorSound(this)binding.startupSweepSwitch.isChecked = Prefs.startupSweep(this)binding.gpsVoiceSwitch.isChecked = Prefs.gpsVoice(this)@@ -3023,6 +3072,8 @@ class SettingsActivity : AppCompatActivity() {categorySwitches.forEach { (c, sw) -> Prefs.setCategoryEnabled(this, c, sw.isChecked) }airTagSwitch?.let { Prefs.setExcludeAirTags(this, it.isChecked) }+ flockSwitch?.let { Prefs.setFlockCameras(this, it.isChecked) }+ mappedCamerasSwitch?.let { Prefs.setMappedCameras(this, it.isChecked) }wazeKeyInput?.let { input ->val key = input.text.toString().trim()val name = com.rfsentinel.app.online.OnlineWatch.WAZE_KEY_NAME@@ -3037,6 +3088,7 @@ class SettingsActivity : AppCompatActivity() {Prefs.setRadarNames(this, binding.radarNamesSwitch.isChecked)Prefs.setRadarSweepLine(this, binding.radarSweepSwitch.isChecked)Prefs.setRadarBeep(this, binding.radarBeepSwitch.isChecked)+ Prefs.setUsbQuickClear(this, binding.usbQuickClearSwitch.isChecked)Prefs.setDetectorSound(this, binding.detectorSoundSwitch.isChecked)Prefs.setStartupSweep(this, binding.startupSweepSwitch.isChecked)Prefs.setGpsVoice(this, binding.gpsVoiceSwitch.isChecked)diff --git a/app/src/main/java/com/rfsentinel/app/ui/LiveWindow.kt b/app/src/main/java/com/rfsentinel/app/ui/LiveWindow.ktindex b0d4c8d..c0e6228 100644--- a/app/src/main/java/com/rfsentinel/app/ui/LiveWindow.kt+++ b/app/src/main/java/com/rfsentinel/app/ui/LiveWindow.kt@@ -14,6 +14,12 @@ object LiveWindow {/** A Bluetooth device not heard for this long is out of range (adverts come every second or so). */const val BLE_IN_RANGE_MS = 8_000L+ /** A USB adapter repeats a device every 2 s until a sweep and a bit no longer hears it, so a gap this long means gone. */+ const val USB_GONE_MS = 5_000L++ /** Settings: end a USB-heard device's alert as soon as the adapter loses it (kept current by the scan service). */+ @Volatile var usbQuickClear = true+/** The WiFi scan interval in use (kept current by the scan service): WiFi devices only refresh once per scan. */@Volatile var wifiScanMs = 30_000L@@ -29,12 +35,14 @@ object LiveWindow {return (((now - scanAt) / turnMs).mod(1.0) * 360.0 - 90.0).toFloat()}- /** Still being heard: Bluetooth within 8 s, WiFi within one scan round + 10 s. */+ /** Still being heard: Bluetooth within 8 s, WiFi within one scan round + 10 s, or 5 s from a USB adapter. */fun inRange(s: DeviceRegistry.Snapshot, now: Long = System.currentTimeMillis()): Boolean {val wifi = Advert.Source.WIFI in s.sources || s.source == Advert.Source.WIFI- return now - s.lastSeen <= if (wifi) wifiScanMs + 10_000L else BLE_IN_RANGE_MS+ return now - s.lastSeen <= if (wifi) wifiWindowMs(HeardBy.usb.recent(s.mac, now)) else BLE_IN_RANGE_MS}+ internal fun wifiWindowMs(usbHeard: Boolean) = if (usbHeard && usbQuickClear) USB_GONE_MS else wifiScanMs + 10_000L+/*** Flagged (more than a very weak match) AND in range: what drives the live alerts (bubble, banner, radar blips, car* headline, proximity beeps). A flagged device that's gone stops alerting right away butdiff --git a/app/src/main/java/com/rfsentinel/app/ui/SetupActivity.kt b/app/src/main/java/com/rfsentinel/app/ui/SetupActivity.ktindex 8d4fc3f..01daee9 100644--- a/app/src/main/java/com/rfsentinel/app/ui/SetupActivity.kt+++ b/app/src/main/java/com/rfsentinel/app/ui/SetupActivity.kt@@ -196,7 +196,8 @@ class SetupActivity : AppCompatActivity() {"germany" to "Germany - Motorola VB400 body cams, Motorola and Sepura BOS digital radios","spain" to "Spain - Axon body cams of the Policia Nacional, Teltronic radios","italy" to "Italy - Leonardo / Selex police radios, Selea and Elsag plate readers",- "netherlands" to "Netherlands - Zepcam body cams"+ "netherlands" to "Netherlands - Zepcam body cams",+ "sweden" to "Sweden - Axon body cams, Sepura and Airbus Rakel radios").forEach { (key, label) ->check(label, key in enabled) { on ->if (on) enabled += key else enabled -= keydiff --git a/app/src/main/java/com/rfsentinel/app/ui/WazeStatusActivity.kt b/app/src/main/java/com/rfsentinel/app/ui/WazeStatusActivity.ktindex 6b52527..673f187 100644--- a/app/src/main/java/com/rfsentinel/app/ui/WazeStatusActivity.kt+++ b/app/src/main/java/com/rfsentinel/app/ui/WazeStatusActivity.kt@@ -187,7 +187,7 @@ class WazeStatusActivity : AppCompatActivity() {" (${WazeRtFetcher.accountsMadeToday(this)} of ${WazeRtFetcher.dailyAccountLimit()} made today)",Diagnostics.lastError.takeIf { it.isNotEmpty() }?.let { "Last problem: $it" }).joinToString("\n") else listOf(- "Your API key and a box of about ${Prefs.formatRange(maxOf(Prefs.wazeViewKm(this) * 1000, Prefs.wazeAlertM(this)))} around your position (not rounded)",+ "Your API key and a box of about ${Prefs.formatRange(Prefs.wazeReachM(this))} around your position (not rounded)","API key: " + (if (SecureStore.get(this, OnlineWatch.WAZE_KEY_NAME).isNullOrBlank()) "not set" else "set")).joinToString("\n")v.answer.text = OnlineWatch.wazeStatus.ifEmpty { "No answer yet" }@@ -235,7 +235,7 @@ class WazeStatusActivity : AppCompatActivity() {if (Diagnostics.lastError.isNotEmpty()) lines += "Last problem: ${Diagnostics.lastError}"} else {lines += "Source: OpenWeb Ninja (api.openwebninja.com)"- lines += "Sent: your API key and a box of about ${Prefs.formatRange(maxOf(Prefs.wazeViewKm(this) * 1000, Prefs.wazeAlertM(this)))} around your position (not rounded)"+ lines += "Sent: your API key and a box of about ${Prefs.formatRange(Prefs.wazeReachM(this))} around your position (not rounded)"lines += "API key: " + (if (SecureStore.get(this, OnlineWatch.WAZE_KEY_NAME).isNullOrBlank()) "not set" else "set")}lines += ""diff --git a/app/src/main/java/com/rfsentinel/app/util/Prefs.kt b/app/src/main/java/com/rfsentinel/app/util/Prefs.ktindex b89bc28..c99d988 100644--- a/app/src/main/java/com/rfsentinel/app/util/Prefs.kt+++ b/app/src/main/java/com/rfsentinel/app/util/Prefs.kt@@ -139,6 +139,14 @@ object Prefs {return WAZE_ALERT_STEPS_M.minByOrNull { kotlin.math.abs(it - m) } ?: 2000}fun setWazeAlertM(context: Context, m: Int) = setInt(context, "waze_alert_m", m)+ /** The alert distance at highway speed, where reports come up sooner. Follows [wazeAlertM] until set. */+ fun wazeFastAlertM(context: Context): Int {+ val m = int(context, "waze_fast_alert_m", wazeAlertM(context))+ return WAZE_ALERT_STEPS_M.minByOrNull { kotlin.math.abs(it - m) } ?: 2000+ }+ fun setWazeFastAlertM(context: Context, m: Int) = setInt(context, "waze_fast_alert_m", m)+ /** How far around you reports are asked for: the view range or an alert distance, whichever is widest. */+ fun wazeReachM(context: Context): Int = maxOf(wazeViewKm(context) * 1000, wazeAlertM(context), wazeFastAlertM(context))/** "100 m", "750 m", "1.5 km", "10 km". */fun formatRange(m: Int): String = if (Units.imperial) Units.length(m.toDouble())else if (m < 1000) "$m m" else if (m % 1000 == 0) "${m / 1000} km" else "${m / 1000.0} km"@@ -269,6 +277,12 @@ object Prefs {/** Start recording a trace automatically whenever scanning starts. *//** Warn when approaching a plate reader mapped in OpenStreetMap (needs downloaded data). */+ /** Flock plate cameras among the detected ones (What to detect). */+ fun flockCameras(context: Context): Boolean = bool(context, "flock_cameras", true)+ fun setFlockCameras(context: Context, value: Boolean) = setBool(context, "flock_cameras", value)+ /** Alerts for cameras mapped in OpenStreetMap, apart from detected ones. Follows the plate camera switch until set. */+ fun mappedCameras(context: Context): Boolean = bool(context, "mapped_cameras", categoryEnabled(context, Category.ALPR))+ fun setMappedCameras(context: Context, value: Boolean) = setBool(context, "mapped_cameras", value)fun knownAlprAlerts(context: Context): Boolean = bool(context, "known_alpr_alerts", true)fun setKnownAlprAlerts(context: Context, value: Boolean) = setBool(context, "known_alpr_alerts", value)/** Warn when approaching a speed or red-light camera mapped in OpenStreetMap. */@@ -586,6 +600,9 @@ object Prefs {/** Radar-detector mode: after a device alert, keep beeping faster as its signal gets stronger. */fun radarBeep(context: Context): Boolean = bool(context, "radar_beep", false)fun setRadarBeep(context: Context, value: Boolean) = setBool(context, "radar_beep", value)+ /** A device a USB WiFi adapter stops hearing stops alerting and beeping right away, without waiting for a phone scan. */+ fun usbQuickClear(context: Context): Boolean = bool(context, "usb_quick_clear", true)+ fun setUsbQuickClear(context: Context, value: Boolean) = setBool(context, "usb_quick_clear", value)/** Radar-detector sound style: Ka / K / X style tones, startup sweep, "GPS connected", short voice. */fun detectorSound(context: Context): Boolean = bool(context, "detector_sound", false)@@ -671,6 +688,9 @@ object Prefs {/** The SDR decodes pager messages (off by default); they stay in memory ([com.rfsentinel.app.sdr.PagerLog]). */fun sdrPager(context: Context): Boolean = bool(context, "sdr_pager", false)fun setSdrPager(context: Context, v: Boolean) { keepSdrSweep(context); setBool(context, "sdr_pager", v) }+ /** Paging frequencies typed by the user, one per line in MHz: listened to instead of scanning for a channel. */+ fun pagerFreqs(context: Context) = str(context, "pager_freqs")+ fun setPagerFreqs(context: Context, v: String) = sp(context).edit { putString("pager_freqs", v) }/** The sweep's default follows the ADS-B and P25 settings: store it before they change, or ticking one would untick it. */private fun keepSdrSweep(context: Context) { if (!sp(context).contains("sdr_sweep")) setSdrSweep(context, sdrSweep(context)) }/** P25 talkgroups to alert on, "1234 Name" a line ([com.rfsentinel.app.sdr.P25Log.watched]). */diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xmlindex 614888f..dc805b9 100644--- a/app/src/main/res/layout/activity_main.xml+++ b/app/src/main/res/layout/activity_main.xml@@ -34,20 +34,38 @@android:layout_height="wrap_content" /></LinearLayout>- <TextView- android:id="@+id/threatBanner"+ <FrameLayoutandroid:layout_width="match_parent"- android:layout_height="wrap_content"- android:layout_marginBottom="4dp"- android:background="@drawable/banner_bg"- android:paddingStart="12dp"- android:paddingTop="6dp"- android:paddingEnd="12dp"- android:paddingBottom="6dp"- android:textColor="#FFFFFF"- android:textSize="@dimen/text_body"- android:textStyle="bold"- android:visibility="gone" />+ android:layout_height="wrap_content">++ <TextView+ android:id="@+id/threatBanner"+ android:layout_width="match_parent"+ android:layout_height="wrap_content"+ android:layout_marginBottom="4dp"+ android:background="@drawable/banner_bg"+ android:paddingStart="12dp"+ android:paddingTop="6dp"+ android:paddingEnd="12dp"+ android:paddingBottom="6dp"+ android:textColor="#FFFFFF"+ android:textSize="@dimen/text_body"+ android:textStyle="bold"+ android:visibility="gone" />++ <ImageButton+ android:id="@+id/bannerClose"+ android:layout_width="44dp"+ android:layout_height="match_parent"+ android:layout_gravity="end"+ android:layout_marginBottom="4dp"+ android:background="?attr/selectableItemBackgroundBorderless"+ android:contentDescription="Hide all clear"+ android:paddingVertical="3dp"+ android:scaleType="centerInside"+ android:src="@drawable/ic_nav_close"+ android:visibility="gone" />+ </FrameLayout><TextViewandroid:id="@+id/statusText"diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xmlindex c491ff7..5594550 100644--- a/app/src/main/res/layout/activity_settings.xml+++ b/app/src/main/res/layout/activity_settings.xml@@ -212,6 +212,7 @@<CheckBox style="@style/SettingsControl" android:id="@+id/presetSpain" android:text="Spain" /><CheckBox style="@style/SettingsControl" android:id="@+id/presetItaly" android:text="Italy" /><CheckBox style="@style/SettingsControl" android:id="@+id/presetNetherlands" android:text="Netherlands" />+ <CheckBox style="@style/SettingsControl" android:id="@+id/presetSweden" android:text="Sweden" /></LinearLayout><!-- ================= Alerts ================= -->@@ -258,6 +259,11 @@android:id="@+id/radarBeepSwitch"android:text="Radar-detector beeps" />+ <com.google.android.material.switchmaterial.SwitchMaterial+ style="@style/SettingsControl"+ android:id="@+id/usbQuickClearSwitch"+ android:text="USB WiFi: end alerts out of range" />+<com.google.android.material.switchmaterial.SwitchMaterialstyle="@style/SettingsControl"android:id="@+id/detectorSoundSwitch"diff --git a/app/src/test/java/com/rfsentinel/app/detect/FlockNoiseTest.kt b/app/src/test/java/com/rfsentinel/app/detect/FlockNoiseTest.ktindex e78db4c..2a241e8 100644--- a/app/src/test/java/com/rfsentinel/app/detect/FlockNoiseTest.kt+++ b/app/src/test/java/com/rfsentinel/app/detect/FlockNoiseTest.kt@@ -35,6 +35,15 @@ class FlockNoiseTest {assertEquals(1, FlockNoise.filter(listOf(shape), null, flockRegion = true).size)}+ @Test+ fun flockSwitchOffDropsOnlyFlockPlateCameras() {+ val raven = Hit(Category.AUDIO_SENSOR, "Flock Raven audio / gunshot sensor", 80, "", "")+ val other = Hit(Category.ALPR, "Motorola Vigilant plate reader", 70, "", "")+ val kept = FlockNoise.filter(listOf(fsName, penguin, raven, other), null, flockRegion = true, flockCameras = false)+ assertEquals(listOf(raven, other), kept)+ assertEquals(1, FlockNoise.filter(listOf(fsName), "FS-ABC123", flockRegion = true, flockCameras = true).size)+ }+@Testfun djiOsmoIsAnActionCameraNotADrone() {val osmo = SignatureEngine.classify(Advert("4C:43:F6:11:22:33", Advert.Source.BLE, -70, "OsmoNano-AB12"))diff --git a/app/src/test/java/com/rfsentinel/app/online/OnlineSourcesTest.kt b/app/src/test/java/com/rfsentinel/app/online/OnlineSourcesTest.ktindex bca6751..cfa3e99 100644--- a/app/src/test/java/com/rfsentinel/app/online/OnlineSourcesTest.kt+++ b/app/src/test/java/com/rfsentinel/app/online/OnlineSourcesTest.kt@@ -46,6 +46,10 @@ class OnlineSourcesTest {assertTrue(gov.label.startsWith("Government aircraft") && PoliceAircraft.alerts(gov, 900.0))assertTrue(!PoliceAircraft.alerts(gov, 9000.0) && PoliceAircraft.alerts(gov, 9000.0, alertM = 10_000.0))assertTrue(!PoliceAircraft.alerts(gov, 3000.0, alertM = 2_000.0))+ // Listed from 43 km away, but only "overhead" inside the alert range.+ val far = PoliceAircraft.classify(sheriff, registry, circling = false, distanceM = 43_000.0, alertM = 5_000.0)!!+ assertTrue(far.label.startsWith("Police aircraft: "))+ assertTrue(h1.label.startsWith("Police aircraft overhead: "))assertEquals("Police aircraft overhead", com.rfsentinel.app.util.Spoken.aircraft(h1, 300.0, 0.0))assertEquals("Police aircraft, 2 kilometers northeast", com.rfsentinel.app.util.Spoken.aircraft(h1, 2000.0, 50.0))}diff --git a/app/src/test/java/com/rfsentinel/app/online/WazePrefsTest.kt b/app/src/test/java/com/rfsentinel/app/online/WazePrefsTest.ktindex 2ddd634..b2451d8 100644--- a/app/src/test/java/com/rfsentinel/app/online/WazePrefsTest.kt+++ b/app/src/test/java/com/rfsentinel/app/online/WazePrefsTest.kt@@ -16,6 +16,20 @@ import org.robolectric.annotation.Configclass WazePrefsTest {private val ctx get() = RuntimeEnvironment.getApplication()+ @Test+ fun highwayDistanceFollowsTheNormalOneUntilSet() {+ Prefs.setWazeAlertM(ctx, 1000)+ assertEquals(1000, Prefs.wazeFastAlertM(ctx))+ Prefs.setWazeFastAlertM(ctx, 7500)+ Prefs.setWazeAlertM(ctx, 500)+ assertEquals(7500, Prefs.wazeFastAlertM(ctx))+ assertEquals(7500, Prefs.wazeReachM(ctx)) // wider than the 5 km view range+ WazeStatus.motion = MotionTracker.State.FAST+ assertEquals(7500.0, WazeStatus.alertM(ctx), 0.0)+ WazeStatus.motion = MotionTracker.State.MOVING+ assertEquals(500.0, WazeStatus.alertM(ctx), 0.0)+ }+@Testfun defaultsAreTheShippedBehaviour() {assertEquals(2000, Prefs.wazeAlertM(ctx))diff --git a/app/src/test/java/com/rfsentinel/app/sdr/RadioFeaturesTest.kt b/app/src/test/java/com/rfsentinel/app/sdr/RadioFeaturesTest.ktindex 087ac42..4666a66 100644--- a/app/src/test/java/com/rfsentinel/app/sdr/RadioFeaturesTest.kt+++ b/app/src/test/java/com/rfsentinel/app/sdr/RadioFeaturesTest.kt@@ -87,6 +87,8 @@ class RadioFeaturesTest {val details = """<frequencies><item><locationNumber>1</locationNumber><frequency xsi:type="xsd:decimal">155.475</frequency></item><item><frequency>460.125</frequency></item><item><frequency>3.0</frequency></item></frequencies>"""assertEquals(listOf(155_475_000L, 460_125_000L), RadioReference.parseFrequencies(details))+ assertEquals("12-31-2027", RadioReference.parseExpiry("<return><username xsi:type=\"xsd:string\">a</username><subExpireDate xsi:type=\"xsd:string\">12-31-2027</subExpireDate></return>"))+ assertEquals(null, RadioReference.parseExpiry("<return><subExpireDate xsi:type=\"xsd:string\"></subExpireDate></return>"))assertEquals("Invalid Username or Password.", RadioReference.fault("<SOAP-ENV:Fault><faultcode>AUTH</faultcode><faultstring xsi:type=\"xsd:string\">Invalid Username or Password.</faultstring></SOAP-ENV:Fault>"))assertNull(RadioReference.fault(prox))diff --git a/app/src/test/java/com/rfsentinel/app/ui/LiveWindowUsbTest.kt b/app/src/test/java/com/rfsentinel/app/ui/LiveWindowUsbTest.ktnew file mode 100644index 0000000..abaa585--- /dev/null+++ b/app/src/test/java/com/rfsentinel/app/ui/LiveWindowUsbTest.kt@@ -0,0 +1,18 @@+package com.rfsentinel.app.ui++import org.junit.After+import org.junit.Assert.assertEquals+import org.junit.Test++class LiveWindowUsbTest {+ @After fun reset() { LiveWindow.usbQuickClear = true }++ @Test+ fun aUsbHeardDeviceEndsSoonerOnlyWithTheSwitchOn() {+ LiveWindow.wifiScanMs = 30_000L+ assertEquals(LiveWindow.USB_GONE_MS, LiveWindow.wifiWindowMs(usbHeard = true))+ assertEquals(40_000L, LiveWindow.wifiWindowMs(usbHeard = false))+ LiveWindow.usbQuickClear = false+ assertEquals(40_000L, LiveWindow.wifiWindowMs(usbHeard = true))+ }+}diff --git a/docs/SIGNATURES.md b/docs/SIGNATURES.mdindex ef30679..a9945e8 100644--- a/docs/SIGNATURES.md+++ b/docs/SIGNATURES.md@@ -398,6 +398,13 @@ No IEEE block or Bluetooth ID exists for Getac (its blocks are shared with consulaptops), Whelen, Feniex, SoundOff or Laser Technology, so they can only be matched bynames captured in the field.+## Sweden preset (`assets/oui_presets/sweden.json`), researched 2026-11++Vendor and public facts only: the Swedish Police Authority announced 1,000 Axon body cameras in 2019 after an+18-month field trial, and Rakel, the Swedish public-safety network, is a TETRA network. The Sepura and Airbus blocks+are the TETRA makers' IEEE blocks and stay at candidate level, like in the global preset. Sensys Traffic is not+repeated here: it stays in the global preset. Flock detection is off with this preset, as with the other European ones.+## Canada preset (`assets/oui_presets/canada.json`), researched 2026-09Built only from public records: police pilot reports, public procurement