diff --git a/src/core/ext/transport/binder/client/channel_create.cc b/src/core/ext/transport/binder/client/channel_create.cc index 8b409505968..7078743c728 100644 --- a/src/core/ext/transport/binder/client/channel_create.cc +++ b/src/core/ext/transport/binder/client/channel_create.cc @@ -78,8 +78,20 @@ void BindToOnDeviceServerService(void* jni_env_void, jobject application, // https://stackoverflow.com/a/3055749) // TODO(mingcl): Support multiple endpoint binder objects std::shared_ptr CreateBinderChannel( + void* jni_env_void, jobject application, absl::string_view package_name, + absl::string_view class_name) { + return CreateCustomBinderChannel(jni_env_void, application, package_name, + class_name, ChannelArguments()); +} + +// BindToOndeviceServerService need to be called before this, in a different +// task (due to Android API design). (Reference: +// https://stackoverflow.com/a/3055749) +// TODO(mingcl): Support multiple endpoint binder objects +std::shared_ptr CreateCustomBinderChannel( void* jni_env_void, jobject /*application*/, - absl::string_view /*package_name*/, absl::string_view /*class_name*/) { + absl::string_view /*package_name*/, absl::string_view /*class_name*/, + const ChannelArguments& args) { JNIEnv* jni_env = static_cast(jni_env_void); // clang-format off @@ -90,12 +102,14 @@ std::shared_ptr CreateBinderChannel( "()Landroid/os/IBinder;"); // clang-format on + grpc_channel_args channel_args; + args.SetChannelArgs(&channel_args); return CreateChannelInternal( "", ::grpc::internal::CreateChannelFromBinderImpl( absl::make_unique( grpc_binder::FromJavaBinder(jni_env, object)), - nullptr), + &channel_args), std::vector< std::unique_ptr>()); } @@ -120,6 +134,13 @@ std::shared_ptr CreateBinderChannel(void*, jobject, return {}; } +std::shared_ptr CreateCustomBinderChannel( + void*, jobject, absl::string_view, absl::string_view, + const ChannelArguments&) { + GPR_ASSERT(0); + return {}; +} + } // namespace experimental } // namespace grpc diff --git a/src/core/ext/transport/binder/client/channel_create.h b/src/core/ext/transport/binder/client/channel_create.h index 260abd0d82f..55ec0416fbf 100644 --- a/src/core/ext/transport/binder/client/channel_create.h +++ b/src/core/ext/transport/binder/client/channel_create.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "absl/strings/string_view.h" @@ -42,6 +43,13 @@ std::shared_ptr CreateBinderChannel( void* jni_env_void, jobject application, absl::string_view package_name, absl::string_view class_name); +// Need to be invoked after BindToOnDeviceServerService +// Create a new Channel from server package name and service class name and with +// custom channel arguments. +std::shared_ptr CreateCustomBinderChannel( + void* jni_env_void, jobject application, absl::string_view package_name, + absl::string_view class_name, const ChannelArguments& args); + } // namespace experimental } // namespace grpc