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.

Draw the radar at 30 fps, load the watchlist off the main thread

CIS-C0dc948172936d
diff --git a/app/src/main/java/com/rfsentinel/app/MainActivity.kt b/app/src/main/java/com/rfsentinel/app/MainActivity.kt
index 5e5b525..4bea366 100644
--- a/app/src/main/java/com/rfsentinel/app/MainActivity.kt
+++ b/app/src/main/java/com/rfsentinel/app/MainActivity.kt
@@ -748,12 +748,13 @@ class MainActivity : AppCompatActivity() {
// Live counts on the chips ("Trackers 2"); empty filters stay unlabelled.
val visualChips = com.rfsentinel.app.ui.VisualMode.on(this, com.rfsentinel.app.ui.VisualMode.Screen.STATUS)
+ val aircraft = currentAircraft(now)
for ((f, chip) in filterChips) {
val n = when (f) {
com.rfsentinel.app.ui.DeviceFilter.CELLS -> liveCellCount(now)
com.rfsentinel.app.ui.DeviceFilter.WAZE -> currentWaze(now).size
- com.rfsentinel.app.ui.DeviceFilter.AIRCRAFT -> currentAircraft(now).size
- com.rfsentinel.app.ui.DeviceFilter.FLAGGED -> all.count { f.matches(it) } + currentAircraft(now).count { it.hit != null }
+ com.rfsentinel.app.ui.DeviceFilter.AIRCRAFT -> aircraft.size
+ com.rfsentinel.app.ui.DeviceFilter.FLAGGED -> all.count { f.matches(it) } + aircraft.count { it.hit != null }
com.rfsentinel.app.ui.DeviceFilter.RADIO -> if (ScanForegroundService.isRunning) com.rfsentinel.app.sdr.RadioLog.current(now).size else 0
com.rfsentinel.app.ui.DeviceFilter.TALKGROUPS -> currentTalkgroups(now).size
else -> all.count { f.matches(it) }
diff --git a/app/src/main/java/com/rfsentinel/app/RFSentinelApp.kt b/app/src/main/java/com/rfsentinel/app/RFSentinelApp.kt
index e776e60..d3562c8 100644
--- a/app/src/main/java/com/rfsentinel/app/RFSentinelApp.kt
+++ b/app/src/main/java/com/rfsentinel/app/RFSentinelApp.kt
@@ -60,7 +60,8 @@ class RFSentinelApp : Application() {
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)
+ // Off the main thread: the scanner loads it itself before it starts, so nothing waits on this one.
+ appScope.launch(Dispatchers.IO) { OuiWatchlist.load(this@RFSentinelApp) }
WhitelistCache.start(this, appScope)
appScope.launch(Dispatchers.IO) { com.rfsentinel.app.data.TrackerMutes.load(this@RFSentinelApp) }
appScope.launch(Dispatchers.IO) { com.rfsentinel.app.data.TrustedNetworks.load(this@RFSentinelApp) }
diff --git a/app/src/main/java/com/rfsentinel/app/ui/RadarView.kt b/app/src/main/java/com/rfsentinel/app/ui/RadarView.kt
index 94fea51..4074b4c 100644
--- a/app/src/main/java/com/rfsentinel/app/ui/RadarView.kt
+++ b/app/src/main/java/com/rfsentinel/app/ui/RadarView.kt
@@ -274,7 +274,8 @@ class RadarView @JvmOverloads constructor(
val footer = footer(width - 16 * density, now)
canvas.drawText(footer, 8 * density, height - 8 * density, textPaint)
- if (isShown) postInvalidateOnAnimation()
+ // About 30 frames a second: the sweep looks the same, and a 120 Hz screen draws a quarter as often.
+ if (isShown) postInvalidateDelayed(FRAME_MS)
}
/** Alert names (and distance + direction when located) beside their blip, flipped left near the right edge;
@@ -345,6 +346,7 @@ class RadarView @JvmOverloads constructor(
private companion object {
const val SAMPLE_MS = 50L
+ const val FRAME_MS = 33L
/** Faster than a brisk walk (m/s): driving. */
const val WALK_MS = 3f
}