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
Camera direction cones, side-facing cameras don't warn, ADS-B switch
CIS-C0b195b1fc484c
diff --git a/README.md b/README.mdindex ceebda7..fdf3d25 100644--- a/README.md+++ b/README.md@@ -371,7 +371,9 @@ Your position, recorded traces, the devices heard around you and the known camerwithin your radius (10-200 km, 100 by default); *US & Canada plate cameras* fetches everyplate reader mapped in the US and Canada (~18 MB, refreshed weekly on WiFi).Both use [DeFlock](https://deflock.org)'s hourly snapshot of OpenStreetMap,- plus cameras it leaves out, straight from OpenStreetMap. Tap a camera →+ plus cameras it leaves out, straight from OpenStreetMap. Where the direction is mapped,+ a cone in the camera's colour shows which way it faces when you zoom in, and a camera+ facing across your way (watching a cross street) doesn't warn. Tap a camera →*Ignore alerts* to never be warned about it again.- **CCTV cameras** (Settings → *Known cameras* → *Show CCTV cameras*, off by default):ordinary surveillance cameras mapped in OpenStreetMap - city street cameras,diff --git a/app/src/main/java/com/rfsentinel/app/alpr/KnownCameras.kt b/app/src/main/java/com/rfsentinel/app/alpr/KnownCameras.ktindex 24c7a00..9408290 100644--- a/app/src/main/java/com/rfsentinel/app/alpr/KnownCameras.kt+++ b/app/src/main/java/com/rfsentinel/app/alpr/KnownCameras.kt@@ -212,13 +212,28 @@ object KnownCameras {): Pair<KnownCamera, Double>? {if (bearingDeg == null) return near(cameras, lat, lon, maxM / 3).firstOrNull { !skip(it.first) }return near(cameras, lat, lon, maxM).firstOrNull { (c, d) ->- if (skip(c)) return@firstOrNull false+ if (skip(c) || !watchesYourWay(c, bearingDeg.toDouble())) return@firstOrNull falseif (d < 30.0) return@firstOrNull true // right hereval diff = kotlin.math.abs(((bearingTo(lat, lon, c.lat, c.lon) - bearingDeg) % 360 + 540) % 360 - 180)diff <= coneDeg}}+ /**+ * Whether [c] watches the road you're on, going [bearingDeg]: it faces along your way, towards+ * you (front plates) or away (rear plates, read once you've passed). One facing across your+ * way - [SIDEWAYS_DEG] or more off - watches a cross street. True when either isn't known.+ */+ fun watchesYourWay(c: KnownCamera, bearingDeg: Double?): Boolean {+ val dir = c.direction ?: return true+ if (bearingDeg == null) return true+ val off = kotlin.math.abs(((dir - bearingDeg) % 180 + 270) % 180 - 90) // 0 = along your way, 90 = across+ return off < SIDEWAYS_DEG+ }++ /** A camera facing this far or more off your way watches another road. */+ const val SIDEWAYS_DEG = 55.0+/** Initial great-circle bearing from one point to another, degrees from north (0-360). */fun bearingTo(lat1: Double, lon1: Double, lat2: Double, lon2: Double): Double {val p1 = Math.toRadians(lat1); val p2 = Math.toRadians(lat2)diff --git a/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt b/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.ktindex 05b9b96..b18803c 100644--- a/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt+++ b/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt@@ -788,9 +788,11 @@ class ScanForegroundService : Service() {val speed = if (loc.hasSpeed()) loc.speed else null// Search out to the larger (speed camera) radius, then apply each kind's own.val radius = KnownCameras.warnRadius(speed, com.rfsentinel.app.alpr.KnownCamera.Kind.SPEED)+ // Moving (~7 km/h or more): a camera facing across your way watches a cross street, not you.+ val heading = if (loc.hasBearing() && (speed ?: 0f) >= 2f) loc.bearing.toDouble() else nullval near = KnownCameras.near(AlprStore.cameras, loc.latitude, loc.longitude, radius).filter { (cam, d) ->- wantsAlert(cam.type) && d <= KnownCameras.warnRadius(speed, cam.type) &&+ wantsAlert(cam.type) && d <= KnownCameras.warnRadius(speed, cam.type) && KnownCameras.watchesYourWay(cam, heading) &&!com.rfsentinel.app.alpr.IgnoredCameras.contains(this, cam.osmId) // silenced from the map}val nearIds = near.map { it.first.osmId }.toSet()diff --git a/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt b/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.ktindex 561702d..2dd4358 100644--- a/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt+++ b/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt@@ -1048,6 +1048,9 @@ class SettingsActivity : AppCompatActivity() {setOnCheckedChangeListener { _, v -> save(v) }}.also { box.addView(if (info == null) it else infoRow(it, info)) }+ switch("ADS-B aircraft receiver", Prefs.sdrAdsb(this),+ "Listens on 1090 MHz for aircraft instead of sweeping the radio bands. Police aircraft are found without internet. " ++ "Needs Police aircraft turned on. A 1090 MHz antenna helps; the stock one hears out to about 50 km.") { Prefs.setSdrAdsb(this, it) }slider(15, 50, Prefs.radioMinSnr(this), { "Sensitivity: $it dB above the noise" }) {Prefs.setRadioMinSnr(this, it)}diff --git a/app/src/main/java/com/rfsentinel/app/ui/RfMap.kt b/app/src/main/java/com/rfsentinel/app/ui/RfMap.ktindex 6972185..cbf361c 100644--- a/app/src/main/java/com/rfsentinel/app/ui/RfMap.kt+++ b/app/src/main/java/com/rfsentinel/app/ui/RfMap.kt@@ -35,8 +35,14 @@ internal class RfMap(private val activity: AppCompatActivity, val map: MapEngineconst val CAMERAS_MIN_ZOOM = 8.0private const val CCTV_MIN_ZOOM = 11.0private const val CCTV_CONE_ZOOM = 14.0+ /** Plate, speed and red-light cameras' facing cones show from here (a street's scale). */+ private const val CAMERA_CONE_ZOOM = 13.0+ /** Drawn view of a road camera: about how far a plate reader reads, and its usual width. */+ private const val CAMERA_CONE_M = 60.0+ private const val CAMERA_CONE_DEG = 40.0private const val PRECISION = "rf-precision"; private const val CONES = "rf-cctv-cones"+ private const val CAM_CONES = "rf-camera-cones"private const val TRACE = "rf-trace"; private const val DRONE_LINES = "rf-drone-lines"private const val TOWERS = "rf-towers"; private const val CCTV = "rf-cctv"; private const val CAMERAS = "rf-cameras"private const val DEVICES = "rf-devices"; private const val DOTS = "rf-device-dots"; private const val LABELS = "rf-device-labels"@@ -127,7 +133,7 @@ internal class RfMap(private val activity: AppCompatActivity, val map: MapEngine/** Every layer, as map style JSON (the same on both engines). */private fun addLayers(dark: Boolean) {- listOf(NAV_ROUTES, NAV_PLACES, PRECISION, CONES, TRACE, DRONE_LINES, TOWERS, CCTV, CAMERAS, DEVICES, WAZE, DRONE_OPS, DRONES, AIRCRAFT)+ listOf(NAV_ROUTES, NAV_PLACES, PRECISION, CONES, CAM_CONES, TRACE, DRONE_LINES, TOWERS, CCTV, CAMERAS, DEVICES, WAZE, DRONE_OPS, DRONES, AIRCRAFT).forEach { map.addSource(it) }fun get(k: String) = a("get", k)val color = a("to-color", get("color"))@@ -166,6 +172,10 @@ internal class RfMap(private val activity: AppCompatActivity, val map: MapEnginelayer("$PRECISION-line", "line", PRECISION, paint = o("line-color" to color, "line-width" to 1.5, "line-opacity" to 0.7)),// What each CCTV camera watches (zoomed in).layer("$CONES-fill", "fill", CONES, minzoom = CCTV_CONE_ZOOM, paint = o("fill-color" to color, "fill-opacity" to get("opacity"))),+ // Which way each plate, speed and red-light camera faces (when mapped), in its icon's colour.+ layer("$CAM_CONES-fill", "fill", CAM_CONES, minzoom = CAMERA_CONE_ZOOM, paint = o("fill-color" to color, "fill-opacity" to get("opacity"))),+ layer("$CAM_CONES-line", "line", CAM_CONES, minzoom = CAMERA_CONE_ZOOM,+ paint = o("line-color" to color, "line-width" to 1.2, "line-opacity" to a("*", get("opacity"), 2.5))),layer(TRACE, "line", layout = o("line-cap" to "round", "line-join" to "round"),paint = o("line-color" to color, "line-width" to 5.0)),layer(DRONE_LINES, "line", paint = o("line-color" to DRONE_COLOR, "line-width" to 2.5, "line-dasharray" to a(4.0, 2.5))),@@ -328,6 +338,12 @@ internal class RfMap(private val activity: AppCompatActivity, val map: MapEngineGeoJson.feature(GeoJson.point(c.lat, c.lon), "id" to c.osmId, "icon" to "rf-cam-${c.type.name}","opacity" to if (com.rfsentinel.app.alpr.IgnoredCameras.contains(activity, c.osmId)) 0.35 else 1.0)})+ set(CAM_CONES, cams.mapNotNull { c ->+ val dir = c.direction ?: return@mapNotNull null+ val faded = com.rfsentinel.app.alpr.IgnoredCameras.contains(activity, c.osmId)+ GeoJson.feature(GeoJson.polygon(MapGeo.wedge(c.lat, c.lon, dir.toDouble(), CAMERA_CONE_DEG, CAMERA_CONE_M)),+ "color" to hex(MapIcons.cameraColor(c.type)), "opacity" to if (faded) 0.08 else 0.25)+ })val showCctv = Prefs.showCctv(activity)val private = Prefs.cctvPrivate(activity)@@ -362,7 +378,7 @@ internal class RfMap(private val activity: AppCompatActivity, val map: MapEngine}private fun clearStatic() {- listOf(CAMERAS, CCTV, CONES, TOWERS).forEach { set(it, emptyList()) }+ listOf(CAMERAS, CAM_CONES, CCTV, CONES, TOWERS).forEach { set(it, emptyList()) }cameras = emptyMap(); cctvs = emptyMap(); towers = emptyMap(); staticBox = null}diff --git a/app/src/main/java/com/rfsentinel/app/util/Prefs.kt b/app/src/main/java/com/rfsentinel/app/util/Prefs.ktindex 3eb4b0d..5ca91b0 100644--- a/app/src/main/java/com/rfsentinel/app/util/Prefs.kt+++ b/app/src/main/java/com/rfsentinel/app/util/Prefs.kt@@ -484,6 +484,7 @@ object Prefs {fun setRadioMatchKhz(context: Context, v: Int) = setInt(context, "radio_match_khz", v.coerceIn(1, 50))/** The RTL-SDR as an ADS-B aircraft receiver on 1090 MHz instead of the radio sweep (off by default). */fun sdrAdsb(context: Context): Boolean = bool(context, "sdr_adsb", false)+ fun setSdrAdsb(context: Context, v: Boolean) = setBool(context, "sdr_adsb", v)/** Name hits from RadioReference (needs the user's own Premium login and developer key; off by default). */fun radioReferenceOn(context: Context): Boolean = bool(context, "radio_reference_on", false)diff --git a/app/src/test/java/com/rfsentinel/app/alpr/KnownCamerasTest.kt b/app/src/test/java/com/rfsentinel/app/alpr/KnownCamerasTest.ktindex d11404d..5bf0b38 100644--- a/app/src/test/java/com/rfsentinel/app/alpr/KnownCamerasTest.kt+++ b/app/src/test/java/com/rfsentinel/app/alpr/KnownCamerasTest.kt@@ -1,6 +1,7 @@package com.rfsentinel.app.alprimport org.junit.Assert.assertEquals+import org.junit.Assert.assertFalseimport org.junit.Assert.assertNullimport org.junit.Assert.assertTrueimport org.junit.Test@@ -114,4 +115,15 @@ class KnownCamerasTest {assertTrue(found[0].second <= found[1].second)assertTrue(KnownCameras.near(cams, 10.6, -20.5, 150.0).isEmpty())}++ @Test+ fun aCameraFacingAcrossYourWayWatchesAnotherRoad() {+ fun cam(dir: Int?) = KnownCamera("n1", 10.5, -20.5, null, null, dir)+ // Driving north (0°): facing you (180°), away (0° / 350°) or slightly off all watch your road.+ for (d in listOf(180, 0, 350, 30, 200)) assertTrue("$d", KnownCameras.watchesYourWay(cam(d), 0.0))+ // Facing east or west: a cross street.+ for (d in listOf(90, 270, 110, 245)) assertFalse("$d", KnownCameras.watchesYourWay(cam(d), 0.0))+ assertTrue(KnownCameras.watchesYourWay(cam(null), 0.0))+ assertTrue(KnownCameras.watchesYourWay(cam(90), null))+ }}