|
|
|
@ -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<grpc::Channel> 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<grpc::Channel> 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<JNIEnv*>(jni_env_void); |
|
|
|
|
|
|
|
|
|
// clang-format off
|
|
|
|
@ -90,12 +102,14 @@ std::shared_ptr<grpc::Channel> 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::BinderAndroid>( |
|
|
|
|
grpc_binder::FromJavaBinder(jni_env, object)), |
|
|
|
|
nullptr), |
|
|
|
|
&channel_args), |
|
|
|
|
std::vector< |
|
|
|
|
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>()); |
|
|
|
|
} |
|
|
|
@ -120,6 +134,13 @@ std::shared_ptr<grpc::Channel> CreateBinderChannel(void*, jobject, |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::shared_ptr<grpc::Channel> CreateCustomBinderChannel( |
|
|
|
|
void*, jobject, absl::string_view, absl::string_view, |
|
|
|
|
const ChannelArguments&) { |
|
|
|
|
GPR_ASSERT(0); |
|
|
|
|
return {}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // namespace experimental
|
|
|
|
|
} // namespace grpc
|
|
|
|
|
|
|
|
|
|