jni_utils.h
Go to the documentation of this file.
1 // Copyright 2021 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GRPC_CORE_EXT_TRANSPORT_BINDER_CLIENT_JNI_UTILS_H
16 #define GRPC_CORE_EXT_TRANSPORT_BINDER_CLIENT_JNI_UTILS_H
17 
18 #if defined(ANDROID) || defined(__ANDROID__)
19 
21 
22 #include <jni.h>
23 
24 #include <functional>
25 #include <string>
26 
27 #include "absl/strings/string_view.h"
28 
29 namespace grpc_binder {
30 
31 // Finds NativeConnectionHelper Java class and caches it. This is useful because
32 // FindClass only works when there is a Java class in the call stack. Typically
33 // user might want to call this once in a place that is called from Java (ex.
34 // JNI_OnLoad) so subsequent BinderTransport code can find Java class
35 jclass FindNativeConnectionHelper(JNIEnv* env);
36 
37 jclass FindNativeConnectionHelper(
38  JNIEnv* env, std::function<void*(std::string)> class_finder);
39 
40 // Calls Java method NativeConnectionHelper.tryEstablishConnection
41 void TryEstablishConnection(JNIEnv* env, jobject application,
43  absl::string_view action_name,
44  absl::string_view conn_id);
45 
46 // Calls Java method NativeConnectionHelper.isSignatureMatch.
47 // Will also return false if failed to invoke Java.
48 bool IsSignatureMatch(JNIEnv* env, jobject context, int uid1, int uid2);
49 
50 } // namespace grpc_binder
51 
52 #endif
53 
54 #endif // GRPC_CORE_EXT_TRANSPORT_BINDER_CLIENT_JNI_UTILS_H
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
grpc_binder
Definition: connection_id_generator.cc:45
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
env
Definition: env.py:1
context
grpc::ClientContext context
Definition: istio_echo_server_lib.cc:61
function
std::function< bool(GrpcTool *, int, const char **, const CliCredentials &, GrpcToolOutputCallback)> function
Definition: grpc_tool.cc:250
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:24