Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
jni_util.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_FML_PLATFORM_ANDROID_JNI_UTIL_H_
6#define FLUTTER_FML_PLATFORM_ANDROID_JNI_UTIL_H_
7
8#include <jni.h>
9
10#include <vector>
11
12#include "flutter/fml/macros.h"
13#include "flutter/fml/platform/android/scoped_java_ref.h"
14
15namespace fml {
16namespace jni {
17
18void InitJavaVM(JavaVM* vm);
19
20// Returns a JNI environment for the current thread.
21// Attaches the thread to JNI if needed.
22JNIEnv* AttachCurrentThread();
23
24void DetachFromVM();
25
26std::string JavaStringToString(JNIEnv* env, jstring string);
27
28ScopedJavaLocalRef<jstring> StringToJavaString(JNIEnv* env,
29 const std::string& str);
30
31std::vector<std::string> StringArrayToVector(JNIEnv* env, jobjectArray jargs);
32
33std::vector<std::string> StringListToVector(JNIEnv* env, jobject list);
34
35ScopedJavaLocalRef<jobjectArray> VectorToStringArray(
36 JNIEnv* env,
37 const std::vector<std::string>& vector);
38
39ScopedJavaLocalRef<jobjectArray> VectorToBufferArray(
40 JNIEnv* env,
41 const std::vector<std::vector<uint8_t>>& vector);
42
43bool HasException(JNIEnv* env);
44
45bool ClearException(JNIEnv* env, bool silent = false);
46
47bool CheckException(JNIEnv* env);
48std::string GetJavaExceptionInfo(JNIEnv* env, jthrowable java_throwable);
49
50} // namespace jni
51} // namespace fml
52
53#endif // FLUTTER_FML_PLATFORM_ANDROID_JNI_UTIL_H_
Definition __init__.py:1
JNIEnv * AttachCurrentThread()
Definition jni_util.cc:34
ScopedJavaLocalRef< jobjectArray > VectorToBufferArray(JNIEnv *env, const std::vector< std::vector< uint8_t > > &vector)
Definition jni_util.cc:164
std::string JavaStringToString(JNIEnv *env, jstring str)
Definition jni_util.cc:70
void DetachFromVM()
Definition jni_util.cc:64
bool ClearException(JNIEnv *env, bool silent)
Definition jni_util.cc:188
bool CheckException(JNIEnv *env)
Definition jni_util.cc:199
std::string GetJavaExceptionInfo(JNIEnv *env, jthrowable java_throwable)
Definition jni_util.cc:211
ScopedJavaLocalRef< jobjectArray > VectorToStringArray(JNIEnv *env, const std::vector< std::string > &vector)
Definition jni_util.cc:147
std::vector< std::string > StringListToVector(JNIEnv *env, jobject list)
Definition jni_util.cc:118
bool HasException(JNIEnv *env)
Definition jni_util.cc:184
void InitJavaVM(JavaVM *vm)
Definition jni_util.cc:29
std::vector< std::string > StringArrayToVector(JNIEnv *env, jobjectArray array)
Definition jni_util.cc:96
ScopedJavaLocalRef< jstring > StringToJavaString(JNIEnv *env, const std::string &u8_string)
Definition jni_util.cc:86