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 15 namespace fml { 16 namespace jni { 17 18 void InitJavaVM(JavaVM* vm); 19 20 JNIEnv* AttachCurrentThread(); 21 22 void DetachFromVM(); 23 24 std::string JavaStringToString(JNIEnv* env, jstring string); 25 26 ScopedJavaLocalRef<jstring> StringToJavaString(JNIEnv* env, 27 const std::string& str); 28 29 std::vector<std::string> StringArrayToVector(JNIEnv* env, jobjectArray jargs); 30 31 ScopedJavaLocalRef<jobjectArray> VectorToStringArray( 32 JNIEnv* env, 33 const std::vector<std::string>& vector); 34 35 bool HasException(JNIEnv* env); 36 37 bool ClearException(JNIEnv* env); 38 39 std::string GetJavaExceptionInfo(JNIEnv* env, jthrowable java_throwable); 40 41 } // namespace jni 42 } // namespace fml 43 44 #endif // FLUTTER_FML_PLATFORM_ANDROID_JNI_UTIL_H_ 45