Skip to content

Commit a6a9f94

Browse files
committed
2 parents cdef03b + 95d16d8 commit a6a9f94

File tree

61 files changed

+1402
-181
lines changed

Some content is hidden

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

61 files changed

+1402
-181
lines changed

MODULE.bazel

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ module(
22
name = "grpc-java",
33
compatibility_level = 0,
44
repo_name = "io_grpc_grpc_java",
5-
version = "1.75.0-SNAPSHOT", # CURRENT_GRPC_VERSION
5+
version = "1.76.0-SNAPSHOT", # CURRENT_GRPC_VERSION
66
)
77

88
# GRPC_DEPS_START
99
IO_GRPC_GRPC_JAVA_ARTIFACTS = [
1010
"com.google.android:annotations:4.1.1.4",
11-
"com.google.api.grpc:proto-google-common-protos:2.51.0",
11+
"com.google.api.grpc:proto-google-common-protos:2.59.2",
1212
"com.google.auth:google-auth-library-credentials:1.24.1",
1313
"com.google.auth:google-auth-library-oauth2-http:1.24.1",
1414
"com.google.auto.value:auto-value-annotations:1.11.0",
@@ -19,24 +19,24 @@ IO_GRPC_GRPC_JAVA_ARTIFACTS = [
1919
"com.google.guava:failureaccess:1.0.1",
2020
"com.google.guava:guava:33.3.1-android",
2121
"com.google.re2j:re2j:1.8",
22-
"com.google.s2a.proto.v2:s2a-proto:0.1.1",
22+
"com.google.s2a.proto.v2:s2a-proto:0.1.2",
2323
"com.google.truth:truth:1.4.2",
2424
"com.squareup.okhttp:okhttp:2.7.5",
2525
"com.squareup.okio:okio:2.10.0", # 3.0+ needs swapping to -jvm; need work to avoid flag-day
26-
"io.netty:netty-buffer:4.1.110.Final",
27-
"io.netty:netty-codec-http2:4.1.110.Final",
28-
"io.netty:netty-codec-http:4.1.110.Final",
29-
"io.netty:netty-codec-socks:4.1.110.Final",
30-
"io.netty:netty-codec:4.1.110.Final",
31-
"io.netty:netty-common:4.1.110.Final",
32-
"io.netty:netty-handler-proxy:4.1.110.Final",
33-
"io.netty:netty-handler:4.1.110.Final",
34-
"io.netty:netty-resolver:4.1.110.Final",
26+
"io.netty:netty-buffer:4.1.124.Final",
27+
"io.netty:netty-codec-http2:4.1.124.Final",
28+
"io.netty:netty-codec-http:4.1.124.Final",
29+
"io.netty:netty-codec-socks:4.1.124.Final",
30+
"io.netty:netty-codec:4.1.124.Final",
31+
"io.netty:netty-common:4.1.124.Final",
32+
"io.netty:netty-handler-proxy:4.1.124.Final",
33+
"io.netty:netty-handler:4.1.124.Final",
34+
"io.netty:netty-resolver:4.1.124.Final",
3535
"io.netty:netty-tcnative-boringssl-static:2.0.70.Final",
3636
"io.netty:netty-tcnative-classes:2.0.70.Final",
37-
"io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.110.Final",
38-
"io.netty:netty-transport-native-unix-common:4.1.110.Final",
39-
"io.netty:netty-transport:4.1.110.Final",
37+
"io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.124.Final",
38+
"io.netty:netty-transport-native-unix-common:4.1.124.Final",
39+
"io.netty:netty-transport:4.1.124.Final",
4040
"io.opencensus:opencensus-api:0.31.0",
4141
"io.opencensus:opencensus-contrib-grpc-metrics:0.31.0",
4242
"io.perfmark:perfmark-api:0.27.0",
@@ -50,7 +50,8 @@ bazel_dep(name = "bazel_jar_jar", version = "0.1.7")
5050
bazel_dep(name = "bazel_skylib", version = "1.7.1")
5151
bazel_dep(name = "googleapis", repo_name = "com_google_googleapis", version = "0.0.0-20240326-1c8d509c5")
5252
bazel_dep(name = "grpc-proto", repo_name = "io_grpc_grpc_proto", version = "0.0.0-20240627-ec30f58")
53-
bazel_dep(name = "protobuf", repo_name = "com_google_protobuf", version = "23.1")
53+
# Protobuf 25.5+ is incompatible with Bazel 7 with bzlmod
54+
bazel_dep(name = "protobuf", repo_name = "com_google_protobuf", version = "24.4")
5455
bazel_dep(name = "rules_cc", version = "0.0.9")
5556
bazel_dep(name = "rules_java", version = "5.3.5")
5657
bazel_dep(name = "rules_jvm_external", version = "6.0")

SECURITY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ grpc-netty version | netty-handler version | netty-tcnative-boringssl-static ver
400400
1.59.x | 4.1.97.Final | 2.0.61.Final
401401
1.60.x-1.66.x | 4.1.100.Final | 2.0.61.Final
402402
1.67.x-1.70.x | 4.1.110.Final | 2.0.65.Final
403-
1.71.x- | 4.1.110.Final | 2.0.70.Final
403+
1.71.x-1.74.x | 4.1.110.Final | 2.0.70.Final
404+
1.75.x- | 4.1.124.Final | 2.0.72.Final
404405

405406
_(grpc-netty-shaded avoids issues with keeping these versions in sync.)_
406407

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ android {
1414
}
1515
compileSdkVersion 34
1616
defaultConfig {
17-
minSdkVersion 21
17+
minSdkVersion 22
1818
targetSdkVersion 33
1919
versionCode 1
2020
versionName "1.0"

android/src/main/java/io/grpc/android/AndroidChannelBuilder.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ private void configureNetworkMonitoring() {
217217
connectivityManager.registerDefaultNetworkCallback(defaultNetworkCallback);
218218
unregisterRunnable =
219219
new Runnable() {
220-
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
221220
@Override
222221
public void run() {
223222
connectivityManager.unregisterNetworkCallback(defaultNetworkCallback);
@@ -231,7 +230,6 @@ public void run() {
231230
context.registerReceiver(networkReceiver, networkIntentFilter);
232231
unregisterRunnable =
233232
new Runnable() {
234-
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
235233
@Override
236234
public void run() {
237235
context.unregisterReceiver(networkReceiver);

api/src/main/java/io/grpc/NameResolverRegistry.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ static List<Class<?>> getHardCodedClasses() {
166166
} catch (ClassNotFoundException e) {
167167
logger.log(Level.FINE, "Unable to find DNS NameResolver", e);
168168
}
169+
try {
170+
list.add(Class.forName("io.grpc.binder.internal.IntentNameResolverProvider"));
171+
} catch (ClassNotFoundException e) {
172+
logger.log(Level.FINE, "Unable to find IntentNameResolverProvider", e);
173+
}
169174
return Collections.unmodifiableList(list);
170175
}
171176

binder/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ android {
1313
targetCompatibility 1.8
1414
}
1515
defaultConfig {
16-
minSdkVersion 21
16+
minSdkVersion 22
1717
targetSdkVersion 33
1818
versionCode 1
1919
versionName "1.0"

binder/src/androidTest/AndroidManifest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
<service android:name="io.grpc.binder.HostServices$HostService1" android:exported="false">
1212
<intent-filter>
1313
<action android:name="action1"/>
14+
<data android:scheme="scheme" android:host="authority" android:path="/path"/>
1415
</intent-filter>
1516
</service>
1617
<service android:name="io.grpc.binder.HostServices$HostService2" android:exported="false">
1718
<intent-filter>
1819
<action android:name="action2"/>
20+
<data android:scheme="scheme" android:host="authority" android:path="/path"/>
1921
</intent-filter>
2022
</service>
2123
</application>

binder/src/androidTest/java/io/grpc/binder/BinderChannelSmokeTest.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import android.content.Context;
2525
import android.content.Intent;
26+
import android.net.Uri;
2627
import android.os.Parcel;
2728
import android.os.Parcelable;
2829
import androidx.test.core.app.ApplicationProvider;
@@ -39,7 +40,6 @@
3940
import io.grpc.ManagedChannel;
4041
import io.grpc.Metadata;
4142
import io.grpc.MethodDescriptor;
42-
import io.grpc.NameResolverRegistry;
4343
import io.grpc.ServerCall;
4444
import io.grpc.ServerCall.Listener;
4545
import io.grpc.ServerCallHandler;
@@ -49,7 +49,6 @@
4949
import io.grpc.Status.Code;
5050
import io.grpc.StatusRuntimeException;
5151
import io.grpc.internal.GrpcUtil;
52-
import io.grpc.internal.testing.FakeNameResolverProvider;
5352
import io.grpc.stub.ClientCalls;
5453
import io.grpc.stub.MetadataUtils;
5554
import io.grpc.stub.ServerCalls;
@@ -77,7 +76,6 @@ public final class BinderChannelSmokeTest {
7776

7877
private static final int SLIGHTLY_MORE_THAN_ONE_BLOCK = 16 * 1024 + 100;
7978
private static final String MSG = "Some text which will be repeated many many times";
80-
private static final String SERVER_TARGET_URI = "fake://server";
8179
private static final Metadata.Key<PoisonParcelable> POISON_KEY =
8280
ParcelableUtils.metadataKey("poison-bin", PoisonParcelable.CREATOR);
8381

@@ -99,7 +97,6 @@ public final class BinderChannelSmokeTest {
9997
.setType(MethodDescriptor.MethodType.BIDI_STREAMING)
10098
.build();
10199

102-
FakeNameResolverProvider fakeNameResolverProvider;
103100
ManagedChannel channel;
104101
AtomicReference<Metadata> headersCapture = new AtomicReference<>();
105102
AtomicReference<PeerUid> clientUidCapture = new AtomicReference<>();
@@ -138,8 +135,6 @@ public void setUp() throws Exception {
138135
PeerUids.newPeerIdentifyingServerInterceptor());
139136

140137
AndroidComponentAddress serverAddress = HostServices.allocateService(appContext);
141-
fakeNameResolverProvider = new FakeNameResolverProvider(SERVER_TARGET_URI, serverAddress);
142-
NameResolverRegistry.getDefaultRegistry().register(fakeNameResolverProvider);
143138
HostServices.configureService(
144139
serverAddress,
145140
HostServices.serviceParamsBuilder()
@@ -166,7 +161,6 @@ public void setUp() throws Exception {
166161
@After
167162
public void tearDown() throws Exception {
168163
channel.shutdownNow();
169-
NameResolverRegistry.getDefaultRegistry().deregister(fakeNameResolverProvider);
170164
HostServices.awaitServiceShutdown();
171165
}
172166

@@ -235,7 +229,11 @@ public void testStreamingCallOptionHeaders() throws Exception {
235229

236230
@Test
237231
public void testConnectViaTargetUri() throws Exception {
238-
channel = BinderChannelBuilder.forTarget(SERVER_TARGET_URI, appContext).build();
232+
// Compare with the <intent-filter> mapping in AndroidManifest.xml.
233+
channel =
234+
BinderChannelBuilder.forTarget(
235+
"intent://authority/path#Intent;action=action1;scheme=scheme;end;", appContext)
236+
.build();
239237
assertThat(doCall("Hello").get()).isEqualTo("Hello");
240238
}
241239

@@ -245,7 +243,10 @@ public void testConnectViaIntentFilter() throws Exception {
245243
channel =
246244
BinderChannelBuilder.forAddress(
247245
AndroidComponentAddress.forBindIntent(
248-
new Intent().setAction("action1").setPackage(appContext.getPackageName())),
246+
new Intent()
247+
.setAction("action1")
248+
.setData(Uri.parse("scheme://authority/path"))
249+
.setPackage(appContext.getPackageName())),
249250
appContext)
250251
.build();
251252
assertThat(doCall("Hello").get()).isEqualTo("Hello");

binder/src/main/java/io/grpc/binder/ApiConstants.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ private ApiConstants() {}
3434
*/
3535
public static final String ACTION_BIND = "grpc.io.action.BIND";
3636

37+
/**
38+
* Gives a {@link NameResolver} access to its Channel's "source" {@link android.content.Context},
39+
* the entry point to almost every other Android API.
40+
*
41+
* <p>This argument is set automatically by {@link BinderChannelBuilder}. Any value passed to
42+
* {@link io.grpc.ManagedChannelBuilder#setNameResolverArg} will be ignored.
43+
*
44+
* <p>See {@link BinderChannelBuilder#forTarget(String, android.content.Context)} for more.
45+
*/
46+
public static final NameResolver.Args.Key<android.content.Context> SOURCE_ANDROID_CONTEXT =
47+
NameResolver.Args.Key.create("source-android-context");
48+
3749
/**
3850
* Specifies the Android user in which target URIs should be resolved.
3951
*

binder/src/main/java/io/grpc/binder/AsyncSecurityPolicy.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,25 @@ public final Status checkAuthorization(int uid) {
6767
* authorized.
6868
*/
6969
public abstract ListenableFuture<Status> checkAuthorizationAsync(int uid);
70+
71+
/**
72+
* Decides whether the given Android UID is authorized, without providing its raw integer value.
73+
*
74+
* <p>Calling this is equivalent to calling {@link SecurityPolicy#checkAuthorization(int)}, except
75+
* the caller provides a {@link PeerUid} wrapper instead of the raw integer uid (known only to the
76+
* transport). This allows a server to check additional application-layer security policy for
77+
* itself *after* the call itself is authorized by the transport layer. Cross cutting application-
78+
* layer checks could be done from a {@link io.grpc.ServerInterceptor}. Checks based on the
79+
* substance of a request message could be done by the individual RPC method implementations
80+
* themselves.
81+
*
82+
* <p>See #checkAuthorizationAsync(int) for details on the semantics. See {@link
83+
* PeerUids#newPeerIdentifyingServerInterceptor()} for how to get a {@link PeerUid}.
84+
*
85+
* @param uid The Android UID to authenticate.
86+
* @return A gRPC {@link Status} object, with OK indicating authorized.
87+
*/
88+
public final ListenableFuture<Status> checkAuthorizationAsync(PeerUid uid) {
89+
return checkAuthorizationAsync(uid.getUid());
90+
}
7091
}

0 commit comments

Comments
 (0)