Skip to content

Commit c50da13

Browse files
committed
Clarify requirements for creating a cross-user Channel.
1 parent fdf6b21 commit c50da13

3 files changed

Lines changed: 25 additions & 7 deletions

File tree

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,22 @@ public Builder setBindIntentFromComponent(ComponentName component) {
250250
return this;
251251
}
252252

253-
/** See {@link AndroidComponentAddress#getTargetUser()}. */
253+
/**
254+
* Specifies the Android user in which the built Address' bind Intent will be evaluated.
255+
*
256+
* <p>Connecting to a server in a different Android user is uncommon and requires the client app
257+
* have runtime visibility of &#064;SystemApi's and hold certain &#064;SystemApi permissions.
258+
* The device must also be running Android SDK version 30 or higher.
259+
*
260+
* <p>See https://developer.android.com/guide/app-compatibility/restrictions-non-sdk-interfaces
261+
* for details on which apps can call the underlying &#064;SystemApi's needed to make this type
262+
* of connection.
263+
*
264+
* <p>One of the "android.permission.INTERACT_ACROSS_XXX" permissions is required. The exact one
265+
* depends on the calling user's relationship to the target user, whether client and server are
266+
* in the same or different apps, and the version of Android in use. See {@link
267+
* Context#bindServiceAsUser}, the essential underlying Android API, for details.
268+
*/
254269
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/10173")
255270
public Builder setTargetUser(@Nullable UserHandle targetUser) {
256271
this.targetUser = targetUser;

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ private ApiConstants() {}
3535
/**
3636
* Specifies the Android user in which target URIs should be resolved.
3737
*
38-
* <p>{@link UserHandle} can't reasonably be encoded in a target URI string. Instead, all
39-
* {@link io.grpc.NameResolverProvider}s producing {@link AndroidComponentAddress}es should let
40-
* clients address servers in another Android user using this argument.
38+
* <p>{@link UserHandle} can't reasonably be encoded in a target URI string. Instead, all {@link
39+
* io.grpc.NameResolverProvider}s producing {@link AndroidComponentAddress}es should let clients
40+
* address servers in another Android user using this argument.
4141
*
42-
* <p>See also {@link AndroidComponentAddress#getTargetUser()}.
42+
* <p>Connecting to a server in a different Android user is uncommon and can only be done by a
43+
* "system app" client. See {@link AndroidComponentAddress.Builder#setTargetUser(UserHandle)} for
44+
* details.
4345
*/
46+
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/10173")
4447
public static final NameResolver.Args.Key<UserHandle> TARGET_ANDROID_USER =
4548
NameResolver.Args.Key.create("target-android-user");
4649
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ public BinderChannelBuilder securityPolicy(SecurityPolicy securityPolicy) {
242242
* specify a {@link UserHandle}. If neither the Channel nor the {@link AndroidComponentAddress}
243243
* specifies a target user, the {@link UserHandle} of the current process will be used.
244244
*
245-
* <p>Targeting a Service in a different Android user is uncommon and requires special permissions
246-
* normally reserved for system apps. See {@link android.content.Context#bindServiceAsUser} for
245+
* <p>Connecting to a server in a different Android user is uncommon and can only be done by a
246+
* "system app" client. See {@link AndroidComponentAddress.Builder#setTargetUser(UserHandle)} for
247247
* details.
248248
*
249249
* @deprecated This method's name is misleading because it implies an impersonated client identity

0 commit comments

Comments
 (0)