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
List: one row format, alert order and pulse for every kind of row
CIS-C0d0a095e9ce93
diff --git a/app/src/main/java/com/rfsentinel/app/MainActivity.kt b/app/src/main/java/com/rfsentinel/app/MainActivity.ktindex 7862546..f45e9ef 100644--- a/app/src/main/java/com/rfsentinel/app/MainActivity.kt+++ b/app/src/main/java/com/rfsentinel/app/MainActivity.kt@@ -819,19 +819,24 @@ class MainActivity : AppCompatActivity() {val radio = radioRows(now, Prefs.alertThreshold(this, Category.RADIO))val talkgroups = talkgroupRows(now, Prefs.alertThreshold(this, Category.RADIO))val air = aircraftRows(now, Prefs.alertThreshold(this, Category.AIRCRAFT))- // Waze reports, radios on the air and aircraft that meet the alert threshold flash at the very top;+ // Waze reports, radios on the air and aircraft that meet the alert threshold rank with the flagged devices;// the rest follow the devices.val (urgent, quiet) = waze.partition { it.flashing }val (radioLive, radioOld) = radio.partition { it.flashing }val (tgLive, tgOld) = talkgroups.partition { it.flashing || it.mac == TG_ROW + com.rfsentinel.app.sdr.SdrRadio.p25Hold }val (airUrgent, airQuiet) = air.partition { it.flashing }+ // Under the default sort; another Sort by keeps its own order for the devices.+ fun ranked(rows: List<DeviceRow>) = if (com.rfsentinel.app.ui.DeviceOrder.sort(this) != com.rfsentinel.app.ui.DeviceOrder.Sort.ALERTS) rows+ else rows.sortedWith(compareByDescending<DeviceRow> { it.tag?.startsWith("FOLLOWING") == true }.thenByDescending { it.confidence ?: 0 })// Alerting devices from your own watchlist entries go above all of them.fun mine(s: DeviceRegistry.Snapshot) = com.rfsentinel.app.ui.LiveWindow.alerting(s, now) &&s.hits.any { it.source == com.rfsentinel.app.oui.OuiEntry.YOURS }if (com.rfsentinel.app.ui.DeviceOrder.group(this) == com.rfsentinel.app.ui.DeviceOrder.Group.NONE) {val (yours, devices) = sections.flatMap { it.items }.partition(::mine)- submitRows(yours.map { toRow(it, now, threshold) } + airUrgent + tgLive + radioLive + urgent + devices.map { toRow(it, now, threshold) } +- airQuiet + tgOld + radioOld + cells + quiet)+ val (alerting, others) = devices.partition { it.best != null && !WhitelistCache.contains(it.mac) }+ submitRows(yours.map { toRow(it, now, threshold) } ++ ranked(airUrgent + tgLive + radioLive + urgent + alerting.map { toRow(it, now, threshold) }) ++ others.map { toRow(it, now, threshold) } + airQuiet + tgOld + radioOld + cells + quiet)} else {// Grouped: everything the list shows has a group, not only Bluetooth and WiFi devices. What's// urgent (Waze, radio, aircraft) joins the flagged devices in Alerts, at the top.@@ -840,8 +845,8 @@ class MainActivity : AppCompatActivity() {val alerts = com.rfsentinel.app.ui.DeviceOrder.ALERTSval (yours, flagged) = sections.filter { it.header == alerts }.flatMap { it.items }.partition(::mine)submitRows(- block(alerts, alerts, yours.map { toRow(it, now, threshold) } + airUrgent + tgLive + radioLive + urgent +- flagged.map { toRow(it, now, threshold) }) ++ block(alerts, alerts, yours.map { toRow(it, now, threshold) } ++ ranked(airUrgent + tgLive + radioLive + urgent + flagged.map { toRow(it, now, threshold) })) +sections.filter { it.header != alerts }.flatMap { sec -> block(sec.header.orEmpty(), sec.header.orEmpty(), sec.items.map { toRow(it, now, threshold) }) } +block("x:aircraft", "Aircraft", airQuiet) + block("x:talkgroups", "Talkgroups", tgOld) +block("x:radio", "Radio transmissions", radioOld) +@@ -953,7 +958,7 @@ class MainActivity : AppCompatActivity() {subtitle = com.rfsentinel.app.online.WazePolice.relativeText(w.where, w.trend) + if (off) " · not on your way" else "",meta = "Reported $ago" + listOfNotNull(w.report.street, w.report.city).joinToString(", ").takeIf { it.isNotEmpty() }?.let { " · $it" }.orEmpty() +(if (w.report.thumbsUp > 0) " · ${w.report.thumbsUp} confirmed" else ""),- tag = "WAZE · ${w.hit.tier.label.lowercase()} ${w.hit.confidence}%",+ tag = com.rfsentinel.app.ui.DeviceRows.matchTag("WAZE", w.hit.confidence),tagColor = w.report.type.color,highlight = if (urgent) w.report.type.color else null,flashing = urgent,@@ -978,8 +983,9 @@ class MainActivity : AppCompatActivity() {.filter { r -> query.isBlank() || listOfNotNull(r.mhz, r.name, r.bandLabel).any { it.contains(query.trim(), ignoreCase = true) } }.map { r ->val live = now - r.lastSeen <= RADIO_LIVE_MS- // Dismissed (swiped left): listed, but quiet.- val urgent = live && r.confidence >= threshold && !hidden(RADIO_ROW + r.freqHz, now)+ // Muted or dismissed (swiped left): listed, but quiet.+ val muted = com.rfsentinel.app.data.AlertMutes.isMuted(this, RADIO_ROW + r.freqHz, now)+ val urgent = live && r.confidence >= threshold && !mutedval ago = (now - r.lastSeen) / 1000val trend = when (r.trend) {com.rfsentinel.app.sdr.RadioLog.Trend.CLOSER -> "getting closer ↑"@@ -990,14 +996,16 @@ class MainActivity : AppCompatActivity() {mac = RADIO_ROW + r.freqHz,title = "Radio ${r.mhz} MHz" + (r.name?.let { " · $it" } ?: ""),subtitle = listOfNotNull("${r.snrDb} dB above the noise (peak ${r.peakSnrDb})", trend, r.bandLabel).joinToString(" · "),- meta = (if (ago < 3) "On the air now" else "Last heard ${ago}s ago") ++ meta = (if (ago < 3) "On the air now" else "Last heard ${com.rfsentinel.app.ui.DeviceRows.ago(ago)}") +" · first ${java.text.DateFormat.getTimeInstance(java.text.DateFormat.SHORT).format(java.util.Date(r.firstSeen))}",- tag = "RADIO · ${r.confidence}%",+ tag = com.rfsentinel.app.ui.DeviceRows.matchTag("RADIO", r.confidence),tagColor = color,highlight = if (urgent) color else null,flashing = urgent,bold = live,- confidence = r.confidence+ confidence = r.confidence,+ canMute = true,+ muted = muted)}}@@ -1037,8 +1045,8 @@ class MainActivity : AppCompatActivity() {title = title,subtitle = listOfNotNull(r.lastSource?.let { "Radio $it keyed up" }, "${r.calls} call" + (if (r.calls == 1) "" else "s"),"EMERGENCY".takeIf { r.emergency }, "encrypted".takeIf { r.encrypted }).joinToString(" · "),- meta = if (ago < 3) "Call going on" else "Last call ${ago}s ago",- tag = (if (near) "P25 NEAR" else "P25") + " · $confidence%",+ meta = if (ago < 3) "Call going on" else "Last call ${com.rfsentinel.app.ui.DeviceRows.ago(ago)}",+ tag = com.rfsentinel.app.ui.DeviceRows.matchTag(if (near) "P25 NEAR" else "P25", confidence),tagColor = color,highlight = if (urgent) color else null,flashing = urgent,@@ -1106,7 +1114,8 @@ class MainActivity : AppCompatActivity() {.map { (s, d) ->val p = s.planeval hit = s.hit- val urgent = hit != null && hit.confidence >= threshold+ val muted = hit != null && com.rfsentinel.app.data.AlertMutes.isMuted(this, AIRCRAFT_ROW + p.hex, now)+ val urgent = hit != null && hit.confidence >= threshold && !mutedval where = d?.let { m -> com.rfsentinel.app.util.Units.distance(m) +me?.let { " " + air.compass(air.bearing(it.first, it.second, p.lat, p.lon)) }.orEmpty() }DeviceRow(@@ -1115,12 +1124,14 @@ class MainActivity : AppCompatActivity() {subtitle = listOfNotNull(where, air.altitude(p), p.speedKt?.let { String.format(java.util.Locale.US, "%.0f kt", it) }).joinToString(" · "),meta = listOfNotNull(p.type, p.owner, p.registration?.takeIf { it != air.name(p) }).joinToString(" · ").ifEmpty { p.hex.uppercase() },- tag = if (hit != null) "AIRCRAFT · ${hit.confidence}%" else "AIRCRAFT",+ tag = if (hit != null) com.rfsentinel.app.ui.DeviceRows.matchTag("AIRCRAFT", hit.confidence) else "AIRCRAFT",tagColor = color,highlight = if (urgent) color else null,flashing = urgent,bold = hit != null,- confidence = hit?.confidence+ confidence = hit?.confidence,+ canMute = hit != null,+ muted = muted)}}@@ -1145,9 +1156,9 @@ class MainActivity : AppCompatActivity() {subtitle = listOfNotNull(if (c.mcc != null || c.mnc != null) "${c.mcc ?: "?"}-${c.mnc ?: "?"}" else null,c.area?.let { "$area $it" }, c.cellId?.let { "Cell $it" }, c.pci?.let { "PCI $it" }- ).joinToString(" · ").ifEmpty { "No IDs reported" },+ ).joinToString(" · ").ifEmpty { "No IDs reported" },meta = (if (c.registered) "Serving your phone" else "Neighbour cell") +- (c.dbm?.let { " · $it dBm" } ?: "") + " · " + (if (ageSec < 2) "now" else "${ageSec}s ago"),+ (c.dbm?.let { " · $it dBm" } ?: "") + " · " + com.rfsentinel.app.ui.DeviceRows.ago(ageSec),tag = if (c.registered) "CELL · serving" else "CELL",tagColor = 0xFF5E35B1.toInt(),highlight = null, flashing = false, bold = c.registered,@@ -1301,7 +1312,7 @@ class MainActivity : AppCompatActivity() {val alert = best != null && !whitelistedval muted = alert && com.rfsentinel.app.data.AlertMutes.isMuted(this, s.mac, now)val ageSec = (now - s.lastSeen) / 1000- val age = if (ageSec < 2) "now" else "${ageSec}s ago"+ val age = com.rfsentinel.app.ui.DeviceRows.ago(ageSec)val badges = buildList {if (s.following) add("FOLLOWING")if (Favorites.contains(s.mac)) add("★")@@ -1311,7 +1322,7 @@ class MainActivity : AppCompatActivity() {val tag = when {whitelisted -> "WHITELISTED"best != null -> (if (s.following) "FOLLOWING · " else "") +- "${best.category.shortTag} · ${best.tier.label} ${best.confidence}%"+ com.rfsentinel.app.ui.DeviceRows.matchTag(best.category.shortTag, best.confidence)else -> radioTag(s)}val alias = com.rfsentinel.app.data.DeviceNames.of(s.mac)@@ -1319,8 +1330,8 @@ class MainActivity : AppCompatActivity() {return DeviceRow(mac = s.mac,title = alias ?: best?.label ?: s.name ?: s.deviceType,- subtitle = s.mac + " · " + (s.vendor ?: s.addressType.label),- meta = listOf(+ subtitle = s.mac + " · " + (s.vendor ?: s.addressType.label),+ meta = (listOf(// Under your own name, what it's heard as comes first.if (alias != null) best?.label ?: s.name?.let { "\"$it\"" } ?: s.deviceTypeelse if (best != null && s.name != null) "\"${s.name}\"" else s.deviceType,@@ -1329,7 +1340,7 @@ class MainActivity : AppCompatActivity() {if (tag == radioTag(s)) null else s.sources.joinToString("+") { if (it == Advert.Source.BLE) "BLE" else "WiFi" },"${ProximityUtil.band(s.rssi)} ${s.rssi} dBm ${DeviceIntel.formatDistance(s.distanceM)}",age- ).filterNotNull().joinToString(" · ") + if (badges.isNotEmpty()) " " + badges.joinToString(" ") else "",+ ) + badges).filterNotNull().joinToString(" · "),tag = tag,tagColor = when {whitelisted -> com.rfsentinel.app.ui.ThemeManager.ink(this, WHITELIST_COLOR)diff --git a/app/src/main/java/com/rfsentinel/app/ui/DeviceAdapter.kt b/app/src/main/java/com/rfsentinel/app/ui/DeviceAdapter.ktindex 2e7e539..329e29c 100644--- a/app/src/main/java/com/rfsentinel/app/ui/DeviceAdapter.kt+++ b/app/src/main/java/com/rfsentinel/app/ui/DeviceAdapter.kt@@ -135,6 +135,8 @@ class DeviceAdapter(repeatCount = ValueAnimator.INFINITEaddUpdateListener { binding.root.setBackgroundColor(it.animatedValue as Int) }start()+ // All rows on one beat: the same kind of alert is the same shade at any moment.+ currentPlayTime = android.os.SystemClock.uptimeMillis() % (2 * duration)}} else {stopFlash()@@ -171,10 +173,14 @@ class DeviceAdapter(}b.titleText.text = row.titleb.titleText.setTypeface(b.titleText.typeface, if (row.bold) Typeface.BOLD else Typeface.NORMAL)- b.macText.text = row.subtitle+ // Only an address is monospaced: names and distances read as normal text.+ b.macText.text = if (row.subtitle.startsWith(row.mac)) android.text.SpannableString(row.subtitle).apply {+ setSpan(android.text.style.TypefaceSpan("monospace"), 0, row.mac.length, android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)+ } else row.subtitleb.metaText.text = metaWithBadges(row)// Grey is hard to read on an alert's colour.b.metaText.setTextColor(if (row.highlight != null) b.macText.textColors else holder.metaColors)+ b.signalText.setTextColor(if (row.highlight != null) b.macText.textColors else holder.metaColors)val conf = row.confidenceb.confidenceBar.visibility = if (visual && conf != null) View.VISIBLE else View.GONEif (visual && conf != null) b.confidenceBar.set(conf / 100f, row.tagColor)diff --git a/app/src/main/java/com/rfsentinel/app/ui/DeviceDetailActivity.kt b/app/src/main/java/com/rfsentinel/app/ui/DeviceDetailActivity.ktindex 133b0d4..58eafe4 100644--- a/app/src/main/java/com/rfsentinel/app/ui/DeviceDetailActivity.kt+++ b/app/src/main/java/com/rfsentinel/app/ui/DeviceDetailActivity.kt@@ -181,20 +181,20 @@ class DeviceDetailActivity : AppCompatActivity() {// Headerif (whitelisted) {binding.tagText.visibility = View.VISIBLE- binding.tagText.text = "WHITELISTED · trusted"+ binding.tagText.text = "WHITELISTED"binding.tagText.background.mutate().setTint(0xFF6B7B80.toInt())} else if (best != null) {binding.tagText.visibility = View.VISIBLE- binding.tagText.text = "${best.category.shortTag} · ${best.tier.label} ${best.confidence}%"+ binding.tagText.text = DeviceRows.matchTag(best.category.shortTag, best.confidence)binding.tagText.background.mutate().setTint(ThemeManager.ink(this, if (best.tier == Tier.WEAK) 0xFFB26A00.toInt() else best.category.colorArgb))} else if (s == null && pastBest != null) {val h = pastBestbinding.tagText.visibility = View.VISIBLE- binding.tagText.text = "${h.category.shortTag} · ${h.tier.label} ${h.confidence}%"+ binding.tagText.text = DeviceRows.matchTag(h.category.shortTag, h.confidence)binding.tagText.background.mutate().setTint(ThemeManager.ink(this, if (h.tier == Tier.WEAK) 0xFFB26A00.toInt() else h.category.colorArgb))} else if (s != null) {binding.tagText.visibility = View.VISIBLE- binding.tagText.text = "Not flagged"+ binding.tagText.text = "NOT FLAGGED"binding.tagText.background.mutate().setTint(0xFF6B7B80.toInt())} else {binding.tagText.visibility = View.GONE@@ -205,8 +205,8 @@ class DeviceDetailActivity : AppCompatActivity() {binding.titleText.text = alias ?: heardAsbinding.subtitleText.text = buildSpannedString {if (alias != null) append("$heardAs\n")- (s?.vendor ?: known?.vendor ?: VendorDb.macVendor(mac))?.let { append("$it\n") }color(secondaryText) { inSpans(TypefaceSpan("monospace")) { append(mac) } }+ (s?.vendor ?: known?.vendor ?: VendorDb.macVendor(mac))?.let { append("\n$it") }}val note = known?.note?.takeIf { it.isNotBlank() }binding.noteText.visibility = if (note != null) View.VISIBLE else View.GONE@@ -495,11 +495,7 @@ class DeviceDetailActivity : AppCompatActivity() {input.requestFocus()}- private fun ago(ms: Long) = when {- ms < 2000 -> "just now"- ms < 60_000 -> "${ms / 1000}s ago"- else -> "${ms / 60_000} min ago"- }+ private fun ago(ms: Long) = DeviceRows.ago(ms / 1000)// ---- Actions --------------------------------------------------------------diff --git a/app/src/main/java/com/rfsentinel/app/ui/DeviceFilter.kt b/app/src/main/java/com/rfsentinel/app/ui/DeviceFilter.ktindex d4969af..114d72b 100644--- a/app/src/main/java/com/rfsentinel/app/ui/DeviceFilter.kt+++ b/app/src/main/java/com/rfsentinel/app/ui/DeviceFilter.kt@@ -170,7 +170,7 @@ enum class DeviceFilter(val label: String, val liveOnly: Boolean = false) {* The main screen's chip order: the counts worth a glance first (flagged, then what's heard on each* radio), so they fit without scrolling; the narrower filters after them.*/- val MAIN_ORDER = listOf(ALL, FLAGGED, BLE, WIFI, CELLS, TRACKERS, DRONES, AIRCRAFT, RADIO, TALKGROUPS, WAZE, EXTERNAL, SENTINELS, FAVORITES, NEW) + KINDS + OTHER+ val MAIN_ORDER = listOf(ALL, FLAGGED, BLE, WIFI, CELLS, TRACKERS, DRONES, AIRCRAFT, RADIO, TALKGROUPS, WAZE, EXTERNAL, SENTINELS, FAVORITES, NEW, CAMERAS) + (KINDS - CAMERAS) + OTHER/** The chips of a saved snapshot or trace: the main screen's, less those that only mean something live. */val SAVED_ORDER = MAIN_ORDER.filterNot { it.liveOnly }diff --git a/app/src/main/java/com/rfsentinel/app/ui/DeviceRows.kt b/app/src/main/java/com/rfsentinel/app/ui/DeviceRows.ktindex 43abeee..54d4d1b 100644--- a/app/src/main/java/com/rfsentinel/app/ui/DeviceRows.kt+++ b/app/src/main/java/com/rfsentinel/app/ui/DeviceRows.kt@@ -20,6 +20,16 @@ object DeviceRows {const val WEAK_COLOR = 0xFFB26A00.toInt()const val WHITELIST_COLOR = 0xFF6B7B80.toInt()+ /** A match's tag, the same on every kind of row: "BODY CAM · strong 90%". */+ fun matchTag(name: String, confidence: Int) = "$name · ${Tier.of(confidence).label} $confidence%"++ /** How long ago, the same on every row. */+ fun ago(sec: Long) = when {+ sec < 2 -> "now"+ sec < 60 -> "${sec}s ago"+ else -> "${sec / 60} min ago"+ }+/** An ordinary (not flagged) row's tag: the radios it was heard on. */fun radioTag(sources: Set<Advert.Source>): String = when {Advert.Source.BLE in sources && Advert.Source.WIFI in sources -> "BLUETOOTH + WIFI"@@ -47,21 +57,21 @@ object DeviceRows {val alias = DeviceNames.of(d.mac)val tag = when {whitelisted -> "WHITELISTED"- category != null -> "${category.shortTag} · ${tier.label} ${d.confidence}%"+ category != null -> matchTag(category.shortTag, d.confidence)else -> radioTag(sources)}val badges = buildList { if (Favorites.contains(d.mac)) add("★") }return DeviceRow(mac = d.mac,title = alias ?: label,- subtitle = d.mac + (d.vendor?.let { " · $it" } ?: ""),- meta = listOfNotNull(+ subtitle = d.mac + (d.vendor?.let { " · $it" } ?: ""),+ meta = (listOfNotNull(if (alias != null) labelelse if (category != null && d.name != null && d.name != label) "\"${d.name}\"" else type?.takeIf { it != label },if (category != null) sources.joinToString("+") { if (it == Advert.Source.BLE) "BLE" else "WiFi" }.ifEmpty { null } else null,"${ProximityUtil.band(d.bestRssi)} ${d.bestRssi} dBm",timeFmt.format(Date(d.firstSeen)) + "–" + timeFmt.format(Date(d.lastSeen))- ).joinToString(" · ") + if (badges.isNotEmpty()) " " + badges.joinToString(" ") else "",+ ) + badges).joinToString(" · "),tag = tag,tagColor = when {whitelisted -> ThemeManager.ink(context, WHITELIST_COLOR)diff --git a/app/src/main/res/layout/item_device.xml b/app/src/main/res/layout/item_device.xmlindex f8a4b55..3792ad2 100644--- a/app/src/main/res/layout/item_device.xml+++ b/app/src/main/res/layout/item_device.xml@@ -54,7 +54,6 @@android:id="@+id/macText"android:layout_width="match_parent"android:layout_height="wrap_content"- android:fontFamily="monospace"android:textSize="@dimen/text_body" /><TextView