Skip to content

Commit 4b427e1

Browse files
committed
switch from grpc-netty to grpc-okhttp
1 parent d9fb9b9 commit 4b427e1

File tree

4 files changed

+23
-34
lines changed

4 files changed

+23
-34
lines changed

build.gradle.kts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,11 @@ dependencies {
165165
implementation("com.squareup.okhttp:okhttp:2.7.5")
166166
implementation("com.squareup.okhttp3:okhttp:4.9.3")
167167
implementation("android.arch.lifecycle:common:1.1.1")
168-
implementation("io.grpc:grpc-protobuf-lite:1.44.1")
169-
implementation("io.grpc:grpc-stub:1.44.1")
168+
implementation("io.grpc:grpc-protobuf-lite:1.52.1")
169+
implementation("io.grpc:grpc-stub:1.52.1")
170170
implementation("androidx.collection:collection:1.2.0")
171171
implementation("androidx.lifecycle:lifecycle-common:2.4.0")
172-
// gprc https://github.com/grpc/grpc-java/blob/master/SECURITY.md
173-
implementation("io.grpc:grpc-netty:1.44.1")
174-
implementation("io.netty:netty-tcnative-boringssl-static:2.0.51.Final")
172+
implementation("io.grpc:grpc-okhttp:1.52.1")
175173
}
176174

177175
tasks.named("publishToMavenLocal").configure {

src/main/java/android/net/Uri.kt

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package android.net
22

3-
import io.netty.handler.codec.http.QueryStringDecoder
43
import java.net.URI
4+
import java.util.*
55

66
class Uri(private val uri: URI) {
77

@@ -10,12 +10,25 @@ class Uri(private val uri: URI) {
1010
fun parse(uriString: String) = Uri(URI.create(uriString))
1111
}
1212

13-
private val parameters by lazy {
14-
QueryStringDecoder(uri).parameters()
15-
}
16-
1713
val scheme get() = uri.scheme
1814
val port get() = uri.port
1915
val host get() = uri.host
20-
fun getQueryParameter(name: String) = parameters[name]?.first()
21-
}
16+
17+
fun getQueryParameterNames(): Set<String> {
18+
val query: String = uri.query ?: return emptySet()
19+
val names: MutableSet<String> = LinkedHashSet()
20+
var start = 0
21+
do {
22+
val next = query.indexOf('&', start)
23+
val end = if ((next == -1)) query.length else next
24+
var separator = query.indexOf('=', start)
25+
if (separator > end || separator == -1) {
26+
separator = end
27+
}
28+
val name = query.substring(start, separator)
29+
names.add(name)
30+
// Move start to end of name.
31+
start = end + 1
32+
} while (start < query.length)
33+
return Collections.unmodifiableSet(names)
34+
}}

src/main/java/com/google/firebase/FirebasePlatform.kt

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
package com.google.firebase
22

3-
import com.google.firebase.firestore.FirebaseFirestore
4-
import com.google.firebase.firestore.remote.GrpcCallProvider
5-
import com.google.firebase.firestore.util.Supplier
6-
import io.grpc.ManagedChannelBuilder
7-
import io.grpc.netty.NettyChannelBuilder
8-
93
abstract class FirebasePlatform {
104

115
companion object {
@@ -16,18 +10,6 @@ abstract class FirebasePlatform {
1610
firebasePlatform = platform
1711
// prevent coroutines from thinking its on android
1812
System.setProperty("kotlinx.coroutines.fast.service.loader", "false")
19-
20-
GrpcCallProvider::class.java
21-
.getDeclaredField("overrideChannelBuilderSupplier")
22-
.apply { trySetAccessible() }
23-
.set(
24-
null,
25-
object : Supplier<ManagedChannelBuilder<*>> {
26-
override fun get(): ManagedChannelBuilder<*> = FirebaseFirestore.getInstance(FirebaseApp.INSTANCES.values.first()).firestoreSettings.run {
27-
NettyChannelBuilder.forTarget(host).also { it.takeUnless { isSslEnabled }?.usePlaintext() }
28-
}
29-
}
30-
)
3113
}
3214
}
3315

src/main/java/io/grpc/okhttp/OkHttpChannelBuilder.java

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)