blob: 1d3c274b15fcb8da42cfb950c1dfb8bf4526ddec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// Copyright (C) 2021 The Qt Company Ltd.
// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef SENSORMANAGER_H
#define SENSORMANAGER_H
#include <QtCore/qthread.h>
#include <QtCore/qsemaphore.h>
#include <QtCore/qmutex.h>
#include <QtCore/qwaitcondition.h>
#include <QtCore/qjniobject.h>
#include <android/sensor.h>
class SensorManager : public QThread
{
public:
~SensorManager() override;
static QSharedPointer<SensorManager> &instance();
ALooper *looper() const;
ASensorManager *manager() const;
QJniObject javaSensor(const ASensor *sensor) const;
QString description(const ASensor *sensor) const;
double getMaximumRange(const ASensor *sensor) const;
private:
SensorManager();
// QThread interface
void run() override;
private:
QAtomicInt m_quit{0};
ALooper *m_looper = nullptr;
QSemaphore m_waitForStart;
QJniObject m_sensorManager;
};
#endif // SENSORMANAGER_H
|