Skip to content

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.

Settings > Scanning: how long ordinary Bluetooth (default 30 s) and WiFi (default 60 s) devices stay in the list and radar

CIS-C094e4e850a7b4
diff --git a/app/src/main/java/com/rfsentinel/app/MainActivity.kt b/app/src/main/java/com/rfsentinel/app/MainActivity.kt
index 82dd633..cb18d55 100644
--- a/app/src/main/java/com/rfsentinel/app/MainActivity.kt
+++ b/app/src/main/java/com/rfsentinel/app/MainActivity.kt
@@ -305,9 +305,10 @@ class MainActivity : AppCompatActivity() {
private fun render() {
val now = System.currentTimeMillis()
// Ordinary devices leave the list and radar soon after they're out of range (LiveWindow).
- val scanInterval = Prefs.scanIntervalMs(this)
+ val bleMs = Prefs.liveBleSec(this) * 1000L
+ val wifiMs = Prefs.liveWifiSec(this) * 1000L
val all = DeviceRegistry.snapshot(now).filter {
- com.rfsentinel.app.ui.LiveWindow.keep(it, it.best != null && !WhitelistCache.contains(it.mac), now, scanInterval)
+ com.rfsentinel.app.ui.LiveWindow.keep(it, it.best != null && !WhitelistCache.contains(it.mac), now, bleMs, wifiMs)
}
val threshold = Prefs.alertThreshold(this)
deviceCount = all.size
diff --git a/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt b/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt
index a9dd78f..909c2c5 100644
--- a/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt
+++ b/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt
@@ -292,7 +292,8 @@ class SettingsActivity : AppCompatActivity() {
"Bluetooth intensity: Battery saver misses short broadcasts.\n\n" +
"WiFi interval: Android allows about one WiFi scan per 30 s unless \"Wi-Fi scan throttling\" " +
"is turned off in Developer options; then down to 5 s works, at some battery cost.\n\n" +
- "Background scanning: lets the scan keep running with the screen off."),
+ "Background scanning: lets the scan keep running with the screen off.\n\n" +
+ "Remove from the list: how long an ordinary device stays in the list and radar once it stops being heard (default 30 s Bluetooth, 60 s WiFi). Flagged, favourite and following devices always stay 3 minutes."),
Section("autostart", binding.headerAutoStart, binding.sectionAutoStart,
"When the phone starts: begins scanning after a reboot.\n\n" +
"In the car: starts scanning when the phone connects to your car's Bluetooth and stops when you leave. " +
@@ -428,6 +429,37 @@ class SettingsActivity : AppCompatActivity() {
view.visibility = if (text.isBlank()) View.GONE else View.VISIBLE
}
+ /**
+ * How long ordinary devices stay in the list and radar after they're last heard
+ * (flagged, favourite and following ones always stay 3 minutes). Saved as you slide.
+ */
+ private fun addLiveWindowSliders() {
+ fun slider(label: (Int) -> String, from: Int, to: Int, value: Int, save: (Int) -> Unit) {
+ val text = android.widget.TextView(this).apply {
+ textSize = 13f
+ setPadding(0, (10 * resources.displayMetrics.density).toInt(), 0, 0)
+ this.text = label(value)
+ }
+ binding.sectionScanning.addView(text)
+ binding.sectionScanning.addView(com.google.android.material.slider.Slider(this).apply {
+ valueFrom = from.toFloat(); valueTo = to.toFloat(); stepSize = 5f
+ this.value = (value - value % 5).coerceIn(from, to).toFloat()
+ setLabelFormatter { "${it.toInt()} s" }
+ contentDescription = label(value)
+ addOnChangeListener { _, v, fromUser ->
+ if (!fromUser) return@addOnChangeListener
+ save(v.toInt()); text.text = label(v.toInt())
+ }
+ })
+ }
+ slider({ "Remove Bluetooth devices from the list after $it s out of range" }, 10, 180, Prefs.liveBleSec(this)) {
+ Prefs.setLiveBleSec(this, it)
+ }
+ slider({ "Remove WiFi devices from the list after $it s out of range" }, 30, 180, Prefs.liveWifiSec(this)) {
+ Prefs.setLiveWifiSec(this, it)
+ }
+ }
+
/** Aircraft search radius (10-50 km) and the feed status, under the aircraft switch. */
private fun addAircraftControls(sw: SwitchMaterial) {
val dp = resources.displayMetrics.density
@@ -602,6 +634,7 @@ class SettingsActivity : AppCompatActivity() {
).show()
}
updateWifiThrottleHint()
+ addLiveWindowSliders()
binding.bootSwitch.isChecked = Prefs.autoStartOnBoot(this)
binding.carAutoSwitch.isChecked = Prefs.carAutoStart(this)
binding.carAutoSwitch.setOnCheckedChangeListener { _, on ->
diff --git a/app/src/main/java/com/rfsentinel/app/ui/LiveWindow.kt b/app/src/main/java/com/rfsentinel/app/ui/LiveWindow.kt
index 79267ee..f73456a 100644
--- a/app/src/main/java/com/rfsentinel/app/ui/LiveWindow.kt
+++ b/app/src/main/java/com/rfsentinel/app/ui/LiveWindow.kt
@@ -4,19 +4,14 @@ import com.rfsentinel.app.detect.Advert
import com.rfsentinel.app.service.DeviceRegistry
/**
- * How long a device stays in the live list and radar after it was last heard. Ordinary
- * devices leave quickly once out of range; flagged, favourite and following ones stay for
- * the registry's full 3 minutes so a passing threat doesn't vanish between sightings.
+ * How long a device stays in the live list and radar after it was last heard (Settings >
+ * Scanning, defaults 30 s Bluetooth / 60 s WiFi). Flagged, favourite and following devices
+ * stay for the registry's full 3 minutes so a passing threat doesn't vanish between sightings.
*/
object LiveWindow {
- /** Bluetooth devices advertise several times a second: 30 s of silence means gone. */
- const val BLE_MS = 30_000L
- /** WiFi is only seen on each scan: allow two scan rounds plus a margin, at least 60 s. */
- fun wifiMs(scanIntervalMs: Long): Long = maxOf(60_000L, 2 * scanIntervalMs + 10_000L)
-
- fun keep(s: DeviceRegistry.Snapshot, important: Boolean, now: Long, scanIntervalMs: Long): Boolean {
+ fun keep(s: DeviceRegistry.Snapshot, important: Boolean, now: Long, bleMs: Long, wifiMs: Long): Boolean {
if (important || s.following || s.known?.favorite == true) return true
- val window = if (Advert.Source.WIFI in s.sources || s.source == Advert.Source.WIFI) wifiMs(scanIntervalMs) else BLE_MS
+ val window = if (Advert.Source.WIFI in s.sources || s.source == Advert.Source.WIFI) wifiMs else bleMs
return now - s.lastSeen <= window
}
}
diff --git a/app/src/main/java/com/rfsentinel/app/util/Prefs.kt b/app/src/main/java/com/rfsentinel/app/util/Prefs.kt
index 22c5d07..5e8103b 100644
--- a/app/src/main/java/com/rfsentinel/app/util/Prefs.kt
+++ b/app/src/main/java/com/rfsentinel/app/util/Prefs.kt
@@ -118,6 +118,12 @@ object Prefs {
/** Fetch known cameras for the map area on screen (and around you in the car) automatically. */
/** Radius of "download the cameras around me" (Settings, setup wizard, map menu), in km. */
/** How far to look for aircraft (ADS-B feeds), 10-50 km. */
+ /** How long an ordinary device stays in the list / radar after it was last heard (seconds). */
+ fun liveBleSec(context: Context): Int = int(context, "live_ble_sec", 30).coerceIn(10, 180)
+ fun setLiveBleSec(context: Context, sec: Int) = setInt(context, "live_ble_sec", sec.coerceIn(10, 180))
+ fun liveWifiSec(context: Context): Int = int(context, "live_wifi_sec", 60).coerceIn(30, 180)
+ fun setLiveWifiSec(context: Context, sec: Int) = setInt(context, "live_wifi_sec", sec.coerceIn(30, 180))
+
fun aircraftRadiusKm(context: Context): Int = int(context, "aircraft_radius_km", 30).coerceIn(10, 50)
fun setAircraftRadiusKm(context: Context, km: Int) = setInt(context, "aircraft_radius_km", km.coerceIn(10, 50))