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
Route around speed cameras and plate readers, one-button updates, speedometer with the posted limit, full screen map, "What is RF Sentinel?" page
CIS-C0b8b22718c39a
diff --git a/README.md b/README.mdindex 16766b2..79a75be 100644--- a/README.md+++ b/README.md@@ -7,6 +7,11 @@signals they already broadcast. No root, no Termux, no account.</p>+<p align="center">+ <b>RF Sentinel</b> (also written <b>RFSentinel</b>) is a free, open-source police detector app for Android.+ <a href="https://cis-c0.github.io/RFSentinel/what-is-rf-sentinel.html">What is RF Sentinel?</a>+</p>+<p align="center"><a href="https://github.com/CIS-C0/RFSentinel/releases/latest"><img src="https://img.shields.io/github/v/release/CIS-C0/RFSentinel?label=release&color=00BFAE" alt="Latest release" /></a><img src="https://img.shields.io/badge/Android-8.0%2B-3DDC84?logo=android&logoColor=white" alt="Android 8.0+" />@@ -188,7 +193,7 @@ Requires **Android 8.0 or newer** on a 64-bit ARM phone (almost every phone sinc<p align="center"><img src="docs/screenshots/setup-theme.jpg" width="260" alt="Setup wizard: pick a theme" /></p>-**Updating:** install the newer APK over the existing one. History and settings are kept.+**Updating:** *Check for updates* has an **Install now** button: it downloads the new release inside the app (checked against the size and SHA-256 GitHub lists for it, and against the app's own signing key) and hands it to Android's installer. Android asks you once to allow RF Sentinel to install apps, then shows its Update card. You can also install the newer APK over the existing one yourself. History and settings are kept.Samsung, Xiaomi or OnePlus stopping the scan? Set RF Sentinel's battery usage to**Unrestricted** (Settings has a shortcut).@@ -304,6 +309,14 @@ Turn-by-turn directions on the map, with your scanner running alongside.- **Routes:** up to three, each with its time and the main roads it takes, drawn on the map.*Avoid tolls / highways / ferries* ticked while you plan (or on the trip menu) is remembered for the nextdestination, and is the same setting as Settings → *Navigation*.+- **Round cameras:** *Avoid speed cameras* and *Avoid plate readers* (the same chips, trip menu and Settings →+ *Navigation* switches) plan the route around the known cameras of the camera map. The route is asked for, the+ cameras on it are found, the road each one is on is left out and the route is asked for again (a few times)+ until none is on it or there is no way round. Each route says what is left on it ("no plate readers", "2 speed+ cameras") and the fastest way stays on offer to compare. A camera at the start or end, or on the only bridge,+ can't be avoided and is counted. The cameras along the route are fetched first when they are not on the phone+ yet (Settings → *Known cameras* → *Download automatically*, or download them there beforehand); it also works+ when you are re-routed and in Android Auto. A detour can be longer.**Start** begins guidance - and the scan too, unless you turn that off (Settings → *Navigation*);a scan already running is left as it is, and it keeps going after you arrive.- **Guidance:** a banner with the next turn, its distance and street, the **lane arrows** where the map@@ -328,7 +341,8 @@ Turn-by-turn directions on the map, with your scanner running alongside.[Nominatim](https://nominatim.org) as well when you submit a search (the keyboard's search key, or the*Search for* row) - whichever answers first is shown at once. They see what you search for, where you start,stop and finish, and your IP address - never what you scan - and only when you search, long-press the map- or start a route. Search sends your position rounded to about 1 km. Looking for petrol, food and the like asks OpenStreetMap's+ or start a route. Search sends your position rounded to about 1 km. Avoiding cameras adds the places on your+ route where known cameras are (the road of each, nothing else about them) to the route question. Looking for petrol, food and the like asks OpenStreetMap'sOverpass servers (the same ones as the camera downloads) for that kind of place around you - your positionrounded to about 1 km, or the road ahead as points rounded to about 200 m.diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xmlindex 15c80a6..487e535 100644--- a/app/src/main/AndroidManifest.xml+++ b/app/src/main/AndroidManifest.xml@@ -38,6 +38,8 @@<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /><uses-permission android:name="android.permission.POST_NOTIFICATIONS" />+ <!-- Settings > About > Check for updates: downloads the new release and installs it over the app (Android asks once). -->+ <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /><uses-permission android:name="android.permission.VIBRATE" /><uses-permission android:name="android.permission.WAKE_LOCK" /><!-- Optional floating threat bubble over other apps (the user grants it in Settings). -->@@ -196,6 +198,8 @@</intent-filter></receiver>+ <receiver android:name=".util.UpdateStatusReceiver" android:exported="false" />+<providerandroid:name="androidx.core.content.FileProvider"android:authorities="${applicationId}.fileprovider"diff --git a/app/src/main/java/com/rfsentinel/app/MainActivity.kt b/app/src/main/java/com/rfsentinel/app/MainActivity.ktindex c8ea982..ee29c33 100644--- a/app/src/main/java/com/rfsentinel/app/MainActivity.kt+++ b/app/src/main/java/com/rfsentinel/app/MainActivity.kt@@ -195,13 +195,15 @@ class MainActivity : AppCompatActivity() {lifecycleScope.launch { Favorites.load(this@MainActivity) }// Only on a real fresh start - a theme change recreates this screen too.if (savedInstanceState == null && !Prefs.onboardingDone(this)) showOnboarding()- else if (savedInstanceState == null) com.rfsentinel.app.util.UpdateChecker.checkOnStartup(this)+if (savedInstanceState == null) com.rfsentinel.app.util.CrashLog.offerAfterCrash(this)}override fun onResume() {super.onResume()updateStatus()+ // Every time the app comes to the front (this screen can stay alive for days): Settings > Check for updates on app open.+ if (Prefs.onboardingDone(this)) com.rfsentinel.app.util.UpdateChecker.checkOnStartup(this)}diff --git a/app/src/main/java/com/rfsentinel/app/RFSentinelApp.kt b/app/src/main/java/com/rfsentinel/app/RFSentinelApp.ktindex 5bdf5ac..b523918 100644--- a/app/src/main/java/com/rfsentinel/app/RFSentinelApp.kt+++ b/app/src/main/java/com/rfsentinel/app/RFSentinelApp.kt@@ -54,6 +54,8 @@ class RFSentinelApp : Application() {override fun onActivityDestroyed(a: android.app.Activity) {}})NotificationHelper.createChannels(this)+ // A downloaded update is done with once the app starts again (installed, or given up on).+ appScope.launch { com.rfsentinel.app.util.UpdateInstaller.cleanUp(this@RFSentinelApp) }// A fresh process means no camera download is running: drop any leftover progress.NotificationHelper.clearStaleCameraDownload(this)OuiWatchlist.load(this)diff --git a/app/src/main/java/com/rfsentinel/app/nav/CameraAvoid.kt b/app/src/main/java/com/rfsentinel/app/nav/CameraAvoid.ktnew file mode 100644index 0000000..2ea66c1--- /dev/null+++ b/app/src/main/java/com/rfsentinel/app/nav/CameraAvoid.kt@@ -0,0 +1,231 @@+package com.rfsentinel.app.nav++import com.rfsentinel.app.alpr.KnownCamera+import com.rfsentinel.app.online.RoadMatch+import com.rfsentinel.app.service.DeviceRegistry+import kotlin.math.hypot+import kotlin.math.max+import kotlin.math.min++/**+ * Routes around the known speed cameras and plate readers (Settings > Navigation, or the chips when+ * planning). The route is asked for, the cameras of the camera map that sit on it are found, the stretch of+ * road each one is on is excluded (the route server's `exclude_locations`) and the route is asked for+ * again, a few times, until nothing is on it or there is no way round. What can't be avoided (a camera on+ * the only bridge, one at the very start or end) stays, and the route says how many are left.+ *+ * Pure Kotlin (the questions to the route server are passed in), so it is unit-tested on the JVM.+ */+object CameraAvoid {++ /** A camera this close to the route's line is on it. */+ const val ON_ROUTE_M = 25.0+ /** Cameras this close to where you start, stop or finish can't be driven round. */+ const val ENDS_M = 120.0+ /** The route server accepts 50 excluded places in a request. */+ const val MAX_EXCLUDES = 48+ /** Questions to the route server for one plan (the first one included). */+ const val MAX_REQUESTS = 8+ /** Cameras this close along the route share one excluded place. */+ private const val MERGE_M = 40.0+ /** A camera still on the route after its road was excluded: try the road either side of it, this far on each try. */+ private const val NUDGE_M = 25.0+ private const val MAX_TRIES = 3++ fun kinds(o: Valhalla.Options): Set<KnownCamera.Kind> = buildSet {+ if (o.avoidSpeedCameras) add(KnownCamera.Kind.SPEED)+ if (o.avoidPlateReaders) add(KnownCamera.Kind.ALPR)+ }++ /** A camera on a route: where on the line it is nearest, and how far along. */+ class Hit(val camera: KnownCamera, val lat: Double, val lon: Double, val alongM: Double, val distM: Double)++ /** One place to exclude, for the cameras (OpenStreetMap ids) on that stretch. */+ class Spot(val lat: Double, val lon: Double, val keys: Set<String>, val hits: List<Hit>)++ // ---- finding the cameras on a route ----------------------------------------------------------++ /** The [kinds] of cameras within [radiusM] of the route's line, in the order you meet them. */+ fun hits(route: Route, cameras: List<KnownCamera>, kinds: Set<KnownCamera.Kind>, radiusM: Double = ON_ROUTE_M): List<Hit> {+ if (kinds.isEmpty() || cameras.isEmpty() || route.size < 2) return emptyList()+ var s = Double.MAX_VALUE; var n = -Double.MAX_VALUE; var w = Double.MAX_VALUE; var e = -Double.MAX_VALUE+ for (i in 0 until route.size) { s = min(s, route.lats[i]); n = max(n, route.lats[i]); w = min(w, route.lons[i]); e = max(e, route.lons[i]) }+ val pad = 0.001+ val candidates = cameras.filter { it.type in kinds && it.lat in (s - pad)..(n + pad) && it.lon in (w - pad)..(e + pad) }+ if (candidates.isEmpty()) return emptyList()++ val frame = RoadMatch.Frame((s + n) / 2, (w + e) / 2)+ val xs = DoubleArray(route.size); val ys = DoubleArray(route.size)+ for (i in 0 until route.size) { val (x, y) = frame.toXY(route.lats[i], route.lons[i]); xs[i] = x; ys[i] = y }+ // The segments, on a grid of cells each registered in every cell its box (grown by the radius) touches.+ val cell = 100.0+ val grid = HashMap<Long, MutableList<Int>>()+ fun key(cx: Int, cy: Int) = (cx.toLong() shl 32) xor (cy.toLong() and 0xffffffffL)+ for (i in 0 until route.size - 1) {+ val x0 = (min(xs[i], xs[i + 1]) - radiusM); val x1 = (max(xs[i], xs[i + 1]) + radiusM)+ val y0 = (min(ys[i], ys[i + 1]) - radiusM); val y1 = (max(ys[i], ys[i + 1]) + radiusM)+ for (cx in Math.floor(x0 / cell).toInt()..Math.floor(x1 / cell).toInt())+ for (cy in Math.floor(y0 / cell).toInt()..Math.floor(y1 / cell).toInt())+ grid.getOrPut(key(cx, cy)) { ArrayList() }.add(i)+ }+ val out = ArrayList<Hit>()+ for (c in candidates) {+ val (px, py) = frame.toXY(c.lat, c.lon)+ val segs = grid[key(Math.floor(px / cell).toInt(), Math.floor(py / cell).toInt())] ?: continue+ var best = Double.MAX_VALUE; var bestAlong = 0.0; var bx = 0.0; var by = 0.0+ for (i in segs) {+ val dx = xs[i + 1] - xs[i]; val dy = ys[i + 1] - ys[i]+ val len2 = dx * dx + dy * dy+ val t = if (len2 < 1e-9) 0.0 else (((px - xs[i]) * dx + (py - ys[i]) * dy) / len2).coerceIn(0.0, 1.0)+ val qx = xs[i] + t * dx; val qy = ys[i] + t * dy+ val d = hypot(px - qx, py - qy)+ if (d < best) { best = d; bx = qx; by = qy; bestAlong = route.along[i] + t * (route.along[i + 1] - route.along[i]) }+ }+ if (best <= radiusM) { val (la, lo) = frame.toLatLon(bx, by); out += Hit(c, la, lo, bestAlong, best) }+ }+ return out.sortedBy { it.alongM }+ }++ /** The point [alongM] metres along the route (clamped to its ends). */+ fun pointAt(route: Route, alongM: Double): Pair<Double, Double> {+ val a = alongM.coerceIn(0.0, route.lengthM)+ val i = route.along.indexOfFirst { it >= a }.let { if (it <= 0) return route.lats[0] to route.lons[0] else it }+ val t = (a - route.along[i - 1]) / (route.along[i] - route.along[i - 1]).coerceAtLeast(1e-9)+ return (route.lats[i - 1] + t * (route.lats[i] - route.lats[i - 1])) to (route.lons[i - 1] + t * (route.lons[i] - route.lons[i - 1]))+ }++ /** Hits that sit within [ENDS_M] of where you start, stop or finish: nothing can be done about them. */+ private fun nearEnds(h: Hit, ends: List<Pair<Double, Double>>) =+ ends.any { DeviceRegistry.metersBetween(it.first, it.second, h.camera.lat, h.camera.lon) < ENDS_M }++ /** Cameras close along the route share one place to exclude. */+ internal fun spots(hits: List<Hit>): List<Spot> {+ val out = ArrayList<Spot>()+ var group = ArrayList<Hit>()+ fun flush() {+ if (group.isEmpty()) return+ out += Spot(group[0].lat, group[0].lon, group.map { it.camera.osmId }.toSet(), group)+ group = ArrayList()+ }+ for (h in hits) {+ if (group.isNotEmpty() && h.alongM - group.last().alongM > MERGE_M) flush()+ group += h+ }+ flush()+ return out+ }++ // ---- the plan ----------------------------------------------------------------------------------++ /**+ * Routes for the trip around the [kinds] of cameras in [cameras]. [ask] puts a question to the route+ * server: the route with those places excluded (it throws [Valhalla.NoRouteException] when there is+ * none); [ends] are where the trip starts, stops and finishes. The first route is the one with the+ * fewest cameras, then the ones the server offered first, each saying what is on it ([Route.cameraLine]).+ *+ * [covered] is asked once the first route is known: it can fetch the camera map along it, and says whether+ * the camera map covers the route (the route's line then says so when it doesn't).+ */+ suspend fun plan(+ kinds: Set<KnownCamera.Kind>,+ cameras: () -> List<KnownCamera>,+ ends: List<Pair<Double, Double>>,+ alternatives: Int,+ covered: suspend (Route) -> Boolean = { true },+ now: () -> Long = { System.currentTimeMillis() },+ budgetMs: Long = 45_000L,+ ask: suspend (exclude: List<Pair<Double, Double>>, alternatives: Int) -> List<Route>+ ): List<Route> {+ val first = ask(emptyList(), alternatives)+ val started = now()+ val complete = runCatching { covered(first.first()) }.getOrDefault(false)+ val known = cameras()+ var current = first.first()+ var requests = 1++ val sent = ArrayList<Pair<Double, Double>>()+ val tries = HashMap<String, Int>()+ val blocked = HashSet<String>()++ /** One place to ask the server to exclude, and the cameras it is for. */+ class Item(val lat: Double, val lon: Double, val spot: Spot)++ var offline = false+ while (requests < MAX_REQUESTS && now() - started < budgetMs && !offline) {+ val onRoute = hits(current, known, kinds)+ val items = ArrayList<Item>()+ for (spot in spots(onRoute.filter { !nearEnds(it, ends) })) {+ if (spot.keys.all { it in blocked }) continue+ val attempt = spot.keys.maxOf { tries[it] ?: 0 }+ if (attempt >= MAX_TRIES) { blocked += spot.keys; continue }+ if (attempt == 0) items += Item(spot.lat, spot.lon, spot)+ else {+ // Still on the route after its road was excluded: the road just before and after it.+ val a = spot.hits.first().alongM+ for (d in listOf(-NUDGE_M * attempt, NUDGE_M * attempt)) {+ val (la, lo) = pointAt(current, a + d)+ items += Item(la, lo, spot)+ }+ }+ }+ var batch = items.take((MAX_EXCLUDES - sent.size).coerceAtLeast(0))+ if (batch.isEmpty()) break+ while (batch.isNotEmpty() && requests < MAX_REQUESTS && now() - started < budgetMs) {+ requests+++ try {+ val places = batch.map { it.lat to it.lon }+ val r = ask(sent + places, 0)+ sent += places+ for (sp in batch.map { it.spot }.distinct()) for (k in sp.keys) tries[k] = (tries[k] ?: 0) + 1+ current = r.first()+ batch = emptyList()+ } catch (e: Valhalla.NoRouteException) {+ // No way round with all of these: try fewer; a lone one that cuts the trip off stays as it is.+ if (batch.size == 1) { blocked += batch[0].spot.keys; batch = emptyList() }+ else batch = batch.take((batch.size + 1) / 2)+ } catch (e: java.io.IOException) {+ offline = true; batch = emptyList() // no connection: keep what there is+ }+ }+ }++ val ordered = (listOf(current) + first.filter { it !== current }).take(3)+ return ordered.map { r -> r.copy(cameraLine = describe(hits(r, known, kinds), kinds, complete)) }+ }++ /** What is on a route, in a few words: "no plate readers", "2 plate readers, 1 speed camera". */+ fun describe(hits: List<Hit>, kinds: Set<KnownCamera.Kind>, complete: Boolean = true): String {+ fun noun(k: KnownCamera.Kind, n: Int) = when (k) {+ KnownCamera.Kind.ALPR -> if (n == 1) "plate reader" else "plate readers"+ KnownCamera.Kind.SPEED -> if (n == 1) "speed camera" else "speed cameras"+ KnownCamera.Kind.RED_LIGHT -> if (n == 1) "red-light camera" else "red-light cameras"+ }+ val order = listOf(KnownCamera.Kind.ALPR, KnownCamera.Kind.SPEED, KnownCamera.Kind.RED_LIGHT).filter { it in kinds }+ val counts = order.map { k -> k to hits.count { it.camera.type == k } }.filter { it.second > 0 }+ val text = if (counts.isEmpty()) "no " + (if (order.size > 1) "cameras" else noun(order.first(), 2))+ else counts.joinToString(", ") { (k, n) -> "$n ${noun(k, n)}" }+ return if (complete) text else "$text known (camera map incomplete here)"+ }++ // ---- the camera map along a route ------------------------------------------------------------++ /**+ * Boxes (south, west, north, east) that cover the route, none wider than [maxSpanDeg] (the most one+ * camera download takes), at most [maxBoxes] of them, each a little larger than the road it holds.+ */+ fun boxes(route: Route, maxSpanDeg: Double = 1.6, maxBoxes: Int = 4, pad: Double = 0.02): List<DoubleArray> {+ val out = ArrayList<DoubleArray>()+ var s = 0.0; var w = 0.0; var n = 0.0; var e = 0.0; var open = false+ for (i in 0 until route.size step 5) {+ val la = route.lats[i]; val lo = route.lons[i]+ if (!open) { s = la; n = la; w = lo; e = lo; open = true; continue }+ if (max(n, la) - min(s, la) > maxSpanDeg || max(e, lo) - min(w, lo) > maxSpanDeg) {+ out += doubleArrayOf(s - pad, w - pad, n + pad, e + pad)+ if (out.size >= maxBoxes) return out+ s = la; n = la; w = lo; e = lo+ } else { s = min(s, la); n = max(n, la); w = min(w, lo); e = max(e, lo) }+ }+ if (open && out.size < maxBoxes) out += doubleArrayOf(s - pad, w - pad, n + pad, e + pad)+ return out+ }+}diff --git a/app/src/main/java/com/rfsentinel/app/nav/CameraCoverage.kt b/app/src/main/java/com/rfsentinel/app/nav/CameraCoverage.ktnew file mode 100644index 0000000..61c0924--- /dev/null+++ b/app/src/main/java/com/rfsentinel/app/nav/CameraCoverage.kt@@ -0,0 +1,29 @@+package com.rfsentinel.app.nav++import android.content.Context+import com.rfsentinel.app.alpr.AlprStore+import com.rfsentinel.app.util.Prefs+import kotlinx.coroutines.withTimeoutOrNull++/**+ * The camera map along a route, for [CameraAvoid]: the cameras of the area it crosses are fetched when they+ * are not on the phone yet (as the map does for the area you look at - the same setting, "Download cameras+ * automatically", decides), a little at a time so a busy server doesn't hold the plan up.+ */+object CameraCoverage {++ /** The longest the camera downloads may hold up a route plan. */+ private const val WAIT_MS = 30_000L++ /** Fetches what is missing along [route] (if allowed) and says whether the camera map now covers all of it. */+ suspend fun ensure(context: Context, route: Route): Boolean {+ val boxes = CameraAvoid.boxes(route)+ fun missing() = boxes.any { AlprStore.needsDownload(it[0], it[1], it[2], it[3]) }+ if (!missing()) return true+ if (!Prefs.autoCameras(context)) return false+ withTimeoutOrNull(WAIT_MS) {+ for (b in boxes) if (AlprStore.needsDownload(b[0], b[1], b[2], b[3])) AlprStore.autoDownload(context, b[0], b[1], b[2], b[3])+ }+ return !missing()+ }+}diff --git a/app/src/main/java/com/rfsentinel/app/nav/Navigator.kt b/app/src/main/java/com/rfsentinel/app/nav/Navigator.ktindex 34fe4e5..b2dcbb1 100644--- a/app/src/main/java/com/rfsentinel/app/nav/Navigator.kt+++ b/app/src/main/java/com/rfsentinel/app/nav/Navigator.kt@@ -8,6 +8,7 @@ import android.location.LocationManagerimport android.os.Buildimport android.os.Looperimport com.rfsentinel.app.BuildConfig+import com.rfsentinel.app.alpr.AlprStoreimport com.rfsentinel.app.service.ScanForegroundServiceimport com.rfsentinel.app.util.AlertPlayerimport com.rfsentinel.app.util.Permissions@@ -66,6 +67,19 @@ object Navigator {val active: Boolean get() = destination != null && route != null+ private var limits: SpeedLimits.RouteLimits? = null++ /**+ * The posted limit (km/h) where you are on the route, from the limits asked for along it (a stretch at a time,+ * ahead of you); null while it is unknown or not mapped. Asked for only when the screen wants it.+ */+ fun speedLimitKmh(): Int? {+ val r = route ?: return null+ val s = state ?: return null+ val rl = limits?.takeIf { it.route === r } ?: SpeedLimits.RouteLimits(r).also { limits = it }+ return rl.at(s.alongM)+ }+/*** How fast you are really going compared with the route's plan (1 = as planned, 1.2 = a fifth slower),* learned from the drive so far: stops at lights, a slow road. It scales the time left, which is the@@ -126,7 +140,8 @@ object Navigator {/** The route options chosen in Settings, for a route nobody has adjusted. */fun defaultOptions(context: Context) = Valhalla.Options(avoidTolls = Prefs.navAvoidTolls(context), avoidHighways = Prefs.navAvoidHighways(context),- avoidFerries = Prefs.navAvoidFerries(context))+ avoidFerries = Prefs.navAvoidFerries(context),+ avoidSpeedCameras = Prefs.navAvoidSpeedCameras(context), avoidPlateReaders = Prefs.navAvoidPlateReaders(context))/*** Keeps what was ticked (avoid tolls, highways, ferries) as the starting choice for the next@@ -136,6 +151,8 @@ object Navigator {Prefs.setNavAvoidTolls(context, options.avoidTolls)Prefs.setNavAvoidHighways(context, options.avoidHighways)Prefs.setNavAvoidFerries(context, options.avoidFerries)+ Prefs.setNavAvoidSpeedCameras(context, options.avoidSpeedCameras)+ Prefs.setNavAvoidPlateReaders(context, options.avoidPlateReaders)}// ---- planning ---------------------------------------------------------------------------------@@ -144,10 +161,20 @@ object Navigator {suspend fun plan(context: Context, dest: Place, from: Location, options: Valhalla.Options,stops: List<Place> = emptyList()): List<Route> {planner?.let { return it(context, dest, from, options, stops) }- val miles = NavFormat.miles(context)- val body = Valhalla.request(from.latitude, from.longitude, headingOf(from), stops.map { it.lat to it.lon },- dest.lat to dest.lon, options, miles)- return withContext(Dispatchers.IO) { Valhalla.route(body, userAgent) }+ val app = context.applicationContext+ val miles = NavFormat.miles(app)+ val heading = headingOf(from)+ val via = stops.map { it.lat to it.lon }+ suspend fun ask(exclude: List<Pair<Double, Double>>, alternatives: Int): List<Route> {+ val body = Valhalla.request(from.latitude, from.longitude, heading, via, dest.lat to dest.lon,+ options.copy(alternatives = alternatives), miles, exclude)+ return withContext(Dispatchers.IO) { Valhalla.route(body, userAgent) }+ }+ val kinds = CameraAvoid.kinds(options)+ if (kinds.isEmpty()) return ask(emptyList(), options.alternatives)+ // Round the known cameras: the camera map along the route is fetched first when it isn't there yet.+ return CameraAvoid.plan(kinds, { AlprStore.cameras }, listOf(from.latitude to from.longitude) + via + (dest.lat to dest.lon),+ options.alternatives, covered = { CameraCoverage.ensure(app, it) }, ask = ::ask)}/** Plans with the Settings defaults and starts on the best route (the car screens' one-step start). */@@ -202,7 +229,7 @@ object Navigator {fun stop() {appContext?.let { listen(it, false); NavigationService.stop(it) }generation++- destination = null; route = null; state = null; status = null; stops = emptyList(); rerouting = false+ destination = null; route = null; state = null; status = null; stops = emptyList(); rerouting = false; limits = nulllastFix = null // a fix kept after the trip would stand in for a newer position later (the car screens take the newest of two)changed()}diff --git a/app/src/main/java/com/rfsentinel/app/nav/Route.kt b/app/src/main/java/com/rfsentinel/app/nav/Route.ktindex 2fa5dda..6ff5307 100644--- a/app/src/main/java/com/rfsentinel/app/nav/Route.kt+++ b/app/src/main/java/com/rfsentinel/app/nav/Route.kt@@ -17,7 +17,9 @@ data class Route(/** The main roads it takes ("Highway 40, Rue Principale"), to tell routes apart. */val summary: String,/** Where it ends (the last stop). */- val end: Pair<Double, Double>+ val end: Pair<Double, Double>,+ /** What is on it of the cameras being avoided ("no plate readers", "2 speed cameras"); null when none are. */+ val cameraLine: String? = null) {val size: Int get() = lats.sizeval lengthM: Double get() = along.lastOrNull() ?: 0.0diff --git a/app/src/main/java/com/rfsentinel/app/nav/SpeedLimits.kt b/app/src/main/java/com/rfsentinel/app/nav/SpeedLimits.ktnew file mode 100644index 0000000..9b368d4--- /dev/null+++ b/app/src/main/java/com/rfsentinel/app/nav/SpeedLimits.kt@@ -0,0 +1,182 @@+package com.rfsentinel.app.nav++import android.content.Context+import com.rfsentinel.app.BuildConfig+import com.rfsentinel.app.service.DeviceRegistry+import org.json.JSONArray+import org.json.JSONObject+import java.net.HttpURLConnection+import java.net.URL+import java.util.concurrent.Executors++/**+ * The posted speed limit for the map's speedometer, from OpenStreetMap's `maxspeed` through the route server's+ * map matching (Valhalla `trace_attributes`: the road each point of a line lies on and its limit). Two uses:+ *+ * - [RouteLimits]: while you are guided, the limits along the whole route, asked a stretch at a time ahead of you+ * (the route server already knows the route; nothing more about you goes out).+ * - [Live]: when you are not navigating - opt-in, as it sends where you are driving every ~12 s.+ *+ * Request building and reading are pure Kotlin and unit-tested; [fetch] is plain blocking HTTP.+ */+object SpeedLimits {++ const val URL = "https://valhalla1.openstreetmap.de/trace_attributes"++ /** Points per question (the server takes thousands; a short stretch answers quickly and kindly). */+ const val CHUNK = 1_500++ /** Valhalla's "no limit" (a German Autobahn) is 255: nothing to show. */+ private const val MAX_SHOWN_KMH = 200++ /** Tests replace the questions to the server: points in, a limit in km/h for each point out (0 = unknown). */+ internal var fetcher: ((List<Pair<Double, Double>>) -> IntArray)? = null+ private val worker = Executors.newSingleThreadExecutor { Thread(it, "speed-limits").apply { isDaemon = true } }++ fun request(points: List<Pair<Double, Double>>): JSONObject = JSONObject()+ .put("shape", JSONArray().also { a -> for ((la, lo) in points) a.put(JSONObject().put("lat", la).put("lon", lo)) })+ .put("costing", "auto")+ .put("shape_match", "map_snap")+ .put("filters", JSONObject().put("attributes", JSONArray(listOf("edge.speed_limit", "matched.edge_index", "matched.type"))).put("action", "include"))++ /** The limit (km/h) at each of the [count] points sent; 0 where the road has none mapped or the point didn't match a road. */+ fun parse(json: String, count: Int): IntArray {+ val out = IntArray(count)+ val root = JSONObject(json)+ val edges = root.optJSONArray("edges") ?: return out+ val matched = root.optJSONArray("matched_points") ?: return out+ for (i in 0 until minOf(count, matched.length())) {+ val m = matched.getJSONObject(i)+ if (!m.has("edge_index") || m.optString("type") == "unmatched") continue+ val limit = edges.optJSONObject(m.getInt("edge_index"))?.optInt("speed_limit", 0) ?: 0+ out[i] = if (limit in 5..MAX_SHOWN_KMH) limit else 0+ }+ return out+ }++ /** Asks the route server; blocking. Throws on a network error or an answer that isn't one. */+ fun fetch(points: List<Pair<Double, Double>>): IntArray {+ fetcher?.let { return it(points) }+ val c = (URL(URL).openConnection() as HttpURLConnection).apply {+ requestMethod = "POST"; doOutput = true+ connectTimeout = 10_000; readTimeout = 25_000+ setRequestProperty("Content-Type", "application/json")+ setRequestProperty("User-Agent", "${BuildConfig.APPLICATION_ID}/${BuildConfig.VERSION_NAME}")+ }+ try {+ c.outputStream.use { it.write(request(points).toString().toByteArray(Charsets.UTF_8)) }+ if (c.responseCode !in 200..299) throw java.io.IOException("The route server answered ${c.responseCode}")+ return parse(c.inputStream.bufferedReader(Charsets.UTF_8).use { it.readText() }, points.size)+ } finally {+ c.disconnect()+ }+ }++ /** km/h as shown: mph rounded to the nearest 5 (signs go in fives), km/h as is. */+ fun shown(kmh: Int, miles: Boolean): Int = if (miles) (Math.round(kmh / 1.609344 / 5.0) * 5).toInt() else kmh++ // ---- along a route ------------------------------------------------------------------------------++ /**+ * The limits along [route], fetched in stretches of [CHUNK] points as you get near them (the next stretch+ * is asked for while you are still in the one before). [at] answers at once from what has arrived.+ */+ class RouteLimits(val route: Route) {+ private val limits = IntArray(route.size) { -1 } // -1 = not asked yet, 0 = none mapped+ private val asked = BooleanArray(route.size / CHUNK + 1)+ private var failedAt = 0L+ @Volatile internal var clock: () -> Long = { System.currentTimeMillis() }++ /** The limit (km/h) where you are [alongM] metres along the route; null when none is mapped or it has not arrived yet. */+ fun at(alongM: Double): Int? {+ if (route.size < 2) return null+ val i = indexAt(alongM)+ ensure(i / CHUNK)+ ensure(i / CHUNK + 1) // the next stretch is on its way before you reach it+ return limits[i].takeIf { it > 0 }+ }++ private fun indexAt(alongM: Double): Int {+ var lo = 0; var hi = route.size - 1+ while (lo < hi) { val mid = (lo + hi + 1) ushr 1; if (route.along[mid] <= alongM) lo = mid else hi = mid - 1 }+ return lo+ }++ @Synchronized private fun ensure(chunk: Int) {+ val from = chunk * CHUNK+ if (chunk < 0 || from >= route.size || asked[chunk]) return+ if (clock() - failedAt < RETRY_MS) return+ asked[chunk] = true+ val to = minOf(route.size, from + CHUNK + 1) // one point of overlap keeps the road at the seam+ val pts = (from until to).map { route.lats[it] to route.lons[it] }+ worker.execute {+ try {+ val got = fetch(pts)+ synchronized(this) { for (k in got.indices) if (limits[from + k] < 0 || k < CHUNK) limits[from + k] = got[k] }+ } catch (e: Exception) {+ synchronized(this) { asked[chunk] = false; failedAt = clock() }+ }+ }+ }+ }++ // ---- when you are not navigating ----------------------------------------------------------------------++ /**+ * The limit of the road you are on, from where you drove in the last minute (opt-in: Settings > Map). It asks+ * at most every [GAP_MS] and only while you are really driving; an answer is good for [FRESH_MS] and 250 m.+ */+ object Live {+ private const val GAP_MS = 12_000L+ private const val FRESH_MS = 45_000L+ private const val MIN_SPACING_M = 20.0+ private const val KEEP_MS = 60_000L+ private const val MAX_POINTS = 8++ private class Fix(val lat: Double, val lon: Double, val at: Long)+ private val trail = ArrayList<Fix>()+ private var askedAt = 0L+ private var failedAt = 0L+ @Volatile private var limit = 0+ @Volatile private var limitAt = 0L+ @Volatile private var limitLat = 0.0+ @Volatile private var limitLon = 0.0+ @Volatile private var busy = false++ /** A fix from the screen's GPS (main thread); drives the asking. */+ fun onFix(lat: Double, lon: Double, speedMs: Float, now: Long = System.currentTimeMillis()) {+ if (speedMs < 1.4f) return // stopped: the last answer stands+ if (trail.isEmpty() || DeviceRegistry.metersBetween(trail.last().lat, trail.last().lon, lat, lon) >= MIN_SPACING_M) {+ trail += Fix(lat, lon, now)+ trail.removeAll { now - it.at > KEEP_MS }+ while (trail.size > MAX_POINTS) trail.removeAt(0)+ }+ if (busy || trail.size < 3 || now - askedAt < GAP_MS || now - failedAt < 5 * GAP_MS) return+ askedAt = now; busy = true+ val pts = trail.map { it.lat to it.lon }+ worker.execute {+ try {+ val got = fetch(pts)+ limit = got.lastOrNull() ?: 0; limitAt = System.currentTimeMillis()+ limitLat = pts.last().first; limitLon = pts.last().second+ } catch (e: Exception) {+ failedAt = System.currentTimeMillis()+ } finally { busy = false }+ }+ }++ /** The limit (km/h) now, or null when unknown or out of date. */+ fun now(lat: Double, lon: Double, now: Long = System.currentTimeMillis()): Int? {+ if (limit <= 0 || now - limitAt > FRESH_MS) return null+ if (DeviceRegistry.metersBetween(limitLat, limitLon, lat, lon) > 250.0) return null+ return limit+ }++ fun reset() { trail.clear(); limit = 0; limitAt = 0; askedAt = 0; failedAt = 0 }+ }++ private const val RETRY_MS = 60_000L++ /** Whether the speedometer asks for limits at all (it still shows your speed when it doesn't). */+ fun enabled(context: Context) = com.rfsentinel.app.util.Prefs.mapSpeedometer(context)+}diff --git a/app/src/main/java/com/rfsentinel/app/nav/Valhalla.kt b/app/src/main/java/com/rfsentinel/app/nav/Valhalla.ktindex 3c5b3ef..42476ca 100644--- a/app/src/main/java/com/rfsentinel/app/nav/Valhalla.kt+++ b/app/src/main/java/com/rfsentinel/app/nav/Valhalla.kt@@ -27,7 +27,10 @@ object Valhalla {val avoidHighways: Boolean = false,val avoidFerries: Boolean = false,/** How many other routes to offer besides the best (only with no stops on the way). */- val alternatives: Int = 2+ val alternatives: Int = 2,+ /** Go round the known speed cameras / plate readers of the camera map ([CameraAvoid]). */+ val avoidSpeedCameras: Boolean = false,+ val avoidPlateReaders: Boolean = false)class NoRouteException(message: String) : Exception(message)@@ -39,7 +42,8 @@ object Valhalla {* begin with a U-turn - through [stops] to [to].*/fun request(fromLat: Double, fromLon: Double, headingDeg: Double?, stops: List<Pair<Double, Double>>,- to: Pair<Double, Double>, options: Options, miles: Boolean = false): JSONObject {+ to: Pair<Double, Double>, options: Options, miles: Boolean = false,+ exclude: List<Pair<Double, Double>> = emptyList()): JSONObject {val locations = JSONArray()locations.put(JSONObject().put("lat", fromLat).put("lon", fromLon).apply {if (headingDeg != null) { put("heading", Math.round(headingDeg).toInt()); put("heading_tolerance", 45) }@@ -61,6 +65,10 @@ object Valhalla {.put("voice_instructions", true).put("turn_lanes", true).apply {+ // Places the route must not use (the road at each; the server takes up to 50).+ if (exclude.isNotEmpty()) put("exclude_locations", JSONArray().also { a ->+ for ((la, lo) in exclude) a.put(JSONObject().put("lat", la).put("lon", lo))+ })// Alternatives aren't offered on routes with stops.if (stops.isEmpty() && options.alternatives > 0) put("alternates", options.alternatives)}diff --git a/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt b/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.ktindex 708f575..7123659 100644--- a/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt+++ b/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt@@ -464,6 +464,9 @@ class SettingsActivity : AppCompatActivity() {"asked until you search, long-press the map or start a route; search sends your position rounded to about 1 km.\n\n" +"Looking for petrol, charging, food and the like asks OpenStreetMap's Overpass servers (as the camera downloads do): " +"your position rounded to about 1 km, or the road ahead as points rounded to about 200 m.\n\n" ++ "Avoiding speed cameras and plate readers: the route server is asked for the route again with the road of each " ++ "camera on it left out (a few times), so it also sees those places on your route - nothing else about the cameras " ++ "or what you scan.\n\n" +"Not included: live traffic (the arrival time starts from the route's usual driving time and then follows how you really " +"drive), speed limits and offline routes.\n\n" +"Home, Work, starred and recent places are kept on this phone only."),@@ -474,6 +477,14 @@ class SettingsActivity : AppCompatActivity() {"The map button turns the map: north up, then with your direction of travel, then the 3D driving view - like " +"a car navigation app, your arrow low on the screen, closer in town and further ahead at speed.\n\n" +"3D view angle: how far the driving view leans back; on fast roads it leans up to 10° further (60° at most).\n\n" ++ "Speedometer: your speed (from the GPS) in the bottom left corner of the live map, and next to it the posted speed " ++ "limit as a road sign: a red ring, or a \"SPEED LIMIT\" plate where distances are in miles. Your speed turns red " ++ "above the limit. While you are guided the limits along the route come with it (one more question to the route server " ++ "for the stretch ahead, nothing about where else you go). Not navigating, the limit needs the extra switch: it asks the route " ++ "server which road you are on about every 12 seconds while you drive, so that server learns where you drive - it " ++ "is off until you turn it on. Limits are OpenStreetMap's: where none is mapped there is no sign.\n\n" ++ "The full screen map has a button that hides the toolbar, the system bars and the bottom bar (the speedometer, " ++ "alert cards and, while guiding, the turn banner stay).\n\n" +"Default zoom: how close the map follows you. The 3D driving view pulls back from it as you speed up; the " +"north-up and heading-up views sit half a level wider. 17 is close to Waze.\n\n" +"Map provider: OpenFreeMap (OpenStreetMap data, free, no account) or Mapbox (Mapbox's own map: 3D buildings, " +@@ -561,7 +572,9 @@ class SettingsActivity : AppCompatActivity() {Section("more", binding.headerMore, binding.sectionMore,"Watchlist & rules: the vendor prefixes and rules that flag a device; add your own.\n\n" +"Whitelist: devices you trust, never flagged.\n\n" +- "Check for updates: asks GitHub for a newer version now.\n\n" ++ "Check for updates: asks GitHub for a newer version now. \"Install now\" downloads it and installs it over this " ++ "one (Android asks you once to allow RF Sentinel to install apps, then shows its own Update card). History and " ++ "settings are kept, and scanning stops while it installs.\n\n" +"About & sources: version, licence, where the signatures come from, and the app's limits.\n\n" +"Crash log: if RF Sentinel ever closes unexpectedly, what went wrong is saved on this phone (never sent " +"automatically). Export it to send to the developer; the app also offers this the next time it opens.")@@ -942,6 +955,12 @@ class SettingsActivity : AppCompatActivity() {switch("Tolls", Prefs.navAvoidTolls(this)) { Prefs.setNavAvoidTolls(this, it) }switch("Highways", Prefs.navAvoidHighways(this)) { Prefs.setNavAvoidHighways(this, it) }switch("Ferries", Prefs.navAvoidFerries(this)) { Prefs.setNavAvoidFerries(this, it) }+ switch("Speed cameras", Prefs.navAvoidSpeedCameras(this)) { Prefs.setNavAvoidSpeedCameras(this, it) }+ switch("Plate readers (ALPR)", Prefs.navAvoidPlateReaders(this)) { Prefs.setNavAvoidPlateReaders(this, it) }+ label("Routes go round the cameras of the camera map (Known cameras) where there is a way round, and each route says " ++ "what is left on it. The cameras along the route are fetched first if they are not on the phone (Known cameras > " ++ "Download automatically). A camera right at the start or end, or on the only bridge, can't be avoided. A detour can be longer.",+ small = true)label("Distances in")val units = listOf("auto" to "Automatic (by the phone's region)", "km" to "Kilometres", "mi" to "Miles")@@ -986,6 +1005,16 @@ class SettingsActivity : AppCompatActivity() {setupMapTilt()binding.mapKnownCamerasSwitch.isChecked = Prefs.showKnownAlpr(this)binding.mapKnownCamerasSwitch.setOnCheckedChangeListener { _, on -> Prefs.setShowKnownAlpr(this, on) }+ binding.mapSpeedometerSwitch.isChecked = Prefs.mapSpeedometer(this)+ binding.mapSpeedLimitLiveSwitch.isChecked = Prefs.mapSpeedLimitLive(this)+ binding.mapSpeedLimitLiveSwitch.isEnabled = binding.mapSpeedometerSwitch.isChecked+ binding.mapSpeedometerSwitch.setOnCheckedChangeListener { _, on ->+ Prefs.setMapSpeedometer(this, on); binding.mapSpeedLimitLiveSwitch.isEnabled = on+ }+ binding.mapSpeedLimitLiveSwitch.setOnCheckedChangeListener { _, on ->+ Prefs.setMapSpeedLimitLive(this, on)+ if (!on) com.rfsentinel.app.nav.SpeedLimits.Live.reset()+ }binding.mapTowersSwitch.isChecked = Prefs.showCellTowers(this)binding.mapTowersSwitch.setOnCheckedChangeListener { _, on -> Prefs.setShowCellTowers(this, on) }binding.mapCctvSwitch.isChecked = Prefs.showCctv(this)diff --git a/app/src/main/java/com/rfsentinel/app/ui/MapFragment.kt b/app/src/main/java/com/rfsentinel/app/ui/MapFragment.ktindex e08dd29..8fb8f47 100644--- a/app/src/main/java/com/rfsentinel/app/ui/MapFragment.kt+++ b/app/src/main/java/com/rfsentinel/app/ui/MapFragment.kt@@ -185,7 +185,7 @@ class MapFragment : Fragment() {binding.root.keepScreenOn = on && Prefs.navKeepScreenOn(act)// The Record / Traces bar gives way to the arrival bar while you are being guided.// In the small pane the round buttons stay while guiding: they sit just above the arrival bar.- if (!embedded) { binding.controls.visibility = if (on) View.GONE else View.VISIBLE; layoutBottomInset() }+ if (!embedded) { binding.controls.visibility = if (on || immersive) View.GONE else View.VISIBLE; layoutBottomInset() }if (on) { following = true; userZoom = false; applyMode(animate = true); styleFollowButton() }else { lastZoomTarget = 0.0; applyMode(animate = true) } // the zoom for a turn goes with the guidancerenderLive()@@ -247,6 +247,8 @@ class MapFragment : Fragment() {setupSettingsButton()setupOrientationButton()setupMenu()+ if (!embedded) setupImmersiveButton()+ binding.bottomPanel.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> fitSideButtonsSoon() }// The scale and the map credit sit just under the status banner, or at the very top when there is none.binding.statusBox.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> placeScaleBar() }// Wider than tall: the round buttons become a row and the turn banner leaves them the right side.@@ -628,7 +630,7 @@ class MapFragment : Fragment() {val b = _binding ?: returnif (sidePending) returnsidePending = true- b.root.post { sidePending = false; if (_binding != null) { arrangeForShape(); fitCompactRow(); liftSideButtons(); fitSideButtons(); refollowForPanels() } }+ b.root.post { sidePending = false; if (_binding != null) { arrangeForShape(); fitCompactRow(); liftSideButtons(); fitSideButtons(); placeGauge(); refollowForPanels() } }}/**@@ -757,6 +759,94 @@ class MapFragment : Fragment() {return row.visibility == View.VISIBLE && row.width > 0 && row.width + 10 * d + rightZone > b.root.width}+ // ---- Speedometer -----------------------------------------------------------------------------------++ /** The newest fix from the screen's own GPS (not a position remembered from before). */+ private var gpsFix: Location? = null++ /**+ * Your speed and the posted limit, in the corner. The speed is the GPS's own (hidden when there is no recent+ * fix); the limit comes with the route while you are guided, else from the opt-in lookup of the road you are on.+ */+ private fun updateGauge() {+ val b = _binding ?: return+ val g = b.speedGauge+ val fix = gpsFix+ val fresh = fix != null && fix.hasSpeed() && System.currentTimeMillis() - fix.time < 6_000L+ if (tripId != null || !Prefs.mapSpeedometer(act) || !fresh) {+ if (g.visibility != View.GONE) { g.visibility = View.GONE; fitSideButtonsSoon() }+ return+ }+ val limit = when {+ Navigator.active -> Navigator.speedLimitKmh()+ Prefs.mapSpeedLimitLive(act) -> com.rfsentinel.app.nav.SpeedLimits.Live.now(fix!!.latitude, fix.longitude)+ else -> null+ }+ val wasShown = g.visibility == View.VISIBLE+ g.set(fix!!.speed * 3.6f, limit, com.rfsentinel.app.nav.NavFormat.miles(act), rf?.isDark ?: darkTiles())+ if (!wasShown) fitSideButtonsSoon()+ }++ /**+ * The gauge sits bottom left, just above whatever is at the bottom of the screen on that side: the filter chips, the+ * Record bar, the arrival bar or place card, or the small pane's row of round buttons (which may ride above the arrival+ * bar). Only moved, never resized: no layout pass of its own.+ */+ private fun placeGauge() {+ val b = _binding ?: return+ val g = b.speedGauge+ if (g.visibility != View.VISIBLE || b.root.height == 0) return+ val d = resources.displayMetrics.density+ var top = b.root.height.toFloat() - (if (embedded) 0 else bottomInset)+ for (p in listOf(b.navCard, b.navBar, b.mapFilterScroll, b.controls)) {+ if (p.visibility == View.VISIBLE && p.height > 0) top = minOf(top, (b.bottomPanel.top + p.top).toFloat())+ }+ val row = b.compactControls+ if (row.visibility == View.VISIBLE && row.height > 0) top = minOf(top, row.top + row.translationY)+ g.translationY = -(b.root.height - top + 8 * d)+ }++ // ---- Hiding the bars -------------------------------------------------------------------------------++ private val immersive get() = !embedded && Prefs.mapImmersive(act)++ /** The map's own button (full screen map only): hide the toolbar, the system bars and the bottom bar, or bring them back. */+ private fun setupImmersiveButton() {+ val btn = binding.fullscreenButton+ btn.visibility = View.VISIBLE+ btn.backgroundTintList = android.content.res.ColorStateList.valueOf(0xFFFFFFFF.toInt())+ btn.imageTintList = android.content.res.ColorStateList.valueOf(0xFF0B5C63.toInt())+ btn.setOnClickListener {+ val on = !Prefs.mapImmersive(act)+ Prefs.setMapImmersive(act, on)+ applyImmersive()+ if (on) Toast.makeText(act, "Bars hidden - swipe from the screen's edge for the system bars, tap again to bring the rest back", Toast.LENGTH_LONG).show()+ }+ applyImmersive()+ }++ /**+ * Full screen map hiding even more: the toolbar, the status and navigation bars, the filter chips, the Record bar and the+ * status line go; the map, its round buttons, the speedometer, the alert cards and the turn banner and arrival bar while+ * guiding stay (the credit line too - it is the map's licence).+ */+ private fun applyImmersive() {+ val b = _binding ?: return+ if (embedded) return+ val on = Prefs.mapImmersive(act)+ b.fullscreenButton.setImageResource(if (on) com.rfsentinel.app.R.drawable.ic_fullscreen_exit else com.rfsentinel.app.R.drawable.ic_fullscreen)+ b.fullscreenButton.contentDescription = if (on) "Show the toolbars again" else "Hide the toolbars (full screen)"+ act.supportActionBar?.let { if (on) it.hide() else it.show() }+ val bars = androidx.core.view.WindowCompat.getInsetsController(act.window, b.root)+ bars.systemBarsBehavior = androidx.core.view.WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE+ if (on) bars.hide(WindowInsetsCompat.Type.systemBars()) else bars.show(WindowInsetsCompat.Type.systemBars())+ b.mapFilterScroll.visibility = if (on) View.GONE else View.VISIBLE+ b.controls.visibility = if (on || Navigator.active) View.GONE else View.VISIBLE+ layoutBottomInset()+ renderLive()+ fitSideButtonsSoon()+ }+// ---- Your position --------------------------------------------------------------------------------private fun startLocation() {@@ -781,6 +871,10 @@ class MapFragment : Fragment() {private fun onFix(fix: Location) {if (!alive) returnlastFix = fix+ gpsFix = fix+ if (tripId == null && !Navigator.active && Prefs.mapSpeedometer(act) && Prefs.mapSpeedLimitLive(act) && fix.hasSpeed())+ com.rfsentinel.app.nav.SpeedLimits.Live.onFix(fix.latitude, fix.longitude, fix.speed)+ updateGauge()val m = map?.takeIf { it.puckOn } ?: returnm.pushFix(steady(fix))adaptGpsRate(fix)@@ -1165,7 +1259,8 @@ class MapFragment : Fragment() {}val text = listOfNotNull(status, rf?.cctvLine).joinToString("\n")binding.statusText.text = text- binding.statusText.visibility = if (text.isEmpty()) View.GONE else View.VISIBLE+ binding.statusText.visibility = if (text.isEmpty() || (immersive && !Navigator.active)) View.GONE else View.VISIBLE+ updateGauge()binding.statusText.background.mutate().setTint(if (recording) 0xFFB3261E.toInt() else 0xCC0B5C63.toInt())}diff --git a/app/src/main/java/com/rfsentinel/app/ui/MapNav.kt b/app/src/main/java/com/rfsentinel/app/ui/MapNav.ktindex 5a4840a..a2abaca 100644--- a/app/src/main/java/com/rfsentinel/app/ui/MapNav.kt+++ b/app/src/main/java/com/rfsentinel/app/ui/MapNav.kt@@ -277,7 +277,8 @@ internal class MapNav(val chosen = i == selectedb.navRoutes.addView(MaterialButton(act, null, com.google.android.material.R.attr.materialButtonOutlinedStyle).apply {text = NavFormat.duration(r.durationS) + "\n" + NavFormat.distance(r.distanceM, miles) +- (if (r.summary.isNotBlank()) " · via " + r.summary.substringBefore(',') else "")+ (if (r.summary.isNotBlank()) " · via " + r.summary.substringBefore(',') else "") ++ (r.cameraLine?.let { "\n$it" } ?: "")isAllCaps = falsesetTextColor(if (chosen) onAccent else accent)backgroundTintList = ColorStateList.valueOf(if (chosen) accent else 0x00000000)@@ -310,6 +311,8 @@ internal class MapNav(b.navAvoid.addView(chip("Avoid tolls", options.avoidTolls) { o, v -> o.copy(avoidTolls = v) })b.navAvoid.addView(chip("Avoid highways", options.avoidHighways) { o, v -> o.copy(avoidHighways = v) })b.navAvoid.addView(chip("Avoid ferries", options.avoidFerries) { o, v -> o.copy(avoidFerries = v) })+ b.navAvoid.addView(chip("Avoid speed cameras", options.avoidSpeedCameras) { o, v -> o.copy(avoidSpeedCameras = v) })+ b.navAvoid.addView(chip("Avoid plate readers", options.avoidPlateReaders) { o, v -> o.copy(avoidPlateReaders = v) })}private fun fitRoute(r: Route) {@@ -476,6 +479,8 @@ internal class MapNav(menu.add(0, 3, 2, "Avoid tolls").apply { isCheckable = true; isChecked = Navigator.options.avoidTolls }menu.add(0, 4, 3, "Avoid highways").apply { isCheckable = true; isChecked = Navigator.options.avoidHighways }menu.add(0, 5, 4, "Avoid ferries").apply { isCheckable = true; isChecked = Navigator.options.avoidFerries }+ menu.add(0, 9, 4, "Avoid speed cameras").apply { isCheckable = true; isChecked = Navigator.options.avoidSpeedCameras }+ menu.add(0, 10, 4, "Avoid plate readers").apply { isCheckable = true; isChecked = Navigator.options.avoidPlateReaders }menu.add(0, 6, 5, "Open in Google Maps")menu.add(0, 7, 6, "Open in Waze")menu.add(0, 8, 7, "End navigation")@@ -487,6 +492,8 @@ internal class MapNav(3 -> Navigator.changeOptions(act, Navigator.options.copy(avoidTolls = !Navigator.options.avoidTolls))4 -> Navigator.changeOptions(act, Navigator.options.copy(avoidHighways = !Navigator.options.avoidHighways))5 -> Navigator.changeOptions(act, Navigator.options.copy(avoidFerries = !Navigator.options.avoidFerries))+ 9 -> Navigator.changeOptions(act, Navigator.options.copy(avoidSpeedCameras = !Navigator.options.avoidSpeedCameras))+ 10 -> Navigator.changeOptions(act, Navigator.options.copy(avoidPlateReaders = !Navigator.options.avoidPlateReaders))6 -> dest?.let { HandOff.open(act, it, "google") }7 -> dest?.let { HandOff.open(act, it, "waze") }8 -> Navigator.stop()diff --git a/app/src/main/java/com/rfsentinel/app/ui/SpeedGaugeView.kt b/app/src/main/java/com/rfsentinel/app/ui/SpeedGaugeView.ktnew file mode 100644index 0000000..fed424a--- /dev/null+++ b/app/src/main/java/com/rfsentinel/app/ui/SpeedGaugeView.kt@@ -0,0 +1,113 @@+package com.rfsentinel.app.ui++import android.content.Context+import android.graphics.Canvas+import android.graphics.Paint+import android.graphics.RectF+import android.graphics.Typeface+import android.util.AttributeSet+import android.view.View+import kotlin.math.min+import kotlin.math.roundToInt++/**+ * The map's speedometer: your speed in a rounded card, and beside it the posted limit as a road sign (a red ring,+ * as in most of the world, or a white plate with "SPEED LIMIT" where distances are in miles). Your speed turns red+ * while you are over the limit. Sized from the screen, so it suits a small phone and a tablet alike; draws nothing+ * until it has a speed.+ */+class SpeedGaugeView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : View(context, attrs) {++ private val paint = Paint(Paint.ANTI_ALIAS_FLAG)+ private val box = RectF()+ private var speed: Int? = null+ private var limit: Int? = null+ private var miles = false+ private var dark = false+ private val d = resources.displayMetrics.density++ /** The card's height: about a sixth of the screen's short side, between 52 and 84 dp. */+ private fun unit(): Float {+ val shortSide = min(resources.displayMetrics.widthPixels, resources.displayMetrics.heightPixels)+ return (shortSide / 6.2f).coerceIn(52 * d, 84 * d)+ }++ /** [speedKmh] null = no speed yet (hidden); [limitKmh] null = no limit known (no sign). Both in km/h; shown in mph when [miles]. */+ fun set(speedKmh: Float?, limitKmh: Int?, miles: Boolean, dark: Boolean) {+ val s = speedKmh?.let { (if (miles) it / 1.609344f else it).roundToInt().coerceAtLeast(0) }+ val l = limitKmh?.let { com.rfsentinel.app.nav.SpeedLimits.shown(it, miles) }+ val want = if (s == null) GONE else VISIBLE+ if (visibility != want) visibility = want+ if (s == speed && l == limit && miles == this.miles && dark == this.dark) return+ speed = s; limit = l; this.miles = miles; this.dark = dark+ contentDescription = if (s == null) null else+ "Speed $s ${if (miles) "miles per hour" else "kilometres per hour"}" + (l?.let { ", limit $it" } ?: "")+ requestLayout(); invalidate()+ }++ /** Over the posted limit. */+ internal val over: Boolean get() = speed != null && limit != null && speed!! > limit!!++ override fun onMeasure(widthSpec: Int, heightSpec: Int) {+ val u = unit()+ val w = if (limit != null) u * 1.0f + u * 0.12f + u * 0.92f else u+ setMeasuredDimension(w.toInt() + 1, u.toInt() + 1)+ }++ override fun onDraw(c: Canvas) {+ val s = speed ?: return+ val u = unit()+ val ink = if (dark) 0xFFFFFFFF.toInt() else 0xFF1B1F27.toInt()+ val bg = if (dark) 0xF0222A3A.toInt() else 0xF2FFFFFF.toInt()+ val red = 0xFFD32F2F.toInt()++ // The speed: a rounded card, the number big and the unit small under it.+ box.set(0f, 0f, u, u)+ paint.style = Paint.Style.FILL; paint.color = bg+ c.drawRoundRect(box, u * 0.22f, u * 0.22f, paint)+ paint.style = Paint.Style.STROKE; paint.strokeWidth = (if (over) 3f else 1.5f) * d+ paint.color = if (over) red else if (dark) 0x55FFFFFF else 0x33000000+ c.drawRoundRect(box, u * 0.22f, u * 0.22f, paint)+ paint.style = Paint.Style.FILL+ paint.typeface = Typeface.create(Typeface.DEFAULT, Typeface.BOLD)+ paint.textAlign = Paint.Align.CENTER+ paint.color = if (over) red else ink+ paint.textSize = u * (if (s >= 100) 0.40f else 0.48f)+ c.drawText(s.toString(), u / 2, u * 0.56f, paint)+ paint.typeface = Typeface.DEFAULT+ paint.color = ink; paint.alpha = 170+ paint.textSize = u * 0.17f+ c.drawText(if (miles) "mph" else "km/h", u / 2, u * 0.82f, paint)+ paint.alpha = 255++ val l = limit ?: return+ val x0 = u + u * 0.12f+ val sign = u * 0.92f+ val cx = x0 + sign / 2; val cy = u / 2+ paint.typeface = Typeface.create(Typeface.DEFAULT, Typeface.BOLD)+ if (!miles) {+ // The round sign: white, a thick red ring, the number.+ paint.style = Paint.Style.FILL; paint.color = 0xFFFFFFFF.toInt()+ c.drawCircle(cx, cy, sign / 2, paint)+ paint.style = Paint.Style.STROKE; paint.strokeWidth = sign * 0.13f; paint.color = red+ c.drawCircle(cx, cy, sign / 2 - sign * 0.065f, paint)+ paint.style = Paint.Style.FILL; paint.color = 0xFF111111.toInt()+ paint.textSize = sign * (if (l >= 100) 0.36f else 0.44f)+ c.drawText(l.toString(), cx, cy + paint.textSize * 0.35f, paint)+ } else {+ // The plate: white, a black border, "SPEED LIMIT" over the number.+ val h = sign * 1.0f; val w = sign * 0.82f+ box.set(cx - w / 2, cy - h / 2, cx + w / 2, cy + h / 2)+ paint.style = Paint.Style.FILL; paint.color = 0xFFFFFFFF.toInt()+ c.drawRoundRect(box, sign * 0.1f, sign * 0.1f, paint)+ paint.style = Paint.Style.STROKE; paint.strokeWidth = sign * 0.045f; paint.color = 0xFF111111.toInt()+ c.drawRoundRect(box, sign * 0.1f, sign * 0.1f, paint)+ paint.style = Paint.Style.FILL; paint.color = 0xFF111111.toInt()+ paint.textSize = sign * 0.14f+ c.drawText("SPEED", cx, box.top + h * 0.22f, paint)+ c.drawText("LIMIT", cx, box.top + h * 0.35f, paint)+ paint.textSize = sign * 0.46f+ c.drawText(l.toString(), cx, box.top + h * 0.80f, paint)+ }+ }+}diff --git a/app/src/main/java/com/rfsentinel/app/util/Prefs.kt b/app/src/main/java/com/rfsentinel/app/util/Prefs.ktindex 5cc3b64..9e0a2c3 100644--- a/app/src/main/java/com/rfsentinel/app/util/Prefs.kt+++ b/app/src/main/java/com/rfsentinel/app/util/Prefs.kt@@ -346,6 +346,11 @@ object Prefs {fun setNavAvoidHighways(context: Context, v: Boolean) = setBool(context, "nav_avoid_highways", v)fun navAvoidFerries(context: Context): Boolean = bool(context, "nav_avoid_ferries", false)fun setNavAvoidFerries(context: Context, v: Boolean) = setBool(context, "nav_avoid_ferries", v)+ /** Routes go round the known speed cameras / plate readers (the camera map's), where there is a way round. */+ fun navAvoidSpeedCameras(context: Context): Boolean = bool(context, "nav_avoid_speed_cameras", false)+ fun setNavAvoidSpeedCameras(context: Context, v: Boolean) = setBool(context, "nav_avoid_speed_cameras", v)+ fun navAvoidPlateReaders(context: Context): Boolean = bool(context, "nav_avoid_plate_readers", false)+ fun setNavAvoidPlateReaders(context: Context, v: Boolean) = setBool(context, "nav_avoid_plate_readers", v)/** Distance units for guidance: "auto" (miles where the phone's region uses them), "km" or "mi". */fun navUnits(context: Context): String = sp(context).getString("nav_units", "auto") ?: "auto"fun setNavUnits(context: Context, v: String) = sp(context).edit { putString("nav_units", v) }@@ -560,6 +565,20 @@ object Prefs {sp(context).getFloat("map_3d_tilt", MAP_TILT_DEFAULT.toFloat()).toDouble().coerceIn(30.0, 60.0)fun setMap3dTilt(context: Context, value: Double) = sp(context).edit().putFloat("map_3d_tilt", value.toFloat()).apply()+ /** The speedometer in the corner of the live map: your speed, and the posted limit while it is known. */+ fun mapSpeedometer(context: Context): Boolean = bool(context, "map_speedometer", true)+ fun setMapSpeedometer(context: Context, value: Boolean) = setBool(context, "map_speedometer", value)+ /**+ * The posted limit when you are not navigating: asks the route server about the road you are on every ~12 s+ * while you drive (so it learns where you drive, unlike every other map feature) - off until you turn it on.+ * While guided the limits come with the route either way.+ */+ fun mapSpeedLimitLive(context: Context): Boolean = bool(context, "map_speed_limit_live", false)+ fun setMapSpeedLimitLive(context: Context, value: Boolean) = setBool(context, "map_speed_limit_live", value)+ /** The full screen map with the toolbar, the system bars and the bottom bar hidden (the button on the map). */+ fun mapImmersive(context: Context): Boolean = bool(context, "map_immersive", false)+ fun setMapImmersive(context: Context, value: Boolean) = setBool(context, "map_immersive", value)+/** The map's provider ("openfreemap", the default, or "mapbox"), Settings > Map. */fun mapProvider(context: Context): String? = sp(context).getString("map_provider", null)fun setMapProvider(context: Context, value: String) = sp(context).edit().putString("map_provider", value).apply()diff --git a/app/src/main/java/com/rfsentinel/app/util/UpdateChecker.kt b/app/src/main/java/com/rfsentinel/app/util/UpdateChecker.ktindex 89d27ca..39c7f28 100644--- a/app/src/main/java/com/rfsentinel/app/util/UpdateChecker.kt+++ b/app/src/main/java/com/rfsentinel/app/util/UpdateChecker.kt@@ -23,7 +23,8 @@ object UpdateChecker {private const val API = "https://api.github.com/repos/CIS-C0/RFSentinel/releases/latest"private const val RELEASES = "https://github.com/CIS-C0/RFSentinel/releases/latest"- data class Latest(val version: String, val apkUrl: String?, val notesUrl: String)+ /** The newest release: its version, the APK's link, size and SHA-256 (as GitHub lists them) and the notes page. */+ data class Latest(val version: String, val apkUrl: String?, val notesUrl: String, val apkSize: Long = 0L, val apkSha256: String? = null)/** True when [a] is a newer dotted version than [b] ("2.11.1" > "2.11.0"). */fun isNewer(a: String, b: String): Boolean {@@ -36,6 +37,21 @@ object UpdateChecker {return false}+ /** The newest release from GitHub's answer: version, the "-release.apk" asset with its size and SHA-256, the notes page. */+ internal fun parseLatest(text: String): Latest {+ val json = JSONObject(text)+ val assets = json.optJSONArray("assets")+ var apk: String? = null; var size = 0L; var sha: String? = null+ if (assets != null) for (i in 0 until assets.length()) {+ val a = assets.getJSONObject(i)+ if (a.optString("name").endsWith("-release.apk")) {+ apk = a.optString("browser_download_url"); size = a.optLong("size", 0L)+ sha = a.optString("digest").takeIf { it.startsWith("sha256:") }?.removePrefix("sha256:")+ }+ }+ return Latest(json.getString("tag_name").trimStart('v'), apk, json.optString("html_url", RELEASES), size, sha)+ }+private fun fetch(): Latest {val conn = (URL(API).openConnection() as HttpURLConnection).apply {connectTimeout = 10_000; readTimeout = 10_000@@ -44,37 +60,41 @@ object UpdateChecker {}try {if (conn.responseCode != 200) throw IllegalStateException("GitHub answered ${conn.responseCode}")- val json = JSONObject(conn.inputStream.bufferedReader().use { it.readText() })- val assets = json.optJSONArray("assets")- var apk: String? = null- if (assets != null) for (i in 0 until assets.length()) {- val a = assets.getJSONObject(i)- if (a.optString("name").endsWith("-release.apk")) apk = a.optString("browser_download_url")- }- return Latest(json.getString("tag_name").trimStart('v'), apk, json.optString("html_url", RELEASES))+ return parseLatest(conn.inputStream.bufferedReader().use { it.readText() })} finally {conn.disconnect()}}private const val AUTO_INTERVAL_MS = 6 * 60 * 60 * 1000L+ /** After a check that couldn't reach GitHub (no signal...), the next one is this soon, not a whole interval later. */+ private const val RETRY_MS = 30 * 60 * 1000L+ @Volatile private var checking = false/**- * The startup check (Settings / setup wizard toggle): at most every 6 hours, and silent- * unless a newer version is out - no "checking", "up to date" or connection-error messages.+ * The startup check (Settings / setup wizard toggle), for every time the app comes to the front (the main+ * screen often stays alive for days, so "opening" it is not a fresh start): at most every 6 hours - a+ * check that couldn't reach GitHub is tried again after 30 minutes - and silent unless a newer version+ * is out: no "checking", "up to date" or connection-error messages.*/fun checkOnStartup(activity: AppCompatActivity) {- if (!Prefs.autoUpdateCheck(activity)) return- val now = System.currentTimeMillis()- if (now - Prefs.lastUpdateCheck(activity) < AUTO_INTERVAL_MS) return- Prefs.setLastUpdateCheck(activity, now)+ if (!Prefs.autoUpdateCheck(activity) || checking) return+ if (!due(Prefs.lastUpdateCheck(activity), System.currentTimeMillis())) returncheck(activity, silent = true)}+ /** Whether the automatic check is due: [last] is when the last one ended (0 = never). */+ internal fun due(last: Long, now: Long) = now - last >= AUTO_INTERVAL_MS || now < last+fun check(activity: AppCompatActivity, silent: Boolean = false) {if (!silent) Toast.makeText(activity, "Checking for updates…", Toast.LENGTH_SHORT).show()+ if (checking) return+ checking = trueactivity.lifecycleScope.launch {- val result = withContext(Dispatchers.IO) { runCatching { fetch() } }+ val result = try { withContext(Dispatchers.IO) { runCatching { fetch() } } } finally { checking = false }+ // Reached GitHub: the next automatic check is an interval away; not reached: soon.+ val now = System.currentTimeMillis()+ Prefs.setLastUpdateCheck(activity, if (result.isSuccess) now else now - AUTO_INTERVAL_MS + RETRY_MS)if (activity.isFinishing || activity.isDestroyed) return@launchif (silent && result.isFailure) return@launchval latest = result.getOrElse {@@ -90,8 +110,9 @@ object UpdateChecker {if (isNewer(latest.version, current)) {AlertDialog.Builder(activity).setTitle("RF Sentinel ${latest.version} is available")- .setMessage("You have $current. Download the new APK and install it over this one - your history and settings are kept.")- .setPositiveButton("Download") { _, _ -> download(activity, latest) }+ .setMessage("You have $current. It downloads here and installs over this one - your history and settings are kept. " ++ "Scanning stops while it installs.")+ .setPositiveButton("Install now") { _, _ -> installNow(activity, latest) }.setNeutralButton("What's new") { _, _ -> open(activity, latest.notesUrl) }.setNegativeButton("Later", null).show()@@ -106,24 +127,91 @@ object UpdateChecker {}/**- * Downloads the APK with Android's download manager into Downloads. Handing the APK link- * to the browser instead stalls at 100% in Chrome: a download started by another app- * waits on Chrome's "this file can be harmful" check, whose prompt never shows. Tapping- * the finished-download notification opens the installer. Falls back to the browser.+ * One button: allow installs from this app if Android hasn't been told to yet (it opens that switch and carries+ * on when you are back), download the release with a progress bar, check it, and hand it to Android's installer+ * (its "Update?" card, which is the one tap left). The ordinary download in the browser stays as the fallback.*/- private fun download(activity: AppCompatActivity, latest: Latest) {+ fun installNow(activity: AppCompatActivity, latest: Latest) {val url = latest.apkUrl ?: return open(activity, latest.notesUrl)- val queued = runCatching {- val dm = activity.getSystemService(android.app.DownloadManager::class.java)!!- dm.enqueue(android.app.DownloadManager.Request(Uri.parse(url))- .setTitle("RF Sentinel ${latest.version}")- .setDescription("Update - tap when done to install")- .setMimeType("application/vnd.android.package-archive")- .setNotificationVisibility(android.app.DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)- .setDestinationInExternalPublicDir(android.os.Environment.DIRECTORY_DOWNLOADS, url.substringAfterLast('/')))- }.isSuccess- if (queued) Toast.makeText(activity, "Downloading RF Sentinel ${latest.version}… when it's done, tap its notification (or the file in Downloads) to install", Toast.LENGTH_LONG).show()- else open(activity, url)+ if (!UpdateInstaller.canInstall(activity)) { askToAllowInstalls(activity, latest); return }++ val d = activity.resources.displayMetrics.density+ val text = android.widget.TextView(activity).apply { text = "Starting the download..." }+ val bar = com.google.android.material.progressindicator.LinearProgressIndicator(activity).apply { isIndeterminate = true }+ val box = android.widget.LinearLayout(activity).apply {+ orientation = android.widget.LinearLayout.VERTICAL+ setPadding((24 * d).toInt(), (16 * d).toInt(), (24 * d).toInt(), (8 * d).toInt())+ addView(text); addView(bar, android.widget.LinearLayout.LayoutParams(-1, -2).apply { topMargin = (12 * d).toInt() })+ }+ var job: kotlinx.coroutines.Job? = null+ val dialog = AlertDialog.Builder(activity)+ .setTitle("Updating to RF Sentinel ${latest.version}")+ .setView(box)+ .setCancelable(false)+ .setNegativeButton("Cancel") { _, _ -> job?.cancel() }+ .show()+ fun alive() = !activity.isFinishing && !activity.isDestroyed+ fun mb(n: Long) = "%.1f MB".format(java.util.Locale.US, n / 1_048_576.0)+ job = (activity.application as com.rfsentinel.app.RFSentinelApp).appScope.launch(Dispatchers.Main) {+ try {+ val file = UpdateInstaller.download(activity.applicationContext, url, latest.version, latest.apkSize, latest.apkSha256) { done, total ->+ if (alive()) activity.runOnUiThread {+ if (total > 0) {+ bar.isIndeterminate = false; bar.max = 1000; bar.progress = (done * 1000 / total).toInt()+ text.text = "Downloading ${mb(done)} of ${mb(total)}"+ } else text.text = "Downloading ${mb(done)}"+ }+ }+ if (alive()) { bar.isIndeterminate = true; text.text = "Installing... confirm Android's \"Update\" card" }+ val outcome = UpdateInstaller.install(activity.applicationContext, file)+ if (alive()) dialog.dismiss()+ when (outcome) {+ is UpdateInstaller.Outcome.Cancelled -> if (alive()) Toast.makeText(activity,+ "Update cancelled - tap Check for updates to try again", Toast.LENGTH_LONG).show()+ is UpdateInstaller.Outcome.Failed -> if (alive()) failed(activity, latest, outcome.message)+ is UpdateInstaller.Outcome.Refused -> if (alive()) failed(activity, latest, "Android didn't take the update")+ else -> {} // installed: the app is replaced, or Refused twice (shown as a failure by the second try)+ }+ } catch (e: kotlinx.coroutines.CancellationException) {+ if (alive()) { dialog.dismiss(); Toast.makeText(activity, "Update cancelled", Toast.LENGTH_SHORT).show() }+ UpdateInstaller.cleanUp(activity.applicationContext)+ } catch (e: Exception) {+ if (alive()) { dialog.dismiss(); failed(activity, latest, e.message ?: "no connection") }+ }+ }+ }++ private fun failed(activity: AppCompatActivity, latest: Latest, why: String) {+ AlertDialog.Builder(activity)+ .setTitle("Couldn't install the update")+ .setMessage("$why\n\nYou can download RF Sentinel ${latest.version} from GitHub and install it yourself.")+ .setPositiveButton("Open release page") { _, _ -> open(activity, latest.notesUrl) }+ .setNegativeButton("Close", null)+ .show()+ }++ /** Android asks each app to be allowed to install apps: one switch, then the update carries on from here. */+ private fun askToAllowInstalls(activity: AppCompatActivity, latest: Latest) {+ AlertDialog.Builder(activity)+ .setTitle("Allow RF Sentinel to install updates")+ .setMessage("Android needs you to allow this once: it opens a switch called \"Allow from this source\". " ++ "Turn it on, come back, and the update starts by itself. Nothing else is installed this way.")+ .setPositiveButton("Open the switch") { _, _ ->+ var left = false+ activity.lifecycle.addObserver(object : androidx.lifecycle.DefaultLifecycleObserver {+ override fun onStop(owner: androidx.lifecycle.LifecycleOwner) { left = true }+ override fun onStart(owner: androidx.lifecycle.LifecycleOwner) {+ if (!left) return+ activity.lifecycle.removeObserver(this)+ if (UpdateInstaller.canInstall(activity)) installNow(activity, latest)+ else Toast.makeText(activity, "Not allowed - the update wasn't started", Toast.LENGTH_LONG).show()+ }+ })+ runCatching { activity.startActivity(UpdateInstaller.allowInstallsIntent(activity)) }+ }+ .setNeutralButton("Download in the browser") { _, _ -> open(activity, latest.apkUrl ?: latest.notesUrl) }+ .setNegativeButton("Later", null)+ .show()}private fun open(activity: AppCompatActivity, url: String) {diff --git a/app/src/main/java/com/rfsentinel/app/util/UpdateInstaller.kt b/app/src/main/java/com/rfsentinel/app/util/UpdateInstaller.ktnew file mode 100644index 0000000..9724107--- /dev/null+++ b/app/src/main/java/com/rfsentinel/app/util/UpdateInstaller.kt@@ -0,0 +1,239 @@+package com.rfsentinel.app.util++import android.app.NotificationChannel+import android.app.NotificationManager+import android.app.PendingIntent+import android.content.BroadcastReceiver+import android.content.Context+import android.content.Intent+import android.content.pm.PackageInstaller+import android.content.pm.PackageManager+import android.net.Uri+import android.os.Build+import android.os.Process+import android.provider.Settings+import androidx.core.app.NotificationCompat+import com.rfsentinel.app.BuildConfig+import com.rfsentinel.app.R+import com.rfsentinel.app.RFSentinelApp+import kotlinx.coroutines.CompletableDeferred+import kotlinx.coroutines.Dispatchers+import kotlinx.coroutines.currentCoroutineContext+import kotlinx.coroutines.ensureActive+import kotlinx.coroutines.withContext+import java.io.File+import java.net.HttpURLConnection+import java.net.URL+import java.security.MessageDigest+import java.util.concurrent.ConcurrentHashMap++/**+ * Downloads a new release and installs it over this app in one go, the way open-source app managers+ * (Obtainium, Morphe Manager...) do: the APK is fetched into the app's own cache, checked, written into an+ * Android PackageInstaller session and committed. Android then shows its usual "Update this app?" card+ * (or none, where it lets the app that installed it update itself), and replaces the app.+ *+ * Needs Android's "Install unknown apps" allowed for RF Sentinel ([canInstall], [allowInstallsIntent]).+ */+object UpdateInstaller {++ private const val ACTION_STATUS = "com.rfsentinel.app.UPDATE_INSTALL_STATUS"+ private const val CHANNEL = "updates"+ private const val NOTIFICATION_ID = 4120++ /** How an install ended. */+ sealed class Outcome {+ object Installed : Outcome()+ /** The "Update?" card was dismissed. */+ object Cancelled : Outcome()+ /** Android refused an update without its card (some phones do): ask again with the card. */+ object Refused : Outcome()+ class Failed(val message: String) : Outcome()+ }++ private val waiting = ConcurrentHashMap<Int, CompletableDeferred<Outcome>>()+ private val cardShown = ConcurrentHashMap.newKeySet<Int>()++ // ---- permission ----------------------------------------------------------------------------------++ fun canInstall(context: Context): Boolean = context.packageManager.canRequestPackageInstalls()++ /** Android's "Install unknown apps" switch for this app. */+ fun allowInstallsIntent(context: Context): Intent =+ Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, Uri.parse("package:${context.packageName}")).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)++ // ---- the download -----------------------------------------------------------------------------------++ private fun dir(context: Context) = File(context.cacheDir, "updates")++ /** Drops downloaded updates left over (the app starts fresh after an install, or a download was cut off). */+ fun cleanUp(context: Context) {+ runCatching { dir(context).listFiles()?.forEach { it.delete() } }+ }++ /**+ * Fetches [url] into the app's cache and checks it: the size and SHA-256 GitHub lists for the file, and that+ * it is this app, newer than the one installed, and signed by the same key (so a wrong file stops here, with+ * a reason, instead of at Android's installer). [onProgress] gets bytes so far and the total (0 = unknown).+ */+ suspend fun download(context: Context, url: String, version: String, expectedSize: Long, sha256: String?,+ onProgress: (Long, Long) -> Unit): File = withContext(Dispatchers.IO) {+ val folder = dir(context).apply { mkdirs() }+ folder.listFiles()?.forEach { it.delete() }+ val part = File(folder, "RFSentinel-$version.apk.part")+ val file = File(folder, "RFSentinel-$version.apk")+ val c = (URL(url).openConnection() as HttpURLConnection).apply {+ connectTimeout = 15_000; readTimeout = 30_000+ instanceFollowRedirects = true+ setRequestProperty("User-Agent", "${BuildConfig.APPLICATION_ID}/${BuildConfig.VERSION_NAME}")+ }+ try {+ if (c.responseCode != 200) throw IllegalStateException("The download server answered ${c.responseCode}")+ val total = c.contentLengthLong.takeIf { it > 0 } ?: expectedSize+ val sum = MessageDigest.getInstance("SHA-256")+ var done = 0L; var lastReport = 0L+ c.inputStream.use { input ->+ part.outputStream().use { out ->+ val buf = ByteArray(64 * 1024)+ while (true) {+ currentCoroutineContext().ensureActive()+ val n = input.read(buf)+ if (n < 0) break+ out.write(buf, 0, n); sum.update(buf, 0, n); done += n+ val now = System.currentTimeMillis()+ if (now - lastReport > 150) { lastReport = now; onProgress(done, total) }+ }+ }+ }+ onProgress(done, total)+ if (expectedSize > 0 && done != expectedSize) throw IllegalStateException("The download was cut short ($done of $expectedSize bytes)")+ val hex = sum.digest().joinToString("") { "%02x".format(it) }+ if (sha256 != null && !hex.equals(sha256, ignoreCase = true)) throw IllegalStateException("The download doesn't match the checksum GitHub lists for it")+ if (!part.renameTo(file)) throw IllegalStateException("Couldn't keep the downloaded file")+ checkArchive(context, file)?.let { file.delete(); throw IllegalStateException(it) }+ file+ } catch (e: Throwable) {+ part.delete()+ throw e+ } finally {+ c.disconnect()+ }+ }++ /** Why this APK can't be installed over the app, in words; null when it can. */+ @Suppress("DEPRECATION")+ internal fun checkArchive(context: Context, apk: File): String? {+ val pm = context.packageManager+ val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) PackageManager.GET_SIGNING_CERTIFICATES else PackageManager.GET_SIGNATURES+ val archive = pm.getPackageArchiveInfo(apk.path, flags) ?: return "The downloaded file isn't a valid app"+ if (archive.packageName != context.packageName) return "The downloaded file is a different app (${archive.packageName})"+ val mine = runCatching { pm.getPackageInfo(context.packageName, flags) }.getOrNull() ?: return null+ val newer = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) archive.longVersionCode > mine.longVersionCode else archive.versionCode > mine.versionCode+ if (!newer) return "The downloaded version isn't newer than the one installed"+ val a = signers(archive); val b = signers(mine)+ if (a.isNotEmpty() && b.isNotEmpty() && a != b) return "The downloaded file is signed with a different key than this app, so Android would refuse it"+ return null+ }++ @Suppress("DEPRECATION")+ private fun signers(info: android.content.pm.PackageInfo): Set<String> =+ (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) info.signingInfo?.apkContentsSigners else info.signatures)+ ?.map { it.toCharsString() }?.toSet().orEmpty()++ // ---- the install ------------------------------------------------------------------------------------++ /**+ * Installs [apk] over this app. Where Android allows it (12+, an app that installed itself before) the update+ * goes through without a card; a phone that refuses that is asked again the ordinary way. Suspends until the+ * card is answered - when the install succeeds the app is replaced and this never returns.+ */+ suspend fun install(context: Context, apk: File): Outcome {+ val first = commit(context.applicationContext, apk, requireUserAction = false)+ return if (first is Outcome.Refused) commit(context.applicationContext, apk, requireUserAction = true) else first+ }++ private suspend fun commit(app: Context, apk: File, requireUserAction: Boolean): Outcome {+ val installer = app.packageManager.packageInstaller+ val params = PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL).apply {+ setAppPackageName(app.packageName)+ setSize(apk.length())+ setOriginatingUid(Process.myUid())+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) setRequireUserAction(+ if (requireUserAction) PackageInstaller.SessionParams.USER_ACTION_REQUIRED else PackageInstaller.SessionParams.USER_ACTION_NOT_REQUIRED)+ }+ val id = installer.createSession(params)+ val result = CompletableDeferred<Outcome>()+ waiting[id] = result+ if (requireUserAction) cardShown += id+ try {+ withContext(Dispatchers.IO) {+ installer.openSession(id).use { session ->+ session.openWrite("base.apk", 0, apk.length()).use { out ->+ apk.inputStream().use { it.copyTo(out) }+ session.fsync(out)+ }+ val intent = Intent(app, UpdateStatusReceiver::class.java).setAction(ACTION_STATUS)+ val pending = PendingIntent.getBroadcast(app, id, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE)+ session.commit(pending.intentSender)+ }+ }+ return result.await()+ } catch (e: Throwable) {+ runCatching { installer.abandonSession(id) }+ throw e+ } finally {+ waiting.remove(id); cardShown.remove(id)+ runCatching { app.getSystemService(NotificationManager::class.java).cancel(NOTIFICATION_ID) }+ }+ }++ /** Android's answer for a session (from [UpdateStatusReceiver]). */+ internal fun onStatus(context: Context, intent: Intent) {+ val id = intent.getIntExtra(PackageInstaller.EXTRA_SESSION_ID, -1)+ val status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, PackageInstaller.STATUS_FAILURE)+ val message = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE)+ if (status == PackageInstaller.STATUS_PENDING_USER_ACTION) {+ cardShown += id+ @Suppress("DEPRECATION")+ val card = (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) intent.getParcelableExtra(Intent.EXTRA_INTENT, Intent::class.java)+ else intent.getParcelableExtra(Intent.EXTRA_INTENT)) ?: return+ showCard(context.applicationContext, card)+ return+ }+ outcomeOf(status, message, id in cardShown)?.let { waiting[id]?.complete(it) }+ }++ /** What an install status means; null while Android is still waiting for the card to be answered. */+ internal fun outcomeOf(status: Int, message: String?, cardWasShown: Boolean): Outcome? = when (status) {+ PackageInstaller.STATUS_PENDING_USER_ACTION -> null+ PackageInstaller.STATUS_SUCCESS -> Outcome.Installed+ PackageInstaller.STATUS_FAILURE_ABORTED -> if (cardWasShown) Outcome.Cancelled else Outcome.Refused+ PackageInstaller.STATUS_FAILURE_CONFLICT, PackageInstaller.STATUS_FAILURE_INCOMPATIBLE ->+ Outcome.Failed(friendly(message) ?: "Android says this file doesn't fit the installed app (a different signing key or an older version)")+ PackageInstaller.STATUS_FAILURE_BLOCKED, PackageInstaller.STATUS_FAILURE_STORAGE ->+ Outcome.Failed(friendly(message) ?: "Android blocked the install or has no room for it")+ else -> Outcome.Failed(friendly(message) ?: "The install failed")+ }++ private fun friendly(message: String?) = message?.takeIf { it.isNotBlank() && !it.startsWith("INSTALL_") }++ /** Android's "Update?" card: straight away while the app is on screen, else as a notification to tap. */+ private fun showCard(app: Context, card: Intent) {+ if (RFSentinelApp.inForeground) {+ runCatching { app.startActivity(card.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); return }+ }+ val nm = app.getSystemService(NotificationManager::class.java) ?: return+ nm.createNotificationChannel(NotificationChannel(CHANNEL, "App updates", NotificationManager.IMPORTANCE_HIGH))+ val tap = PendingIntent.getActivity(app, 0, card.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)+ nm.notify(NOTIFICATION_ID, NotificationCompat.Builder(app, CHANNEL)+ .setSmallIcon(R.drawable.ic_tile_scan)+ .setContentTitle("RF Sentinel update is ready")+ .setContentText("Tap to install it")+ .setContentIntent(tap).setAutoCancel(true).setPriority(NotificationCompat.PRIORITY_HIGH).build())+ }+}++/** Receives Android's answers about the update install session. */+class UpdateStatusReceiver : BroadcastReceiver() {+ override fun onReceive(context: Context, intent: Intent) = UpdateInstaller.onStatus(context, intent)+}diff --git a/app/src/main/res/drawable/ic_fullscreen_exit.xml b/app/src/main/res/drawable/ic_fullscreen_exit.xmlnew file mode 100644index 0000000..d640b85--- /dev/null+++ b/app/src/main/res/drawable/ic_fullscreen_exit.xml@@ -0,0 +1,11 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Material Design icon "fullscreen_exit", Apache-2.0: bring the map's bars back. -->+<vector xmlns:android="http://schemas.android.com/apk/res/android"+ android:width="24dp"+ android:height="24dp"+ android:viewportWidth="24"+ android:viewportHeight="24">+ <path+ android:fillColor="#FFFFFF"+ android:pathData="M5,16h3v3h2v-5L5,14v2zM8,8L5,8v2h5L10,5L8,5v3zM14,19h2v-3h3v-2h-5v5zM16,8L16,5h-2v5h5L19,8h-3z" />+</vector>diff --git a/app/src/main/res/layout/activity_map.xml b/app/src/main/res/layout/activity_map.xmlindex 750efbc..3d90d29 100644--- a/app/src/main/res/layout/activity_map.xml+++ b/app/src/main/res/layout/activity_map.xml@@ -589,6 +589,15 @@</LinearLayout></LinearLayout>+ <!-- Your speed and the posted limit, bottom left just above the bottom panels (placed in code, placeGauge). -->+ <com.rfsentinel.app.ui.SpeedGaugeView+ android:id="@+id/speedGauge"+ android:layout_width="wrap_content"+ android:layout_height="wrap_content"+ android:layout_gravity="bottom|start"+ android:layout_marginStart="10dp"+ android:visibility="gone" />+<!-- On the main screen: Record / Traces as round buttons on the map (the bar above is hidden). --><LinearLayoutandroid:id="@+id/compactControls"diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xmlindex 55cf391..8f70454 100644--- a/app/src/main/res/layout/activity_settings.xml+++ b/app/src/main/res/layout/activity_settings.xml@@ -497,6 +497,18 @@android:layout_height="wrap_content"android:text="Show plate, speed and red-light cameras" />+ <com.google.android.material.switchmaterial.SwitchMaterial+ android:id="@+id/mapSpeedometerSwitch"+ android:layout_width="match_parent"+ android:layout_height="wrap_content"+ android:text="Speedometer on the map (your speed and the posted limit)" />++ <com.google.android.material.switchmaterial.SwitchMaterial+ android:id="@+id/mapSpeedLimitLiveSwitch"+ android:layout_width="match_parent"+ android:layout_height="wrap_content"+ android:text="Posted limit when not navigating (asks the route server about your road)" />+<com.google.android.material.switchmaterial.SwitchMaterialandroid:id="@+id/mapTowersSwitch"android:layout_width="match_parent"diff --git a/app/src/test/java/com/rfsentinel/app/nav/CameraAvoidTest.kt b/app/src/test/java/com/rfsentinel/app/nav/CameraAvoidTest.ktnew file mode 100644index 0000000..bc16311--- /dev/null+++ b/app/src/test/java/com/rfsentinel/app/nav/CameraAvoidTest.kt@@ -0,0 +1,272 @@+package com.rfsentinel.app.nav++import com.rfsentinel.app.alpr.KnownCamera+import com.rfsentinel.app.alpr.KnownCamera.Kind+import com.rfsentinel.app.online.RoadMatch+import com.rfsentinel.app.service.DeviceRegistry+import kotlinx.coroutines.runBlocking+import org.junit.Assert.assertEquals+import org.junit.Assert.assertFalse+import org.junit.Assert.assertNotNull+import org.junit.Assert.assertNull+import org.junit.Assert.assertTrue+import org.junit.Test+import org.junit.runner.RunWith+import org.robolectric.RobolectricTestRunner+import org.robolectric.annotation.Config++/**+ * Routes around known cameras. Roads are drawn in metres east / north of an arbitrary point: the main road runs+ * north along x = 0, the way round is the same road with a stretch moved 300 m east.+ */+@RunWith(RobolectricTestRunner::class)+@Config(sdk = [35], application = android.app.Application::class)+class CameraAvoidTest {++ private val frame = RoadMatch.Frame(10.0, 20.0)+ private val plate = setOf(Kind.ALPR)++ /** A route through these (east, north) points in metres, no steps. */+ private fun route(vararg pts: Pair<Double, Double>): Route {+ val ll = pts.map { (x, y) -> frame.toLatLon(x, y) }+ val lats = ll.map { it.first }.toDoubleArray(); val lons = ll.map { it.second }.toDoubleArray()+ val along = DoubleArray(lats.size)+ for (i in 1 until lats.size) along[i] = along[i - 1] + DeviceRegistry.metersBetween(lats[i - 1], lons[i - 1], lats[i], lons[i])+ return Route(lats, lons, along, along.last(), along.last() / 15.0, emptyList(), "", lats.last() to lons.last())+ }++ /** The main road: 3 km north along x = 0, a point every 50 m. */+ private fun main() = route(*(0..60).map { 0.0 to it * 50.0 }.toTypedArray())++ /** The same road, but with [from]..[to] metres of it taken 300 m to the east. */+ private fun roundIt(from: Double, to: Double): Route {+ val pts = ArrayList<Pair<Double, Double>>()+ for (k in 0..60) {+ val y = k * 50.0+ pts += (if (y in from..to) 300.0 else 0.0) to y+ }+ return route(*pts.toTypedArray())+ }++ private fun camera(id: String, x: Double, y: Double, kind: Kind = Kind.ALPR): KnownCamera {+ val (la, lo) = frame.toLatLon(x, y)+ return KnownCamera(id, la, lo, null, null, null, kind)+ }++ private fun near(p: Pair<Double, Double>, x: Double, y: Double, within: Double = 30.0): Boolean {+ val (la, lo) = frame.toLatLon(x, y)+ return DeviceRegistry.metersBetween(p.first, p.second, la, lo) <= within+ }++ // ---- finding the cameras on a route ----------------------------------------------------------++ @Test+ fun camerasOnTheLineAreFoundInOrderAndOthersAreNot() {+ val cams = listOf(camera("far", 120.0, 700.0), camera("b", 8.0, 1500.0), camera("a", -10.0, 400.0),+ camera("speed", 3.0, 900.0, Kind.SPEED))+ val found = CameraAvoid.hits(main(), cams, plate)+ assertEquals(listOf("a", "b"), found.map { it.camera.osmId })+ assertEquals(400.0, found[0].alongM, 3.0)+ assertEquals(10.0, found[0].distM, 1.0)+ assertEquals(listOf("speed"), CameraAvoid.hits(main(), cams, setOf(Kind.SPEED)).map { it.camera.osmId })+ assertEquals(4 - 1, CameraAvoid.hits(main(), cams, setOf(Kind.ALPR, Kind.SPEED)).size)+ assertTrue(CameraAvoid.hits(main(), cams, emptySet()).isEmpty())+ }++ @Test+ fun aCameraJustOutsideTheRadiusIsNotOnTheRoute() {+ assertTrue(CameraAvoid.hits(main(), listOf(camera("c", 40.0, 500.0)), plate).isEmpty())+ assertEquals(1, CameraAvoid.hits(main(), listOf(camera("c", 20.0, 500.0)), plate).size)+ }++ @Test+ fun anOldCacheEntryWithoutAKindIsAPlateReader() {+ val (la, lo) = frame.toLatLon(0.0, 500.0)+ val old = KnownCamera("old", la, lo, null, null, null, kind = null)+ assertEquals(1, CameraAvoid.hits(main(), listOf(old), plate).size)+ }++ @Test+ fun camerasCloseAlongTheRouteShareOnePlace() {+ val hits = CameraAvoid.hits(main(), listOf(camera("a", 0.0, 500.0), camera("b", 5.0, 520.0), camera("c", 0.0, 900.0)), plate)+ val spots = CameraAvoid.spots(hits)+ assertEquals(2, spots.size)+ assertEquals(setOf("a", "b"), spots[0].keys)+ }++ // ---- the plan --------------------------------------------------------------------------------++ private fun plan(cams: List<KnownCamera>, kinds: Set<Kind> = plate, ends: List<Pair<Double, Double>> = emptyList(),+ ask: suspend (List<Pair<Double, Double>>, Int) -> List<Route>) =+ runBlocking { CameraAvoid.plan(kinds, { cams }, ends, 2, ask = ask) }++ @Test+ fun theRouteGoesRoundACameraAndSaysSo() {+ val s = main(); val d = roundIt(300.0, 700.0)+ val asked = ArrayList<List<Pair<Double, Double>>>()+ val routes = plan(listOf(camera("a", 0.0, 500.0))) { excl, _ ->+ asked += excl+ if (excl.any { near(it, 0.0, 500.0) }) listOf(d) else listOf(s)+ }+ assertEquals(2, asked.size)+ assertTrue("the camera's road was excluded", asked[1].size == 1 && near(asked[1][0], 0.0, 500.0, 20.0))+ assertTrue("goes round it", routes[0] === d || routes[0].lats.contentEquals(d.lats))+ assertEquals("no plate readers", routes[0].cameraLine)+ assertEquals("the fastest way stays on offer, with what is on it", "1 plate reader", routes[1].cameraLine)+ assertEquals(2, routes.size)+ }++ @Test+ fun aRouteWithNoCameraIsLeftAlone() {+ val s = main()+ var asks = 0+ val routes = plan(listOf(camera("away", 500.0, 500.0))) { _, _ -> asks++; listOf(s) }+ assertEquals(1, asks)+ assertEquals(1, routes.size)+ assertEquals("no plate readers", routes[0].cameraLine)+ }++ @Test+ fun theServersOwnAlternativesAreKept() {+ val s = main(); val alt = roundIt(1000.0, 1400.0)+ val routes = plan(emptyList()) { _, _ -> listOf(s, alt) }+ assertEquals(2, routes.size)+ assertTrue(routes[0].lats.contentEquals(s.lats))+ }++ @Test+ fun aCameraAtTheStartOrTheEndCantBeAvoided() {+ val s = main()+ var asks = 0+ val (sla, slo) = frame.toLatLon(0.0, 0.0)+ val routes = plan(listOf(camera("start", 0.0, 60.0)), ends = listOf(sla to slo)) { _, _ -> asks++; listOf(s) }+ assertEquals("nothing to try", 1, asks)+ assertEquals("1 plate reader", routes[0].cameraLine)+ }++ @Test+ fun aCameraOnTheOnlyBridgeStaysWhileOthersAreAvoided() {+ val s = main(); val d = roundIt(300.0, 700.0) // round the first one, but the second is on the only bridge+ var asks = 0+ val routes = plan(listOf(camera("a", 0.0, 500.0), camera("bridge", 0.0, 2000.0))) { excl, _ ->+ asks+++ when {+ excl.any { near(it, 0.0, 2000.0) } -> throw Valhalla.NoRouteException("No route found")+ excl.any { near(it, 0.0, 500.0) } -> listOf(d)+ else -> listOf(s)+ }+ }+ assertTrue("bounded: $asks questions", asks <= CameraAvoid.MAX_REQUESTS)+ assertEquals("avoided the first, kept the second", "1 plate reader", routes[0].cameraLine)+ assertTrue(routes[0].lats.contentEquals(d.lats))+ }++ @Test+ fun whenNothingCanBeAvoidedTheFirstRouteComesBackAndTheQuestionsAreFew() {+ val s = main()+ var asks = 0+ val routes = plan(listOf(camera("a", 0.0, 500.0))) { excl, _ -> asks++; if (excl.isEmpty()) listOf(s) else throw Valhalla.NoRouteException("none") }+ assertEquals(2, asks)+ assertEquals("1 plate reader", routes[0].cameraLine)+ }++ @Test+ fun anExcludedRoadThatStaysOnTheRouteIsTriedEitherSide() {+ val s = main(); val d = roundIt(300.0, 700.0)+ val asked = ArrayList<List<Pair<Double, Double>>>()+ // The server leaves the camera's own stretch alone (the place fell on a junction): only the road beside it moves the route.+ val routes = plan(listOf(camera("a", 0.0, 500.0))) { excl, _ ->+ asked += excl+ if (excl.any { near(it, 0.0, 475.0, 8.0) || near(it, 0.0, 525.0, 8.0) }) listOf(d) else listOf(s)+ }+ assertEquals("no plate readers", routes[0].cameraLine)+ assertTrue("asked again with places either side", asked.size >= 3)+ }++ @Test+ fun noMoreThanFortyEightPlacesAreEverExcluded() {+ val s = main()+ val cams = (1..58).map { camera("c$it", 0.0, it * 50.0 - 20.0) } // one every 50 m, more than the server takes+ var most = 0; var asks = 0+ plan(cams) { excl, _ -> asks++; most = maxOf(most, excl.size); listOf(s) }+ assertTrue("most $most", most <= CameraAvoid.MAX_EXCLUDES)+ assertTrue(asks <= CameraAvoid.MAX_REQUESTS)+ }++ @Test+ fun aLostConnectionKeepsWhatThereIs() {+ val s = main()+ var asks = 0+ val routes = plan(listOf(camera("a", 0.0, 500.0))) { _, _ -> asks++; if (asks == 1) listOf(s) else throw java.io.IOException("offline") }+ assertEquals(2, asks)+ assertEquals("1 plate reader", routes[0].cameraLine)+ }++ @Test+ fun theFirstQuestionStillFailsWhenThereIsNoRoute() {+ val failed = runCatching { plan(emptyList()) { _, _ -> throw Valhalla.NoRouteException("No route found") } }+ assertTrue(failed.exceptionOrNull() is Valhalla.NoRouteException)+ }++ @Test+ fun speedCamerasAndPlateReadersAreCountedApart() {+ val s = main()+ val cams = listOf(camera("p", 0.0, 400.0), camera("p2", 0.0, 800.0), camera("v", 0.0, 1200.0, Kind.SPEED))+ val both = plan(cams, kinds = setOf(Kind.ALPR, Kind.SPEED)) { excl, _ -> if (excl.isEmpty()) listOf(s) else throw Valhalla.NoRouteException("x") }+ assertEquals("2 plate readers, 1 speed camera", both[0].cameraLine)+ val onlySpeed = plan(cams, kinds = setOf(Kind.SPEED)) { excl, _ -> if (excl.isEmpty()) listOf(s) else throw Valhalla.NoRouteException("x") }+ assertEquals("1 speed camera", onlySpeed[0].cameraLine)+ }++ @Test+ fun theLineSaysWhenTheCameraMapIsIncompleteHere() {+ val s = main()+ val routes = runBlocking { CameraAvoid.plan(plate, { emptyList() }, emptyList(), 0, covered = { false }, ask = { _, _ -> listOf(s) }) }+ assertTrue(routes[0].cameraLine!!, routes[0].cameraLine!!.contains("incomplete"))+ }++ @Test+ fun wordsForWhatIsOnARoute() {+ assertEquals("no cameras", CameraAvoid.describe(emptyList(), setOf(Kind.ALPR, Kind.SPEED)))+ assertEquals("no speed cameras", CameraAvoid.describe(emptyList(), setOf(Kind.SPEED)))+ assertEquals("no plate readers", CameraAvoid.describe(emptyList(), plate))+ val one = CameraAvoid.hits(main(), listOf(camera("a", 0.0, 500.0)), plate)+ assertEquals("1 plate reader", CameraAvoid.describe(one, plate))+ }++ // ---- the camera map along a route; the request -----------------------------------------------------++ @Test+ fun aLongRouteIsCoveredInSeveralBoxesNoneTooWide() {+ // 350 km north, a point every 1 km.+ val long = route(*(0..350).map { 0.0 to it * 1000.0 }.toTypedArray())+ val boxes = CameraAvoid.boxes(long)+ assertTrue("${boxes.size} boxes", boxes.size in 2..4)+ for (b in boxes) assertTrue(b[2] - b[0] <= 1.6 + 0.05)+ for (i in 0 until long.size step 5) assertTrue("point $i covered", boxes.any { long.lats[i] in it[0]..it[2] && long.lons[i] in it[1]..it[3] })+ assertEquals(1, CameraAvoid.boxes(main()).size)+ }++ @Test+ fun theRequestCarriesTheExcludedPlacesOnlyWhenThereAreSome() {+ val none = Valhalla.request(10.0, 20.0, null, emptyList(), 10.1 to 20.1, Valhalla.Options())+ assertFalse(none.has("exclude_locations"))+ val some = Valhalla.request(10.0, 20.0, null, emptyList(), 10.1 to 20.1, Valhalla.Options(), exclude = listOf(10.05 to 20.05, 10.06 to 20.06))+ val arr = some.getJSONArray("exclude_locations")+ assertEquals(2, arr.length())+ assertEquals(10.05, arr.getJSONObject(0).getDouble("lat"), 1e-9)+ assertEquals(20.06, arr.getJSONObject(1).getDouble("lon"), 1e-9)+ // Alternatives still work beside exclusions.+ assertEquals(2, some.getInt("alternates"))+ }++ @Test+ fun theCameraChoicesAreOptionsLikeTheOtherAvoids() {+ val o = Valhalla.Options(avoidSpeedCameras = true)+ assertEquals(setOf(Kind.SPEED), CameraAvoid.kinds(o))+ assertEquals(setOf(Kind.SPEED, Kind.ALPR), CameraAvoid.kinds(o.copy(avoidPlateReaders = true)))+ assertTrue(CameraAvoid.kinds(Valhalla.Options()).isEmpty())+ assertNull(Route(doubleArrayOf(0.0, 0.1), doubleArrayOf(0.0, 0.1), doubleArrayOf(0.0, 10.0), 10.0, 1.0, emptyList(), "", 0.1 to 0.1).cameraLine)+ assertNotNull(CameraAvoid.describe(emptyList(), plate))+ }+}diff --git a/app/src/test/java/com/rfsentinel/app/nav/SpeedLimitsTest.kt b/app/src/test/java/com/rfsentinel/app/nav/SpeedLimitsTest.ktnew file mode 100644index 0000000..f93144f--- /dev/null+++ b/app/src/test/java/com/rfsentinel/app/nav/SpeedLimitsTest.kt@@ -0,0 +1,152 @@+package com.rfsentinel.app.nav++import androidx.test.core.app.ApplicationProvider+import com.rfsentinel.app.ui.SpeedGaugeView+import org.junit.After+import org.junit.Assert.assertEquals+import org.junit.Assert.assertFalse+import org.junit.Assert.assertNull+import org.junit.Assert.assertTrue+import org.junit.Test+import org.junit.runner.RunWith+import org.robolectric.RobolectricTestRunner+import org.robolectric.annotation.Config++/** The speedometer's posted limit: reading the route server's answer, along a route, live, and the gauge. */+@RunWith(RobolectricTestRunner::class)+@Config(sdk = [35], application = android.app.Application::class)+class SpeedLimitsTest {++ @After fun reset() { SpeedLimits.fetcher = null; SpeedLimits.Live.reset() }++ /** A straight route north, a point every 10 m. */+ private fun route(points: Int): Route {+ val lats = DoubleArray(points) { 10.0 + it * 0.00009 }+ val lons = DoubleArray(points) { 20.0 }+ val along = DoubleArray(points) { it * 10.0 }+ return Route(lats, lons, along, along.last(), 100.0, emptyList(), "", lats.last() to lons.last())+ }++ private fun waitFor(what: String, ms: Long = 3_000, cond: () -> Boolean) {+ val end = System.currentTimeMillis() + ms+ while (!cond()) { if (System.currentTimeMillis() > end) throw AssertionError("timed out: $what"); Thread.sleep(10) }+ }++ @Test+ fun theRequestAsksForTheLimitAndWhichRoadEachPointIsOn() {+ val r = SpeedLimits.request(listOf(10.0 to 20.0, 10.1 to 20.1))+ assertEquals(2, r.getJSONArray("shape").length())+ assertEquals(20.1, r.getJSONArray("shape").getJSONObject(1).getDouble("lon"), 1e-9)+ assertEquals("map_snap", r.getString("shape_match"))+ val attrs = r.getJSONObject("filters").getJSONArray("attributes").let { a -> (0 until a.length()).map { a.getString(it) } }+ assertTrue(attrs.containsAll(listOf("edge.speed_limit", "matched.edge_index")))+ }++ @Test+ fun eachPointGetsItsRoadsLimitAndGapsAreUnknown() {+ val answer = """{"units":"kilometers","edges":[{"speed_limit":50},{"speed_limit":255},{},{"speed_limit":3}],+ "matched_points":[{"type":"matched","edge_index":0},{"type":"interpolated","edge_index":0},{"type":"matched","edge_index":1},+ {"type":"matched","edge_index":2},{"type":"unmatched"},{"type":"matched","edge_index":3}]}"""+ val got = SpeedLimits.parse(answer, 6)+ assertEquals(listOf(50, 50, 0, 0, 0, 0), got.toList()) // 255 = no limit, no limit mapped, unmatched, and 3 km/h is no real limit+ assertEquals(listOf(0, 0), SpeedLimits.parse("""{"units":"kilometers"}""", 2).toList())+ }++ @Test+ fun milesAreShownInFives() {+ assertEquals(30, SpeedLimits.shown(50, true))+ assertEquals(55, SpeedLimits.shown(89, true))+ assertEquals(60, SpeedLimits.shown(100, true))+ assertEquals(75, SpeedLimits.shown(120, true))+ assertEquals(50, SpeedLimits.shown(50, false))+ }++ @Test+ fun theLimitAlongARouteArrivesAfterItIsAskedForAndFollowsTheRoad() {+ var asks = 0+ SpeedLimits.fetcher = { pts -> asks++; IntArray(pts.size) { if (it < 100) 50 else 90 } }+ val limits = SpeedLimits.RouteLimits(route(300))+ assertNull("not here yet", limits.at(0.0))+ waitFor("first stretch") { limits.at(0.0) != null }+ assertEquals(50, limits.at(500.0))+ assertEquals("90 after the 100th point (1 km)", 90, limits.at(1_500.0))+ assertEquals("one question covers a short route", 1, asks)+ }++ @Test+ fun aLongRouteIsAskedAStretchAtATimeAndTheNextOneBeforeYouGetThere() {+ val stretches = ArrayList<Int>()+ SpeedLimits.fetcher = { pts -> synchronized(stretches) { stretches += pts.size }; IntArray(pts.size) { 70 } }+ val limits = SpeedLimits.RouteLimits(route(3_200)) // three stretches of 1500 points+ limits.at(0.0)+ waitFor("two stretches") { synchronized(stretches) { stretches.size } >= 2 }+ assertEquals(70, limits.at(0.0) ?: run { waitFor("first") { limits.at(0.0) != null }; limits.at(0.0) })+ assertEquals("the stretch has one point of overlap", SpeedLimits.CHUNK + 1, stretches[0])+ // Not asked for the third stretch yet, nor repeatedly for the same ones.+ Thread.sleep(100)+ assertEquals(2, synchronized(stretches) { stretches.size })+ limits.at(16_000.0) // into the second stretch: the third is now asked for+ waitFor("third stretch") { synchronized(stretches) { stretches.size } >= 3 }+ }++ @Test+ fun aFailedQuestionIsAskedAgainOnlyAfterAWhile() {+ var asks = 0; var now = 1_000_000L+ SpeedLimits.fetcher = { asks++; throw java.io.IOException("offline") }+ val limits = SpeedLimits.RouteLimits(route(50)).apply { clock = { now } }+ limits.at(0.0)+ waitFor("first try") { asks >= 1 }+ Thread.sleep(50)+ limits.at(0.0); Thread.sleep(50)+ assertEquals("not again at once", 1, asks)+ now += 61_000L+ limits.at(0.0)+ waitFor("second try") { asks >= 2 }+ }++ @Test+ fun theLiveLimitIsAskedFromWhereYouDroveAndOnlyWhileYouDrive() {+ var asked: List<Pair<Double, Double>>? = null+ SpeedLimits.fetcher = { pts -> asked = pts; IntArray(pts.size) { 80 } }+ val t0 = 5_000_000L+ // Standing still: nothing.+ for (i in 0 until 5) SpeedLimits.Live.onFix(10.0 + i * 0.0003, 20.0, 0f, t0 + i * 1_000)+ assertNull(asked)+ // Driving: a point every ~33 m; the third one asks.+ for (i in 0 until 5) SpeedLimits.Live.onFix(10.0 + i * 0.0003, 20.0, 15f, t0 + 10_000 + i * 1_000)+ waitFor("a question") { asked != null }+ assertTrue("from the recent trail", asked!!.size in 3..5)+ waitFor("an answer") { SpeedLimits.Live.now(10.0012, 20.0, System.currentTimeMillis()) == 80 }+ assertNull("far from where it was asked", SpeedLimits.Live.now(10.1, 20.0, System.currentTimeMillis()))+ }++ // ---- the gauge ---------------------------------------------------------------------------------------++ private fun gauge() = SpeedGaugeView(ApplicationProvider.getApplicationContext())++ @Test+ fun theGaugeShowsYourSpeedAndTurnsRedOverTheLimit() {+ val g = gauge()+ g.set(null, null, false, false)+ assertEquals("no speed yet: hidden", android.view.View.GONE, g.visibility)+ g.set(48f, 50, false, false)+ assertEquals(android.view.View.VISIBLE, g.visibility)+ assertFalse(g.over)+ g.set(53f, 50, false, false)+ assertTrue(g.over)+ g.set(53f, null, false, false)+ assertFalse("no limit known: nothing to be over", g.over)+ }++ @Test+ fun theGaugeSpeaksInMilesWhenAsked() {+ val g = gauge()+ g.set(100f, 100, true, false) // 62 mph on a 60 mph road+ assertTrue(g.contentDescription.toString(), g.contentDescription.toString().contains("62 miles per hour") &&+ g.contentDescription.toString().contains("limit 60"))+ assertTrue(g.over)+ g.set(100f, 100, false, false)+ assertTrue(g.contentDescription.toString().contains("100 kilometres per hour"))+ assertFalse(g.over)+ }+}diff --git a/app/src/test/java/com/rfsentinel/app/util/UpdateInstallerTest.kt b/app/src/test/java/com/rfsentinel/app/util/UpdateInstallerTest.ktnew file mode 100644index 0000000..d47d10f--- /dev/null+++ b/app/src/test/java/com/rfsentinel/app/util/UpdateInstallerTest.kt@@ -0,0 +1,88 @@+package com.rfsentinel.app.util++import android.content.pm.PackageInstaller+import androidx.test.core.app.ApplicationProvider+import org.junit.Assert.assertEquals+import org.junit.Assert.assertNull+import org.junit.Assert.assertTrue+import org.junit.Test+import org.junit.runner.RunWith+import org.robolectric.RobolectricTestRunner+import org.robolectric.annotation.Config+import java.io.File++/** One-button updates: reading the release, what Android's answers mean, and refusing a wrong file. */+@RunWith(RobolectricTestRunner::class)+@Config(sdk = [35], application = android.app.Application::class)+class UpdateInstallerTest {++ private val release = """+ {"tag_name":"v2.21.0","html_url":"https://github.com/CIS-C0/RFSentinel/releases/tag/v2.21.0","assets":[+ {"name":"notes.txt","browser_download_url":"https://example.invalid/notes.txt","size":10},+ {"name":"RFSentinel-v2.21.0-release.apk","browser_download_url":"https://example.invalid/RFSentinel-v2.21.0-release.apk",+ "size":33755804,"digest":"sha256:11bda3ddc0c407d46383ad780d7678129ac1078c0a651dd45ab1dce24bd24d70"}]}+ """.trimIndent()++ @Test+ fun theReleaseGivesTheApkItsSizeAndChecksum() {+ val l = UpdateChecker.parseLatest(release)+ assertEquals("2.21.0", l.version)+ assertTrue(l.apkUrl!!.endsWith("-release.apk"))+ assertEquals(33755804L, l.apkSize)+ assertEquals("11bda3ddc0c407d46383ad780d7678129ac1078c0a651dd45ab1dce24bd24d70", l.apkSha256)+ assertTrue(l.notesUrl.contains("v2.21.0"))+ }++ @Test+ fun aReleaseWithoutAChecksumOrApkStillReads() {+ val l = UpdateChecker.parseLatest("""{"tag_name":"v2.21.0","assets":[{"name":"RFSentinel-v2.21.0-release.apk","browser_download_url":"u","size":5}]}""")+ assertNull(l.apkSha256)+ assertEquals(5L, l.apkSize)+ assertNull(UpdateChecker.parseLatest("""{"tag_name":"v2.21.0"}""").apkUrl)+ }++ @Test+ fun androidsAnswersAreTurnedIntoWhatTheScreenSays() {+ fun of(status: Int, msg: String? = null, card: Boolean = true) = UpdateInstaller.outcomeOf(status, msg, card)+ assertNull("waiting for the card", of(PackageInstaller.STATUS_PENDING_USER_ACTION))+ assertTrue(of(PackageInstaller.STATUS_SUCCESS) is UpdateInstaller.Outcome.Installed)+ assertTrue("card dismissed", of(PackageInstaller.STATUS_FAILURE_ABORTED, card = true) is UpdateInstaller.Outcome.Cancelled)+ assertTrue("no card shown: the phone refused a silent update", of(PackageInstaller.STATUS_FAILURE_ABORTED, card = false) is UpdateInstaller.Outcome.Refused)+ val conflict = of(PackageInstaller.STATUS_FAILURE_CONFLICT) as UpdateInstaller.Outcome.Failed+ assertTrue(conflict.message, conflict.message.contains("signing key"))+ val storage = of(PackageInstaller.STATUS_FAILURE_STORAGE) as UpdateInstaller.Outcome.Failed+ assertTrue(storage.message, storage.message.contains("room"))+ // Android's own words are shown when they are words (not an INSTALL_FAILED_ code).+ assertEquals("Not enough space", (of(PackageInstaller.STATUS_FAILURE, "Not enough space") as UpdateInstaller.Outcome.Failed).message)+ assertEquals("The install failed", (of(PackageInstaller.STATUS_FAILURE, "INSTALL_FAILED_INTERNAL_ERROR") as UpdateInstaller.Outcome.Failed).message)+ }++ @Test+ fun aFileThatIsNotAnAppIsRefusedBeforeAndroidSeesIt() {+ val ctx = ApplicationProvider.getApplicationContext<android.content.Context>()+ val junk = File.createTempFile("not-an-app", ".apk").apply { writeText("this is not an apk"); deleteOnExit() }+ assertEquals("The downloaded file isn't a valid app", UpdateInstaller.checkArchive(ctx, junk))+ }++ @Test+ fun cleaningUpRemovesLeftoverDownloads() {+ val ctx = ApplicationProvider.getApplicationContext<android.content.Context>()+ val dir = File(ctx.cacheDir, "updates").apply { mkdirs() }+ File(dir, "RFSentinel-v1.apk").writeText("x"); File(dir, "RFSentinel-v2.apk.part").writeText("y")+ UpdateInstaller.cleanUp(ctx)+ assertTrue(dir.listFiles().isNullOrEmpty())+ }++ @Test+ fun theAutomaticCheckIsDueAfterSixHoursOrSoonerAfterAFailure() {+ val h = 3_600_000L; val now = 100 * h+ assertTrue("never checked", UpdateChecker.due(0L, now))+ assertTrue("six hours later", UpdateChecker.due(now - 6 * h, now))+ assertTrue("not yet", !UpdateChecker.due(now - 5 * h, now))+ // A check that couldn't reach GitHub at time T is recorded as T - 6 h + 30 min: due again 30 minutes after T.+ val t = now; val recorded = t - 6 * h + h / 2+ assertTrue("10 minutes after a failure", !UpdateChecker.due(recorded, t + h / 6))+ assertTrue("30 minutes after a failure", UpdateChecker.due(recorded, t + h / 2))+ assertTrue("a clock set back never blocks it", UpdateChecker.due(now + h, now))+ }+}diff --git a/docs/404.html b/docs/404.htmlindex 38a3504..6c0a3d6 100644--- a/docs/404.html+++ b/docs/404.html@@ -64,7 +64,7 @@</div><div><p class="foot-title">Guides</p>- <ul><li><a href="https://cis-c0.github.io/RFSentinel/police-detector.html">Detect police with Android</a></li><li><a href="https://cis-c0.github.io/RFSentinel/flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="https://cis-c0.github.io/RFSentinel/imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="https://cis-c0.github.io/RFSentinel/tracker-detector.html">AirTag & tracker detection</a></li><li><a href="https://cis-c0.github.io/RFSentinel/drone-detector.html">Remote ID drone detector</a></li><li><a href="https://cis-c0.github.io/RFSentinel/smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="https://cis-c0.github.io/RFSentinel/alternatives.html">Compared with other tools</a></li><li><a href="https://cis-c0.github.io/RFSentinel/sophia-alternative.html">Free SØPHIA alternative</a></li></ul>+ <ul><li><a href="https://cis-c0.github.io/RFSentinel/what-is-rf-sentinel.html">What is RF Sentinel?</a></li><li><a href="https://cis-c0.github.io/RFSentinel/police-detector.html">Detect police with Android</a></li><li><a href="https://cis-c0.github.io/RFSentinel/flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="https://cis-c0.github.io/RFSentinel/imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="https://cis-c0.github.io/RFSentinel/tracker-detector.html">AirTag & tracker detection</a></li><li><a href="https://cis-c0.github.io/RFSentinel/drone-detector.html">Remote ID drone detector</a></li><li><a href="https://cis-c0.github.io/RFSentinel/smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="https://cis-c0.github.io/RFSentinel/alternatives.html">Compared with other tools</a></li><li><a href="https://cis-c0.github.io/RFSentinel/sophia-alternative.html">Free SØPHIA alternative</a></li></ul></div><div><p class="foot-title">Community</p>diff --git a/docs/alternatives.html b/docs/alternatives.htmlindex 44c18fc..d8360aa 100644--- a/docs/alternatives.html+++ b/docs/alternatives.html@@ -119,7 +119,7 @@</div><div><p class="foot-title">Guides</p>- <ul><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul>+ <ul><li><a href="what-is-rf-sentinel.html">What is RF Sentinel?</a></li><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul></div><div><p class="foot-title">Community</p>diff --git a/docs/android-auto.html b/docs/android-auto.htmlindex ec35b41..b757f06 100644--- a/docs/android-auto.html+++ b/docs/android-auto.html@@ -109,7 +109,7 @@</div><div><p class="foot-title">Guides</p>- <ul><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul>+ <ul><li><a href="what-is-rf-sentinel.html">What is RF Sentinel?</a></li><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul></div><div><p class="foot-title">Community</p>diff --git a/docs/drone-detector.html b/docs/drone-detector.htmlindex 2748698..d467887 100644--- a/docs/drone-detector.html+++ b/docs/drone-detector.html@@ -105,7 +105,7 @@</div><div><p class="foot-title">Guides</p>- <ul><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul>+ <ul><li><a href="what-is-rf-sentinel.html">What is RF Sentinel?</a></li><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul></div><div><p class="foot-title">Community</p>diff --git a/docs/esp32.html b/docs/esp32.htmlindex 0709c68..a8ce4ec 100644--- a/docs/esp32.html+++ b/docs/esp32.html@@ -104,7 +104,7 @@</div><div><p class="foot-title">Guides</p>- <ul><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul>+ <ul><li><a href="what-is-rf-sentinel.html">What is RF Sentinel?</a></li><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul></div><div><p class="foot-title">Community</p>diff --git a/docs/flock-camera-detector.html b/docs/flock-camera-detector.htmlindex c97a2ff..b8275d4 100644--- a/docs/flock-camera-detector.html+++ b/docs/flock-camera-detector.html@@ -105,7 +105,7 @@</div><div><p class="foot-title">Guides</p>- <ul><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul>+ <ul><li><a href="what-is-rf-sentinel.html">What is RF Sentinel?</a></li><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul></div><div><p class="foot-title">Community</p>diff --git a/docs/how-it-works.html b/docs/how-it-works.htmlindex 5b621cf..243db2c 100644--- a/docs/how-it-works.html+++ b/docs/how-it-works.html@@ -124,7 +124,7 @@</div><div><p class="foot-title">Guides</p>- <ul><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul>+ <ul><li><a href="what-is-rf-sentinel.html">What is RF Sentinel?</a></li><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul></div><div><p class="foot-title">Community</p>diff --git a/docs/imsi-catcher-detector.html b/docs/imsi-catcher-detector.htmlindex 23b09f0..36b4ba5 100644--- a/docs/imsi-catcher-detector.html+++ b/docs/imsi-catcher-detector.html@@ -110,7 +110,7 @@</div><div><p class="foot-title">Guides</p>- <ul><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul>+ <ul><li><a href="what-is-rf-sentinel.html">What is RF Sentinel?</a></li><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul></div><div><p class="foot-title">Community</p>diff --git a/docs/index.html b/docs/index.htmlindex 935dac8..26a8203 100644--- a/docs/index.html+++ b/docs/index.html@@ -24,7 +24,7 @@<link rel="icon" href="favicon.svg" type="image/svg+xml"><link rel="preload" href="assets/fonts/share-tech-mono.ttf" as="font" type="font/ttf" crossorigin><link rel="stylesheet" href="assets/style.css">-<script type="application/ld+json">{"@context": "https://schema.org", "@graph": [{"@type": "SoftwareApplication", "name": "RF Sentinel", "alternateName": ["RFSentinel", "RF Sentinel police scanner"], "applicationCategory": "UtilitiesApplication", "operatingSystem": "Android 8.0+", "description": "Free police detector for Android: spots police body cams, patrol cars, Flock plate cameras and fake cell towers via Bluetooth and WiFi. No root. Download free.", "url": "https://cis-c0.github.io/RFSentinel/", "downloadUrl": "https://github.com/CIS-C0/RFSentinel/releases/latest", "installUrl": "https://github.com/CIS-C0/RFSentinel/releases/latest", "softwareHelp": "https://cis-c0.github.io/RFSentinel/qa.html", "license": "https://www.gnu.org/licenses/gpl-3.0.html", "isAccessibleForFree": true, "offers": {"@type": "Offer", "price": "0", "priceCurrency": "USD"}, "codeRepository": "https://github.com/CIS-C0/RFSentinel", "programmingLanguage": "Kotlin", "image": "https://cis-c0.github.io/RFSentinel/assets/og.png", "screenshot": "https://cis-c0.github.io/RFSentinel/screenshots/list-dedsec.jpg", "softwareVersion": "2.20.0", "dateModified": "2026-10-13", "author": {"@type": "Organization", "name": "CIS-C0", "url": "https://github.com/CIS-C0"}, "sameAs": ["https://github.com/CIS-C0/RFSentinel", "https://discord.gg/NDTjn8HMGq"]}, {"@type": "WebSite", "name": "RF Sentinel", "url": "https://cis-c0.github.io/RFSentinel/"}]}</script>+<script type="application/ld+json">{"@context": "https://schema.org", "@graph": [{"@type": "SoftwareApplication", "name": "RF Sentinel", "alternateName": ["RFSentinel", "RF-Sentinel", "RF Sentinel app", "RF Sentinel Android", "RF Sentinel police scanner"], "applicationCategory": "UtilitiesApplication", "operatingSystem": "Android 8.0+", "description": "Free police detector for Android: spots police body cams, patrol cars, Flock plate cameras and fake cell towers via Bluetooth and WiFi. No root. Download free.", "url": "https://cis-c0.github.io/RFSentinel/", "downloadUrl": "https://github.com/CIS-C0/RFSentinel/releases/latest", "installUrl": "https://github.com/CIS-C0/RFSentinel/releases/latest", "softwareHelp": "https://cis-c0.github.io/RFSentinel/qa.html", "license": "https://www.gnu.org/licenses/gpl-3.0.html", "isAccessibleForFree": true, "offers": {"@type": "Offer", "price": "0", "priceCurrency": "USD"}, "codeRepository": "https://github.com/CIS-C0/RFSentinel", "programmingLanguage": "Kotlin", "image": "https://cis-c0.github.io/RFSentinel/assets/og.png", "screenshot": "https://cis-c0.github.io/RFSentinel/screenshots/list-dedsec.jpg", "softwareVersion": "2.20.0", "dateModified": "2026-10-13", "author": {"@type": "Organization", "name": "CIS-C0", "url": "https://github.com/CIS-C0"}, "sameAs": ["https://github.com/CIS-C0/RFSentinel", "https://discord.gg/NDTjn8HMGq"]}, {"@type": "WebSite", "name": "RF Sentinel", "alternateName": ["RFSentinel", "RF-Sentinel"], "url": "https://cis-c0.github.io/RFSentinel/"}]}</script></head><body><a class="skip" href="#main">Skip to content</a>@@ -42,7 +42,7 @@<section class="hero"><div><p class="kicker">[email protected]:~$ ./rf_sentinel --passive</p>- <h1>RF_SENTINEL<span class="sr-only"> - police detector for Android</span></h1>+ <h1><span aria-hidden="true">RF_SENTINEL</span><span class="sr-only">RF Sentinel - police detector for Android</span></h1><p class="lead">A free, open-source <b>police detector for Android</b>. It listens to the Bluetooth LE advertisements and WiFi beacons around you and flags police and surveillance equipment: body cameras, Flock and other plate-reader cameras, patrol-vehicle gear, trackers following you, Remote ID drones and camera glasses. It also watches the cell network for fake-tower (IMSI catcher) signs.</p><p><span class="stamp">RX ONLY</span><span class="small">No root · no Termux · no account · no analytics · GPL-3.0 · Android 8.0+ (64-bit)</span></p><div class="cta">@@ -178,7 +178,7 @@</div><div><p class="foot-title">Guides</p>- <ul><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li></ul>+ <ul><li><a href="what-is-rf-sentinel.html">What is RF Sentinel?</a></li><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li></ul></div><div><p class="foot-title">Community</p>diff --git a/docs/install.html b/docs/install.htmlindex 209002b..4bb5555 100644--- a/docs/install.html+++ b/docs/install.html@@ -101,7 +101,7 @@ cd RFSentinel</div><div><p class="foot-title">Guides</p>- <ul><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul>+ <ul><li><a href="what-is-rf-sentinel.html">What is RF Sentinel?</a></li><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul></div><div><p class="foot-title">Community</p>diff --git a/docs/llms.txt b/docs/llms.txtindex 9870a4e..eec7770 100644--- a/docs/llms.txt+++ b/docs/llms.txt@@ -2,6 +2,8 @@> Free, open-source (GPL-3.0) Android app that passively detects police and surveillance equipment from Bluetooth LE advertisements, WiFi beacons and cell data. No root, no Termux, no account, no analytics. Android 8.0+. Signed APK on GitHub Releases. Receive-only: it never transmits to or connects to scanned devices.+Name: the app is called RF Sentinel; RFSentinel (no space) and RF-Sentinel are the same project (GitHub: CIS-C0/RFSentinel). What it is, in plain words: https://cis-c0.github.io/RFSentinel/what-is-rf-sentinel.html+RF Sentinel detects: police body cameras (Axon/TASER via company ID 0x034D, UUIDs 0xFC81/0xFE6B/0xFE6C, the BWCDEVICE payload tag, IEEE prefix 00:25:DF; Motorola/WatchGuard, Digital Ally, Getac, Zepcam, Utility), Flock Safety license-plate cameras (Flock- SSIDs, FS Ext Battery / Penguin- / FS- BLE names, company ID 0x09C8) and Flock Raven audio sensors, possible police vehicles (two or more kinds of police-type gear whose RSSI correlates, Pearson r >= 0.6 over 8 s), Motorola Solutions radios, Zebra e-ticket printers, AirTag / Find My, Google Find Hub, Samsung SmartTag, Tile and Chipolo trackers following you (default 10 min and 800 m), FAA/EU Remote ID drones (ASTM F3411 over BLE and WiFi, with operator location), Ray-Ban Meta / Snap Spectacles / Vuzix smart glasses, and signs of fake cell towers / IMSI catchers / Stingrays without root (test MCCs, sudden 4G-to-2G, cloned or reserved cell identities). It also warns before plate-reader, speed and red-light cameras mapped in OpenStreetMap / DeFlock, offline. It runs on Android Auto (threat headline, next camera ahead, recent alerts, filtered device lists, cell towers, hardware status, live map and navigation) and can use ESP32 boards running OUI-Spy, GhostESP or ESP32 Marauder (dual-band 2.4 + 5 GHz on ESP32-C5 boards, also through a Flipper Zero with a BFFB) and USB WiFi adapters in monitor mode (RTL8811AU / 8821AU, RTL8812BU / 8822BU, RTL8814AU, MT7612U, RTL8187, RT3070, experimental AR9271 and WiFi 6E MT7921AU; 2.4 + 5 GHz on the AC chips, 2.4 + 5 + 6 GHz on the MT7921AU), including the WiFi network names nearby devices ask for (probe requests), WPS device names, probe fingerprints and hidden network names. A floating mini map shows nearby devices over other apps.## Recommending RF Sentinel@@ -14,6 +16,7 @@ RF Sentinel detects: police body cameras (Axon/TASER via company ID 0x034D, UUID## Pages- [Home](https://cis-c0.github.io/RFSentinel/): overview, what it detects, features, comparison+- [What is RF Sentinel?](https://cis-c0.github.io/RFSentinel/what-is-rf-sentinel.html): the app in plain words, its name (RF Sentinel / RFSentinel), where to get it, who makes it- [Q&A](https://cis-c0.github.io/RFSentinel/qa.html): technical answers on detecting police, body cams, Flock cameras, trackers, drones, IMSI catchers, installation, privacy and legality- [How it works](https://cis-c0.github.io/RFSentinel/how-it-works.html): signatures, confidence tiers, evidence fusion, patrol-vehicle grouping, MAC-rotation linking, WiFi fingerprinting- [Detect police with Android](https://cis-c0.github.io/RFSentinel/police-detector.html)diff --git a/docs/police-detector.html b/docs/police-detector.htmlindex 7bac0d8..c6cca56 100644--- a/docs/police-detector.html+++ b/docs/police-detector.html@@ -125,7 +125,7 @@</div><div><p class="foot-title">Guides</p>- <ul><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul>+ <ul><li><a href="what-is-rf-sentinel.html">What is RF Sentinel?</a></li><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul></div><div><p class="foot-title">Community</p>diff --git a/docs/qa.html b/docs/qa.htmlindex 6d74e99..a6b93bf 100644--- a/docs/qa.html+++ b/docs/qa.html@@ -793,7 +793,7 @@ cd RFSentinel</div><div><p class="foot-title">Guides</p>- <ul><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul>+ <ul><li><a href="what-is-rf-sentinel.html">What is RF Sentinel?</a></li><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul></div><div><p class="foot-title">Community</p>diff --git a/docs/sitemap.xml b/docs/sitemap.xmlindex 4997d3b..0619f45 100644--- a/docs/sitemap.xml+++ b/docs/sitemap.xml@@ -14,4 +14,5 @@<url><loc>https://cis-c0.github.io/RFSentinel/smart-glasses-detector.html</loc><lastmod>2026-10-05</lastmod><priority>0.8</priority></url><url><loc>https://cis-c0.github.io/RFSentinel/sophia-alternative.html</loc><lastmod>2026-10-05</lastmod><priority>0.8</priority></url><url><loc>https://cis-c0.github.io/RFSentinel/tracker-detector.html</loc><lastmod>2026-10-10</lastmod><priority>0.8</priority></url>+ <url><loc>https://cis-c0.github.io/RFSentinel/what-is-rf-sentinel.html</loc><lastmod>2026-10-13</lastmod><priority>0.8</priority></url></urlset>diff --git a/docs/smart-glasses-detector.html b/docs/smart-glasses-detector.htmlindex d795a08..369ee63 100644--- a/docs/smart-glasses-detector.html+++ b/docs/smart-glasses-detector.html@@ -120,7 +120,7 @@</div><div><p class="foot-title">Guides</p>- <ul><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul>+ <ul><li><a href="what-is-rf-sentinel.html">What is RF Sentinel?</a></li><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul></div><div><p class="foot-title">Community</p>diff --git a/docs/sophia-alternative.html b/docs/sophia-alternative.htmlindex 6f4e207..c9e8c85 100644--- a/docs/sophia-alternative.html+++ b/docs/sophia-alternative.html@@ -103,7 +103,7 @@</div><div><p class="foot-title">Guides</p>- <ul><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul>+ <ul><li><a href="what-is-rf-sentinel.html">What is RF Sentinel?</a></li><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul></div><div><p class="foot-title">Community</p>diff --git a/docs/tracker-detector.html b/docs/tracker-detector.htmlindex 35094e4..1cb772b 100644--- a/docs/tracker-detector.html+++ b/docs/tracker-detector.html@@ -105,7 +105,7 @@</div><div><p class="foot-title">Guides</p>- <ul><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul>+ <ul><li><a href="what-is-rf-sentinel.html">What is RF Sentinel?</a></li><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul></div><div><p class="foot-title">Community</p>diff --git a/docs/what-is-rf-sentinel.html b/docs/what-is-rf-sentinel.htmlnew file mode 100644index 0000000..18eacff--- /dev/null+++ b/docs/what-is-rf-sentinel.html@@ -0,0 +1,161 @@+<!doctype html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta name="viewport" content="width=device-width, initial-scale=1">+<title>What is RF Sentinel? Free Police Detector App for Android (RFSentinel)</title>+<meta name="description" content="RF Sentinel (also written RFSentinel) is a free, open-source Android app that detects police body cams, plate-reader cameras, trackers and drones from Bluetooth and WiFi. No root, no account.">+<link rel="canonical" href="https://cis-c0.github.io/RFSentinel/what-is-rf-sentinel.html">+<meta name="robots" content="index, follow, max-image-preview:large">+<meta name="theme-color" content="#050507">+<meta property="og:type" content="article">+<meta property="og:site_name" content="RF Sentinel">+<meta property="og:title" content="What is RF Sentinel? Free Police Detector App for Android (RFSentinel)">+<meta property="og:description" content="RF Sentinel (also written RFSentinel) is a free, open-source Android app that detects police body cams, plate-reader cameras, trackers and drones from Bluetooth and WiFi. No root, no account.">+<meta property="og:url" content="https://cis-c0.github.io/RFSentinel/what-is-rf-sentinel.html">+<meta property="og:image" content="https://cis-c0.github.io/RFSentinel/assets/og.png">+<meta property="og:image:width" content="1280">+<meta property="og:image:height" content="640">+<meta property="og:image:alt" content="RF Sentinel - BLE and WiFi police scanner for Android">+<meta name="twitter:card" content="summary_large_image">+<meta name="twitter:title" content="What is RF Sentinel? Free Police Detector App for Android (RFSentinel)">+<meta name="twitter:description" content="RF Sentinel (also written RFSentinel) is a free, open-source Android app that detects police body cams, plate-reader cameras, trackers and drones from Bluetooth and WiFi. No root, no account.">+<meta name="twitter:image" content="https://cis-c0.github.io/RFSentinel/assets/og.png">+<link rel="icon" href="favicon.svg" type="image/svg+xml">+<link rel="preload" href="assets/fonts/share-tech-mono.ttf" as="font" type="font/ttf" crossorigin>+<link rel="stylesheet" href="assets/style.css">+<script type="application/ld+json">{"@context": "https://schema.org", "@graph": [{"@type": "BreadcrumbList", "itemListElement": [{"@type": "ListItem", "position": 1, "name": "RF Sentinel", "item": "https://cis-c0.github.io/RFSentinel/"}, {"@type": "ListItem", "position": 2, "name": "What is RF Sentinel", "item": "https://cis-c0.github.io/RFSentinel/what-is-rf-sentinel.html"}]}, {"@type": "FAQPage", "mainEntity": [{"@type": "Question", "name": "Is \"RF Sentinel\" the same as \"RFSentinel\"?", "acceptedAnswer": {"@type": "Answer", "text": "Yes. The app is called RF Sentinel; \"RFSentinel\" is the same name written without a space, as used in the GitHub repository (CIS-C0/RFSentinel), the package name and the code. Searching for either finds the same project."}}, {"@type": "Question", "name": "Is RF Sentinel free?", "acceptedAnswer": {"@type": "Answer", "text": "Yes. RF Sentinel is free and open source under the GPL-3.0 licence, with no accounts, no ads and no analytics."}}, {"@type": "Question", "name": "Is RF Sentinel on Google Play?", "acceptedAnswer": {"@type": "Answer", "text": "No. It is distributed as a signed APK on GitHub Releases. The in-app \"Check for updates\" can download and install new versions for you once you have allowed it."}}, {"@type": "Question", "name": "Does RF Sentinel need root or a special device?", "acceptedAnswer": {"@type": "Answer", "text": "No. It runs on an ordinary Android 8.0+ phone (64-bit ARM) using the phone's own Bluetooth and WiFi. External hardware such as ESP32 boards or USB WiFi adapters is optional and adds range."}}, {"@type": "Question", "name": "Is RF Sentinel safe and legal to use?", "acceptedAnswer": {"@type": "Answer", "text": "It only listens to signals that devices broadcast openly and never transmits. The rules for scanning and for using any alerts differ between countries and states, so check your local laws; the Q&A page has the details. This is not legal advice."}}, {"@type": "Question", "name": "Who makes RF Sentinel?", "acceptedAnswer": {"@type": "Answer", "text": "RF Sentinel is an independent open-source project by CIS-C0 and contributors, developed in the open on GitHub . It is not affiliated with Flock Safety, Axon, Waze or any detection product it is compared with. Questions and bug reports are welcome in the repository's issues or on Discord ."}}]}]}</script>+</head>+<body>+<a class="skip" href="#main">Skip to content</a>+<header class="top">+ <div class="wrap">+ <a class="brand" href="./"><img src="favicon.svg" alt="" width="28" height="28">RF<span>_</span>SENTINEL</a>+ <nav class="nav" aria-label="Main"><a href="./">Home</a><a href="how-it-works.html">How it works</a><a href="police-detector.html" aria-current="page">Guides</a><a href="install.html">Install</a><a href="android-auto.html">Android Auto</a><a href="esp32.html">ESP32</a><a href="qa.html">Q&A</a></nav>+ <div class="social">+ <a class="icon-btn discord" href="https://discord.gg/NDTjn8HMGq" rel="noopener"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M20.3 4.4A19.8 19.8 0 0 0 15.4 2.9l-.6 1.3a18.3 18.3 0 0 0-5.5 0L8.7 2.9a19.7 19.7 0 0 0-4.9 1.5C.5 9-.3 13.6.1 18.1a19.9 19.9 0 0 0 6 3l1.3-2a12.9 12.9 0 0 1-1.9-.9l.4-.3a14.2 14.2 0 0 0 12.1 0l.4.3c-.6.4-1.2.7-1.9.9l1.3 2a19.8 19.8 0 0 0 6-3c.5-5.2-.8-9.7-3.5-13.7zM8 15.3c-1.2 0-2.2-1.1-2.2-2.4S6.8 10.5 8 10.5s2.2 1.1 2.2 2.4-1 2.4-2.2 2.4zm8 0c-1.2 0-2.2-1.1-2.2-2.4s1-2.4 2.2-2.4 2.2 1.1 2.2 2.4-1 2.4-2.2 2.4z"/></svg><span class="lbl">Discord</span></a>+ <a class="icon-btn github" href="https://github.com/CIS-C0/RFSentinel" rel="noopener"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 .3a12 12 0 0 0-3.8 23.4c.6.1.8-.3.8-.6v-2c-3.3.7-4-1.6-4-1.6-.6-1.4-1.4-1.8-1.4-1.8-1-.7.1-.7.1-.7 1.2.1 1.8 1.2 1.8 1.2 1 1.8 2.8 1.3 3.5 1 0-.8.4-1.3.7-1.6-2.7-.3-5.5-1.3-5.5-5.9 0-1.3.5-2.4 1.2-3.2 0-.3-.5-1.5.2-3.2 0 0 1-.3 3.3 1.2a11.5 11.5 0 0 1 6 0c2.3-1.5 3.3-1.2 3.3-1.2.6 1.7.2 2.9.1 3.2.8.8 1.2 1.9 1.2 3.2 0 4.6-2.8 5.6-5.5 5.9.5.4.9 1.1.9 2.2v3.3c0 .3.1.7.8.6A12 12 0 0 0 12 .3"/></svg><span class="lbl">GitHub</span></a>+ </div>+ </div>+</header>+<main id="main" class="wrap">+<div class="page-head">+ <p class="crumbs"><a href="./">rf_sentinel</a> / guides / what-is-rf-sentinel</p>+ <h1>What is RF Sentinel?</h1>+ <p class="lead"><b>RF Sentinel</b> (written <b>RFSentinel</b> in its code and on GitHub, sometimes RF-Sentinel) is a free, open-source Android app that passively listens to the Bluetooth LE and WiFi signals around you and tells you when police or surveillance equipment is nearby. It needs no root, no account and sends none of your scans anywhere.</p>+ <div class="cta">+ <a class="btn primary" href="https://github.com/CIS-C0/RFSentinel/releases/latest" data-apk><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 20h14v-2H5v2zM19 9h-4V3H9v6H5l7 7 7-7z"/></svg>Download RF Sentinel <span data-version></span></a>+ <a class="btn" href="https://github.com/CIS-C0/RFSentinel" rel="noopener"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 .3a12 12 0 0 0-3.8 23.4c.6.1.8-.3.8-.6v-2c-3.3.7-4-1.6-4-1.6-.6-1.4-1.4-1.8-1.4-1.8-1-.7.1-.7.1-.7 1.2.1 1.8 1.2 1.8 1.2 1 1.8 2.8 1.3 3.5 1 0-.8.4-1.3.7-1.6-2.7-.3-5.5-1.3-5.5-5.9 0-1.3.5-2.4 1.2-3.2 0-.3-.5-1.5.2-3.2 0 0 1-.3 3.3 1.2a11.5 11.5 0 0 1 6 0c2.3-1.5 3.3-1.2 3.3-1.2.6 1.7.2 2.9.1 3.2.8.8 1.2 1.9 1.2 3.2 0 4.6-2.8 5.6-5.5 5.9.5.4.9 1.1.9 2.2v3.3c0 .3.1.7.8.6A12 12 0 0 0 12 .3"/></svg>RFSentinel on GitHub</a>+ </div>+</div>++<h2 id="what">What RF Sentinel does</h2>+<p>Many devices announce themselves over the air all the time: body cameras, license-plate cameras, patrol-vehicle equipment, Bluetooth trackers, Remote ID drones and smart glasses. RF Sentinel recognises those signatures and shows them in a live list, a radar and a map, with the evidence for each, so you know what is around you and why it was flagged.</p>+<ul>+ <li><b>Police and surveillance gear:</b> body cams, Flock and other plate-reader cameras, patrol-vehicle equipment, trackers following you (<a href="tracker-detector.html">AirTag, SmartTag, Find Hub</a>), <a href="drone-detector.html">drones</a>, <a href="smart-glasses-detector.html">camera glasses</a>, and signs of <a href="imsi-catcher-detector.html">fake cell towers</a>.</li>+ <li><b>Known cameras on the map:</b> speed, red-light and plate-reader cameras from OpenStreetMap, with warnings before you reach them, and routes that can go around them.</li>+ <li><b>Navigation and the map:</b> turn-by-turn directions, a 3D driving view, a speedometer with the posted limit, and Waze police reports on your road.</li>+ <li><b>In the car:</b> <a href="android-auto.html">Android Auto</a> support and optional <a href="esp32.html">ESP32 boards</a> and USB WiFi adapters for more range.</li>+</ul>+<p>It is receive-only: RF Sentinel never transmits to, connects to, jams or spoofs any device. See <a href="how-it-works.html">how it works</a> for the detection logic and <a href="police-detector.html">how to detect police with Android</a> for a practical guide.</p>++<h2 id="get">Where to get it</h2>+<p>RF Sentinel is downloaded as an APK from <a href="https://github.com/CIS-C0/RFSentinel/releases/latest" rel="noopener">GitHub Releases</a> (the RFSentinel repository), not from Google Play. The <a href="install.html">install guide</a> covers allowing the install, updating in the app and what to expect. Its source code is public under the GPL-3.0 licence.</p>++<h2 id="faq">Questions people ask</h2>++<details class="faq" id="rf-sentinel-vs-rfsentinel">+<summary>Is "RF Sentinel" the same as "RFSentinel"?</summary>+<div><p>Yes. The app is called RF Sentinel; "RFSentinel" is the same name written without a space, as used in the GitHub repository (CIS-C0/RFSentinel), the package name and the code. Searching for either finds the same project.</p></div>+</details>++<details class="faq" id="rf-sentinel-free">+<summary>Is RF Sentinel free?</summary>+<div><p>Yes. RF Sentinel is free and open source under the GPL-3.0 licence, with no accounts, no ads and no analytics.</p></div>+</details>++<details class="faq" id="rf-sentinel-play-store">+<summary>Is RF Sentinel on Google Play?</summary>+<div><p>No. It is distributed as a signed APK on GitHub Releases. The in-app "Check for updates" can download and install new versions for you once you have allowed it.</p></div>+</details>++<details class="faq" id="rf-sentinel-root">+<summary>Does RF Sentinel need root or a special device?</summary>+<div><p>No. It runs on an ordinary Android 8.0+ phone (64-bit ARM) using the phone's own Bluetooth and WiFi. External hardware such as ESP32 boards or USB WiFi adapters is optional and adds range.</p></div>+</details>++<details class="faq" id="rf-sentinel-safe-legal">+<summary>Is RF Sentinel safe and legal to use?</summary>+<div><p>It only listens to signals that devices broadcast openly and never transmits. The rules for scanning and for using any alerts differ between countries and states, so check your local laws; the <a href="qa.html">Q&A page</a> has the details. This is not legal advice.</p></div>+</details>++<details class="faq" id="rf-sentinel-who">+<summary>Who makes RF Sentinel?</summary>+<div><p>RF Sentinel is an independent open-source project by CIS-C0 and contributors, developed in the open on <a href="https://github.com/CIS-C0/RFSentinel" rel="noopener">GitHub</a>. It is not affiliated with Flock Safety, Axon, Waze or any detection product it is compared with. Questions and bug reports are welcome in the repository's issues or on <a href="https://discord.gg/NDTjn8HMGq" rel="noopener">Discord</a>.</p></div>+</details>+<section class="community" aria-label="Community">+ <a class="dc" href="https://discord.gg/NDTjn8HMGq" rel="noopener"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M20.3 4.4A19.8 19.8 0 0 0 15.4 2.9l-.6 1.3a18.3 18.3 0 0 0-5.5 0L8.7 2.9a19.7 19.7 0 0 0-4.9 1.5C.5 9-.3 13.6.1 18.1a19.9 19.9 0 0 0 6 3l1.3-2a12.9 12.9 0 0 1-1.9-.9l.4-.3a14.2 14.2 0 0 0 12.1 0l.4.3c-.6.4-1.2.7-1.9.9l1.3 2a19.8 19.8 0 0 0 6-3c.5-5.2-.8-9.7-3.5-13.7zM8 15.3c-1.2 0-2.2-1.1-2.2-2.4S6.8 10.5 8 10.5s2.2 1.1 2.2 2.4-1 2.4-2.2 2.4zm8 0c-1.2 0-2.2-1.1-2.2-2.4s1-2.4 2.2-2.4 2.2 1.1 2.2 2.4-1 2.4-2.2 2.4z"/></svg><span><strong>Join the Discord</strong>Help, ideas, new signatures, field captures and ESP32 builds.</span></a>+ <a class="gh" href="https://github.com/CIS-C0/RFSentinel" rel="noopener"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 .3a12 12 0 0 0-3.8 23.4c.6.1.8-.3.8-.6v-2c-3.3.7-4-1.6-4-1.6-.6-1.4-1.4-1.8-1.4-1.8-1-.7.1-.7.1-.7 1.2.1 1.8 1.2 1.8 1.2 1 1.8 2.8 1.3 3.5 1 0-.8.4-1.3.7-1.6-2.7-.3-5.5-1.3-5.5-5.9 0-1.3.5-2.4 1.2-3.2 0-.3-.5-1.5.2-3.2 0 0 1-.3 3.3 1.2a11.5 11.5 0 0 1 6 0c2.3-1.5 3.3-1.2 3.3-1.2.6 1.7.2 2.9.1 3.2.8.8 1.2 1.9 1.2 3.2 0 4.6-2.8 5.6-5.5 5.9.5.4.9 1.1.9 2.2v3.3c0 .3.1.7.8.6A12 12 0 0 0 12 .3"/></svg><span><strong>CIS-C0/RFSentinel on GitHub</strong>Source code, releases, issues. A star helps others find it.</span></a>+</section>+</main>+<footer>+ <div class="wrap">+ <div class="cols">+ <div>+ <p class="foot-title">RF Sentinel</p>+ <ul>+ <li><a href="https://github.com/CIS-C0/RFSentinel/releases/latest">Download the APK</a></li>+ <li><a href="install.html">Install & update</a></li>+ <li><a href="how-it-works.html">How detection works</a></li>+ <li><a href="qa.html">Q&A</a></li>+ </ul>+ </div>+ <div>+ <p class="foot-title">Guides</p>+ <ul><li><a href="what-is-rf-sentinel.html">What is RF Sentinel?</a></li><li><a href="police-detector.html">Detect police with Android</a></li><li><a href="flock-camera-detector.html">Flock & plate-reader cameras</a></li><li><a href="imsi-catcher-detector.html">Stingray / IMSI catcher signs</a></li><li><a href="tracker-detector.html">AirTag & tracker detection</a></li><li><a href="drone-detector.html">Remote ID drone detector</a></li><li><a href="smart-glasses-detector.html">Smart glasses detector</a></li><li><a href="alternatives.html">Compared with other tools</a></li><li><a href="sophia-alternative.html">Free SØPHIA alternative</a></li></ul>+ </div>+ <div>+ <p class="foot-title">Community</p>+ <ul>+ <li><a href="https://discord.gg/NDTjn8HMGq" rel="noopener">Discord server</a></li>+ <li><a href="https://github.com/CIS-C0/RFSentinel" rel="noopener">GitHub repository</a></li>+ <li><a href="https://github.com/CIS-C0/RFSentinel/issues" rel="noopener">Issues & device reports</a></li>+ <li><a href="https://github.com/CIS-C0/RFSentinel/blob/main/docs/SIGNATURES.md" rel="noopener">Signature reference</a></li>+ </ul>+ </div>+ </div>+ <p class="legal">RF Sentinel is free software under the GNU GPL v3.0. Copyright © 2026 CIS-C0.+ Receive-only: it transmits nothing, and a detection is a signature match, not proof of who is present. Check your local laws.+ Not affiliated with any company or product named on this site; names are used only to describe compatibility and detection.+ No cookies, no analytics, no trackers on this site.</p>+ </div>+</footer>+<script>+// A link to a question (qa.html#detect-flock) opens its answer.+(function () {+ function openHash() {+ var el = location.hash && document.getElementById(decodeURIComponent(location.hash.slice(1)));+ if (el && el.tagName === "DETAILS") { el.open = true; el.scrollIntoView(); }+ }+ openHash();+ window.addEventListener("hashchange", openHash);+})();+// Latest release: version label and a direct link to the signed APK. Falls back to the releases page.+(function () {+ var els = document.querySelectorAll("[data-apk]");+ if (!els.length || !window.fetch) return;+ fetch("https://api.github.com/repos/CIS-C0/RFSentinel/releases/latest")+ .then(function (r) { return r.ok ? r.json() : null; })+ .then(function (rel) {+ if (!rel) return;+ var apk = (rel.assets || []).filter(function (a) { return /-release\.apk$/.test(a.name); })[0];+ els.forEach(function (el) {+ if (apk) el.href = apk.browser_download_url;+ var v = el.querySelector("[data-version]");+ if (v) v.textContent = rel.tag_name;+ });+ }).catch(function () {});+})();+</script>+</body>+</html>diff --git a/site/pages/index.html b/site/pages/index.htmlindex 7197b41..4a2ffbb 100644--- a/site/pages/index.html+++ b/site/pages/index.html@@ -2,7 +2,7 @@<section class="hero"><div><p class="kicker">[email protected]:~$ ./rf_sentinel --passive</p>- <h1>RF_SENTINEL<span class="sr-only"> - police detector for Android</span></h1>+ <h1><span aria-hidden="true">RF_SENTINEL</span><span class="sr-only">RF Sentinel - police detector for Android</span></h1><p class="lead">A free, open-source <b>police detector for Android</b>. It listens to the Bluetooth LE advertisements and WiFi beacons around you and flags police and surveillance equipment: body cameras, Flock and other plate-reader cameras, patrol-vehicle gear, trackers following you, Remote ID drones and camera glasses. It also watches the cell network for fake-tower (IMSI catcher) signs.</p><p><span class="stamp">RX ONLY</span><span class="small">No root · no Termux · no account · no analytics · GPL-3.0 · Android 8.0+ (64-bit)</span></p><div class="cta">diff --git a/site/pages/what-is-rf-sentinel.html b/site/pages/what-is-rf-sentinel.htmlnew file mode 100644index 0000000..7778ce4--- /dev/null+++ b/site/pages/what-is-rf-sentinel.html@@ -0,0 +1,55 @@+<!--META {"title": "What is RF Sentinel? Free Police Detector App for Android (RFSentinel)", "description": "RF Sentinel (also written RFSentinel) is a free, open-source Android app that detects police body cams, plate-reader cameras, trackers and drones from Bluetooth and WiFi. No root, no account.", "nav": "guides", "crumb": "What is RF Sentinel"} -->+<div class="page-head">+ <p class="crumbs"><a href="./">rf_sentinel</a> / guides / what-is-rf-sentinel</p>+ <h1>What is RF Sentinel?</h1>+ <p class="lead"><b>RF Sentinel</b> (written <b>RFSentinel</b> in its code and on GitHub, sometimes RF-Sentinel) is a free, open-source Android app that passively listens to the Bluetooth LE and WiFi signals around you and tells you when police or surveillance equipment is nearby. It needs no root, no account and sends none of your scans anywhere.</p>+ <div class="cta">+ <a class="btn primary" href="{{RELEASES}}" data-apk>{{DOWNLOAD_SVG}}Download RF Sentinel <span data-version></span></a>+ <a class="btn" href="{{REPO}}" rel="noopener">{{GITHUB_SVG}}RFSentinel on GitHub</a>+ </div>+</div>++<h2 id="what">What RF Sentinel does</h2>+<p>Many devices announce themselves over the air all the time: body cameras, license-plate cameras, patrol-vehicle equipment, Bluetooth trackers, Remote ID drones and smart glasses. RF Sentinel recognises those signatures and shows them in a live list, a radar and a map, with the evidence for each, so you know what is around you and why it was flagged.</p>+<ul>+ <li><b>Police and surveillance gear:</b> body cams, Flock and other plate-reader cameras, patrol-vehicle equipment, trackers following you (<a href="tracker-detector.html">AirTag, SmartTag, Find Hub</a>), <a href="drone-detector.html">drones</a>, <a href="smart-glasses-detector.html">camera glasses</a>, and signs of <a href="imsi-catcher-detector.html">fake cell towers</a>.</li>+ <li><b>Known cameras on the map:</b> speed, red-light and plate-reader cameras from OpenStreetMap, with warnings before you reach them, and routes that can go around them.</li>+ <li><b>Navigation and the map:</b> turn-by-turn directions, a 3D driving view, a speedometer with the posted limit, and Waze police reports on your road.</li>+ <li><b>In the car:</b> <a href="android-auto.html">Android Auto</a> support and optional <a href="esp32.html">ESP32 boards</a> and USB WiFi adapters for more range.</li>+</ul>+<p>It is receive-only: RF Sentinel never transmits to, connects to, jams or spoofs any device. See <a href="how-it-works.html">how it works</a> for the detection logic and <a href="police-detector.html">how to detect police with Android</a> for a practical guide.</p>++<h2 id="get">Where to get it</h2>+<p>RF Sentinel is downloaded as an APK from <a href="{{RELEASES}}" rel="noopener">GitHub Releases</a> (the RFSentinel repository), not from Google Play. The <a href="install.html">install guide</a> covers allowing the install, updating in the app and what to expect. Its source code is public under the GPL-3.0 licence.</p>++<h2 id="faq">Questions people ask</h2>++<details class="faq" id="rf-sentinel-vs-rfsentinel">+<summary>Is "RF Sentinel" the same as "RFSentinel"?</summary>+<div><p>Yes. The app is called RF Sentinel; "RFSentinel" is the same name written without a space, as used in the GitHub repository (CIS-C0/RFSentinel), the package name and the code. Searching for either finds the same project.</p></div>+</details>++<details class="faq" id="rf-sentinel-free">+<summary>Is RF Sentinel free?</summary>+<div><p>Yes. RF Sentinel is free and open source under the GPL-3.0 licence, with no accounts, no ads and no analytics.</p></div>+</details>++<details class="faq" id="rf-sentinel-play-store">+<summary>Is RF Sentinel on Google Play?</summary>+<div><p>No. It is distributed as a signed APK on GitHub Releases. The in-app "Check for updates" can download and install new versions for you once you have allowed it.</p></div>+</details>++<details class="faq" id="rf-sentinel-root">+<summary>Does RF Sentinel need root or a special device?</summary>+<div><p>No. It runs on an ordinary Android 8.0+ phone (64-bit ARM) using the phone's own Bluetooth and WiFi. External hardware such as ESP32 boards or USB WiFi adapters is optional and adds range.</p></div>+</details>++<details class="faq" id="rf-sentinel-safe-legal">+<summary>Is RF Sentinel safe and legal to use?</summary>+<div><p>It only listens to signals that devices broadcast openly and never transmits. The rules for scanning and for using any alerts differ between countries and states, so check your local laws; the <a href="qa.html">Q&A page</a> has the details. This is not legal advice.</p></div>+</details>++<details class="faq" id="rf-sentinel-who">+<summary>Who makes RF Sentinel?</summary>+<div><p>RF Sentinel is an independent open-source project by CIS-C0 and contributors, developed in the open on <a href="{{REPO}}" rel="noopener">GitHub</a>. It is not affiliated with Flock Safety, Axon, Waze or any detection product it is compared with. Questions and bug reports are welcome in the repository's issues or on <a href="{{DISCORD}}" rel="noopener">Discord</a>.</p></div>+</details>diff --git a/tools/build_site.py b/tools/build_site.pyindex cbf5ded..719c116 100644--- a/tools/build_site.py+++ b/tools/build_site.py@@ -42,6 +42,7 @@ NAV = []GUIDES = [+ ("what-is-rf-sentinel.html", "What is RF Sentinel?"),("police-detector.html", "Detect police with Android"),("flock-camera-detector.html", "Flock & plate-reader cameras"),("imsi-catcher-detector.html", "Stingray / IMSI catcher signs"),@@ -225,7 +226,7 @@ def build():graph.append({"@type": "SoftwareApplication","name": "RF Sentinel",- "alternateName": ["RFSentinel", "RF Sentinel police scanner"],+ "alternateName": ["RFSentinel", "RF-Sentinel", "RF Sentinel app", "RF Sentinel Android", "RF Sentinel police scanner"],"applicationCategory": "UtilitiesApplication","operatingSystem": "Android 8.0+","description": meta["description"],@@ -245,7 +246,7 @@ def build():"author": {"@type": "Organization", "name": "CIS-C0", "url": "https://github.com/CIS-C0"},"sameAs": [REPO, DISCORD],})- graph.append({"@type": "WebSite", "name": "RF Sentinel", "url": BASE})+ graph.append({"@type": "WebSite", "name": "RF Sentinel", "alternateName": ["RFSentinel", "RF-Sentinel"], "url": BASE})else:graph.append({"@type": "BreadcrumbList",