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
Radar-detector beeps option (ticks speed up as a flagged device gets closer) and an alert card beside the floating threat bubble
CIS-C0785caee6e5e0
diff --git a/README.md b/README.mdindex 759b2a5..f9668ff 100644--- a/README.md+++ b/README.md@@ -127,9 +127,10 @@ headline as you get closer (strong within 50 m, fading out by 500 m). Full refer**Alerts**- Sound, vibration pattern per tier (1 / 2 / 3 pulses) and spoken announcements through the phone's own speech engine (prioritised, voice and speed pickers)+- **Radar-detector beeps** option: after an alert, beeps speed up as the flagged device gets closer- **Short spoken alerts** option ("Body cam", "Police car", "Speed camera, 50")- Discreet mode, adjustable alert threshold, mute from the app or the car-- **Floating threat bubble** over Waze, Google Maps or any app+- **Floating threat bubble** over Waze, Google Maps or any app, with a pop-up card saying what was just detected- **Floating mini map** over other apps: the devices and known cameras around you, like the app's map (pinch to zoom, drag, resize)- Android Auto alert cards say what it is, how sure, about how far and how many more are flagged ("BODY CAM · strong · ~40 m · near (-58 dBm) · +2 more flagged")- Notification, Quick Settings tile and home-screen widget@@ -221,6 +222,7 @@ Details: [How it works](https://cis-c0.github.io/RFSentinel/how-it-works.html) afavorite, copy, ignore, and **Report unknown device**.- **Floating bubble** (Settings, needs *Display over other apps*): green whenclear, orange for probable, red for strong or a follower, with the count.+ Each new alert shows a small card beside it for a few seconds (what, type, distance).- **Floating mini map** (Settings, same permission): the devices and knowncameras around you over Waze, Google Maps or any app, centred on you, with athreat-colour border. Pinch to zoom, drag to move, the corner handle resizesdiff --git a/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt b/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.ktindex aca255b..c842f3e 100644--- a/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt+++ b/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt@@ -64,6 +64,11 @@ import java.util.concurrent.ConcurrentHashMapclass ScanForegroundService : Service() {companion object {+ /** Radar beeps: start after the alert's own beeps, last up to 2 min, stop 10 s after the device is lost. */+ private const val RADAR_QUIET_MS = 2_500L+ private const val RADAR_HOLD_MS = 120_000L+ private const val RADAR_LOST_MS = 10_000L+private const val TAG = "ScanForegroundService"const val ACTION_STOP = "com.rfsentinel.app.action.STOP"/** Re-evaluates location updates, e.g. after trace recording starts or stops. */@@ -166,6 +171,7 @@ class ScanForegroundService : Service() {private var housekeepingJob: Job? = nullprivate var cellJob: Job? = nullprivate var bubbleJob: Job? = null+ private var radarJob: Job? = nullprivate var cellMonitor: CellMonitor? = nullprivate val lastCellAlert = HashMap<String, Long>()private var btStateReceiverRegistered = false@@ -274,6 +280,7 @@ class ScanForegroundService : Service() {startGnssChecks()onlineWatch.sync()startBubble()+ startRadarBeep()isRunning = truerefreshTile()@@ -980,6 +987,32 @@ class ScanForegroundService : Service() {* Keeps the floating threat bubble and the floating mini map in sync (hidden while* our own screens are visible).*/+ /**+ * Radar-detector beeps: after a device alert, tick faster as the flagged device's+ * signal gets stronger and stop when it's gone. Each alerted device beeps for at+ * most [RADAR_HOLD_MS], so one parked next to you doesn't beep forever; it starts+ * again when the device re-alerts.+ */+ private fun startRadarBeep() {+ radarJob?.cancel()+ radarJob = serviceScope.launch {+ while (isActive) {+ val ctx = this@ScanForegroundService+ val now = System.currentTimeMillis()+ val target = if (!Prefs.radarBeep(ctx)) null else lastAlerted.entries+ .filter { now - it.value in RADAR_QUIET_MS..RADAR_HOLD_MS && !WhitelistCache.contains(it.key) }+ .mapNotNull { DeviceRegistry.get(it.key) }+ .filter { now - it.lastSeen <= RADAR_LOST_MS }+ .maxByOrNull { it.rssi }+ if (target == null) delay(1_000L)+ else {+ AlertPlayer.tick(ctx)+ delay(com.rfsentinel.app.util.Beeper.tickIntervalMs(target.rssi))+ }+ }+ }+ }+private fun startBubble() {bubbleJob?.cancel()val bubble = Prefs.threatBubble(this); val miniMap = Prefs.floatingMap(this)diff --git a/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt b/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.ktindex 909c2c5..f5f7623 100644--- a/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt+++ b/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt@@ -316,12 +316,15 @@ class SettingsActivity : AppCompatActivity() {Section("alerts", binding.headerAlerts, binding.sectionAlerts,"Threshold: \"Weak\" alerts on every match (more false alarms); \"Strong only\" on near-certain ones.\n\n" +"Vibration: 1 pulse weak, 2 probable, 3 strong.\n\n" ++ "Radar-detector beeps (off by default): after a device alert, keeps beeping faster as its signal " ++ "gets stronger, like a radar detector; stops when it's gone or after 2 minutes.\n\n" +"Re-alert: how long before the same device can alert again."),Section("voice", binding.headerVoice, binding.sectionVoice,"Speaks each alert, for example while driving. Short alerts say just the type " +"(\"Body cam\", \"Police car\", \"Speed camera, 50\")."),Section("overlay", binding.headerOverlay, binding.sectionOverlay,"Shown over other apps (Waze, Maps...) while scanning. Needs Android's \"Display over other apps\" permission.\n\n" ++ "Bubble: each new alert shows what was detected in a small card beside it for a few seconds.\n\n" +"Mini map: the devices around you, like the app's map. Drag to move, pinch to zoom, " +"corner handle to resize, tap to open the full map."),Section("follow", binding.headerFollow, binding.sectionFollow,@@ -684,6 +687,7 @@ class SettingsActivity : AppCompatActivity() {)binding.soundSwitch.isChecked = Prefs.soundEnabled(this)binding.vibrateSwitch.isChecked = Prefs.vibrateEnabled(this)+ binding.radarBeepSwitch.isChecked = Prefs.radarBeep(this)binding.voiceSwitch.isChecked = Prefs.voiceEnabled(this)binding.shortVoiceSwitch.isChecked = Prefs.shortVoice(this)setupVoiceControls()@@ -926,6 +930,7 @@ class SettingsActivity : AppCompatActivity() {})Prefs.setSoundEnabled(this, binding.soundSwitch.isChecked)+ Prefs.setRadarBeep(this, binding.radarBeepSwitch.isChecked)Prefs.setVibrateEnabled(this, binding.vibrateSwitch.isChecked)Prefs.setVoiceEnabled(this, binding.voiceSwitch.isChecked)Prefs.setShortVoice(this, binding.shortVoiceSwitch.isChecked)diff --git a/app/src/main/java/com/rfsentinel/app/ui/ThreatBubble.kt b/app/src/main/java/com/rfsentinel/app/ui/ThreatBubble.ktindex f969543..fc33cc9 100644--- a/app/src/main/java/com/rfsentinel/app/ui/ThreatBubble.kt+++ b/app/src/main/java/com/rfsentinel/app/ui/ThreatBubble.kt@@ -6,14 +6,22 @@ import android.content.Intentimport android.graphics.Canvasimport android.graphics.Paintimport android.graphics.PixelFormat+import android.graphics.Typeface+import android.graphics.drawable.GradientDrawableimport android.os.Buildimport android.os.Handlerimport android.os.Looperimport android.provider.Settings+import android.text.SpannableStringBuilder+import android.text.Spanned+import android.text.style.ForegroundColorSpan+import android.text.style.RelativeSizeSpan+import android.text.style.StyleSpanimport android.view.Gravityimport android.view.MotionEventimport android.view.Viewimport android.view.WindowManager+import android.widget.TextViewimport androidx.core.content.editimport com.rfsentinel.app.MainActivityimport kotlin.math.abs@@ -24,7 +32,8 @@ import kotlin.math.min* scanning: green = all clear, orange = a probable match, red = a strong match* or something following you, with the number of flagged devices. Tap to open* the app, drag to move. Needs the "Display over other apps" permission; hidden- * while RF Sentinel itself is on screen.+ * while RF Sentinel itself is on screen. Each new alert also shows a small card+ * next to the bubble for a few seconds saying what was detected.*/object ThreatBubble {@@ -33,6 +42,9 @@ object ThreatBubble {private val main = Handler(Looper.getMainLooper())private var view: BubbleView? = nullprivate var params: WindowManager.LayoutParams? = null+ private var popupView: TextView? = null+ private val hidePopup = Runnable { popupView?.let { removePopupNow(it.context) } }+ private const val POPUP_MS = 6_000Lfun canShow(context: Context) = Settings.canDrawOverlays(context)@@ -46,7 +58,69 @@ object ThreatBubble {fun hide(context: Context) = main.post { removeNow(context.applicationContext) }+ /**+ * Shows what was just detected in a small card beside the bubble (any thread);+ * a newer alert replaces it. Only while the bubble itself is showing.+ */+ fun popup(context: Context, title: String, detail: String?, color: Int) = main.post {+ val app = context.applicationContext+ val lp = params ?: return@post+ if (view == null || !canShow(app)) return@post+ val wm = app.getSystemService(Context.WINDOW_SERVICE) as WindowManager+ val d = app.resources.displayMetrics.density+ val text = SpannableStringBuilder(title).apply {+ setSpan(StyleSpan(Typeface.BOLD), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)+ if (!detail.isNullOrBlank()) {+ val start = length+ append("\n").append(detail)+ setSpan(RelativeSizeSpan(0.85f), start, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)+ setSpan(ForegroundColorSpan(0xFFCFD8DC.toInt()), start, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)+ }+ }+ // Beside the bubble, on whichever side has more room.+ val size = lp.width+ val onLeft = lp.x + size / 2 < app.resources.displayMetrics.widthPixels / 2+ val plp = WindowManager.LayoutParams(+ WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,+ lp.type,+ WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE or+ WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,+ PixelFormat.TRANSLUCENT+ ).apply {+ gravity = Gravity.TOP or (if (onLeft) Gravity.START else Gravity.END)+ x = if (onLeft) lp.x + size + (6 * d).toInt() else app.resources.displayMetrics.widthPixels - lp.x + (6 * d).toInt()+ y = lp.y + (4 * d).toInt()+ }+ val pv = popupView ?: TextView(app).apply {+ setTextColor(0xFFFFFFFF.toInt())+ textSize = 14f+ maxWidth = (240 * d).toInt()+ setPadding((12 * d).toInt(), (7 * d).toInt(), (12 * d).toInt(), (7 * d).toInt())+ accessibilityLiveRegion = View.ACCESSIBILITY_LIVE_REGION_POLITE+ }+ pv.text = text+ pv.background = GradientDrawable().apply {+ cornerRadius = 12 * d+ setColor(0xEE202124.toInt())+ setStroke((2 * d).toInt(), color or 0xFF000000.toInt())+ }+ if (popupView == null) {+ if (runCatching { wm.addView(pv, plp) }.isFailure) return@post+ popupView = pv+ } else runCatching { wm.updateViewLayout(pv, plp) }+ main.removeCallbacks(hidePopup)+ main.postDelayed(hidePopup, POPUP_MS)+ }++ private fun removePopupNow(context: Context) {+ main.removeCallbacks(hidePopup)+ val pv = popupView ?: return+ runCatching { (context.getSystemService(Context.WINDOW_SERVICE) as WindowManager).removeView(pv) }+ popupView = null+ }+private fun removeNow(context: Context) {+ removePopupNow(context)val v = view ?: returnrunCatching { (context.getSystemService(Context.WINDOW_SERVICE) as WindowManager).removeView(v) }view = null; params = null@@ -76,7 +150,7 @@ object ThreatBubble {MotionEvent.ACTION_DOWN -> { downX = e.rawX; downY = e.rawY; startX = lp.x; startY = lp.y; moved = false }MotionEvent.ACTION_MOVE -> {val dx = e.rawX - downX; val dy = e.rawY - downY- if (abs(dx) > 8 * d || abs(dy) > 8 * d) moved = true+ if (!moved && (abs(dx) > 8 * d || abs(dy) > 8 * d)) { moved = true; removePopupNow(context) }if (moved) { lp.x = startX + dx.toInt(); lp.y = startY + dy.toInt(); runCatching { wm.updateViewLayout(v, lp) } }}MotionEvent.ACTION_UP -> {diff --git a/app/src/main/java/com/rfsentinel/app/util/AlertPlayer.kt b/app/src/main/java/com/rfsentinel/app/util/AlertPlayer.ktindex fa94532..7faafb3 100644--- a/app/src/main/java/com/rfsentinel/app/util/AlertPlayer.kt+++ b/app/src/main/java/com/rfsentinel/app/util/AlertPlayer.kt@@ -92,6 +92,17 @@ object AlertPlayer {}}+ /**+ * One short radar-detector tick (no vibration, no voice). Same rules as the alert+ * beeps: off when alerts are muted or the sound is off, and on the phone also in+ * silent / vibrate / Do Not Disturb.+ */+ fun tick(context: Context) {+ val inCar = CarState.connected+ if (Prefs.alertsSilenced(context) || !Prefs.soundEnabled(context) || !(inCar || ringerAllowsSound(context))) return+ Beeper.play(if (inCar) carToneAttributes else phoneToneAttributes, listOf(70 to 0))+ }+/** A spoken navigation instruction (no beep, no vibration); silent when alerts are muted. */fun announce(context: Context, text: String) {if (Prefs.alertsSilenced(context)) returndiff --git a/app/src/main/java/com/rfsentinel/app/util/Beeper.kt b/app/src/main/java/com/rfsentinel/app/util/Beeper.ktindex 8c201c4..d54d160 100644--- a/app/src/main/java/com/rfsentinel/app/util/Beeper.kt+++ b/app/src/main/java/com/rfsentinel/app/util/Beeper.kt@@ -26,6 +26,10 @@ object Beeper {else -> List(beeps.coerceIn(1, 3)) { i -> 140 to if (i == beeps - 1) 0 else 110 }}+ /** Milliseconds between radar ticks: -95 dBm -> 1.6 s, -40 dBm and closer -> 0.15 s (like Locate). */+ fun tickIntervalMs(rssi: Int): Long = (1600 - ((rssi + 95).coerceIn(0, 55) / 55.0) * 1450).toLong()++fun durationMs(pattern: List<Pair<Int, Int>>) = pattern.sumOf { it.first + it.second }/** 16-bit mono PCM for a pattern (pure; unit-tested). */diff --git a/app/src/main/java/com/rfsentinel/app/util/NotificationHelper.kt b/app/src/main/java/com/rfsentinel/app/util/NotificationHelper.ktindex 8fbe383..c96bac7 100644--- a/app/src/main/java/com/rfsentinel/app/util/NotificationHelper.kt+++ b/app/src/main/java/com/rfsentinel/app/util/NotificationHelper.kt@@ -146,6 +146,8 @@ object NotificationHelper {) {recordAlert(context, key, null, hit, null, false, lat, lon)val discreet = Prefs.discreetMode(context)+ com.rfsentinel.app.ui.ThreatBubble.popup(context, if (discreet) "New alert" else hit.label,+ if (discreet) null else hit.category.shortTag, hit.category.colorArgb)if (toCar(context, if (discreet) "New alert" else "${hit.label}. ${hit.evidence}", null)) returnval open = PendingIntent.getActivity(context, key.hashCode(),@@ -239,6 +241,13 @@ object NotificationHelper {val rid = com.rfsentinel.app.service.DeviceRegistry.get(mac)?.remoteId?.takeIf { it.hasPosition }recordAlert(context, mac, mac, hit, rssi, following, rid?.latitude, rid?.longitude)val discreet = Prefs.discreetMode(context)+ com.rfsentinel.app.ui.ThreatBubble.popup(context,+ if (discreet) "New alert" else if (following) "Following you: ${hit.label}" else hit.label,+ if (discreet) null else listOfNotNull(hit.category.shortTag,+ com.rfsentinel.app.service.DeviceRegistry.get(mac)?.distanceM?.takeIf { it > 0 }+ ?.let { "~" + com.rfsentinel.app.detect.DeviceIntel.formatDistance(it) },+ ProximityUtil.band(rssi).lowercase()).joinToString(" · "),+ hit.category.colorArgb)val detail = PendingIntent.getActivity(context, mac.hashCode(),Intent(context, DeviceDetailActivity::class.java)diff --git a/app/src/main/java/com/rfsentinel/app/util/Prefs.kt b/app/src/main/java/com/rfsentinel/app/util/Prefs.ktindex 5e8103b..87871ce 100644--- a/app/src/main/java/com/rfsentinel/app/util/Prefs.kt+++ b/app/src/main/java/com/rfsentinel/app/util/Prefs.kt@@ -211,6 +211,10 @@ object Prefs {fun floatingMap(context: Context): Boolean = bool(context, "floating_map", false)fun setFloatingMap(context: Context, value: Boolean) = setBool(context, "floating_map", value)+ /** Radar-detector mode: after a device alert, keep beeping faster as its signal gets stronger. */+ fun radarBeep(context: Context): Boolean = bool(context, "radar_beep", false)+ fun setRadarBeep(context: Context, value: Boolean) = setBool(context, "radar_beep", value)+fun threatBubble(context: Context): Boolean = bool(context, "threat_bubble", false)fun setThreatBubble(context: Context, value: Boolean) = setBool(context, "threat_bubble", value)diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xmlindex 98deb7d..a1b4c9e 100644--- a/app/src/main/res/layout/activity_settings.xml+++ b/app/src/main/res/layout/activity_settings.xml@@ -215,6 +215,12 @@android:layout_height="wrap_content"android:text="Vibration" />+ <com.google.android.material.switchmaterial.SwitchMaterial+ android:id="@+id/radarBeepSwitch"+ android:layout_width="match_parent"+ android:layout_height="wrap_content"+ android:text="Radar-detector beeps (faster as it gets closer)" />+<TextView style="@style/SettingsLabel" android:text="Re-alert the same device after (minutes)" /><EditTextdiff --git a/app/src/test/java/com/rfsentinel/app/util/BeeperTest.kt b/app/src/test/java/com/rfsentinel/app/util/BeeperTest.ktindex 7197f04..515da33 100644--- a/app/src/test/java/com/rfsentinel/app/util/BeeperTest.kt+++ b/app/src/test/java/com/rfsentinel/app/util/BeeperTest.kt@@ -6,6 +6,13 @@ import org.junit.Testclass BeeperTest {+ @Test+ fun radarTicksSpeedUpAsTheSignalGetsStronger() {+ assertEquals(1600L, Beeper.tickIntervalMs(-100))+ assertEquals(150L, Beeper.tickIntervalMs(-30))+ assertTrue(Beeper.tickIntervalMs(-60) < Beeper.tickIntervalMs(-80))+ }+@Testfun patternMatchesTierAndFollowing() {assertEquals(1, Beeper.pattern(1, following = false).size)