Skip to content
This repository was archived by the owner on Sep 23, 2024. It is now read-only.

Commit d9256bb

Browse files
tw-hxpixincreate
authored andcommitted
Stub out Google Mobile Services and Firebase with Open Source library, new build flavor 'gms' to use it
1 parent b435a68 commit d9256bb

Some content is hidden

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

52 files changed

+942
-11
lines changed

app/build.gradle.kts

+20-5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ val selectableVariants = listOf(
4040
"playProdBenchmark",
4141
"playProdInstrumentation",
4242
"playProdRelease",
43+
"playFossProdRelease",
44+
"playGmsProdRelease",
4345
"playStagingDebug",
4446
"playStagingCanary",
4547
"playStagingSpinner",
@@ -81,7 +83,7 @@ android {
8183
buildToolsVersion = signalBuildToolsVersion
8284
compileSdkVersion = signalCompileSdkVersion
8385

84-
flavorDimensions += listOf("distribution", "environment")
86+
flavorDimensions += listOf("distribution", "gms", "environment")
8587
useLibrary("org.apache.http.legacy")
8688
testBuildType = "instrumentation"
8789

@@ -352,6 +354,17 @@ android {
352354
buildConfigField("String", "BUILD_DISTRIBUTION_TYPE", "\"nightly\"")
353355
}
354356

357+
create("gms") {
358+
dimension = "gms"
359+
isDefault = true
360+
buildConfigField("boolean", "USE_OSM", "false")
361+
}
362+
363+
create("foss") {
364+
dimension = "gms"
365+
buildConfigField("boolean", "USE_OSM", "true")
366+
}
367+
355368
create("prod") {
356369
dimension = "environment"
357370

@@ -507,13 +520,15 @@ dependencies {
507520
implementation(libs.androidx.asynclayoutinflater)
508521
implementation(libs.androidx.asynclayoutinflater.appcompat)
509522
implementation(libs.androidx.emoji2)
510-
implementation(libs.firebase.messaging) {
523+
"gmsImplementation"(libs.firebase.messaging) {
511524
exclude(group = "com.google.firebase", module = "firebase-core")
512525
exclude(group = "com.google.firebase", module = "firebase-analytics")
513526
exclude(group = "com.google.firebase", module = "firebase-measurement-connector")
514527
}
515-
implementation(libs.google.play.services.maps)
516-
implementation(libs.google.play.services.auth)
528+
"gmsImplementation"(libs.google.play.services.maps)
529+
"gmsImplementation"(libs.google.play.services.auth)
530+
"fossImplementation"(project(":libfakegms"))
531+
"fossImplementation"(libs.osmdroid)
517532
implementation(libs.bundles.media3)
518533
implementation(libs.conscrypt.android)
519534
implementation(libs.signal.aesgcmprovider)
@@ -550,7 +565,7 @@ dependencies {
550565
implementation(libs.accompanist.permissions)
551566
implementation(libs.kotlin.stdlib.jdk8)
552567
implementation(libs.kotlin.reflect)
553-
implementation(libs.kotlinx.coroutines.play.services)
568+
"gmsImplementation"(libs.kotlinx.coroutines.play.services)
554569
implementation(libs.jackson.module.kotlin)
555570
implementation(libs.rxjava3.rxandroid)
556571
implementation(libs.rxjava3.rxkotlin)

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

+18-5
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
}

dependencies.gradle.kts

+3
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ dependencyResolutionManagement {
158158
// Can"t use the newest version because it hits some weird NoClassDefFoundException
159159
library("jknack-handlebars", "com.github.jknack:handlebars:4.0.7")
160160

161+
// Signal-FOSS
162+
library("osmdroid", "org.osmdroid:osmdroid-android:6.1.18")
163+
161164
// Mp4Parser
162165
library("mp4parser-isoparser", "org.mp4parser", "isoparser").versionRef("mp4parser")
163166
library("mp4parser-streaming", "org.mp4parser", "streaming").versionRef("mp4parser")

donations/lib/build.gradle.kts

+14-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ plugins {
55

66
android {
77
namespace = "org.signal.donations"
8+
9+
flavorDimensions += listOf("gms")
10+
productFlavors {
11+
create("gms") {
12+
dimension = "gms"
13+
isDefault = true
14+
}
15+
16+
create("foss") {
17+
dimension = "gms"
18+
}
19+
}
820
}
921

1022
dependencies {
@@ -18,6 +30,7 @@ dependencies {
1830
exclude(group = "com.google.protobuf", module = "protobuf-java")
1931
}
2032

21-
api(libs.google.play.services.wallet)
33+
"gmsApi"(libs.google.play.services.wallet)
34+
"fossApi"(project(":libfakegms"))
2235
api(libs.square.okhttp3)
2336
}

gradle/verification-metadata.xml

+46
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,51 @@ https://docs.gradle.org/current/userguide/dependency_verification.html
2020
</trusted-artifacts>
2121
</configuration>
2222
<components>
23+
<!-- Begin Signal-FOSS -->
24+
<component group="androidx.annotation" name="annotation" version="1.2.0">
25+
<artifact name="annotation-1.2.0.jar">
26+
<sha256 value="9029262bddce116e6d02be499e4afdba21f24c239087b76b3b57d7e98b490a36" origin="Generated by Gradle"/>
27+
</artifact>
28+
<artifact name="annotation-1.2.0.module">
29+
<sha256 value="2efcab81ef91b211bacd206eaacd995a51f633a2e96b57a8fc00144c5f9c56b3" origin="Generated by Gradle"/>
30+
</artifact>
31+
</component>
32+
<component group="androidx.appcompat" name="appcompat" version="1.0.0">
33+
<artifact name="appcompat-1.0.0.aar">
34+
<sha256 value="994254e12036cbd3326b2819a4d8bc3bef139f45022cfb0b1086dc58d36d56ce" 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.slidingpanelayout" name="slidingpanelayout" version="1.0.0">
48+
<artifact name="slidingpanelayout-1.0.0.aar">
49+
<sha256 value="76bffb7cefbf780794d8817002dad1562f3e27c0a9f746d62401c8edb30aeede" origin="Generated by Gradle"/>
50+
</artifact>
51+
</component>
52+
<component group="androidx.vectordrawable" name="vectordrawable" version="1.0.0">
53+
<artifact name="vectordrawable-1.0.0.aar">
54+
<sha256 value="507591926583875e3a0e6c46272235f323b4574759b5c02f0ab7a51d2ae7320d" origin="Generated by Gradle"/>
55+
</artifact>
56+
</component>
57+
<component group="androidx.vectordrawable" name="vectordrawable-animated" version="1.0.0">
58+
<artifact name="vectordrawable-animated-1.0.0.aar">
59+
<sha256 value="26c3a0cf0a9a9a7d235a0b00f2f37e431d52d9952751e3eb7c90b4b52c236cf1" origin="Generated by Gradle"/>
60+
</artifact>
61+
</component>
62+
<component group="org.osmdroid" name="osmdroid-android" version="6.1.18">
63+
<artifact name="osmdroid-android-6.1.18.aar">
64+
<sha256 value="b78f833b640866305a7e562498cd1195c6ecd566797e27e03c551cad5a3d07a5" origin="Generated by Gradle"/>
65+
</artifact>
66+
</component>
67+
<!-- End Signal-FOSS -->
2368
<component group="androidx.activity" name="activity" version="1.5.1">
2469
<artifact name="activity-1.5.1.module">
2570
<sha256 value="c4317fb95ce2716b88f1f4a5334795efda084097a3f2447ffccb10a412c85be4" origin="Generated by Gradle"/>
@@ -8408,3 +8453,4 @@ https://docs.gradle.org/current/userguide/dependency_verification.html
84088453
</component>
84098454
</components>
84108455
</verification-metadata>
8456+

libfakegms/build.gradle.kts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
3+
plugins {
4+
id("signal-library")
5+
}
6+
7+
android {
8+
namespace = "com.google.android.gms"
9+
}
10+
11+
dependencies {
12+
implementation(libs.androidx.preference)
13+
implementation(libs.osmdroid)
14+
}
+2
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" />

libfakegms/src/main/java/COPYRIGHT

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Licensed under GNU GENERAL PUBLIC LICENSE 3.0
2+
3+
Files under com/google/android (c) 2020 Angus Turnbull https://www.twinhelix.com/
4+
Files com/google/android/gms/maps/{GoogleMap.java,MapView.java,SupportMapFragment.java} (c) Fumiaki Yoshimatsu https://github.com/fumiakiy/Signal-Android/tree/fumiakiy/share-location-osm
5+
Files under com/google/firebase (c) Oscar Mira / valldrac https://github.com/mollyim/mollyim-android/tree/master/libfakegms/src/main/java/com/google/firebase
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.google.android.gms.auth.api.phone;
2+
3+
import android.content.Context;
4+
5+
public final class SmsRetriever {
6+
public static final String EXTRA_SMS_MESSAGE = "com.google.android.gms.auth.api.phone.EXTRA_SMS_MESSAGE";
7+
public static final String EXTRA_STATUS = "com.google.android.gms.auth.api.phone.EXTRA_STATUS";
8+
public static final String SMS_RETRIEVED_ACTION = "com.google.android.gms.auth.api.phone.SMS_RETRIEVED";
9+
10+
public static SmsRetrieverClient getClient(Context context) {
11+
return new SmsRetrieverClient();
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.google.android.gms.auth.api.phone;
2+
3+
import com.google.android.gms.tasks.Task;
4+
5+
public final class SmsRetrieverClient {
6+
public Task startSmsRetriever() {
7+
return new Task();
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.google.android.gms.common;
2+
3+
public class ConnectionResult {
4+
public static final int SUCCESS = 0;
5+
public static final int SERVICE_MISSING = 1;
6+
public static final int SERVICE_VERSION_UPDATE_REQUIRED = 2;
7+
public static final int SERVICE_DISABLED = 3;
8+
public static final int SERVICE_INVALID = 9;
9+
public static final int API_UNAVAILABLE = 16;
10+
public static final int SERVICE_MISSING_PERMISSION = 19;
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.google.android.gms.common;
2+
3+
import android.app.Activity;
4+
import android.app.Dialog;
5+
import android.content.Context;
6+
7+
public class GoogleApiAvailability {
8+
public static GoogleApiAvailability getInstance() {
9+
return new GoogleApiAvailability();
10+
}
11+
12+
public int isGooglePlayServicesAvailable(Context context) {
13+
return ConnectionResult.SERVICE_MISSING;
14+
}
15+
16+
public Dialog getErrorDialog(Activity activity, int errorCode, int requestCode) {
17+
return null;
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.google.android.gms.common.api;
2+
3+
public class ApiException extends Exception {
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.google.android.gms.common.api;
2+
3+
public class CommonStatusCodes {
4+
public static final int ERROR = 12;
5+
public static final int SUCCESS = 0;
6+
public static final int TIMEOUT = 15;
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.google.android.gms.common.api;
2+
3+
public final class Status {
4+
public Status(int statusCode) {
5+
}
6+
7+
public int getStatusCode() {
8+
return CommonStatusCodes.ERROR;
9+
}
10+
11+
public String getStatusMessage() {
12+
return new String();
13+
}
14+
15+
public static final int RESULT_SUCCESS = 0;
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.google.android.gms.maps;
2+
3+
import com.google.android.gms.maps.model.LatLng;
4+
5+
public final class CameraUpdate {
6+
public final LatLng latLng;
7+
public final float zoom;
8+
9+
public CameraUpdate(LatLng latLng, float zoom) {
10+
this.latLng = latLng;
11+
this.zoom = zoom;
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.google.android.gms.maps;
2+
3+
import com.google.android.gms.maps.model.LatLng;
4+
5+
public final class CameraUpdateFactory {
6+
public static CameraUpdate newLatLngZoom(LatLng latLng, float zoom) {
7+
return new CameraUpdate(latLng, zoom);
8+
}
9+
}

0 commit comments

Comments
 (0)