3#include <QtCore/QJniEnvironment>
4#include <QtCore/QLoggingCategory>
5#include <QtCore/QString>
21 JniLocalRef(JNIEnv* env, T ref =
nullptr) : _env(env), _ref(ref)
64 _env->DeleteLocalRef(_ref);
70 JNIEnv* _env =
nullptr;
74template <
typename... Args>
75inline bool callStaticIntMethod(QJniEnvironment& env, jclass cls, jmethodID method,
const char* caller,
76 const QLoggingCategory& logCategory, jint& result, Args... args)
78 result = env->CallStaticIntMethod(cls, method, args...);
79 if (env.checkAndClearExceptions()) {
80 qCWarning(logCategory) <<
"Exception occurred while calling" << caller;
87template <
typename... Args>
89 const QLoggingCategory& logCategory, jboolean& result, Args... args)
91 result = env->CallStaticBooleanMethod(cls, method, args...);
92 if (env.checkAndClearExceptions()) {
93 qCWarning(logCategory) <<
"Exception occurred while calling" << caller;
Q_DECLARE_LOGGING_CATEGORY(AndroidSerialLog)
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 setKeepScreenOn(bool on)
constexpr const char * kJniQGCActivityClassName