QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
AndroidInterface.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QJniEnvironment>
4#include <QtCore/QString>
5
6#include <functional>
7
8namespace AndroidInterface {
11QString getSDCardPath();
12void setKeepScreenOn(bool on);
13
16{
17 VehicleLink = 1 << 0,
19};
20
24void setBackgroundWork(BackgroundWork work, bool active);
25void openFileImportDialog(const QString& destPath, std::function<void(const QString&)> callback);
26
27constexpr const char* kJniQGCActivityClassName = "org/mavlink/qgroundcontrol/QGCActivity";
28
29template <typename T>
31{
32public:
33 JniLocalRef(JNIEnv* env, T ref = nullptr) : _env(env), _ref(ref)
34 {
35 }
36
38 {
39 reset();
40 }
41
42 JniLocalRef(const JniLocalRef&) = delete;
44
45 JniLocalRef(JniLocalRef&& other) noexcept : _env(other._env), _ref(other._ref)
46 {
47 other._ref = nullptr;
48 }
49
51 {
52 if (this == &other) {
53 return *this;
54 }
55
56 reset();
57 _env = other._env;
58 _ref = other._ref;
59 other._ref = nullptr;
60 return *this;
61 }
62
63 T get() const
64 {
65 return _ref;
66 }
67
68 operator T() const
69 {
70 return _ref;
71 }
72
73 void reset(T ref = nullptr)
74 {
75 if (_env && _ref) {
76 _env->DeleteLocalRef(_ref);
77 }
78 _ref = ref;
79 }
80
81private:
82 JNIEnv* _env = nullptr;
83 T _ref = nullptr;
84};
85} // namespace AndroidInterface
JniLocalRef & operator=(JniLocalRef &&other) noexcept
JniLocalRef & operator=(const JniLocalRef &)=delete
JniLocalRef(const JniLocalRef &)=delete
JniLocalRef(JNIEnv *env, T ref=nullptr)
JniLocalRef(JniLocalRef &&other) noexcept
void setBackgroundWork(BackgroundWork work, bool active)
void openFileImportDialog(const QString &destPath, std::function< void(const QString &)> callback)
BackgroundWork
What should go on while the app is in the background, where Android freezes an app and cuts its netwo...
void setKeepScreenOn(bool on)
constexpr const char * kJniQGCActivityClassName