Skip to content

Commit fa158d2

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

55 files changed

Lines changed: 980 additions & 16 deletions

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
@@ -70,6 +70,8 @@ val selectableVariants = listOf(
7070
"playStagingInstrumentation",
7171
"playStagingRelease",
7272
"websiteProdSpinner",
73+
"websiteFossProdRelease",
74+
"websiteGmsProdRelease",
7375
"websiteProdRelease",
7476
"githubProdSpinner",
7577
"githubProdRelease"
@@ -102,7 +104,7 @@ android {
102104
compileSdkVersion = libs.versions.compileSdk.get()
103105
ndkVersion = libs.versions.ndk.get()
104106

105-
flavorDimensions += listOf("distribution", "environment")
107+
flavorDimensions += listOf("distribution", "gms", "environment")
106108
testBuildType = "instrumentation"
107109

108110
android.bundle.language.enableSplit = false
@@ -377,8 +379,10 @@ android {
377379
}
378380

379381
create("website") {
382+
val MAU = if (gradle.startParameter.taskRequests.toString().contains("Foss")) "false" else "true"
383+
380384
dimension = "distribution"
381-
buildConfigField("boolean", "MANAGES_APP_UPDATES", "true")
385+
buildConfigField("boolean", "MANAGES_APP_UPDATES", "${MAU}")
382386
buildConfigField("String", "APK_UPDATE_MANIFEST_URL", "\"https://updates.signal.org/android/latest.json\"")
383387
buildConfigField("String", "BUILD_DISTRIBUTION_TYPE", "\"website\"")
384388
}
@@ -399,6 +403,17 @@ android {
399403
buildConfigField("boolean", "LINK_DEVICE_UX_ENABLED", "true")
400404
}
401405

406+
create("gms") {
407+
dimension = "gms"
408+
isDefault = true
409+
buildConfigField("boolean", "USE_OSM", "false")
410+
}
411+
412+
create("foss") {
413+
dimension = "gms"
414+
buildConfigField("boolean", "USE_OSM", "true")
415+
}
416+
402417
create("prod") {
403418
dimension = "environment"
404419

@@ -583,14 +598,16 @@ dependencies {
583598
implementation(libs.androidx.asynclayoutinflater)
584599
implementation(libs.androidx.asynclayoutinflater.appcompat)
585600
implementation(libs.androidx.emoji2)
586-
implementation(libs.firebase.messaging) {
601+
"gmsImplementation"(libs.firebase.messaging) {
587602
exclude(group = "com.google.firebase", module = "firebase-core")
588603
exclude(group = "com.google.firebase", module = "firebase-analytics")
589604
exclude(group = "com.google.firebase", module = "firebase-measurement-connector")
590605
}
591-
implementation(libs.google.play.services.maps)
592-
implementation(libs.google.play.services.auth)
593-
implementation(libs.google.signin)
606+
"gmsImplementation"(libs.google.play.services.maps)
607+
"gmsImplementation"(libs.google.play.services.auth)
608+
"gmsImplementation"(libs.google.signin)
609+
"fossImplementation"(project(":lib:fakegms"))
610+
"fossImplementation"(libs.osmdroid)
594611
implementation(libs.bundles.media3)
595612
implementation(libs.conscrypt.android)
596613
implementation(libs.signal.aesgcmprovider)
@@ -628,17 +645,17 @@ dependencies {
628645
implementation(libs.accompanist.drawablepainter)
629646
implementation(libs.kotlin.stdlib.jdk8)
630647
implementation(libs.kotlin.reflect)
631-
implementation(libs.kotlinx.coroutines.play.services)
648+
"gmsImplementation"(libs.kotlinx.coroutines.play.services)
632649
implementation(libs.kotlinx.coroutines.rx3)
633650
implementation(libs.jackson.module.kotlin)
634651
implementation(libs.rxjava3.rxandroid)
635652
implementation(libs.rxjava3.rxkotlin)
636653
implementation(libs.rxdogtag)
637654
implementation(libs.androidx.credentials)
638-
implementation(libs.androidx.credentials.compat)
655+
"gmsImplementation"(libs.androidx.credentials.compat)
639656
implementation(libs.kotlinx.serialization.json)
640657

641-
implementation(project(":lib:billing"))
658+
"gmsImplementation"(project(":lib:billing"))
642659
implementation(project(":feature:media-send"))
643660

644661
"spinnerImplementation"(project(":lib:spinner"))
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.signal.billing
2+
3+
import org.signal.core.util.billing.BillingApi
4+
import org.signal.core.util.billing.BillingDependencies
5+
6+
/**
7+
* Website builds do not support google play billing.
8+
*/
9+
object BillingFactory {
10+
@JvmStatic
11+
fun create(billingDependencies: BillingDependencies, isBackupsAvailable: Boolean): BillingApi {
12+
return BillingApi.Empty
13+
}
14+
}

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.thoughtcrime.securesms.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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ gradle.projectsEvaluated {
109109

110110
// If you let all of these things run in parallel, gradle will likely OOM.
111111
// To avoid this, we put non-app tests and lints behind the much heavier app tests and lints.
112+
113+
if (appTestTask != null ) // AT - dirty hack
112114
subprojects.filter { it.name != "Signal-Android" }.forEach { subproject ->
113115
subproject.tasks.findByName("testDebugUnitTest")?.mustRunAfter(appTestTask)
114116
subproject.tasks.findByName("test")?.mustRunAfter(appTestTask)

gradle/libs.versions.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ mp4parser-streaming = { module = "org.mp4parser:streaming", version.ref = "mp4pa
211211
mp4parser-muxer = { module = "org.mp4parser:muxer", version.ref = "mp4parser" }
212212
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4", version.ref = "ui-test-junit4" }
213213

214+
# Signal-FOSS
215+
osmdroid = "org.osmdroid:osmdroid-android:6.1.20"
216+
214217
[bundles]
215218
media3 = ["androidx-media3-exoplayer", "androidx-media3-session", "androidx-media3-ui"]
216219
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
@@ -23,6 +23,52 @@ https://docs.gradle.org/current/userguide/dependency_verification.html
2323
</trusted-artifacts>
2424
</configuration>
2525
<components>
26+
<!-- Begin Signal-FOSS -->
27+
<component group="org.osmdroid" name="osmdroid-android" version="6.1.20">
28+
<artifact name="osmdroid-android-6.1.20.aar">
29+
<sha256 value="2cbec2a2a1a671a76849897748080079a3158a7a4c8554b86f2c75860f91046a" origin="Generated by Gradle"/>
30+
</artifact>
31+
</component>
32+
<component group="androidx.asynclayoutinflater" name="asynclayoutinflater" version="1.0.0">
33+
<artifact name="asynclayoutinflater-1.0.0.aar">
34+
<sha256 value="f7eab60c57addd94bb06275832fe7600611beaaae1a1ec597c231956faf96c8b" origin="Generated by Gradle"/>
35+
</artifact>
36+
</component>
37+
<component group="androidx.coordinatorlayout" name="coordinatorlayout" version="1.0.0">
38+
<artifact name="coordinatorlayout-1.0.0.aar">
39+
<sha256 value="e508c695489493374d942bf7b4ee02abf7571d25aac4c622e57d6cd5cd29eb73" origin="Generated by Gradle"/>
40+
</artifact>
41+
</component>
42+
<component group="androidx.recyclerview" name="recyclerview" version="1.0.0">
43+
<artifact name="recyclerview-1.0.0.aar">
44+
<sha256 value="06956fb1ac014027ca9d2b40469a4b42aa61b4957bb11848e1ff352701ab4548" origin="Generated by Gradle"/>
45+
</artifact>
46+
</component>
47+
<component group="androidx.transition" name="transition" version="1.4.1">
48+
<artifact name="transition-1.4.1.aar">
49+
<sha256 value="36d28d9ec33a8c64313842bce99c95736da5b27a6b3a513639050de82f075726" origin="Generated by Gradle"/>
50+
</artifact>
51+
<artifact name="transition-1.4.1.module">
52+
<sha256 value="dec13dbe9ab525bcb115b47b4f219ce262c4892859c653912f898964eccf79ae" origin="Generated by Gradle"/>
53+
</artifact>
54+
</component>
55+
<component group="androidx.window" name="window" version="1.0.0">
56+
<artifact name="window-1.0.0.aar">
57+
<sha256 value="i3212985be4127373ca4d0ea7f8b81a250ae2105e924f7940105d067a0f9ac130" origin="Generated by Gradle"/>
58+
</artifact>
59+
<artifact name="window-1.0.0.module">
60+
<sha256 value="536773d2b2d65c26ce06b8c95e0fb415f1ad25d9b87330170f508689d3ad5ffb" origin="Generated by Gradle"/>
61+
</artifact>
62+
</component>
63+
<component group="org.jetbrains.kotlinx" name="kotlinx-coroutines-android" version="1.5.2">
64+
<artifact name="kotlinx-coroutines-android-1.5.2.jar">
65+
<sha256 value="86cf9892b0bd5306a8f4d7ad8a82356f614dc7d519eb3063b0887d7c2b405928" origin="Generated by Gradle"/>
66+
</artifact>
67+
<artifact name="kotlinx-coroutines-android-1.5.2.module">
68+
<sha256 value="5b76ccbd274432887e1e7536313a808d4eb054971d5e0648064d13d27264c811" origin="Generated by Gradle"/>
69+
</artifact>
70+
</component>
71+
<!-- End Signal-FOSS -->
2672
<component group="androidx.activity" name="activity" version="1.0.0">
2773
<artifact name="activity-1.0.0.aar">
2874
<md5 value="4af531df14f0183a79461240ca647de7" 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
@@ -13,6 +13,18 @@ android {
1313
defaultConfig {
1414
vectorDrawables.useSupportLibrary = true
1515
}
16+
17+
flavorDimensions += listOf("gms")
18+
productFlavors {
19+
create("gms") {
20+
dimension = "gms"
21+
isDefault = true
22+
}
23+
24+
create("foss") {
25+
dimension = "gms"
26+
}
27+
}
1628
}
1729

1830
dependencies {
@@ -26,6 +38,7 @@ dependencies {
2638
exclude(group = "com.google.protobuf", module = "protobuf-java")
2739
}
2840

29-
api(libs.google.play.services.wallet)
41+
"gmsApi"(libs.google.play.services.wallet)
42+
"fossApi"(project(":lib:fakegms"))
3043
api(libs.square.okhttp3)
3144
}

lib/fakegms/build.gradle.kts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
plugins {
2+
id("signal-library")
3+
}
4+
5+
android {
6+
namespace = "com.google.android.gms"
7+
}
8+
9+
dependencies {
10+
implementation(libs.androidx.preference)
11+
implementation(libs.osmdroid)
12+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />

0 commit comments

Comments
 (0)