Skip to content

Commit d08e1f0

Browse files
committed
feat: geo blocking build config override
1 parent fae8875 commit d08e1f0

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ Simply pass `E2E=true` as environment variable and build any flavor.
7676
E2E=true ./gradlew assembleDevRelease
7777
```
7878

79+
#### Disable Geoblocking Checks
80+
81+
By default, geoblocking checks via API are enabled. To disable at build time, use the `GEO` environment variable:
82+
83+
```sh
84+
GEO=false E2E=true ./gradlew assembleDevRelease
85+
```
86+
7987
### Build for Release
8088

8189
**Prerequisites**

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ android {
4646
useSupportLibrary = true
4747
}
4848
buildConfigField("boolean", "E2E", System.getenv("E2E")?.toBoolean()?.toString() ?: "false")
49+
buildConfigField("boolean", "GEO", System.getenv("GEO")?.toBoolean()?.toString() ?: "true")
4950
}
5051

5152
flavorDimensions += "network"

app/src/main/java/to/bitkit/env/Env.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import kotlin.io.path.Path
1515
internal object Env {
1616
val isDebug = BuildConfig.DEBUG
1717
const val isE2eTest = BuildConfig.E2E
18+
const val isGeoblockingEnabled = BuildConfig.GEO
1819
val network = Network.valueOf(BuildConfig.NETWORK)
1920
val walletSyncIntervalSecs = 10_uL // TODO review
2021
val platform = "Android ${Build.VERSION.RELEASE} (API ${Build.VERSION.SDK_INT})"

app/src/main/java/to/bitkit/services/CoreService.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@ class CoreService @Inject constructor(
111111
}
112112
}
113113

114+
@Suppress("KotlinConstantConditions")
114115
private suspend fun isGeoBlocked(): Boolean {
116+
if (!Env.isGeoblockingEnabled) {
117+
Logger.verbose("Geoblocking disabled via build config", context = "GeoCheck")
118+
return false
119+
}
120+
115121
return ServiceQueue.CORE.background {
116122
runCatching {
117123
Logger.verbose("Checking geo status…", context = "GeoCheck")

0 commit comments

Comments
 (0)