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
Auto-start in the car, floating threat bubble, Ubicquia
CIS-C0c379758c440b
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xmlindex 0d038c2..2a44723 100644--- a/app/src/main/AndroidManifest.xml+++ b/app/src/main/AndroidManifest.xml@@ -12,6 +12,8 @@makes Android strip some beacon-style advertisements from results, and wehold location permission anyway (WiFi scan results require it). --><uses-permission android:name="android.permission.BLUETOOTH_SCAN" />+ <!-- Only to recognise your car's Bluetooth connection for auto-start (asked when you turn it on). -->+ <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /><uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />@@ -32,6 +34,8 @@<uses-permission android:name="android.permission.POST_NOTIFICATIONS" /><uses-permission android:name="android.permission.VIBRATE" /><uses-permission android:name="android.permission.WAKE_LOCK" />+ <!-- Optional floating threat bubble over other apps (the user grants it in Settings). -->+ <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /><applicationandroid:name=".RFSentinelApp"@@ -137,6 +141,15 @@</intent-filter></receiver>+ <receiver+ android:name=".receiver.CarBluetoothReceiver"+ android:exported="true">+ <intent-filter>+ <action android:name="android.bluetooth.device.action.ACL_CONNECTED" />+ <action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />+ </intent-filter>+ </receiver>+<providerandroid:name="androidx.core.content.FileProvider"android:authorities="${applicationId}.fileprovider"diff --git a/app/src/main/assets/oui_presets/global.json b/app/src/main/assets/oui_presets/global.jsonindex 57a736b..6f17c5e 100644--- a/app/src/main/assets/oui_presets/global.json+++ b/app/src/main/assets/oui_presets/global.json@@ -1278,5 +1278,13 @@"confidence": "candidate","score": 35,"category": "PUBLIC_SAFETY"+ },+ {+ "prefix": "94:7B:BE",+ "label": "Ubicquia smart streetlight hub (powers police plate readers and cameras)",+ "source": "IEEE MA-L registry (Ubicquia LLC); UbiHub streetlight nodes power ALPR and video for police in 50+ US cities (e.g. San Diego PD contract). Also plain smart-streetlight controllers",+ "confidence": "candidate",+ "score": 55,+ "category": "ALPR"}]diff --git a/app/src/main/java/com/rfsentinel/app/MainActivity.kt b/app/src/main/java/com/rfsentinel/app/MainActivity.ktindex 925356c..56f0784 100644--- a/app/src/main/java/com/rfsentinel/app/MainActivity.kt+++ b/app/src/main/java/com/rfsentinel/app/MainActivity.kt@@ -333,6 +333,7 @@ class MainActivity : AppCompatActivity() {}private fun startScanning() {+ Prefs.setStartedByCar(this, false) // started by hand: leaving the car must not stop ittry {ScanForegroundService.start(this)} catch (e: Exception) {@@ -343,6 +344,7 @@ class MainActivity : AppCompatActivity() {}private fun stopScanning() {+ Prefs.setStartedByCar(this, false) // a manual choice: leaving the car must not override itScanForegroundService.stop(this)binding.root.postDelayed({ updateStatus() }, 300)}diff --git a/app/src/main/java/com/rfsentinel/app/RFSentinelApp.kt b/app/src/main/java/com/rfsentinel/app/RFSentinelApp.ktindex f5c4d02..72cbfdd 100644--- a/app/src/main/java/com/rfsentinel/app/RFSentinelApp.kt+++ b/app/src/main/java/com/rfsentinel/app/RFSentinelApp.kt@@ -13,12 +13,28 @@ import kotlinx.coroutines.SupervisorJobimport kotlinx.coroutines.launchclass RFSentinelApp : Application() {+ companion object {+ /** Number of this app's activities currently started (visible). */+ @Volatile var visibleActivities = 0+ private set+ val inForeground get() = visibleActivities > 0+ }+/** Lives as long as the process. */val appScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)override fun onCreate() {super.onCreate()com.rfsentinel.app.ui.ThemeManager.install(this)+ registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks {+ override fun onActivityStarted(a: android.app.Activity) { visibleActivities++ }+ override fun onActivityStopped(a: android.app.Activity) { visibleActivities = (visibleActivities - 1).coerceAtLeast(0) }+ override fun onActivityCreated(a: android.app.Activity, b: android.os.Bundle?) {}+ override fun onActivityResumed(a: android.app.Activity) {}+ override fun onActivityPaused(a: android.app.Activity) {}+ override fun onActivitySaveInstanceState(a: android.app.Activity, b: android.os.Bundle) {}+ override fun onActivityDestroyed(a: android.app.Activity) {}+ })NotificationHelper.createChannels(this)OuiWatchlist.load(this)WhitelistCache.start(this, appScope)diff --git a/app/src/main/java/com/rfsentinel/app/car/CarState.kt b/app/src/main/java/com/rfsentinel/app/car/CarState.ktindex 352c8e5..51b868f 100644--- a/app/src/main/java/com/rfsentinel/app/car/CarState.kt+++ b/app/src/main/java/com/rfsentinel/app/car/CarState.kt@@ -16,9 +16,13 @@ object CarState {/** Call once from the main thread (Application.onCreate). */fun start(context: Context) {runCatching {- CarConnection(context.applicationContext).type.observeForever { type ->- connected = type == CarConnection.CONNECTION_TYPE_PROJECTION ||+ val app = context.applicationContext+ CarConnection(app).type.observeForever { type ->+ val now = type == CarConnection.CONNECTION_TYPE_PROJECTION ||type == CarConnection.CONNECTION_TYPE_NATIVE+ if (now && !connected) com.rfsentinel.app.receiver.CarAutoStart.onCarConnected(app, "Android Auto connected")+ if (!now && connected) com.rfsentinel.app.receiver.CarAutoStart.onCarDisconnected(app, "Android Auto disconnected")+ connected = now}}}diff --git a/app/src/main/java/com/rfsentinel/app/receiver/CarAutoStart.kt b/app/src/main/java/com/rfsentinel/app/receiver/CarAutoStart.ktnew file mode 100644index 0000000..a36f155--- /dev/null+++ b/app/src/main/java/com/rfsentinel/app/receiver/CarAutoStart.kt@@ -0,0 +1,62 @@+package com.rfsentinel.app.receiver++import android.bluetooth.BluetoothDevice+import android.content.BroadcastReceiver+import android.content.Context+import android.content.Intent+import android.os.Build+import android.util.Log+import com.rfsentinel.app.service.ScanForegroundService+import com.rfsentinel.app.util.Permissions+import com.rfsentinel.app.util.Prefs++/**+ * Starts scanning when the phone connects to your car (its Bluetooth, chosen in+ * Settings, or Android Auto) and stops it when you leave - but only if it was+ * started this way, so a scan you started yourself is never cut off.+ *+ * Android lets an app start a foreground service from the background for+ * Bluetooth broadcasts that need BLUETOOTH_CONNECT, which is what makes this work.+ */+object CarAutoStart {++ private const val TAG = "CarAutoStart"++ fun onCarConnected(context: Context, why: String) {+ if (!Prefs.carAutoStart(context) || ScanForegroundService.isRunning) return+ if (Permissions.missingRequired(context).isNotEmpty()) return+ try {+ ScanForegroundService.start(context)+ Prefs.setStartedByCar(context, true)+ Log.i(TAG, "Scanning started: $why")+ } catch (e: Exception) {+ Log.w(TAG, "Could not start scanning ($why)", e)+ }+ }++ fun onCarDisconnected(context: Context, why: String) {+ if (!Prefs.startedByCar(context)) return+ Prefs.setStartedByCar(context, false)+ if (ScanForegroundService.isRunning) {+ ScanForegroundService.stop(context)+ Log.i(TAG, "Scanning stopped: $why")+ }+ }+}++/** Bluetooth connect / disconnect of one of the chosen car devices. */+class CarBluetoothReceiver : BroadcastReceiver() {+ override fun onReceive(context: Context, intent: Intent) {+ val device: BluetoothDevice? = if (Build.VERSION.SDK_INT >= 33) {+ intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE, BluetoothDevice::class.java)+ } else {+ @Suppress("DEPRECATION") intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE)+ }+ val address = device?.address ?: return+ if (address !in Prefs.carDevices(context)) return+ when (intent.action) {+ BluetoothDevice.ACTION_ACL_CONNECTED -> CarAutoStart.onCarConnected(context, "car Bluetooth connected")+ BluetoothDevice.ACTION_ACL_DISCONNECTED -> CarAutoStart.onCarDisconnected(context, "car Bluetooth disconnected")+ }+ }+}diff --git a/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt b/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.ktindex 20e18e9..e05e4f2 100644--- a/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt+++ b/app/src/main/java/com/rfsentinel/app/service/ScanForegroundService.kt@@ -125,6 +125,7 @@ class ScanForegroundService : Service() {private var bleRestartJob: Job? = nullprivate var housekeepingJob: Job? = nullprivate var cellJob: Job? = null+ private var bubbleJob: Job? = nullprivate var cellMonitor: CellMonitor? = nullprivate val lastCellAlert = HashMap<String, Long>()private var btStateReceiverRegistered = false@@ -210,6 +211,7 @@ class ScanForegroundService : Service() {updateLocationUpdates()startHousekeeping()startCellChecks()+ startBubble()isRunning = truerefreshTile()@@ -604,6 +606,32 @@ class ScanForegroundService : Service() {}}+ /** Keeps the floating threat bubble in sync (hidden while our own screens are visible). */+ private fun startBubble() {+ bubbleJob?.cancel()+ if (!Prefs.threatBubble(this)) { com.rfsentinel.app.ui.ThreatBubble.hide(this); return }+ bubbleJob = serviceScope.launch {+ while (isActive) {+ if (RFSentinelApp.inForeground || !com.rfsentinel.app.ui.ThreatBubble.canShow(this@ScanForegroundService)) {+ com.rfsentinel.app.ui.ThreatBubble.hide(this@ScanForegroundService)+ } else {+ val flagged = DeviceRegistry.snapshot().filter { it.best != null && !WhitelistCache.contains(it.mac) }+ val threshold = Prefs.alertThreshold(this@ScanForegroundService)+ val top = flagged.maxOfOrNull { it.best!!.confidence } ?: 0+ val cellWarning = CellMonitor.lastAnomaly?.takeIf { System.currentTimeMillis() - it.first < 15 * 60_000L }+ val level = when {+ flagged.any { it.following } || top >= 80 -> com.rfsentinel.app.ui.ThreatBubble.Level.DANGER+ top >= threshold || cellWarning != null -> com.rfsentinel.app.ui.ThreatBubble.Level.PROBABLE+ flagged.isNotEmpty() -> com.rfsentinel.app.ui.ThreatBubble.Level.WEAK+ else -> com.rfsentinel.app.ui.ThreatBubble.Level.CLEAR+ }+ com.rfsentinel.app.ui.ThreatBubble.update(this@ScanForegroundService, level, flagged.size)+ }+ delay(2_000)+ }+ }+ }+private fun updateLocationOnMain() {android.os.Handler(Looper.getMainLooper()).post { updateLocationUpdates() }}@@ -626,6 +654,7 @@ class ScanForegroundService : Service() {serviceScope.cancel()pipelineThread.quitSafely()cellMonitor?.close()+ com.rfsentinel.app.ui.ThreatBubble.hide(this)// Take the final history and trace synchronously, so a scan restarted right// away (new session, new trace) can't clear or reuse them; write them after.val history = takeHistory()@@ -636,6 +665,7 @@ class ScanForegroundService : Service() {trip?.let { runCatching { TripRecorder.persist(app, it) }.onFailure { e -> Log.w(TAG, "Trace save failed", e) } }}wakeLock?.let { if (it.isHeld) it.release() }+ Prefs.setStartedByCar(this, false)isRunning = falserefreshTile()StatusWidget.updateAll(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 62a667b..fd96982 100644--- a/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt+++ b/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt@@ -39,6 +39,64 @@ class SettingsActivity : AppCompatActivity() {updateBannerButtons()}+ private val connectPermission = registerForActivityResult(+ androidx.activity.result.contract.ActivityResultContracts.RequestPermission()+ ) { granted ->+ if (granted) chooseCarDevices()+ else Toast.makeText(this, "Needed to recognise your car's Bluetooth", Toast.LENGTH_LONG).show()+ }++ private fun hasConnectPermission() = android.os.Build.VERSION.SDK_INT < 31 ||+ checkSelfPermission(android.Manifest.permission.BLUETOOTH_CONNECT) == android.content.pm.PackageManager.PERMISSION_GRANTED++ /** Lists paired Bluetooth devices so the user can tick their car(s). */+ @android.annotation.SuppressLint("MissingPermission") // checked by hasConnectPermission()+ private fun chooseCarDevices() {+ if (!hasConnectPermission()) {+ connectPermission.launch(android.Manifest.permission.BLUETOOTH_CONNECT); return+ }+ val adapter = (getSystemService(BLUETOOTH_SERVICE) as? android.bluetooth.BluetoothManager)?.adapter+ val paired = runCatching { adapter?.bondedDevices?.toList() }.getOrNull().orEmpty()+ .sortedBy { runCatching { it.name }.getOrNull() ?: it.address }+ if (paired.isEmpty()) {+ Toast.makeText(this, "No paired Bluetooth devices - pair your car first", Toast.LENGTH_LONG).show(); return+ }+ val chosen = Prefs.carDevices(this).toMutableSet()+ val labels = paired.map { d ->+ val car = d.bluetoothClass?.deviceClass.let {+ it == android.bluetooth.BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO ||+ it == android.bluetooth.BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE+ }+ (runCatching { d.name }.getOrNull() ?: d.address) + if (car) " (car audio)" else ""+ }.toTypedArray()+ val checked = paired.map { it.address in chosen }.toBooleanArray()+ AlertDialog.Builder(this)+ .setTitle("Which Bluetooth is your car?")+ .setMultiChoiceItems(labels, checked) { _, i, on ->+ if (on) chosen += paired[i].address else chosen -= paired[i].address+ }+ .setPositiveButton("Save") { _, _ ->+ Prefs.setCarDevices(this, chosen)+ updateCarDevicesText()+ }+ .setNegativeButton("Cancel", null)+ .show()+ }++ @android.annotation.SuppressLint("MissingPermission")+ private fun updateCarDevicesText() {+ val chosen = Prefs.carDevices(this)+ val names = if (hasConnectPermission()) {+ val bonded = runCatching {+ (getSystemService(BLUETOOTH_SERVICE) as? android.bluetooth.BluetoothManager)?.adapter?.bondedDevices+ }.getOrNull().orEmpty()+ chosen.map { a -> bonded.firstOrNull { it.address == a }?.let { runCatching { it.name }.getOrNull() } ?: a }+ } else chosen.toList()+ binding.carDevicesText.text = if (names.isEmpty())+ "No car chosen yet. Android Auto also starts it when the app opens on the car screen."+ else "Car: " + names.joinToString() + ". Android Auto also starts it."+ }+private fun updateBannerButtons() {binding.bannerClearButton.isEnabled = ThemeManager.hasBanner(this)}@@ -105,6 +163,12 @@ class SettingsActivity : AppCompatActivity() {}updateWifiThrottleHint()binding.bootSwitch.isChecked = Prefs.autoStartOnBoot(this)+ binding.carAutoSwitch.isChecked = Prefs.carAutoStart(this)+ binding.carAutoSwitch.setOnCheckedChangeListener { _, on ->+ if (on && Prefs.carDevices(this).isEmpty()) chooseCarDevices()+ }+ binding.carDevicesButton.setOnClickListener { chooseCarDevices() }+ updateCarDevicesText()binding.batteryButton.setOnClickListener {runCatching { startActivity(Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS)) }.onFailure { Toast.makeText(this, "Open Android Settings > Apps > RF Sentinel > Battery", Toast.LENGTH_LONG).show() }@@ -137,6 +201,23 @@ class SettingsActivity : AppCompatActivity() {binding.vibrateSwitch.isChecked = Prefs.vibrateEnabled(this)binding.voiceSwitch.isChecked = Prefs.voiceEnabled(this)binding.discreetSwitch.isChecked = Prefs.discreetMode(this)+ binding.bubbleSwitch.isChecked = Prefs.threatBubble(this) && Settings.canDrawOverlays(this)+ binding.bubbleSwitch.setOnCheckedChangeListener { sw, on ->+ if (on && !Settings.canDrawOverlays(this)) {+ sw.isChecked = false+ AlertDialog.Builder(this)+ .setTitle("Allow the floating bubble")+ .setMessage("Android needs the \"Display over other apps\" permission for the bubble. " ++ "Turn it on for RF Sentinel on the next screen, then come back and switch the bubble on.")+ .setPositiveButton("Open settings") { _, _ ->+ runCatching {+ startActivity(Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, android.net.Uri.parse("package:$packageName")))+ }+ }+ .setNegativeButton("Cancel", null)+ .show()+ }+ }binding.dedupeInput.setText((Prefs.dedupeWindowMs(this) / 60000).toString())// Location@@ -244,6 +325,7 @@ class SettingsActivity : AppCompatActivity() {val intervalSec = binding.intervalInput.text.toString().toLongOrNull() ?: 30LPrefs.setScanIntervalMs(this, intervalSec.coerceAtLeast(5) * 1000L)Prefs.setAutoStartOnBoot(this, binding.bootSwitch.isChecked)+ Prefs.setCarAutoStart(this, binding.carAutoSwitch.isChecked)categorySwitches.forEach { (c, sw) -> Prefs.setCategoryEnabled(this, c, sw.isChecked) }val presets = mutableSetOf<String>()@@ -264,6 +346,8 @@ class SettingsActivity : AppCompatActivity() {Prefs.setVibrateEnabled(this, binding.vibrateSwitch.isChecked)Prefs.setVoiceEnabled(this, binding.voiceSwitch.isChecked)Prefs.setDiscreetMode(this, binding.discreetSwitch.isChecked)+ Prefs.setThreatBubble(this, binding.bubbleSwitch.isChecked)+ if (!binding.bubbleSwitch.isChecked) com.rfsentinel.app.ui.ThreatBubble.hide(this)val dedupeMin = binding.dedupeInput.text.toString().toLongOrNull() ?: 5LPrefs.setDedupeWindowMs(this, dedupeMin.coerceAtLeast(1) * 60000L)diff --git a/app/src/main/java/com/rfsentinel/app/ui/ThreatBubble.kt b/app/src/main/java/com/rfsentinel/app/ui/ThreatBubble.ktnew file mode 100644index 0000000..f969543--- /dev/null+++ b/app/src/main/java/com/rfsentinel/app/ui/ThreatBubble.kt@@ -0,0 +1,123 @@+package com.rfsentinel.app.ui++import android.annotation.SuppressLint+import android.content.Context+import android.content.Intent+import android.graphics.Canvas+import android.graphics.Paint+import android.graphics.PixelFormat+import android.os.Build+import android.os.Handler+import android.os.Looper+import android.provider.Settings+import android.view.Gravity+import android.view.MotionEvent+import android.view.View+import android.view.WindowManager+import androidx.core.content.edit+import com.rfsentinel.app.MainActivity+import kotlin.math.abs+import kotlin.math.min++/**+ * A small floating bubble drawn over other apps (e.g. Waze, Google Maps) while+ * 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.+ */+object ThreatBubble {++ enum class Level(val color: Int) { CLEAR(0xFF2E7D32.toInt()), WEAK(0xFF8D6E00.toInt()), PROBABLE(0xFFE08A00.toInt()), DANGER(0xFFC62828.toInt()) }++ private val main = Handler(Looper.getMainLooper())+ private var view: BubbleView? = null+ private var params: WindowManager.LayoutParams? = null++ fun canShow(context: Context) = Settings.canDrawOverlays(context)++ /** Shows or updates the bubble (any thread). */+ fun update(context: Context, level: Level, count: Int) = main.post {+ val app = context.applicationContext+ if (!canShow(app)) { removeNow(app); return@post }+ val v = view ?: add(app) ?: return@post+ v.set(level, count)+ }++ fun hide(context: Context) = main.post { removeNow(context.applicationContext) }++ private fun removeNow(context: Context) {+ val v = view ?: return+ runCatching { (context.getSystemService(Context.WINDOW_SERVICE) as WindowManager).removeView(v) }+ view = null; params = null+ }++ @SuppressLint("ClickableViewAccessibility")+ private fun add(context: Context): BubbleView? {+ val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager+ val d = context.resources.displayMetrics.density+ val size = (52 * d).toInt()+ val prefs = context.getSharedPreferences("threat_bubble", Context.MODE_PRIVATE)+ val lp = WindowManager.LayoutParams(+ size, size,+ if (Build.VERSION.SDK_INT >= 26) WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY+ else @Suppress("DEPRECATION") WindowManager.LayoutParams.TYPE_PHONE,+ WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,+ PixelFormat.TRANSLUCENT+ ).apply {+ gravity = Gravity.TOP or Gravity.START+ x = prefs.getInt("x", (8 * d).toInt())+ y = prefs.getInt("y", (180 * d).toInt())+ }+ val v = BubbleView(context)+ var downX = 0f; var downY = 0f; var startX = 0; var startY = 0; var moved = false+ v.setOnTouchListener { _, e ->+ when (e.actionMasked) {+ 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) { lp.x = startX + dx.toInt(); lp.y = startY + dy.toInt(); runCatching { wm.updateViewLayout(v, lp) } }+ }+ MotionEvent.ACTION_UP -> {+ if (moved) prefs.edit { putInt("x", lp.x); putInt("y", lp.y) }+ else context.startActivity(Intent(context, MainActivity::class.java)+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_REORDER_TO_FRONT))+ }+ }+ true+ }+ return runCatching { wm.addView(v, lp); view = v; params = lp; v }.getOrNull()+ }++ /** The drawn bubble: coloured disc, white ring, count or check mark. */+ private class BubbleView(context: Context) : View(context) {+ private val d = resources.displayMetrics.density+ private var level = Level.CLEAR+ private var count = 0+ private val fill = Paint(Paint.ANTI_ALIAS_FLAG)+ private val ring = Paint(Paint.ANTI_ALIAS_FLAG).apply { style = Paint.Style.STROKE; strokeWidth = 2.5f * d; color = 0xFFFFFFFF.toInt() }+ private val text = Paint(Paint.ANTI_ALIAS_FLAG).apply {+ color = 0xFFFFFFFF.toInt(); textAlign = Paint.Align.CENTER; isFakeBoldText = true; textSize = 20 * d+ }++ init { contentDescription = "RF Sentinel threat level" }++ fun set(level: Level, count: Int) {+ if (level == this.level && count == this.count) return+ this.level = level; this.count = count+ contentDescription = "RF Sentinel: ${if (count == 0) "all clear" else "$count flagged"}"+ invalidate()+ }++ override fun onDraw(canvas: Canvas) {+ val r = min(width, height) / 2f - 2 * d+ fill.color = (level.color and 0x00FFFFFF) or 0xE6000000.toInt()+ canvas.drawCircle(width / 2f, height / 2f, r, fill)+ canvas.drawCircle(width / 2f, height / 2f, r, ring)+ val label = if (count == 0) "✓" else if (count > 99) "99+" else count.toString()+ text.textSize = if (label.length > 2) 14 * d else 20 * d+ canvas.drawText(label, width / 2f, height / 2f - (text.descent() + text.ascent()) / 2, text)+ }+ }+}diff --git a/app/src/main/java/com/rfsentinel/app/util/Prefs.kt b/app/src/main/java/com/rfsentinel/app/util/Prefs.ktindex 1674650..ea5aa6b 100644--- a/app/src/main/java/com/rfsentinel/app/util/Prefs.kt+++ b/app/src/main/java/com/rfsentinel/app/util/Prefs.kt@@ -95,6 +95,20 @@ object Prefs {fun showKnownAlpr(context: Context): Boolean = bool(context, "show_known_alpr", true)fun setShowKnownAlpr(context: Context, value: Boolean) = setBool(context, "show_known_alpr", value)+ /** Start scanning when the phone connects to the car (chosen Bluetooth devices, or Android Auto). */+ fun carAutoStart(context: Context): Boolean = bool(context, "car_auto_start", false)+ fun setCarAutoStart(context: Context, value: Boolean) = setBool(context, "car_auto_start", value)+ /** Bluetooth addresses of the user's car(s). */+ fun carDevices(context: Context): Set<String> = sp(context).getStringSet("car_devices", emptySet()) ?: emptySet()+ fun setCarDevices(context: Context, value: Set<String>) = sp(context).edit { putStringSet("car_devices", value) }+ /** True while the running scan was started by the car (so leaving the car may stop it). */+ fun startedByCar(context: Context): Boolean = bool(context, "started_by_car", false)+ fun setStartedByCar(context: Context, value: Boolean) = setBool(context, "started_by_car", value)++ /** Floating threat bubble over other apps while scanning. */+ fun threatBubble(context: Context): Boolean = bool(context, "threat_bubble", false)+ fun setThreatBubble(context: Context, value: Boolean) = setBool(context, "threat_bubble", value)+fun autoRecordTrace(context: Context): Boolean = bool(context, "auto_record_trace", false)fun setAutoRecordTrace(context: Context, value: Boolean) = setBool(context, "auto_record_trace", value)diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xmlindex 76215f0..9d40963 100644--- a/app/src/main/res/layout/activity_settings.xml+++ b/app/src/main/res/layout/activity_settings.xml@@ -115,6 +115,25 @@android:layout_height="wrap_content"android:text="Open Developer options" />+ <com.google.android.material.switchmaterial.SwitchMaterial+ android:id="@+id/carAutoSwitch"+ android:layout_width="match_parent"+ android:layout_height="wrap_content"+ android:text="Start scanning automatically in the car (and stop when you leave)" />++ <TextView+ android:id="@+id/carDevicesText"+ style="@style/SettingsLabel"+ android:paddingTop="2dp"+ android:textSize="12sp" />++ <Button+ android:id="@+id/carDevicesButton"+ style="@style/Widget.MaterialComponents.Button.TextButton"+ android:layout_width="wrap_content"+ android:layout_height="wrap_content"+ android:text="Choose your car's Bluetooth" />+<com.google.android.material.switchmaterial.SwitchMaterialandroid:id="@+id/bootSwitch"android:layout_width="match_parent"@@ -214,6 +233,12 @@android:layout_height="wrap_content"android:text="Spoken alerts (e.g. while driving)" />+ <com.google.android.material.switchmaterial.SwitchMaterial+ android:id="@+id/bubbleSwitch"+ android:layout_width="match_parent"+ android:layout_height="wrap_content"+ android:text="Floating threat bubble over other apps (e.g. Waze, Maps) while scanning" />+<com.google.android.material.switchmaterial.SwitchMaterialandroid:id="@+id/discreetSwitch"android:layout_width="match_parent"diff --git a/docs/SIGNATURES.md b/docs/SIGNATURES.mdindex 3a61adb..ec8e0f2 100644--- a/docs/SIGNATURES.md+++ b/docs/SIGNATURES.md@@ -234,6 +234,7 @@ registrants are left out on purpose.| Jenoptik | 1 | Traffic enforcement (also optics) | ALPR | 45 || Q-Free | 3 | Tolling and ANPR | ALPR | 40 || Genetec | 4 | AutoVu ALPR (also servers, access control) | ALPR | 40 |+| Ubicquia | 1 | UbiHub smart streetlights powering police ALPR / video | ALPR | 55 || Cradlepoint | 2 | Vehicle routers (police cars, buses, stores) | Public safety | 35 |Left out on purpose: