summaryrefslogtreecommitdiffstats
path: root/src/plugins/sensors/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/sensors/android')
-rw-r--r--src/plugins/sensors/android/CMakeLists.txt35
-rw-r--r--src/plugins/sensors/android/android.pro41
-rw-r--r--src/plugins/sensors/android/androidaccelerometer.cpp40
-rw-r--r--src/plugins/sensors/android/androidaccelerometer.h40
-rw-r--r--src/plugins/sensors/android/androidcompass.cpp40
-rw-r--r--src/plugins/sensors/android/androidcompass.h40
-rw-r--r--src/plugins/sensors/android/androidgyroscope.cpp40
-rw-r--r--src/plugins/sensors/android/androidgyroscope.h40
-rw-r--r--src/plugins/sensors/android/androidlight.cpp40
-rw-r--r--src/plugins/sensors/android/androidlight.h40
-rw-r--r--src/plugins/sensors/android/androidmagnetometer.cpp40
-rw-r--r--src/plugins/sensors/android/androidmagnetometer.h40
-rw-r--r--src/plugins/sensors/android/androidpressure.cpp40
-rw-r--r--src/plugins/sensors/android/androidpressure.h40
-rw-r--r--src/plugins/sensors/android/androidproximity.cpp42
-rw-r--r--src/plugins/sensors/android/androidproximity.h42
-rw-r--r--src/plugins/sensors/android/androidrotation.cpp81
-rw-r--r--src/plugins/sensors/android/androidrotation.h40
-rw-r--r--src/plugins/sensors/android/androidtemperature.cpp40
-rw-r--r--src/plugins/sensors/android/androidtemperature.h40
-rw-r--r--src/plugins/sensors/android/main.cpp58
-rw-r--r--src/plugins/sensors/android/sensoreventqueue.h43
-rw-r--r--src/plugins/sensors/android/sensormanager.cpp80
-rw-r--r--src/plugins/sensors/android/sensormanager.h57
24 files changed, 161 insertions, 918 deletions
diff --git a/src/plugins/sensors/android/CMakeLists.txt b/src/plugins/sensors/android/CMakeLists.txt
new file mode 100644
index 00000000..9a77a9a5
--- /dev/null
+++ b/src/plugins/sensors/android/CMakeLists.txt
@@ -0,0 +1,35 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## QCounterGesturePlugin Plugin:
+#####################################################################
+
+qt_internal_add_plugin(AndroidSensorPlugin
+ OUTPUT_NAME qtsensors_android
+ PLUGIN_TYPE sensors
+ SOURCES
+ androidaccelerometer.cpp androidaccelerometer.h
+ androidcompass.cpp androidcompass.h
+ androidgyroscope.cpp androidgyroscope.h
+ androidlight.cpp androidlight.h
+ androidmagnetometer.cpp androidmagnetometer.h
+ androidpressure.cpp androidpressure.h
+ androidproximity.cpp androidproximity.h
+ androidrotation.cpp androidrotation.h
+ androidtemperature.cpp androidtemperature.h
+ main.cpp
+ sensoreventqueue.h
+ sensormanager.cpp sensormanager.h
+ DEFINES
+ # STATICPLUGIN needed because there's a Q_IMPORT_PLUGIN in main.cpp
+ # Yes, the plugin imports itself statically
+ QT_STATICPLUGIN
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::Sensors
+ android
+)
+
+#### Keys ignored in scope 1:.:.:android.pro:<TRUE>:
+# OTHER_FILES = "plugin.json"
diff --git a/src/plugins/sensors/android/android.pro b/src/plugins/sensors/android/android.pro
deleted file mode 100644
index 15e26ee9..00000000
--- a/src/plugins/sensors/android/android.pro
+++ /dev/null
@@ -1,41 +0,0 @@
-TARGET = qtsensors_android
-
-QT = sensors core-private
-
-# STATICPLUGIN needed because there's a Q_IMPORT_PLUGIN in main.cpp
-# Yes, the plugin imports itself statically
-DEFINES += QT_STATICPLUGIN
-
-HEADERS = \
- androidaccelerometer.h \
- androidcompass.h \
- androidgyroscope.h \
- androidmagnetometer.h \
- androidpressure.h \
- androidproximity.h \
- androidrotation.h \
- androidtemperature.h \
- androidlight.h \
- sensoreventqueue.h \
- sensormanager.h
-
-SOURCES = \
- main.cpp \
- androidaccelerometer.cpp \
- androidcompass.cpp \
- androidgyroscope.cpp \
- androidmagnetometer.cpp \
- androidpressure.cpp \
- androidproximity.cpp \
- androidrotation.cpp \
- androidtemperature.cpp \
- androidlight.cpp \
- sensormanager.cpp
-
-OTHER_FILES = plugin.json
-
-LIBS += -landroid
-
-PLUGIN_TYPE = sensors
-PLUGIN_CLASS_NAME = QCounterGesturePlugin
-load(qt_plugin)
diff --git a/src/plugins/sensors/android/androidaccelerometer.cpp b/src/plugins/sensors/android/androidaccelerometer.cpp
index f38e0047..1e6004ed 100644
--- a/src/plugins/sensors/android/androidaccelerometer.cpp
+++ b/src/plugins/sensors/android/androidaccelerometer.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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
#include "androidaccelerometer.h"
#include <QDebug>
diff --git a/src/plugins/sensors/android/androidaccelerometer.h b/src/plugins/sensors/android/androidaccelerometer.h
index 04362451..32fa6410 100644
--- a/src/plugins/sensors/android/androidaccelerometer.h
+++ b/src/plugins/sensors/android/androidaccelerometer.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 ANDROIDACCELEROMETER_H
#define ANDROIDACCELEROMETER_H
diff --git a/src/plugins/sensors/android/androidcompass.cpp b/src/plugins/sensors/android/androidcompass.cpp
index 653c5e99..d6f4f0f7 100644
--- a/src/plugins/sensors/android/androidcompass.cpp
+++ b/src/plugins/sensors/android/androidcompass.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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
/*
* Copyright (C) 2008 The Android Open Source Project
diff --git a/src/plugins/sensors/android/androidcompass.h b/src/plugins/sensors/android/androidcompass.h
index 1d20de72..592d641c 100644
--- a/src/plugins/sensors/android/androidcompass.h
+++ b/src/plugins/sensors/android/androidcompass.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 ANDROIDCOMPASS_H
#define ANDROIDCOMPASS_H
diff --git a/src/plugins/sensors/android/androidgyroscope.cpp b/src/plugins/sensors/android/androidgyroscope.cpp
index 2a38b5a0..acc4798a 100644
--- a/src/plugins/sensors/android/androidgyroscope.cpp
+++ b/src/plugins/sensors/android/androidgyroscope.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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
#include "androidgyroscope.h"
#include <QtCore/qmath.h>
diff --git a/src/plugins/sensors/android/androidgyroscope.h b/src/plugins/sensors/android/androidgyroscope.h
index 7d1ecec0..2dd3c8cc 100644
--- a/src/plugins/sensors/android/androidgyroscope.h
+++ b/src/plugins/sensors/android/androidgyroscope.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 ANDROIDGYROSCOPE_H
#define ANDROIDGYROSCOPE_H
diff --git a/src/plugins/sensors/android/androidlight.cpp b/src/plugins/sensors/android/androidlight.cpp
index 724ed970..42c8f0b7 100644
--- a/src/plugins/sensors/android/androidlight.cpp
+++ b/src/plugins/sensors/android/androidlight.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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
#include "androidlight.h"
diff --git a/src/plugins/sensors/android/androidlight.h b/src/plugins/sensors/android/androidlight.h
index 74c963fb..59c67981 100644
--- a/src/plugins/sensors/android/androidlight.h
+++ b/src/plugins/sensors/android/androidlight.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 ANDROIDLIGHT_H
#define ANDROIDLIGHT_H
diff --git a/src/plugins/sensors/android/androidmagnetometer.cpp b/src/plugins/sensors/android/androidmagnetometer.cpp
index ec663c0b..54d2225e 100644
--- a/src/plugins/sensors/android/androidmagnetometer.cpp
+++ b/src/plugins/sensors/android/androidmagnetometer.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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
#include "androidmagnetometer.h"
diff --git a/src/plugins/sensors/android/androidmagnetometer.h b/src/plugins/sensors/android/androidmagnetometer.h
index fb1f0ee7..e4e0fcbd 100644
--- a/src/plugins/sensors/android/androidmagnetometer.h
+++ b/src/plugins/sensors/android/androidmagnetometer.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 ANDROIDMAGNETOMETER_H
#define ANDROIDMAGNETOMETER_H
diff --git a/src/plugins/sensors/android/androidpressure.cpp b/src/plugins/sensors/android/androidpressure.cpp
index 46acffd6..50dd86a0 100644
--- a/src/plugins/sensors/android/androidpressure.cpp
+++ b/src/plugins/sensors/android/androidpressure.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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
#include "androidpressure.h"
diff --git a/src/plugins/sensors/android/androidpressure.h b/src/plugins/sensors/android/androidpressure.h
index ec682e59..7121d73c 100644
--- a/src/plugins/sensors/android/androidpressure.h
+++ b/src/plugins/sensors/android/androidpressure.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 ANDROIDPRESSURE_H
#define ANDROIDPRESSURE_H
diff --git a/src/plugins/sensors/android/androidproximity.cpp b/src/plugins/sensors/android/androidproximity.cpp
index 000399b0..2c134ba0 100644
--- a/src/plugins/sensors/android/androidproximity.cpp
+++ b/src/plugins/sensors/android/androidproximity.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 BogDan Vatra <bogdan@kde.org>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 BogDan Vatra <bogdan@kde.org>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "androidproximity.h"
diff --git a/src/plugins/sensors/android/androidproximity.h b/src/plugins/sensors/android/androidproximity.h
index 22169d6f..215292e8 100644
--- a/src/plugins/sensors/android/androidproximity.h
+++ b/src/plugins/sensors/android/androidproximity.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 BogDan Vatra <bogdan@kde.org>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 BogDan Vatra <bogdan@kde.org>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef ANDROIDPROXIMITY_H
#define ANDROIDPROXIMITY_H
diff --git a/src/plugins/sensors/android/androidrotation.cpp b/src/plugins/sensors/android/androidrotation.cpp
index c1d141a0..43586a0f 100644
--- a/src/plugins/sensors/android/androidrotation.cpp
+++ b/src/plugins/sensors/android/androidrotation.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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
#include "androidrotation.h"
@@ -48,12 +12,41 @@ AndroidRotation::AndroidRotation(int type, QSensor *sensor, QObject *parent)
void AndroidRotation::dataReceived(const ASensorEvent &event)
{
- // ### Check me, at first look it seems wrong,
- // here https://developer.android.com/reference/android/hardware/SensorEvent.html#sensor.type_rotation_vector:
- // are the Android values
- qreal rz = -qRadiansToDegrees(qreal(event.data[0])); // event.data[0] corresponds to x
- qreal rx = -qRadiansToDegrees(qreal(event.data[1])); // event.data[1] corresponds to y
- qreal ry = qRadiansToDegrees(qreal(event.data[2])); // event.data[2] corresponds to z
+ // From android documentation, the rotation sensor values are:
+ // values[0]: x*sin(θ/2)
+ // values[1]: y*sin(θ/2)
+ // values[2]: z*sin(θ/2)
+ // values[3]: cos(θ/2)
+
+ // The mathematics below is adapted from
+ // https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/hardware/SensorManager.java#1644
+ // and
+ // https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/hardware/SensorManager.java#1469
+ // (getRotationMatrixFromVector() followed by getOrientation())
+ qreal angles[3];
+ qreal q1 = qreal(event.data[0]);
+ qreal q2 = qreal(event.data[1]);
+ qreal q3 = qreal(event.data[2]);
+ qreal q0 = qreal(event.data[3]);
+
+ qreal sq_q1 = 2 * q1 * q1;
+ qreal sq_q2 = 2 * q2 * q2;
+ qreal sq_q3 = 2 * q3 * q3;
+ qreal q1_q2 = 2 * q1 * q2;
+ qreal q3_q0 = 2 * q3 * q0;
+ qreal q1_q3 = 2 * q1 * q3;
+ qreal q2_q0 = 2 * q2 * q0;
+ qreal q2_q3 = 2 * q2 * q3;
+ qreal q1_q0 = 2 * q1 * q0;
+
+ angles[0] = std::atan2((q1_q2 - q3_q0), (1 - sq_q1 - sq_q3));
+ angles[1] = std::asin(-(q2_q3 + q1_q0));
+ angles[2] = std::atan2(-(q1_q3 - q2_q0), (1 - sq_q1 - sq_q2));
+
+ qreal rz = -qRadiansToDegrees(angles[0]);
+ qreal rx = -qRadiansToDegrees(angles[1]);
+ qreal ry = qRadiansToDegrees(angles[2]);
+
if (sensor()->skipDuplicates() && qFuzzyCompare(m_reader.x(), rx) &&
qFuzzyCompare(m_reader.y(), ry) &&
qFuzzyCompare(m_reader.z(), rz)) {
diff --git a/src/plugins/sensors/android/androidrotation.h b/src/plugins/sensors/android/androidrotation.h
index 9761b249..84860c11 100644
--- a/src/plugins/sensors/android/androidrotation.h
+++ b/src/plugins/sensors/android/androidrotation.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 ANDROIDROTATION_H
#define ANDROIDROTATION_H
diff --git a/src/plugins/sensors/android/androidtemperature.cpp b/src/plugins/sensors/android/androidtemperature.cpp
index 5f85750a..f4c6cbe2 100644
--- a/src/plugins/sensors/android/androidtemperature.cpp
+++ b/src/plugins/sensors/android/androidtemperature.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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
#include "androidtemperature.h"
diff --git a/src/plugins/sensors/android/androidtemperature.h b/src/plugins/sensors/android/androidtemperature.h
index ba626051..654a5faa 100644
--- a/src/plugins/sensors/android/androidtemperature.h
+++ b/src/plugins/sensors/android/androidtemperature.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 ANDROIDTEMPERATURE_H
#define ANDROIDTEMPERATURE_H
diff --git a/src/plugins/sensors/android/main.cpp b/src/plugins/sensors/android/main.cpp
index 85853cd2..8c2855cd 100644
--- a/src/plugins/sensors/android/main.cpp
+++ b/src/plugins/sensors/android/main.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 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
#include <qplugin.h>
#include <qsensorplugin.h>
@@ -77,7 +41,7 @@ public:
switch (sensor) {
case ASENSOR_TYPE_ACCELEROMETER:
m_accelerationModes |= AndroidAccelerometer::Accelerometer;
- QSensorManager::registerBackend(QAccelerometer::type, QByteArray::number(sensor), this);
+ QSensorManager::registerBackend(QAccelerometer::sensorType, QByteArray::number(sensor), this);
accelerometer = true;
break;
case ASENSOR_TYPE_GRAVITY:
@@ -87,26 +51,26 @@ public:
m_accelerationModes |= AndroidAccelerometer::LinearAcceleration;
break;
case ASENSOR_TYPE_AMBIENT_TEMPERATURE:
- QSensorManager::registerBackend(QAmbientTemperatureSensor::type, QByteArray::number(sensor), this);
+ QSensorManager::registerBackend(QAmbientTemperatureSensor::sensorType, QByteArray::number(sensor), this);
break;
case ASENSOR_TYPE_GYROSCOPE:
- QSensorManager::registerBackend(QGyroscope::type, QByteArray::number(sensor), this);
+ QSensorManager::registerBackend(QGyroscope::sensorType, QByteArray::number(sensor), this);
break;
case ASENSOR_TYPE_LIGHT:
- QSensorManager::registerBackend(QLightSensor::type, QByteArray::number(sensor), this);
+ QSensorManager::registerBackend(QLightSensor::sensorType, QByteArray::number(sensor), this);
break;
case ASENSOR_TYPE_MAGNETIC_FIELD:
- QSensorManager::registerBackend(QMagnetometer::type, QByteArray::number(sensor), this);
+ QSensorManager::registerBackend(QMagnetometer::sensorType, QByteArray::number(sensor), this);
magnetometer = true;
break;
case ASENSOR_TYPE_PRESSURE:
- QSensorManager::registerBackend(QPressureSensor::type, QByteArray::number(sensor), this);
+ QSensorManager::registerBackend(QPressureSensor::sensorType, QByteArray::number(sensor), this);
break;
case ASENSOR_TYPE_PROXIMITY:
- QSensorManager::registerBackend(QProximitySensor::type, QByteArray::number(sensor), this);
+ QSensorManager::registerBackend(QProximitySensor::sensorType, QByteArray::number(sensor), this);
break;
case ASENSOR_TYPE_ROTATION_VECTOR:
- QSensorManager::registerBackend(QRotationSensor::type, QByteArray::number(sensor), this);
+ QSensorManager::registerBackend(QRotationSensor::sensorType, QByteArray::number(sensor), this);
break;
case ASENSOR_TYPE_RELATIVE_HUMIDITY:
@@ -128,7 +92,7 @@ public:
}
}
if (accelerometer && magnetometer)
- QSensorManager::registerBackend(QCompass::type, AndroidCompassId, this);
+ QSensorManager::registerBackend(QCompass::sensorType, AndroidCompassId, this);
}
QSensorBackend *createBackend(QSensor *sensor) override
diff --git a/src/plugins/sensors/android/sensoreventqueue.h b/src/plugins/sensors/android/sensoreventqueue.h
index 77bf05c6..b18401e9 100644
--- a/src/plugins/sensors/android/sensoreventqueue.h
+++ b/src/plugins/sensors/android/sensoreventqueue.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 SENSOREVENTQUEUE_H
#define SENSOREVENTQUEUE_H
@@ -125,8 +89,9 @@ public:
void start() override
{
ASensorEventQueue_enableSensor(m_sensorEventQueue, m_sensor);
+ // The QSensor datarate is in Hz (frequency), whereas the setEventRate expects microseconds
if (sensor()->dataRate() > 0)
- ASensorEventQueue_setEventRate(m_sensorEventQueue, m_sensor, std::max(ASensor_getMinDelay(m_sensor), sensor()->dataRate()));
+ ASensorEventQueue_setEventRate(m_sensorEventQueue, m_sensor, std::max(ASensor_getMinDelay(m_sensor), 1000000/sensor()->dataRate()));
m_started = true;
}
void stop() override
diff --git a/src/plugins/sensors/android/sensormanager.cpp b/src/plugins/sensors/android/sensormanager.cpp
index 542e54c9..755b6109 100644
--- a/src/plugins/sensors/android/sensormanager.cpp
+++ b/src/plugins/sensors/android/sensormanager.cpp
@@ -1,48 +1,23 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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
#include "sensormanager.h"
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qjnitypes.h>
+
#include <dlfcn.h>
+Q_DECLARE_JNI_CLASS(AndroidContext, "android/content/Context")
+Q_DECLARE_JNI_CLASS(Sensor, "android/hardware/Sensor")
+
SensorManager::SensorManager()
{
- auto sensorService = QJNIObjectPrivate::getStaticObjectField("android.content.Context", "SENSOR_SERVICE", "Ljava/lang/String;");
- m_sensorManager = QJNIObjectPrivate{QtAndroidPrivate::context()}.callObjectMethod("getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;", sensorService.object());
+ auto sensorService =
+ QJniObject::getStaticField<QtJniTypes::AndroidContext, jstring>("SENSOR_SERVICE");
+
+ QJniObject context = QNativeInterface::QAndroidApplication::context();
+ m_sensorManager = context.callMethod<jobject>("getSystemService",
+ sensorService.object<jstring>());
setObjectName("QtSensorsLooperThread");
start();
m_waitForStart.acquire();
@@ -50,13 +25,14 @@ SensorManager::SensorManager()
SensorManager::~SensorManager()
{
- m_quit.store(1);
+ m_quit.storeRelaxed(1);
wait();
}
-QJNIObjectPrivate SensorManager::javaSensor(const ASensor *sensor) const
+QJniObject SensorManager::javaSensor(const ASensor *sensor) const
{
- return m_sensorManager.callObjectMethod("getDefaultSensor", "(I)Landroid/hardware/Sensor;", ASensor_getType(sensor));
+ return m_sensorManager.callMethod<QtJniTypes::Sensor>("getDefaultSensor",
+ ASensor_getType(sensor));
}
QSharedPointer<SensorManager> &SensorManager::instance()
@@ -72,19 +48,18 @@ ALooper *SensorManager::looper() const
static inline ASensorManager* androidManager()
{
+ QJniObject context = QNativeInterface::QAndroidApplication::context();
+ auto packageName = context.callMethod<jstring>("getPackageName").toString().toUtf8();
+
#if __ANDROID_API__ >= 26
- return ASensorManager_getInstanceForPackage(QJNIObjectPrivate{QtAndroidPrivate::context()}
- .callObjectMethod("getPackageName", "()Ljava/lang/String;")
- .toString().toUtf8().constData());
+ return ASensorManager_getInstanceForPackage(packageName.constData());
#else
- if (QtAndroidPrivate::androidSdkVersion() >= 26) {
+ if (QNativeInterface::QAndroidApplication::sdkVersion() >= 26) {
using GetInstanceForPackage = ASensorManager *(*)(const char *);
auto handler = dlopen("libandroid.so", RTLD_NOW);
auto function = GetInstanceForPackage(dlsym(handler, "ASensorManager_getInstanceForPackage"));
if (function) {
- auto res = function(QJNIObjectPrivate{QtAndroidPrivate::context()}
- .callObjectMethod("getPackageName", "()Ljava/lang/String;")
- .toString().toUtf8().constData());
+ auto res = function(packageName.constData());
dlclose(handler);
return res;
}
@@ -101,7 +76,8 @@ ASensorManager *SensorManager::manager() const
QString SensorManager::description(const ASensor *sensor) const
{
- return QString::fromUtf8(ASensor_getName(sensor)) + " " + ASensor_getVendor(sensor) + " v" + QString::number(javaSensor(sensor).callMethod<jint>("getVersion"));
+ return QString::fromUtf8(ASensor_getName(sensor)) + " " + ASensor_getVendor(sensor)
+ + " v" + QString::number(javaSensor(sensor).callMethod<jint>("getVersion"));
}
double SensorManager::getMaximumRange(const ASensor *sensor) const
@@ -116,5 +92,5 @@ void SensorManager::run()
do {
if (ALooper_pollAll(5 /*ms*/, nullptr, nullptr, nullptr) == ALOOPER_POLL_TIMEOUT)
QThread::yieldCurrentThread();
- } while (!m_quit.load());
+ } while (!m_quit.loadRelaxed());
}
diff --git a/src/plugins/sensors/android/sensormanager.h b/src/plugins/sensors/android/sensormanager.h
index dc7ffe1f..1d3c274b 100644
--- a/src/plugins/sensors/android/sensormanager.h
+++ b/src/plugins/sensors/android/sensormanager.h
@@ -1,52 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QThread>
-#include <QSemaphore>
-#include <QMutex>
-#include <QWaitCondition>
-
-#include <private/qjni_p.h>
-#include <private/qjnihelpers_p.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>
@@ -58,7 +21,7 @@ public:
ALooper *looper() const;
ASensorManager *manager() const;
- QJNIObjectPrivate javaSensor(const ASensor *sensor) const;
+ QJniObject javaSensor(const ASensor *sensor) const;
QString description(const ASensor *sensor) const;
double getMaximumRange(const ASensor *sensor) const;
@@ -71,7 +34,7 @@ private:
QAtomicInt m_quit{0};
ALooper *m_looper = nullptr;
QSemaphore m_waitForStart;
- QJNIObjectPrivate m_sensorManager;
+ QJniObject m_sensorManager;
};
#endif // SENSORMANAGER_H