Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature flagged removal of beacon monitoring #337

Merged
merged 9 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ apply plugin: "org.jetbrains.dokka"
apply plugin: 'io.radar.mvnpublish'

ext {
radarVersion = '3.10.0'
radarVersion = '3.11.0'
}

String buildNumber = ".${System.currentTimeMillis()}"
Expand Down
12 changes: 12 additions & 0 deletions sdk/src/main/java/io/radar/sdk/RadarBeaconManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ internal class RadarBeaconManager(
}

fun startMonitoringBeacons(beacons: Array<RadarBeacon>) {
if (RadarSettings.getFeatureSettings(context).useRadarModifiedBeacon) {
return
}

if (!permissionsHelper.bluetoothPermissionsGranted(context)) {
logger.d("Bluetooth permissions not granted")

Expand Down Expand Up @@ -145,6 +149,10 @@ internal class RadarBeaconManager(
}

fun startMonitoringBeaconUUIDs(beaconUUIDs: Array<String>?, beaconUIDs: Array<String>?) {
if (RadarSettings.getFeatureSettings(context).useRadarModifiedBeacon) {
return
}

if (!permissionsHelper.bluetoothPermissionsGranted(context)) {
logger.d("Bluetooth permissions not granted")

Expand Down Expand Up @@ -248,6 +256,10 @@ internal class RadarBeaconManager(
}

fun stopMonitoringBeacons() {
if (RadarSettings.getFeatureSettings(context).useRadarModifiedBeacon) {
return
}

if (!permissionsHelper.bluetoothPermissionsGranted(context)) {
return
}
Expand Down
11 changes: 8 additions & 3 deletions sdk/src/main/java/io/radar/sdk/model/RadarFeatureSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ internal data class RadarFeatureSettings(
val schedulerRequiresNetwork: Boolean,
val usePersistence: Boolean,
val extendFlushReplays: Boolean,
val useLogPersistence: Boolean
val useLogPersistence: Boolean,
val useRadarModifiedBeacon: Boolean
) {
companion object {
private const val MAX_CONCURRENT_JOBS = "maxConcurrentJobs"
Expand All @@ -19,6 +20,7 @@ internal data class RadarFeatureSettings(
private const val SCHEDULER_REQUIRES_NETWORK = "networkAny"
private const val EXTEND_FLUSH_REPLAYS = "extendFlushReplays"
private const val USE_LOG_PERSISTENCE = "useLogPersistence"
private const val USE_RADAR_MODIFIED_BEACON = "useRadarModifiedBeacon"

fun fromJson(json: JSONObject?): RadarFeatureSettings {
return if (json == null) {
Expand All @@ -29,7 +31,8 @@ internal data class RadarFeatureSettings(
json.optBoolean(SCHEDULER_REQUIRES_NETWORK),
json.optBoolean(USE_PERSISTENCE),
json.optBoolean(EXTEND_FLUSH_REPLAYS),
json.optBoolean(USE_LOG_PERSISTENCE)
json.optBoolean(USE_LOG_PERSISTENCE),
json.optBoolean(USE_RADAR_MODIFIED_BEACON)
)
}
}
Expand All @@ -40,7 +43,8 @@ internal data class RadarFeatureSettings(
false, // networkAny
false, // usePersistence
false, // extendFlushReplays
false // useLogPersistence
false, // useLogPersistence
false, // useRadarModifiedBeacon
)
}
}
Expand All @@ -52,6 +56,7 @@ internal data class RadarFeatureSettings(
putOpt(USE_PERSISTENCE, usePersistence)
putOpt(EXTEND_FLUSH_REPLAYS, extendFlushReplays)
putOpt(USE_LOG_PERSISTENCE, useLogPersistence)
putOpt(USE_RADAR_MODIFIED_BEACON, useRadarModifiedBeacon)
}
}
}
13 changes: 12 additions & 1 deletion sdk/src/test/java/io/radar/sdk/model/RadarFeatureSettingsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class RadarFeatureSettingsTest {
private var usePersistence = true
private var extendFlushReplays = false
private var useLogPersistence = true
private var useRadarModifiedBeacon = false
private lateinit var jsonString: String

@Before
Expand All @@ -31,6 +32,7 @@ class RadarFeatureSettingsTest {
"networkAny":$requiresNetwork,
"maxConcurrentJobs":$maxConcurrentJobs,
"usePersistence":$usePersistence,
"useRadarModifiedBeacon":$useRadarModifiedBeacon,
"useLogPersistence":$useLogPersistence,
"extendFlushReplays":$extendFlushReplays
}""".trimIndent()
Expand All @@ -40,7 +42,14 @@ class RadarFeatureSettingsTest {
fun testToJson() {
assertEquals(
jsonString.removeWhitespace(),
RadarFeatureSettings(maxConcurrentJobs, requiresNetwork, usePersistence, extendFlushReplays, useLogPersistence).toJson().toString().removeWhitespace()
RadarFeatureSettings(
maxConcurrentJobs,
requiresNetwork,
usePersistence,
extendFlushReplays,
useLogPersistence,
useRadarModifiedBeacon
).toJson().toString().removeWhitespace()
)
}

Expand All @@ -52,6 +61,7 @@ class RadarFeatureSettingsTest {
assertEquals(usePersistence, settings.usePersistence)
assertEquals(extendFlushReplays, settings.extendFlushReplays)
assertEquals(useLogPersistence, settings.useLogPersistence)
assertEquals(useRadarModifiedBeacon, settings.useRadarModifiedBeacon)
}

@Test
Expand All @@ -62,6 +72,7 @@ class RadarFeatureSettingsTest {
assertFalse(settings.usePersistence)
assertFalse(settings.extendFlushReplays)
assertFalse(settings.useLogPersistence)
assertFalse(settings.useRadarModifiedBeacon)
}

private fun String.removeWhitespace(): String = replace("\\s".toRegex(), "")
Expand Down