summaryrefslogtreecommitdiff
path: root/tests/shared/bttestutil_p.h
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@insta.fi>2022-09-19 12:32:03 +0300
committerJuha Vuolle <juha.vuolle@insta.fi>2022-10-04 07:53:07 +0300
commit46441888164208ed09ce144f3df0ac9713648db8 (patch)
tree83d2b82bbbc871426e16bad40cafbfa91a860883 /tests/shared/bttestutil_p.h
parent3284614452f011b1788f7500e22c297f9c801633 (diff)
downloadqtconnectivity-6.3.tar.gz
Skip few Bluetooth autotests on Android emulator6.3
This is to unblock Android-12 emulator deployment on CI which, unlike the earlier emulators, has a bluetooth emulation. This means that the emulator triggers permission confirmation dialogues which would timeout on CI. This commit replaces the 1ef066bf7d7a67d1b381443b9ecfa60f9204aca8, which attempted to solve the issue by compile-time configuration. Task-number: QTBUG-106614 Change-Id: Idc155bb8617802054d6ab19993f5417cc254f16e Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 90251f51be3af2d6db994b92993f2944345e10a6)
Diffstat (limited to 'tests/shared/bttestutil_p.h')
-rw-r--r--tests/shared/bttestutil_p.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/shared/bttestutil_p.h b/tests/shared/bttestutil_p.h
new file mode 100644
index 00000000..9d470c29
--- /dev/null
+++ b/tests/shared/bttestutil_p.h
@@ -0,0 +1,48 @@
+// Copyright (C) 2022 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 BTTESTUTIL_P_H
+#define BTTESTUTIL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qcoreapplication.h>
+
+#ifdef Q_OS_ANDROID
+#include <QtCore/QJniObject>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+bool androidBluetoothEmulator()
+{
+#ifdef Q_OS_ANDROID
+ // QTBUG-106614, the Android-12+ emulator (API level 31+) emulates bluetooth.
+ // We need to skip tests on the CI to avoid timeouts when Android waits for bluetooth
+ // permission confirmation from the user. Currently the check below skips generally
+ // on emulator though, not only on CI
+ if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31) {
+ const auto property = QJniObject::fromString("ro.kernel.qemu");
+ const auto isQemu = QJniObject::callStaticObjectMethod(
+ "android.os.SystemProperties", "get",
+ "(Ljava/lang/String;)Ljava/lang/String;",
+ property.object<jstring>());
+ if (isQemu.toString() == "1")
+ return true;
+ }
+#endif
+ return false;
+}
+
+QT_END_NAMESPACE
+
+#endif // BTTESTUTIL_P_H