3#include <QtCore/QJniEnvironment>
4#include <QtCore/QLoggingCategory>
5#include <QtCore/QString>
22 JniLocalRef(JNIEnv* env, T ref =
nullptr) : _env(env), _ref(ref)
65 _env->DeleteLocalRef(_ref);
71 JNIEnv* _env =
nullptr;
75template <
typename... Args>
76inline bool callStaticIntMethod(QJniEnvironment& env, jclass cls, jmethodID method,
const char* caller,
77 const QLoggingCategory& logCategory, jint& result, Args... args)
79 result = env->CallStaticIntMethod(cls, method, args...);
80 if (env.checkAndClearExceptions()) {
81 qCWarning(logCategory) <<
"Exception occurred while calling" << caller;
88template <
typename... Args>
90 const QLoggingCategory& logCategory, jboolean& result, Args... args)
92 result = env->CallStaticBooleanMethod(cls, method, args...);
93 if (env.checkAndClearExceptions()) {
94 qCWarning(logCategory) <<
"Exception occurred while calling" << caller;
JniLocalRef & operator=(JniLocalRef &&other) noexcept
void reset(T ref=nullptr)
JniLocalRef & operator=(const JniLocalRef &)=delete
JniLocalRef(const JniLocalRef &)=delete
JniLocalRef(JNIEnv *env, T ref=nullptr)
JniLocalRef(JniLocalRef &&other) noexcept
bool callStaticBooleanMethod(QJniEnvironment &env, jclass cls, jmethodID method, const char *caller, const QLoggingCategory &logCategory, jboolean &result, Args... args)
bool checkStoragePermissions()
bool callStaticIntMethod(QJniEnvironment &env, jclass cls, jmethodID method, const char *caller, const QLoggingCategory &logCategory, jint &result, Args... args)
void openFileImportDialog(const QString &destPath, std::function< void(const QString &)> callback)
void setKeepScreenOn(bool on)
constexpr const char * kJniQGCActivityClassName