Skip to content

Commit cf17395

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

57 files changed

Lines changed: 1024 additions & 19 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
@@ -50,6 +50,8 @@ val selectableVariants = listOf(
5050
"playStagingInstrumentation",
5151
"playStagingRelease",
5252
"websiteProdSpinner",
53+
"websiteFossProdRelease",
54+
"websiteGmsProdRelease",
5355
"websiteProdRelease"
5456
)
5557

@@ -88,7 +90,7 @@ android {
8890
compileSdkVersion = signalCompileSdkVersion
8991
ndkVersion = signalNdkVersion
9092

91-
flavorDimensions += listOf("distribution", "environment")
93+
flavorDimensions += listOf("distribution", "gms", "environment")
9294
testBuildType = "instrumentation"
9395

9496
android.bundle.language.enableSplit = false
@@ -360,8 +362,10 @@ android {
360362
}
361363

362364
create("website") {
365+
val MAU = if (gradle.startParameter.taskRequests.toString().contains("Foss")) "false" else "true"
366+
363367
dimension = "distribution"
364-
buildConfigField("boolean", "MANAGES_APP_UPDATES", "true")
368+
buildConfigField("boolean", "MANAGES_APP_UPDATES", "${MAU}")
365369
buildConfigField("String", "APK_UPDATE_MANIFEST_URL", "\"https://updates.signal.org/android/latest.json\"")
366370
buildConfigField("String", "BUILD_DISTRIBUTION_TYPE", "\"website\"")
367371
}
@@ -381,6 +385,17 @@ android {
381385
buildConfigField("boolean", "LINK_DEVICE_UX_ENABLED", "true")
382386
}
383387

388+
create("gms") {
389+
dimension = "gms"
390+
isDefault = true
391+
buildConfigField("boolean", "USE_OSM", "false")
392+
}
393+
394+
create("foss") {
395+
dimension = "gms"
396+
buildConfigField("boolean", "USE_OSM", "true")
397+
}
398+
384399
create("prod") {
385400
dimension = "environment"
386401

@@ -551,14 +566,16 @@ dependencies {
551566
implementation(libs.androidx.asynclayoutinflater)
552567
implementation(libs.androidx.asynclayoutinflater.appcompat)
553568
implementation(libs.androidx.emoji2)
554-
implementation(libs.firebase.messaging) {
569+
"gmsImplementation"(libs.firebase.messaging) {
555570
exclude(group = "com.google.firebase", module = "firebase-core")
556571
exclude(group = "com.google.firebase", module = "firebase-analytics")
557572
exclude(group = "com.google.firebase", module = "firebase-measurement-connector")
558573
}
559-
implementation(libs.google.play.services.maps)
560-
implementation(libs.google.play.services.auth)
561-
implementation(libs.google.signin)
574+
"gmsImplementation"(libs.google.play.services.maps)
575+
"gmsImplementation"(libs.google.play.services.auth)
576+
"gmsImplementation"(libs.google.signin)
577+
"fossImplementation"(project(":libfakegms"))
578+
"fossImplementation"(libs.osmdroid)
562579
implementation(libs.bundles.media3)
563580
implementation(libs.conscrypt.android)
564581
implementation(libs.signal.aesgcmprovider)
@@ -596,17 +613,17 @@ dependencies {
596613
implementation(libs.accompanist.drawablepainter)
597614
implementation(libs.kotlin.stdlib.jdk8)
598615
implementation(libs.kotlin.reflect)
599-
implementation(libs.kotlinx.coroutines.play.services)
616+
"gmsImplementation"(libs.kotlinx.coroutines.play.services)
600617
implementation(libs.kotlinx.coroutines.rx3)
601618
implementation(libs.jackson.module.kotlin)
602619
implementation(libs.rxjava3.rxandroid)
603620
implementation(libs.rxjava3.rxkotlin)
604621
implementation(libs.rxdogtag)
605622
implementation(libs.androidx.credentials)
606-
implementation(libs.androidx.credentials.compat)
623+
"gmsImplementation"(libs.androidx.credentials.compat)
607624
implementation(libs.kotlinx.serialization.json)
608625

609-
implementation(project(":billing"))
626+
"gmsImplementation"(project(":billing"))
610627

611628
"spinnerImplementation"(project(":spinner"))
612629

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
}

app/src/main/java/org/thoughtcrime/securesms/components/settings/app/chats/ChatsSettingsState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ data class ChatsSettingsState(
1212
val clientDeprecated: Boolean
1313
// JW: added extra preferences
1414
,
15-
val keepViewOnceMessages: Boolean,
1615
val keepExpiringMessages: Boolean,
16+
val keepViewOnceMessages: Boolean,
1717
val ignoreRemoteDelete: Boolean,
1818
val deleteMediaOnly: Boolean
1919
) {

app/src/main/java/org/thoughtcrime/securesms/components/settings/app/chats/ChatsSettingsViewModel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ class ChatsSettingsViewModel @JvmOverloads constructor(
3232
folderCount = 0,
3333
userUnregistered = TextSecurePreferences.isUnauthorizedReceived(AppDependencies.application) || !SignalStore.account.isRegistered,
3434
clientDeprecated = SignalStore.misc.isClientDeprecated
35-
// AT: added
35+
// AT+JW: added
3636
,
37-
keepViewOnceMessages = SignalStore.settings.isKeepViewOnceMessages,
3837
keepExpiringMessages = SignalStore.settings.isKeepExpiringMessages,
38+
keepViewOnceMessages = SignalStore.settings.isKeepViewOnceMessages,
3939
ignoreRemoteDelete = SignalStore.settings.isIgnoreRemoteDelete,
4040
deleteMediaOnly = SignalStore.settings.isDeleteMediaOnly
4141
)

app/src/main/java/org/thoughtcrime/securesms/keyvalue/SettingsValues.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ public final class SettingsValues extends SignalStoreValues {
7878
public static final int BACKUP_DEFAULT_HOUR = 2;
7979
public static final int BACKUP_DEFAULT_MINUTE = 0;
8080

81+
// AT: added -------
82+
public static final String KEEP_EXPIRING_MESSAGES = "settings.keep.expiring.messages";
83+
public static final String KEEP_VIEW_ONCE_MESSAGES = "settings.keep.view.once.messages";
84+
public static final String IGNORE_REMOTE_DELETE = "settings.ignore.remote.delete";
85+
public static final String DELETE_MEDIA_ONLY = "settings.delete.media.only";
86+
// AT: end added ---
87+
8188
private final SingleLiveEvent<String> onConfigurationSettingChanged = new SingleLiveEvent<>();
8289

8390
SettingsValues(@NonNull KeyValueStore store, Context context) {
@@ -354,6 +361,42 @@ public void setSignalBackupSchedule(int hour, int minute) {
354361
putInteger(SIGNAL_BACKUPS_SCHEDULE_MINUTE, minute);
355362
}
356363

364+
// AT: added ------
365+
366+
public boolean isKeepExpiringMessages() {
367+
return getBoolean(KEEP_EXPIRING_MESSAGES, false);
368+
}
369+
370+
public void setKeepExpiringMessages(boolean keepExpiringMessages) {
371+
putBoolean(KEEP_EXPIRING_MESSAGES, keepExpiringMessages);
372+
}
373+
374+
public boolean isKeepViewOnceMessages() {
375+
return getBoolean(KEEP_VIEW_ONCE_MESSAGES, false);
376+
}
377+
378+
public void setKeepViewOnceMessages(boolean keepViewOnceMessages) {
379+
putBoolean(KEEP_VIEW_ONCE_MESSAGES, keepViewOnceMessages);
380+
}
381+
382+
public boolean isIgnoreRemoteDelete() {
383+
return getBoolean(IGNORE_REMOTE_DELETE, false);
384+
}
385+
386+
public void setIgnoreRemoteDelete(boolean ignoreRemoteDelete) {
387+
putBoolean(IGNORE_REMOTE_DELETE, ignoreRemoteDelete);
388+
}
389+
390+
public boolean isDeleteMediaOnly() {
391+
return getBoolean(DELETE_MEDIA_ONLY, false);
392+
}
393+
394+
public void setDeleteMediaOnly(boolean deleteMediaOnly) {
395+
putBoolean(DELETE_MEDIA_ONLY, deleteMediaOnly);
396+
}
397+
398+
// AT: end added ---
399+
357400
public boolean isSmsDeliveryReportsEnabled() {
358401
return getBoolean(SMS_DELIVERY_REPORTS_ENABLED, TextSecurePreferences.isSmsDeliveryReportsEnabled(AppDependencies.getApplication()));
359402
}

debuglogs-viewer/lib/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
}

donations/lib/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(":libfakegms"))
3043
api(libs.square.okhttp3)
3144
}

gradle/libs.versions.toml

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

191+
# Signal-FOSS
192+
osmdroid = "org.osmdroid:osmdroid-android:6.1.20"
193+
191194
[bundles]
192195
media3 = ["androidx-media3-exoplayer", "androidx-media3-session", "androidx-media3-ui"]
193196
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"/>

0 commit comments

Comments
 (0)