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
Android Auto map: distance spans (fixes crash with places nearby)
CIS-C062ae956e4d11
diff --git a/app/src/main/java/com/rfsentinel/app/car/NearbyMapScreen.kt b/app/src/main/java/com/rfsentinel/app/car/NearbyMapScreen.ktindex 12cd29f..e849f68 100644--- a/app/src/main/java/com/rfsentinel/app/car/NearbyMapScreen.kt+++ b/app/src/main/java/com/rfsentinel/app/car/NearbyMapScreen.kt@@ -55,7 +55,7 @@ class NearbyMapScreen(carContext: CarContext) : LiveScreen(carContext, periodMsitems.forEach { it -> list.addItem(row(it)) }val template = PlaceListMapTemplate.Builder()- .setTitle("Map: cameras, devices, drones")+ .setTitle("Cameras & devices").setHeaderAction(Action.BACK).setCurrentLocationEnabled(me != null).setItemList(list.build())@@ -82,9 +82,14 @@ class NearbyMapScreen(carContext: CarContext) : LiveScreen(carContext, periodMs}).build()).build()+ // Android Auto requires every place row on a map template to carry its distance+ // as a DistanceSpan (the host formats it in the driver's units); plain text throws.+ val text = android.text.SpannableString(" · " + it.detail)+ text.setSpan(androidx.car.app.model.DistanceSpan.create(distanceOf(it.distanceM)), 0, 1,+ android.text.Spanned.SPAN_INCLUSIVE_INCLUSIVE)return Row.Builder().setTitle(it.title)- .addText(distanceText(it.distanceM) + " · " + it.detail)+ .addText(text).setMetadata(Metadata.Builder().setPlace(place).build()).setOnClickListener {if (it.mac != null) screenManager.push(DeviceDetailScreen(carContext, it.mac))@@ -149,6 +154,11 @@ class NearbyMapScreen(carContext: CarContext) : LiveScreen(carContext, periodMsreturn (drones.sortedBy { it.distanceM } + devices.sortedBy { it.distanceM } + cams).take(limit)}+ /** Metres below 1 km (rounded to 10 m), else kilometres with one decimal. */+ fun distanceOf(m: Double): androidx.car.app.model.Distance =+ if (m < 1000) androidx.car.app.model.Distance.create(((m / 10).roundToInt() * 10).toDouble(), androidx.car.app.model.Distance.UNIT_METERS)+ else androidx.car.app.model.Distance.create(m / 1000, androidx.car.app.model.Distance.UNIT_KILOMETERS_P1)+fun distanceText(m: Double) = if (m < 1000) "${(m / 10).roundToInt() * 10} m" else String.format(java.util.Locale.US, "%.1f km", m / 1000)}}diff --git a/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt b/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.ktindex cdd4499..79d21dc 100644--- a/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt+++ b/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt@@ -101,6 +101,10 @@ class ScanForegroundService : Service() {var lastFix: Location? = nullprivate set+ /** Tests only: pretend the scanner has this fix. */+ @androidx.annotation.VisibleForTesting+ fun setLastFixForTest(l: Location?) { lastFix = l }+/** True while an instance is alive in this process. Source of truth for the UI. */@Volatilevar isRunning = falsediff --git a/app/src/test/java/com/rfsentinel/app/car/CarScreensTest.kt b/app/src/test/java/com/rfsentinel/app/car/CarScreensTest.ktindex 56c4021..0c4b0cb 100644--- a/app/src/test/java/com/rfsentinel/app/car/CarScreensTest.kt+++ b/app/src/test/java/com/rfsentinel/app/car/CarScreensTest.kt@@ -136,9 +136,15 @@ class CarScreensTest {assertEquals("330 m", NearbyMapScreen.distanceText(items[1].distanceM))assertEquals("1.1 km", NearbyMapScreen.distanceText(items[2].distanceM))- // The template (host-drawn map + places) builds within Android Auto's limits.+ // The template (host-drawn map + places) builds within Android Auto's limits - with a+ // location, so the rows are really there (each needs a DistanceSpan or build() throws).+ com.rfsentinel.app.service.ScanForegroundService.setLastFixForTest(+ android.location.Location("test").apply { latitude = 10.5; longitude = -20.5 }+ )val t = NearbyMapScreen(car).onGetTemplate() as androidx.car.app.model.PlaceListMapTemplate+ assertEquals(3, t.itemList!!.items.size)assertTrue(t.itemList!!.items.size <= CarUi.listLimit(car))+ com.rfsentinel.app.service.ScanForegroundService.setLastFixForTest(null)com.rfsentinel.app.alpr.AlprStore.setForTest(emptyList())}