|
|
@ -44,13 +44,11 @@ namespace grpc { |
|
|
|
namespace experimental { |
|
|
|
namespace experimental { |
|
|
|
|
|
|
|
|
|
|
|
// This should be called before calling CreateBinderChannel
|
|
|
|
// This should be called before calling CreateBinderChannel
|
|
|
|
// TODO(mingcl): Pass package_name and class_name down to connection helper
|
|
|
|
|
|
|
|
// TODO(mingcl): Invoke a callback and pass binder object to caller after a
|
|
|
|
// TODO(mingcl): Invoke a callback and pass binder object to caller after a
|
|
|
|
// successful bind
|
|
|
|
// successful bind
|
|
|
|
void BindToOnDeviceServerService(void* jni_env_void, jobject application, |
|
|
|
void BindToOnDeviceServerService(void* jni_env_void, jobject application, |
|
|
|
absl::string_view /*package_name*/, |
|
|
|
absl::string_view package_name, |
|
|
|
absl::string_view /*class_name*/ |
|
|
|
absl::string_view class_name) { |
|
|
|
) { |
|
|
|
|
|
|
|
// Init gRPC library first so gpr_log works
|
|
|
|
// Init gRPC library first so gpr_log works
|
|
|
|
grpc::internal::GrpcLibrary init_lib; |
|
|
|
grpc::internal::GrpcLibrary init_lib; |
|
|
|
init_lib.init(); |
|
|
|
init_lib.init(); |
|
|
@ -58,11 +56,11 @@ void BindToOnDeviceServerService(void* jni_env_void, jobject application, |
|
|
|
JNIEnv* jni_env = static_cast<JNIEnv*>(jni_env_void); |
|
|
|
JNIEnv* jni_env = static_cast<JNIEnv*>(jni_env_void); |
|
|
|
|
|
|
|
|
|
|
|
// clang-format off
|
|
|
|
// clang-format off
|
|
|
|
CallStaticJavaMethod(jni_env, |
|
|
|
grpc_binder::CallStaticJavaMethod(jni_env, |
|
|
|
"io/grpc/binder/cpp/NativeConnectionHelper", |
|
|
|
"io/grpc/binder/cpp/NativeConnectionHelper", |
|
|
|
"tryEstablishConnection", |
|
|
|
"tryEstablishConnection", |
|
|
|
"(Landroid/content/Context;)V", |
|
|
|
"(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V", |
|
|
|
application); |
|
|
|
application, std::string(package_name), std::string(class_name)); |
|
|
|
// clang-format on
|
|
|
|
// clang-format on
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -76,7 +74,7 @@ std::shared_ptr<grpc::Channel> CreateBinderChannel( |
|
|
|
JNIEnv* jni_env = static_cast<JNIEnv*>(jni_env_void); |
|
|
|
JNIEnv* jni_env = static_cast<JNIEnv*>(jni_env_void); |
|
|
|
|
|
|
|
|
|
|
|
// clang-format off
|
|
|
|
// clang-format off
|
|
|
|
jobject object = CallStaticJavaMethodForObject( |
|
|
|
jobject object = grpc_binder::CallStaticJavaMethodForObject( |
|
|
|
jni_env, |
|
|
|
jni_env, |
|
|
|
"io/grpc/binder/cpp/NativeConnectionHelper", |
|
|
|
"io/grpc/binder/cpp/NativeConnectionHelper", |
|
|
|
"getServiceBinder", |
|
|
|
"getServiceBinder", |
|
|
|