Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
jni_android_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef JNI_ANDROID_P_H
5#define JNI_ANDROID_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qbluetooth.h"
19#include <QtCore/QJniObject>
20#include <QtCore/private/qglobal_p.h>
21#include <QtCore/qcoreapplication_platform.h>
22
24
25// CLASS declaration implies also TYPE declaration
26Q_DECLARE_JNI_CLASS(QtBtUtility,
27 "org/qtproject/qt/android/bluetooth/QtBluetoothUtility")
28Q_DECLARE_JNI_CLASS(QtBtBroadcastReceiver,
29 "org/qtproject/qt/android/bluetooth/QtBluetoothBroadcastReceiver")
30Q_DECLARE_JNI_CLASS(QtBtGattCharacteristic,
31 "org/qtproject/qt/android/bluetooth/QtBluetoothGattCharacteristic")
32Q_DECLARE_JNI_CLASS(QtBtGattDescriptor,
33 "org/qtproject/qt/android/bluetooth/QtBluetoothGattDescriptor")
34Q_DECLARE_JNI_CLASS(QtBtInputStreamThread,
35 "org/qtproject/qt/android/bluetooth/QtBluetoothInputStreamThread")
36Q_DECLARE_JNI_CLASS(QtBtSocketServer, "org/qtproject/qt/android/bluetooth/QtBluetoothSocketServer")
37Q_DECLARE_JNI_CLASS(QtBtLEServer, "org/qtproject/qt/android/bluetooth/QtBluetoothLEServer")
38Q_DECLARE_JNI_CLASS(QtBtLECentral, "org/qtproject/qt/android/bluetooth/QtBluetoothLE")
39Q_DECLARE_JNI_CLASS(BluetoothAdapter, "android/bluetooth/BluetoothAdapter")
40Q_DECLARE_JNI_CLASS(ParcelUuid, "android/os/ParcelUuid")
41Q_DECLARE_JNI_CLASS(AdvertiseDataBuilder, "android/bluetooth/le/AdvertiseData$Builder")
42Q_DECLARE_JNI_CLASS(BluetoothGattService, "android/bluetooth/BluetoothGattService")
43Q_DECLARE_JNI_CLASS(BluetoothGattDescriptor, "android/bluetooth/BluetoothGattDescriptor")
44Q_DECLARE_JNI_CLASS(BluetoothGattCharacteristic, "android/bluetooth/BluetoothGattCharacteristic")
45Q_DECLARE_JNI_CLASS(BluetoothDevice, "android/bluetooth/BluetoothDevice")
46Q_DECLARE_JNI_CLASS(IntentFilter, "android/content/IntentFilter")
47Q_DECLARE_JNI_CLASS(AndroidContext, "android/content/Context")
48
49
50Q_DECLARE_JNI_CLASS(BluetoothManager, "android/bluetooth/BluetoothManager")
51Q_DECLARE_JNI_CLASS(AdvertiseData, "android/bluetooth/le/AdvertiseData")
52Q_DECLARE_JNI_CLASS(InputStream, "java/io/InputStream")
53Q_DECLARE_JNI_CLASS(OutputStream, "java/io/OutputStream")
54Q_DECLARE_JNI_CLASS(BluetoothSocket, "android/bluetooth/BluetoothSocket")
55Q_DECLARE_JNI_CLASS(BroadcastReceiver, "android/content/BroadcastReceiver")
56Q_DECLARE_JNI_CLASS(BluetoothClass, "android/bluetooth/BluetoothClass")
57Q_DECLARE_JNI_CLASS(Bundle, "android/os/Bundle")
58Q_DECLARE_JNI_CLASS(List, "java/util/List")
59
60Q_DECLARE_JNI_CLASS(AdvertisingSetParameters, "android/bluetooth/le/AdvertisingSetParameters")
61Q_DECLARE_JNI_CLASS(AdvertisingSetParametersBuilder,
62 "android/bluetooth/le/AdvertisingSetParameters$Builder")
63
64// QLowEnergyHandle is a quint16, ensure it is interpreted as jint
65template<>
66constexpr auto QtJniTypes::Traits<QLowEnergyHandle>::signature()
67{
68 return QtJniTypes::Traits<jint>::signature();
69}
70
90
91QString valueFromStaticFieldCache(const char *key, const char *className, const char *fieldName);
92
93
94template<typename Klass, JavaNames Field>
96{
97 constexpr auto className = QtJniTypes::Traits<Klass>::className();
98 constexpr auto fieldName = []() -> auto {
99 if constexpr (Field == JavaNames::ActionAclConnected)
100 return QtJniTypes::CTString("ACTION_ACL_CONNECTED");
101 else if constexpr (Field == ActionAclDisconnected)
102 return QtJniTypes::CTString("ACTION_ACL_DISCONNECTED");
103 else if constexpr (Field == ActionBondStateChanged)
104 return QtJniTypes::CTString("ACTION_BOND_STATE_CHANGED");
105 else if constexpr (Field == ActionDiscoveryStarted)
106 return QtJniTypes::CTString("ACTION_DISCOVERY_STARTED");
107 else if constexpr (Field == ActionDiscoveryFinished)
108 return QtJniTypes::CTString("ACTION_DISCOVERY_FINISHED");
109 else if constexpr (Field == ActionFound)
110 return QtJniTypes::CTString("ACTION_FOUND");
111 else if constexpr (Field == ActionScanModeChanged)
112 return QtJniTypes::CTString("ACTION_SCAN_MODE_CHANGED");
113 else if constexpr (Field == ActionUuid)
114 return QtJniTypes::CTString("ACTION_UUID");
115 else if constexpr (Field == ExtraBondState)
116 return QtJniTypes::CTString("EXTRA_BOND_STATE");
117 else if constexpr (Field == ExtraDevice)
118 return QtJniTypes::CTString("EXTRA_DEVICE");
119 else if constexpr (Field == ExtraPairingKey)
120 return QtJniTypes::CTString("EXTRA_PAIRING_KEY");
121 else if constexpr (Field == ExtraPairingVariant)
122 return QtJniTypes::CTString("EXTRA_PAIRING_VARIANT");
123 else if constexpr (Field == ExtraRssi)
124 return QtJniTypes::CTString("EXTRA_RSSI");
125 else if constexpr (Field == ExtraScanMode)
126 return QtJniTypes::CTString("EXTRA_SCAN_MODE");
127 else if constexpr (Field == ExtraUuid)
128 return QtJniTypes::CTString("EXTRA_UUID");
129 else
130 static_assert(QtPrivate::value_dependent_false<Field>());
131 }();
132
133 return valueFromStaticFieldCache(className + fieldName, className.data(), fieldName.data());
134}
135
136QT_END_NAMESPACE
137
138#endif // JNI_ANDROID_P_H
void addAction(const QJniObject &filter)
QString valueForStaticField()
JavaNames
@ ExtraDevice
@ ExtraUuid
@ ExtraBondState
@ ExtraRssi
@ ActionScanModeChanged
@ ExtraPairingKey
@ ActionFound
@ ActionDiscoveryStarted
@ ActionAclDisconnected
@ ActionBondStateChanged
@ ActionUuid
@ BluetoothAdapter
@ ExtraPairingVariant
@ ExtraScanMode
@ BluetoothDevice
@ ActionAclConnected
@ ActionDiscoveryFinished
QString valueFromStaticFieldCache(const char *key, const char *className, const char *fieldName)
Combined button and popup list for selecting options.