Skip to content

Commit 3393d8b

Browse files
committed
Stub out Google Mobile Services and Firebase with Open Source library, new build flavor 'gms' to use it
1 parent e9db4bb commit 3393d8b

65 files changed

Lines changed: 1223 additions & 22 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎app/build.gradle.kts‎

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ val selectableVariants = listOf(
8585
"playProdQuickstart",
8686
"playStagingQuickstart",
8787
"websiteProdSpinner",
88-
"websiteProdRelease",
88+
"websiteFossProdRelease",
89+
"websiteGmsProdRelease",
8990
"githubProdSpinner",
9091
"githubProdRelease"
9192
)
@@ -159,7 +160,7 @@ android {
159160

160161
ndkVersion = libs.versions.ndk.get()
161162

162-
flavorDimensions += listOf("distribution", "environment")
163+
flavorDimensions += listOf("distribution", "gms", "environment")
163164

164165
android.bundle.language.enableSplit = false
165166

@@ -446,8 +447,10 @@ android {
446447
}
447448

448449
create("website") {
450+
val MAU = if (gradle.startParameter.taskRequests.toString().contains("Foss")) "false" else "true"
451+
449452
dimension = "distribution"
450-
buildConfigField("boolean", "MANAGES_APP_UPDATES", "true")
453+
buildConfigField("boolean", "MANAGES_APP_UPDATES", "${MAU}")
451454
buildConfigField("String", "APK_UPDATE_MANIFEST_URL", "\"https://updates.signal.org/android/latest.json\"")
452455
buildConfigField("String", "BUILD_DISTRIBUTION_TYPE", "\"website\"")
453456
}
@@ -468,6 +471,17 @@ android {
468471
buildConfigField("boolean", "LINK_DEVICE_UX_ENABLED", "true")
469472
}
470473

474+
create("gms") {
475+
dimension = "gms"
476+
isDefault = true
477+
buildConfigField("boolean", "USE_OSM", "false")
478+
}
479+
480+
create("foss") {
481+
dimension = "gms"
482+
buildConfigField("boolean", "USE_OSM", "true")
483+
}
484+
471485
create("prod") {
472486
dimension = "environment"
473487

@@ -759,14 +773,16 @@ dependencies {
759773
implementation(libs.androidx.emoji2)
760774
implementation(libs.androidx.paging.runtime)
761775
implementation(libs.androidx.paging.compose)
762-
implementation(libs.firebase.messaging) {
776+
"gmsImplementation"(libs.firebase.messaging) {
763777
exclude(group = "com.google.firebase", module = "firebase-core")
764778
exclude(group = "com.google.firebase", module = "firebase-analytics")
765779
exclude(group = "com.google.firebase", module = "firebase-measurement-connector")
766780
}
767-
implementation(libs.google.play.services.maps)
768-
implementation(libs.google.play.services.auth)
769-
implementation(libs.google.signin)
781+
"gmsImplementation"(libs.google.play.services.maps)
782+
"gmsImplementation"(libs.google.play.services.auth)
783+
"gmsImplementation"(libs.google.signin)
784+
"fossImplementation"(project(":lib:fakegms"))
785+
"fossImplementation"(libs.osmdroid)
770786
implementation(libs.androidx.media)
771787
implementation(libs.bundles.media3)
772788
implementation(libs.conscrypt.android)
@@ -806,15 +822,16 @@ dependencies {
806822
implementation(libs.accompanist.drawablepainter)
807823
implementation(libs.kotlin.stdlib.jdk8)
808824
implementation(libs.kotlin.reflect)
809-
implementation(libs.kotlinx.coroutines.play.services)
825+
"gmsImplementation"(libs.kotlinx.coroutines.play.services)
810826
implementation(libs.kotlinx.coroutines.rx3)
811827
implementation(libs.jackson.module.kotlin)
812828
implementation(libs.rxjava3.rxandroid)
813829
implementation(libs.rxjava3.rxkotlin)
814830
implementation(libs.rxdogtag)
815831
implementation(libs.kotlinx.serialization.json)
816832

817-
implementation(project(":lib:billing"))
833+
"gmsImplementation"(project(":lib:billing"))
834+
"fossImplementation"(project(":lib:fakebilling"))
818835
implementation(project(":feature:media-send"))
819836

820837
"spinnerImplementation"(project(":lib:spinner"))

‎app/src/main/java/org/thoughtcrime/securesms/components/location/SignalPlace.java‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.fasterxml.jackson.annotation.JsonProperty;
1212
import com.google.android.gms.maps.model.LatLng;
1313

14+
import org.thoughtcrime.securesms.BuildConfig;
1415
import org.signal.core.util.logging.Log;
1516
import org.thoughtcrime.securesms.maps.AddressData;
1617
import org.signal.core.util.JsonUtils;
@@ -19,7 +20,8 @@
1920

2021
public class SignalPlace {
2122

22-
private static final String URL = "https://maps.google.com/maps";
23+
private static final String GMS_URL = "https://maps.google.com/maps";
24+
private static final String OSM_URL = "https://www.openstreetmap.org/";
2325
private static final String TAG = Log.tag(SignalPlace.class);
2426

2527
@JsonProperty
@@ -62,10 +64,21 @@ public String getDescription() {
6264
description += (address + "\n");
6365
}
6466

65-
description += Uri.parse(URL)
66-
.buildUpon()
67-
.appendQueryParameter("q", String.format("%s,%s", latitude, longitude))
68-
.build().toString();
67+
if (BuildConfig.USE_OSM) {
68+
// Thanks to https://github.com/sergimn for suggesting place marker
69+
description += Uri.parse(OSM_URL)
70+
.buildUpon()
71+
.appendQueryParameter("mlat", String.format("%s", latitude))
72+
.appendQueryParameter("mlon", String.format("%s", longitude))
73+
.encodedFragment(String.format("map=15/%s/%s", latitude, longitude))
74+
.build().toString();
75+
}
76+
else {
77+
description += Uri.parse(GMS_URL)
78+
.buildUpon()
79+
.appendQueryParameter("q", String.format("%s,%s", latitude, longitude))
80+
.build().toString();
81+
}
6982

7083
return description;
7184
}

‎build.gradle.kts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ tasks.register("ciRemote") {
126126
}
127127

128128
// Wire up QA dependencies after all projects are evaluated
129-
gradle.projectsEvaluated {
129+
// AT - dirty hack
130+
val sptr = gradle.startParameter.taskRequests.toString()
131+
if (!sptr.contains("Foss") && !sptr.contains("Gms") && !sptr.contains("depend")) gradle.projectsEvaluated {
130132
val appTestTask = tasks.findByPath(":Signal-Android:testPlayProdDebugUnitTest")!!
131133
val appLintTask = tasks.findByPath(":Signal-Android:lintPlayProdDebug")!!
132134
val appCompileInstrumentationTask = tasks.findByPath(":Signal-Android:compilePlayProdDebugAndroidTestSources")
@@ -204,6 +206,7 @@ gradle.projectsEvaluated {
204206

205207
// If you let all of these things run in parallel, gradle will likely OOM.
206208
// To avoid this, we put non-app tests and lints behind the much heavier app tests and lints.
209+
207210
subprojects.filter { it.name != "Signal-Android" }.forEach { subproject ->
208211
appTestTask.let { task ->
209212
subproject.tasks.findByName("testDebugUnitTest")?.mustRunAfter(task)

‎core/util/build.gradle.kts‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,26 @@ plugins {
77

88
android {
99
namespace = "org.signal.core.util"
10+
11+
flavorDimensions += listOf("gms")
12+
productFlavors {
13+
create("gms") {
14+
dimension = "gms"
15+
isDefault = true
16+
}
17+
18+
create("foss") {
19+
dimension = "gms"
20+
}
21+
}
22+
}
23+
24+
androidComponents {
25+
beforeVariants { variant ->
26+
val sptr = gradle.startParameter.taskRequests.toString()
27+
if (variant.name.lowercase().contains("foss")) variant.enable = sptr.contains("Foss")
28+
else if (variant.name.lowercase().contains("gms")) variant.enable = sptr.contains("Gms")
29+
}
1030
}
1131

1232
dependencies {
@@ -21,7 +41,8 @@ dependencies {
2141
implementation(libs.jackson.core)
2242
implementation(libs.jackson.module.kotlin)
2343
implementation(libs.google.libphonenumber)
24-
implementation(libs.google.play.services.base)
44+
"gmsImplementation"(libs.google.play.services.base)
45+
"fossImplementation"(project(":lib:fakegms"))
2546
testImplementation(libs.androidx.sqlite.framework)
2647

2748
testImplementation(testLibs.junit.junit)

‎feature/registration/build.gradle.kts‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ android {
2323
isIncludeAndroidResources = true
2424
}
2525
}
26+
27+
flavorDimensions += listOf("gms")
28+
productFlavors {
29+
create("gms") {
30+
dimension = "gms"
31+
isDefault = true
32+
}
33+
34+
create("foss") {
35+
dimension = "gms"
36+
}
37+
}
2638
}
2739

2840
screenshotTests {
@@ -58,7 +70,8 @@ dependencies {
5870
implementation(project(":core:util"))
5971
implementation(project(":core:models-jvm"))
6072
implementation(project(":core:serialization"))
61-
implementation(project(":lib:billing"))
73+
"gmsImplementation"(project(":lib:billing"))
74+
"fossImplementation"(project(":lib:fakebilling"))
6275
implementation(project(":lib:device-transfer"))
6376
implementation(project(":lib:password-manager"))
6477
implementation(project(":lib:signal-login"))
@@ -95,8 +108,9 @@ dependencies {
95108
implementation(libs.google.libphonenumber)
96109

97110
// Phone number hint + SMS verification code retriever
98-
implementation(libs.google.play.services.auth)
99-
implementation(libs.kotlinx.coroutines.play.services)
111+
"gmsImplementation"(libs.google.play.services.auth)
112+
"gmsImplementation"(libs.kotlinx.coroutines.play.services)
113+
"fossImplementation"(project(":lib:fakegms"))
100114

101115
// Testing
102116
testImplementation(testFixtures(project(":core:ui")))

‎gradle/libs.versions.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ mp4parser-isoparser = { module = "org.mp4parser:isoparser", version.ref = "mp4pa
213213
mp4parser-streaming = { module = "org.mp4parser:streaming", version.ref = "mp4parser" }
214214
mp4parser-muxer = { module = "org.mp4parser:muxer", version.ref = "mp4parser" }
215215

216+
# Signal-FOSS
217+
osmdroid = "org.osmdroid:osmdroid-android:6.1.20"
218+
216219
[bundles]
217220
media3 = ["androidx-media3-exoplayer", "androidx-media3-session", "androidx-media3-ui"]
218221
mp4parser = ["mp4parser-isoparser", "mp4parser-streaming", "mp4parser-muxer"]

‎gradle/verification-metadata.xml‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,52 @@ https://docs.gradle.org/current/userguide/dependency_verification.html
2020
</trusted-artifacts>
2121
</configuration>
2222
<components>
23+
<!-- Begin Signal-FOSS -->
24+
<component group="org.osmdroid" name="osmdroid-android" version="6.1.20">
25+
<artifact name="osmdroid-android-6.1.20.aar">
26+
<sha256 value="2cbec2a2a1a671a76849897748080079a3158a7a4c8554b86f2c75860f91046a" origin="Generated by Gradle"/>
27+
</artifact>
28+
</component>
29+
<component group="androidx.asynclayoutinflater" name="asynclayoutinflater" version="1.0.0">
30+
<artifact name="asynclayoutinflater-1.0.0.aar">
31+
<sha256 value="f7eab60c57addd94bb06275832fe7600611beaaae1a1ec597c231956faf96c8b" origin="Generated by Gradle"/>
32+
</artifact>
33+
</component>
34+
<component group="androidx.coordinatorlayout" name="coordinatorlayout" version="1.0.0">
35+
<artifact name="coordinatorlayout-1.0.0.aar">
36+
<sha256 value="e508c695489493374d942bf7b4ee02abf7571d25aac4c622e57d6cd5cd29eb73" origin="Generated by Gradle"/>
37+
</artifact>
38+
</component>
39+
<component group="androidx.recyclerview" name="recyclerview" version="1.0.0">
40+
<artifact name="recyclerview-1.0.0.aar">
41+
<sha256 value="06956fb1ac014027ca9d2b40469a4b42aa61b4957bb11848e1ff352701ab4548" origin="Generated by Gradle"/>
42+
</artifact>
43+
</component>
44+
<component group="androidx.transition" name="transition" version="1.4.1">
45+
<artifact name="transition-1.4.1.aar">
46+
<sha256 value="36d28d9ec33a8c64313842bce99c95736da5b27a6b3a513639050de82f075726" origin="Generated by Gradle"/>
47+
</artifact>
48+
<artifact name="transition-1.4.1.module">
49+
<sha256 value="dec13dbe9ab525bcb115b47b4f219ce262c4892859c653912f898964eccf79ae" origin="Generated by Gradle"/>
50+
</artifact>
51+
</component>
52+
<component group="androidx.window" name="window" version="1.0.0">
53+
<artifact name="window-1.0.0.aar">
54+
<sha256 value="i3212985be4127373ca4d0ea7f8b81a250ae2105e924f7940105d067a0f9ac130" origin="Generated by Gradle"/>
55+
</artifact>
56+
<artifact name="window-1.0.0.module">
57+
<sha256 value="536773d2b2d65c26ce06b8c95e0fb415f1ad25d9b87330170f508689d3ad5ffb" origin="Generated by Gradle"/>
58+
</artifact>
59+
</component>
60+
<component group="org.jetbrains.kotlinx" name="kotlinx-coroutines-android" version="1.5.2">
61+
<artifact name="kotlinx-coroutines-android-1.5.2.jar">
62+
<sha256 value="86cf9892b0bd5306a8f4d7ad8a82356f614dc7d519eb3063b0887d7c2b405928" origin="Generated by Gradle"/>
63+
</artifact>
64+
<artifact name="kotlinx-coroutines-android-1.5.2.module">
65+
<sha256 value="5b76ccbd274432887e1e7536313a808d4eb054971d5e0648064d13d27264c811" origin="Generated by Gradle"/>
66+
</artifact>
67+
</component>
68+
<!-- End Signal-FOSS -->
2369
<component group="androidx.activity" name="activity" version="1.0.0">
2470
<artifact name="activity-1.0.0.aar">
2571
<sha256 value="d1bc9842455c2e534415d88c44df4d52413b478db9093a1ba36324f705f44c3d" origin="Generated by Gradle"/>

‎lib/debuglogs-viewer/build.gradle.kts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ android {
99
buildFeatures {
1010
buildConfig = true
1111
}
12+
13+
flavorDimensions += listOf("gms")
14+
productFlavors {
15+
create("gms") {
16+
dimension = "gms"
17+
isDefault = true
18+
}
19+
20+
create("foss") {
21+
dimension = "gms"
22+
}
23+
}
1224
}
1325

1426
dependencies {
@@ -23,6 +35,6 @@ dependencies {
2335
exclude(group = "com.google.protobuf", module = "protobuf-java")
2436
}
2537

26-
api(libs.google.play.services.wallet)
38+
"gmsApi"(libs.google.play.services.wallet)
2739
api(libs.square.okhttp3)
2840
}

‎lib/donations/build.gradle.kts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ android {
1515
defaultConfig {
1616
vectorDrawables.useSupportLibrary = true
1717
}
18+
19+
flavorDimensions += listOf("gms")
20+
productFlavors {
21+
create("gms") {
22+
dimension = "gms"
23+
isDefault = true
24+
}
25+
26+
create("foss") {
27+
dimension = "gms"
28+
}
29+
}
1830
}
1931

2032
dependencies {
@@ -35,6 +47,7 @@ dependencies {
3547
}
3648
testImplementation(testFixtures(project(":lib:libsignal-service")))
3749

38-
api(libs.google.play.services.wallet)
50+
"gmsApi"(libs.google.play.services.wallet)
51+
"fossApi"(project(":lib:fakegms"))
3952
api(libs.square.okhttp3)
4053
}

‎lib/fakebilling/build.gradle.kts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
plugins {
2+
id("signal-library")
3+
}
4+
5+
android {
6+
namespace = "org.signal.billing"
7+
}
8+
9+
dependencies {
10+
lintChecks(project(":lintchecks"))
11+
12+
implementation(project(":core:util"))
13+
}

0 commit comments

Comments
 (0)