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.

Canada preset no longer on by default for new installs; installs already set up with no saved regions keep it

CIS-C07057ddd726c5
diff --git a/app/src/main/java/com/rfsentinel/app/oui/OuiWatchlist.kt b/app/src/main/java/com/rfsentinel/app/oui/OuiWatchlist.kt
index bfea2a9..7bdf71c 100644
--- a/app/src/main/java/com/rfsentinel/app/oui/OuiWatchlist.kt
+++ b/app/src/main/java/com/rfsentinel/app/oui/OuiWatchlist.kt
@@ -24,7 +24,7 @@ object OuiWatchlist {
private const val PREFS = "oui_watchlist_prefs"
private const val KEY_CUSTOM = "custom_entries"
private const val KEY_ENABLED_PRESETS = "enabled_presets"
- private val DEFAULT_PRESETS = setOf("global", "canada")
+ private val DEFAULT_PRESETS = setOf("global")
private val gson = Gson()
private val listType = object : TypeToken<List<OuiEntry>>() {}.type
@@ -48,7 +48,7 @@ object OuiWatchlist {
/**
* False when a European region is on without the United States: Flock isn't deployed there, so its matches are
- * ignored (see FlockNoise). Canada doesn't count: it's on by default, so a European user may never have unticked it.
+ * ignored (see FlockNoise). Canada doesn't count: it was on by default, so a European user may never have unticked it.
*/
@Volatile
var flockRegion = true
@@ -146,9 +146,13 @@ object OuiWatchlist {
}
}
+ /** With no saved choice: an install set up before Canada stopped being a default keeps it, so its detection doesn't silently change. */
+ fun defaultPresets(setupDone: Boolean) = if (setupDone) DEFAULT_PRESETS + "canada" else DEFAULT_PRESETS
+
fun getEnabledPresets(context: Context): Set<String> {
val prefs = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
- val set = prefs.getStringSet(KEY_ENABLED_PRESETS, DEFAULT_PRESETS) ?: DEFAULT_PRESETS
+ val default = defaultPresets(com.rfsentinel.app.util.Prefs.onboardingDone(context))
+ val set = prefs.getStringSet(KEY_ENABLED_PRESETS, default) ?: default
// Presets that no longer exist were merged into "canada".
return set.map { if (it in availablePresets) it else "canada" }.toSet()
}
diff --git a/app/src/main/java/com/rfsentinel/app/ui/SetupActivity.kt b/app/src/main/java/com/rfsentinel/app/ui/SetupActivity.kt
index 722fa05..7445066 100644
--- a/app/src/main/java/com/rfsentinel/app/ui/SetupActivity.kt
+++ b/app/src/main/java/com/rfsentinel/app/ui/SetupActivity.kt
@@ -347,6 +347,8 @@ class SetupActivity : AppCompatActivity() {
}
private fun finishSetup() {
+ // Before the flag: a finished setup with no saved regions reads as an older install (OuiWatchlist.defaultPresets).
+ OuiWatchlist.setEnabledPresets(this, OuiWatchlist.getEnabledPresets(this))
Prefs.setOnboardingDone(this)
val prefetch = com.rfsentinel.app.alpr.CameraPrefetch
if (step == STEPS - 1 && prefetchOnFinish && prefetch.canRun(this) && !prefetch.isRunning &&
diff --git a/app/src/test/java/com/rfsentinel/app/ui/RegionNoticeTest.kt b/app/src/test/java/com/rfsentinel/app/ui/RegionNoticeTest.kt
index 0db022f..f88b6a7 100644
--- a/app/src/test/java/com/rfsentinel/app/ui/RegionNoticeTest.kt
+++ b/app/src/test/java/com/rfsentinel/app/ui/RegionNoticeTest.kt
@@ -1,6 +1,7 @@
package com.rfsentinel.app.ui
import com.rfsentinel.app.oui.OuiWatchlist
+import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
@@ -19,6 +20,12 @@ class RegionNoticeTest {
assertNull(RegionNotice.textFor("us"))
}
+ @Test
+ fun canadaIsADefaultOnlyForInstallsSetUpBefore() {
+ assertEquals(setOf("global"), OuiWatchlist.defaultPresets(setupDone = false))
+ assertEquals(setOf("global", "canada"), OuiWatchlist.defaultPresets(setupDone = true))
+ }
+
@Test
fun newRegionsAreAvailable() {
assertTrue(OuiWatchlist.availablePresets.containsAll(listOf("france", "uk", "portugal", "germany", "spain", "italy")))