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
Waze only-ahead: stay quiet when there is no driving direction (parked or not yet driven)
CIS-C0830b796b2671
diff --git a/app/src/main/java/com/rfsentinel/app/online/AheadOnRoad.kt b/app/src/main/java/com/rfsentinel/app/online/AheadOnRoad.ktindex b795b3f..5cfbdff 100644--- a/app/src/main/java/com/rfsentinel/app/online/AheadOnRoad.kt+++ b/app/src/main/java/com/rfsentinel/app/online/AheadOnRoad.kt@@ -50,7 +50,7 @@ internal class AheadOnRoad {}/** Your heading while driving; stopped, the last one for 2 minutes (as long as you haven't moved off). */- private fun headingOf(me: Location): Double? {+ fun headingOf(me: Location): Double? {val now = System.currentTimeMillis()if (me.hasBearing() && me.hasSpeed() && me.speed > 1.5f) {heading = me.bearing.toDouble(); headingAt = now; headingLat = me.latitude; headingLon = me.longitudediff --git a/app/src/main/java/com/rfsentinel/app/online/WazePolice.kt b/app/src/main/java/com/rfsentinel/app/online/WazePolice.ktindex 2edd26e..6e3977f 100644--- a/app/src/main/java/com/rfsentinel/app/online/WazePolice.kt+++ b/app/src/main/java/com/rfsentinel/app/online/WazePolice.kt@@ -96,6 +96,17 @@ object WazePolice {}}+ /**+ * "Only ahead" where neither the route nor the map's roads decide: the corridor test along your heading,+ * or along [lastHeading] (kept a while when you stop) when the fix has none. With no heading at all+ * there is no "ahead", so the report stays quiet.+ */+ fun quietWhenUnsure(w: Where, lastHeading: Double?, meLat: Double, meLon: Double, lat: Double, lon: Double): Boolean {+ if (w.relDeg != null) return !w.maybeOnMyWay()+ val h = lastHeading ?: return true+ return !where(meLat, meLon, h, lat, lon).maybeOnMyWay()+ }+/** Half-width of the "could be my road" corridor at [distanceM]: a road's width plus room for bends. */fun corridorM(distanceM: Double): Double = (CORRIDOR_BASE_M + CORRIDOR_SPREAD * distanceM).coerceAtMost(CORRIDOR_MAX_M)diff --git a/app/src/main/java/com/rfsentinel/app/online/WazeWatch.kt b/app/src/main/java/com/rfsentinel/app/online/WazeWatch.ktindex 94d1c85..2cd5a62 100644--- a/app/src/main/java/com/rfsentinel/app/online/WazeWatch.kt+++ b/app/src/main/java/com/rfsentinel/app/online/WazeWatch.kt@@ -252,10 +252,13 @@ class WazeWatch(// (no data yet, not driving), inside a corridor along your heading.val onRoute = if (aheadOnly) routeVerdicts(shown, alertM) else emptyMap()val verdicts = if (aheadOnly && onRoute.isEmpty()) road.verdicts(context, me, alertM, shown.map { it.report }) else onRoute+ // Stopped (a light, a jam), the last heading still says which way is ahead; with none at all+ // (parked, or not driven yet) nothing is ahead of you, so nothing counts until you drive.+ val lastHeading = if (aheadOnly && onRoute.isEmpty()) road.headingOf(me) else nullfun quiet(s: WazePolice.Shown) = when (verdicts[s.report.id]) {RoadMatch.Verdict.ON_MY_ROAD -> falseRoadMatch.Verdict.OTHER_ROAD, RoadMatch.Verdict.BEHIND -> true- else -> !s.where.maybeOnMyWay()+ else -> WazePolice.quietWhenUnsure(s.where, lastHeading, me.latitude, me.longitude, s.report.lat, s.report.lon)}// The list shows what counts as on your way; the map keeps the wider picture.for (i in shown.indices) shown[i] = shown[i].copy(onMyWay = !(aheadOnly && quiet(shown[i])))diff --git a/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt b/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.ktindex 3e32c5d..8f229b1 100644--- a/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt+++ b/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt@@ -1619,7 +1619,8 @@ class SettingsActivity : AppCompatActivity() {"roads, so one on a parallel road, a cross street, an overpass or behind you stays quiet (it stays on the list, " +"marked \"not on your way\" unless you hide them below). While you are being guided to a destination the route " +"decides: only reports on the part of it still ahead count, round corners too. Where the map can't tell yet, " +- "reports behind you stay quiet.",+ "reports behind you stay quiet. Parked, or before you've driven off, there is no \"ahead\" yet, so reports " ++ "stay quiet until you move.",Prefs.wazeAheadOnly(this)) { Prefs.setWazeAheadOnly(this, it) }switchRow("Hide reports that aren't on my way","With the switch above on, a report behind you, on another street or off your route is left off the list (the map " +diff --git a/app/src/test/java/com/rfsentinel/app/online/WazeRelativeTest.kt b/app/src/test/java/com/rfsentinel/app/online/WazeRelativeTest.ktindex 49d2301..e8fca5d 100644--- a/app/src/test/java/com/rfsentinel/app/online/WazeRelativeTest.kt+++ b/app/src/test/java/com/rfsentinel/app/online/WazeRelativeTest.kt@@ -70,4 +70,19 @@ class WazeRelativeTest {assertTrue(where(150.0, null).maybeOnMyWay())assertEquals(null, where(150.0, null).lateralM)}++ @Test+ fun onlyAheadStaysQuietWithNoHeadingAtAll() {+ // A report 270 m due south (synthetic coordinates), the phone parked: no heading now, none remembered.+ val lat = 10.0 - 270.0 / 111_320.0+ val parked = WazePolice.where(10.0, 10.0, null, lat, 10.0)+ assertTrue(WazePolice.quietWhenUnsure(parked, null, 10.0, 10.0, lat, 10.0))+ // Stopped at a light, last heading south: it's ahead on your line, so it counts.+ assertTrue(!WazePolice.quietWhenUnsure(parked, 180.0, 10.0, 10.0, lat, 10.0))+ // Last heading north: it's behind you.+ assertTrue(WazePolice.quietWhenUnsure(parked, 0.0, 10.0, 10.0, lat, 10.0))+ // Driving south right now: the fix's own heading decides.+ val driving = WazePolice.where(10.0, 10.0, 180.0, lat, 10.0)+ assertTrue(!WazePolice.quietWhenUnsure(driving, null, 10.0, 10.0, lat, 10.0))+ }}