summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.cmake.conf2
-rw-r--r--dependencies.yaml4
-rw-r--r--examples/nfc/annotatedurl/android/AndroidManifest.xml69
-rw-r--r--src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothBroadcastReceiver.java19
-rw-r--r--src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothGattCharacteristic.java12
-rw-r--r--src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothGattDescriptor.java8
-rw-r--r--src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothInputStreamThread.java19
-rw-r--r--src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothLE.java96
-rw-r--r--src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothLEServer.java62
-rw-r--r--src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothSocketServer.java15
-rw-r--r--src/android/nfc/src/org/qtproject/qt/android/nfc/QtNfc.java18
-rw-r--r--src/android/nfc/src/org/qtproject/qt/android/nfc/QtNfcBroadcastReceiver.java9
-rw-r--r--src/bluetooth/CMakeLists.txt1
-rw-r--r--src/bluetooth/android/jni_android_p.h18
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp1
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_android.cpp18
-rw-r--r--src/nfc/CMakeLists.txt1
-rw-r--r--src/nfc/android/androidjninfc.cpp23
-rw-r--r--src/nfc/android/androidjninfc_p.h10
-rw-r--r--src/nfc/android/androidmainnewintentlistener.cpp13
-rw-r--r--src/nfc/qnearfieldmanager_android.cpp20
-rw-r--r--src/nfc/qnearfieldmanager_android_p.h3
-rw-r--r--src/nfc/qnearfieldtarget.cpp2
-rw-r--r--src/nfc/qnearfieldtarget.h3
-rw-r--r--src/nfc/qnearfieldtarget_android.cpp42
-rw-r--r--src/nfc/qnearfieldtarget_android_p.h1
-rw-r--r--src/nfc/qnearfieldtarget_ios.mm12
27 files changed, 231 insertions, 270 deletions
diff --git a/.cmake.conf b/.cmake.conf
index 62cb061c..ac6b6729 100644
--- a/.cmake.conf
+++ b/.cmake.conf
@@ -1,4 +1,4 @@
-set(QT_REPO_MODULE_VERSION "6.8.0")
+set(QT_REPO_MODULE_VERSION "6.9.0")
set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1")
set(QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_AS_CONST=1")
list(APPEND QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_FOREACH=1")
diff --git a/dependencies.yaml b/dependencies.yaml
index dc08c4af..aa562790 100644
--- a/dependencies.yaml
+++ b/dependencies.yaml
@@ -1,7 +1,7 @@
dependencies:
../qtbase:
- ref: 0cd5eb895cc96126a495eb3d2d258be47eed193a
+ ref: 08c6de0c5d646a1c99834408ccd257f60f7624db
required: true
../qtdeclarative:
- ref: c63bb2bad5b4e741ed8a1e16d8f1f916c9baf61d
+ ref: 53b3a0d41545106fdd82cedc42393ff38d70f1fd
required: false
diff --git a/examples/nfc/annotatedurl/android/AndroidManifest.xml b/examples/nfc/annotatedurl/android/AndroidManifest.xml
index 3378612d..101900ab 100644
--- a/examples/nfc/annotatedurl/android/AndroidManifest.xml
+++ b/examples/nfc/annotatedurl/android/AndroidManifest.xml
@@ -1,53 +1,32 @@
-<?xml version="1.0"?>
-<manifest package="org.qtproject.example.annotatedurl" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="-- %%INSERT_VERSION_NAME%% --" android:versionCode="-- %%INSERT_VERSION_CODE%% --" android:installLocation="auto">
- <!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
- Remove the comment if you do not require these default permissions. -->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.qtproject.annotatedurl"
+ android:installLocation="auto"
+ android:versionCode="-- %%INSERT_VERSION_CODE%% --"
+ android:versionName="-- %%INSERT_VERSION_NAME%% --">
<!-- %%INSERT_PERMISSIONS -->
-
- <!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
- Remove the comment if you do not require these default features. -->
<!-- %%INSERT_FEATURES -->
-
- <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
- <application android:hardwareAccelerated="true" android:name="org.qtproject.qt.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --" android:extractNativeLibs="true" android:requestLegacyExternalStorage="true" android:allowBackup="true" android:fullBackupOnly="false">
- <activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:name="org.qtproject.qt.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTask" android:exported="true">
+ <supports-screens android:anyDensity="true"
+ android:largeScreens="true"
+ android:normalScreens="true"
+ android:smallScreens="true"/>
+ <application android:name="org.qtproject.qt.android.bindings.QtApplication"
+ android:hardwareAccelerated="true"
+ android:label="-- %%INSERT_APP_NAME%% --"
+ android:requestLegacyExternalStorage="true"
+ android:allowBackup="true"
+ android:fullBackupOnly="false"
+ android:icon="@drawable/icon">
+ <activity android:name="org.qtproject.qt.android.bindings.QtActivity"
+ android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
+ android:launchMode="singleTop"
+ android:screenOrientation="unspecified"
+ android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
- <intent-filter>
- <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
- <category android:name="android.intent.category.DEFAULT"/>
- <data android:mimeType="text/plain"/>
- </intent-filter>
-
- <!-- Application arguments -->
- <meta-data android:name="android.app.arguments" android:value="-- %%INSERT_APP_ARGUMENTS%% --"/>
- <!-- Application arguments -->
-
- <meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
-
- <!-- Background running -->
- <!-- Warning: changing this value to true may cause unexpected crashes if the
- application still try to draw after
- "applicationStateChanged(Qt::ApplicationSuspended)"
- signal is sent! -->
- <meta-data android:name="android.app.background_running" android:value="false"/>
- <!-- Background running -->
-
- <!-- extract android style -->
- <!-- available android:values :
- * default - In most cases this will be the same as "full", but it can also be something else if needed, e.g., for compatibility reasons
- * full - useful QWidget & Quick Controls 1 apps
- * minimal - useful for Quick Controls 2 apps, it is much faster than "full"
- * none - useful for apps that don't use any of the above Qt modules
- -->
- <meta-data android:name="android.app.extract_android_style" android:value="default"/>
- <!-- extract android style -->
- </activity>
-
- <!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
-
+ <meta-data android:name="android.app.lib_name"
+ android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
+ </activity>
</application>
-
</manifest>
diff --git a/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothBroadcastReceiver.java b/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothBroadcastReceiver.java
index 6c74c3e3..5df5cb81 100644
--- a/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothBroadcastReceiver.java
+++ b/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothBroadcastReceiver.java
@@ -32,11 +32,12 @@ public class QtBluetoothBroadcastReceiver extends BroadcastReceiver
private static final int TURN_BT_DISABLED = 3332;
// The 'Disable' action identifier is hidden in the public APIs so we define it here
- public static final String ACTION_REQUEST_DISABLE =
+ static final String ACTION_REQUEST_DISABLE =
"android.bluetooth.adapter.action.REQUEST_DISABLE";
private static final String TAG = "QtBluetoothBroadcastReceiver";
+ @Override
public void onReceive(Context context, Intent intent)
{
synchronized (qtContext) {
@@ -47,7 +48,7 @@ public class QtBluetoothBroadcastReceiver extends BroadcastReceiver
}
}
- public void unregisterReceiver()
+ void unregisterReceiver()
{
synchronized (qtContext) {
qtObject = 0;
@@ -59,14 +60,14 @@ public class QtBluetoothBroadcastReceiver extends BroadcastReceiver
}
}
- public native void jniOnReceive(long qtObject, Context context, Intent intent);
+ native void jniOnReceive(long qtObject, Context context, Intent intent);
- static public void setContext(Context context)
+ public static void setContext(Context context)
{
qtContext = context;
}
- static public boolean setDisabled()
+ static boolean setDisabled()
{
if (!(qtContext instanceof android.app.Activity)) {
Log.w(TAG, "Bluetooth cannot be disabled from a service.");
@@ -86,7 +87,7 @@ public class QtBluetoothBroadcastReceiver extends BroadcastReceiver
return true;
}
- static public boolean setDiscoverable()
+ static boolean setDiscoverable()
{
if (!(qtContext instanceof android.app.Activity)) {
Log.w(TAG, "Discovery mode cannot be enabled from a service.");
@@ -105,7 +106,7 @@ public class QtBluetoothBroadcastReceiver extends BroadcastReceiver
return true;
}
- static public boolean setEnabled()
+ static boolean setEnabled()
{
if (!(qtContext instanceof android.app.Activity)) {
Log.w(TAG, "Bluetooth cannot be enabled from a service.");
@@ -123,7 +124,7 @@ public class QtBluetoothBroadcastReceiver extends BroadcastReceiver
return true;
}
- static public boolean setPairingMode(String address, boolean isPairing)
+ static boolean setPairingMode(String address, boolean isPairing)
{
BluetoothManager manager =
(BluetoothManager)qtContext.getSystemService(Context.BLUETOOTH_SERVICE);
@@ -159,7 +160,7 @@ public class QtBluetoothBroadcastReceiver extends BroadcastReceiver
* Unfortunately there is no API that provides the complete list.
*
*/
- static public String[] getConnectedDevices()
+ static String[] getConnectedDevices()
{
BluetoothManager bluetoothManager =
(BluetoothManager) qtContext.getSystemService(Context.BLUETOOTH_SERVICE);
diff --git a/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothGattCharacteristic.java b/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothGattCharacteristic.java
index 375aebb5..6473541a 100644
--- a/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothGattCharacteristic.java
+++ b/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothGattCharacteristic.java
@@ -8,22 +8,22 @@ import android.os.Build;
import java.util.UUID;
-public class QtBluetoothGattCharacteristic extends BluetoothGattCharacteristic {
- public QtBluetoothGattCharacteristic(UUID uuid, int properties, int permissions,
+class QtBluetoothGattCharacteristic extends BluetoothGattCharacteristic {
+ QtBluetoothGattCharacteristic(UUID uuid, int properties, int permissions,
int minimumValueLength, int maximumValueLength) {
super(uuid, properties, permissions);
minValueLength = minimumValueLength;
maxValueLength = maximumValueLength;
}
- public int minValueLength;
- public int maxValueLength;
+ int minValueLength;
+ int maxValueLength;
// Starting from API 33 Android Bluetooth deprecates characteristic local value caching by
// deprecating the getValue() and setValue() accessors. For peripheral role we store the value
// locally in the characteristic as a convenience - looking up the value on the C++ side would
// be somewhat complicated. This should be safe as all accesses to this class are synchronized.
// For clarity: For API levels below 33 we still need to use the setValue() of the base class
// because Android internally uses getValue() with APIs below 33.
- public boolean setLocalValue(byte[] value) {
+ boolean setLocalValue(byte[] value) {
if (Build.VERSION.SDK_INT >= 33) {
m_localValue = value;
return true;
@@ -32,7 +32,7 @@ public class QtBluetoothGattCharacteristic extends BluetoothGattCharacteristic {
}
}
- public byte[] getLocalValue()
+ byte[] getLocalValue()
{
if (Build.VERSION.SDK_INT >= 33)
return m_localValue;
diff --git a/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothGattDescriptor.java b/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothGattDescriptor.java
index 10194ea4..b6c195d3 100644
--- a/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothGattDescriptor.java
+++ b/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothGattDescriptor.java
@@ -8,8 +8,8 @@ import android.os.Build;
import java.util.UUID;
-public class QtBluetoothGattDescriptor extends BluetoothGattDescriptor {
- public QtBluetoothGattDescriptor(UUID uuid, int permissions) {
+class QtBluetoothGattDescriptor extends BluetoothGattDescriptor {
+ QtBluetoothGattDescriptor(UUID uuid, int permissions) {
super(uuid, permissions);
}
// Starting from API 33 Android Bluetooth deprecates descriptor local value caching by
@@ -18,7 +18,7 @@ public class QtBluetoothGattDescriptor extends BluetoothGattDescriptor {
// be somewhat complicated. This should be safe as all accesses to this class are synchronized.
// For clarity: For API levels below 33 we still need to use the setValue() of the base class
// because Android internally uses getValue() with APIs below 33.
- public boolean setLocalValue(byte[] value) {
+ boolean setLocalValue(byte[] value) {
if (Build.VERSION.SDK_INT >= 33) {
m_localValue = value;
return true;
@@ -27,7 +27,7 @@ public class QtBluetoothGattDescriptor extends BluetoothGattDescriptor {
}
}
- public byte[] getLocalValue()
+ byte[] getLocalValue()
{
if (Build.VERSION.SDK_INT >= 33)
return m_localValue;
diff --git a/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothInputStreamThread.java b/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothInputStreamThread.java
index 0fd6f292..3c12cb34 100644
--- a/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothInputStreamThread.java
+++ b/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothInputStreamThread.java
@@ -8,31 +8,32 @@ import java.io.IOException;
import android.util.Log;
@SuppressWarnings("WeakerAccess")
-public class QtBluetoothInputStreamThread extends Thread
+class QtBluetoothInputStreamThread extends Thread
{
/* Pointer to the Qt object that "owns" the Java object */
@SuppressWarnings("CanBeFinal")
long qtObject = 0;
@SuppressWarnings("CanBeFinal")
- public boolean logEnabled = false;
+ boolean logEnabled = false;
private static final String TAG = "QtBluetooth";
private InputStream m_inputStream = null;
//error codes
- public static final int QT_MISSING_INPUT_STREAM = 0;
- public static final int QT_READ_FAILED = 1;
- public static final int QT_THREAD_INTERRUPTED = 2;
+ static final int QT_MISSING_INPUT_STREAM = 0;
+ static final int QT_READ_FAILED = 1;
+ static final int QT_THREAD_INTERRUPTED = 2;
- public QtBluetoothInputStreamThread()
+ QtBluetoothInputStreamThread()
{
setName("QtBtInputStreamThread");
}
- public void setInputStream(InputStream stream)
+ void setInputStream(InputStream stream)
{
m_inputStream = stream;
}
+ @Override
public void run()
{
if (m_inputStream == null) {
@@ -63,6 +64,6 @@ public class QtBluetoothInputStreamThread extends Thread
Log.d(TAG, "Leaving input stream thread");
}
- public static native void errorOccurred(long qtObject, int errorCode);
- public static native void readyData(long qtObject, byte[] buffer, int bufferLength);
+ static native void errorOccurred(long qtObject, int errorCode);
+ static native void readyData(long qtObject, byte[] buffer, int bufferLength);
}
diff --git a/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothLE.java b/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothLE.java
index 0e612add..d133d8dc 100644
--- a/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothLE.java
+++ b/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothLE.java
@@ -39,7 +39,7 @@ import java.util.NoSuchElementException;
import java.util.UUID;
-public class QtBluetoothLE {
+class QtBluetoothLE {
private static final String TAG = "QtBluetoothGatt";
private BluetoothAdapter mBluetoothAdapter = null;
private boolean mLeScanRunning = false;
@@ -72,7 +72,7 @@ public class QtBluetoothLE {
private BluetoothLeScanner mBluetoothLeScanner = null;
private class TimeoutRunnable implements Runnable {
- public TimeoutRunnable(int handle) { pendingJobHandle = handle; }
+ TimeoutRunnable(int handle) { pendingJobHandle = handle; }
@Override
public void run() {
boolean timeoutStillValid = handleForTimeout.compareAndSet(pendingJobHandle, HANDLE_FOR_RESET);
@@ -170,7 +170,7 @@ public class QtBluetoothLE {
Context qtContext = null;
@SuppressWarnings("WeakerAccess")
- public QtBluetoothLE(Context context) {
+ QtBluetoothLE(Context context) {
qtContext = context;
BluetoothManager manager =
@@ -185,7 +185,7 @@ public class QtBluetoothLE {
mBluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner();
}
- public QtBluetoothLE(final String remoteAddress, Context context) {
+ QtBluetoothLE(final String remoteAddress, Context context) {
this(context);
mRemoteGattAddress = remoteAddress;
}
@@ -197,7 +197,7 @@ public class QtBluetoothLE {
/* variables that are not accessed from Java threads */
/*************************************************************/
- public boolean scanForLeDevice(final boolean isEnabled) {
+ boolean scanForLeDevice(final boolean isEnabled) {
if (isEnabled == mLeScanRunning)
return true;
@@ -253,7 +253,7 @@ public class QtBluetoothLE {
}
};
- public native void leScanResult(long qtObject, BluetoothDevice device, int rssi, byte[] scanRecord);
+ native void leScanResult(long qtObject, BluetoothDevice device, int rssi, byte[] scanRecord);
private synchronized void handleOnConnectionStateChange(BluetoothGatt gatt,
int status, int newState) {
@@ -646,18 +646,20 @@ public class QtBluetoothLE {
/*************************************************************/
private final BluetoothGattCallback gattCallback = new BluetoothGattCallback() {
-
+ @Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
super.onConnectionStateChange(gatt, status, newState);
handleOnConnectionStateChange(gatt, status, newState);
}
+ @Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
super.onServicesDiscovered(gatt, status);
handleOnServicesDiscovered(gatt, status);
}
+ @Override
// API < 33
public void onCharacteristicRead(android.bluetooth.BluetoothGatt gatt,
android.bluetooth.BluetoothGattCharacteristic characteristic,
@@ -667,6 +669,7 @@ public class QtBluetoothLE {
handleOnCharacteristicRead(gatt, characteristic, characteristic.getValue(), status);
}
+ @Override
// API >= 33
public void onCharacteristicRead(android.bluetooth.BluetoothGatt gatt,
android.bluetooth.BluetoothGattCharacteristic characteristic,
@@ -678,6 +681,7 @@ public class QtBluetoothLE {
handleOnCharacteristicRead(gatt, characteristic, value, status);
}
+ @Override
public void onCharacteristicWrite(android.bluetooth.BluetoothGatt gatt,
android.bluetooth.BluetoothGattCharacteristic characteristic,
int status)
@@ -687,6 +691,7 @@ public class QtBluetoothLE {
}
// API < 33
+ @Override
public void onCharacteristicChanged(android.bluetooth.BluetoothGatt gatt,
android.bluetooth.BluetoothGattCharacteristic characteristic)
{
@@ -695,6 +700,7 @@ public class QtBluetoothLE {
}
// API >= 33
+ @Override
public void onCharacteristicChanged(android.bluetooth.BluetoothGatt gatt,
android.bluetooth.BluetoothGattCharacteristic characteristic,
byte[] value)
@@ -705,6 +711,7 @@ public class QtBluetoothLE {
}
// API < 33
+ @Override
public void onDescriptorRead(android.bluetooth.BluetoothGatt gatt,
android.bluetooth.BluetoothGattDescriptor descriptor,
int status)
@@ -714,6 +721,7 @@ public class QtBluetoothLE {
}
// API >= 33
+ @Override
public void onDescriptorRead(android.bluetooth.BluetoothGatt gatt,
android.bluetooth.BluetoothGattDescriptor descriptor,
int status,
@@ -724,6 +732,7 @@ public class QtBluetoothLE {
handleOnDescriptorRead(gatt, descriptor, status, value);
}
+ @Override
public void onDescriptorWrite(android.bluetooth.BluetoothGatt gatt,
android.bluetooth.BluetoothGattDescriptor descriptor,
int status)
@@ -732,17 +741,20 @@ public class QtBluetoothLE {
handleOnDescriptorWrite(gatt, descriptor, status);
}
//TODO currently not supported
-// public void onReliableWriteCompleted(android.bluetooth.BluetoothGatt gatt,
+// @Override
+// void onReliableWriteCompleted(android.bluetooth.BluetoothGatt gatt,
// int status) {
// System.out.println("onReliableWriteCompleted");
// }
//
+ @Override
public void onReadRemoteRssi(android.bluetooth.BluetoothGatt gatt, int rssi, int status)
{
super.onReadRemoteRssi(gatt, rssi, status);
handleOnReadRemoteRssi(gatt, rssi, status);
}
+ @Override
public void onMtuChanged(android.bluetooth.BluetoothGatt gatt, int mtu, int status)
{
super.onMtuChanged(gatt, mtu, status);
@@ -751,7 +763,7 @@ public class QtBluetoothLE {
};
// This function is called from Qt thread
- public synchronized int mtu() {
+ synchronized int mtu() {
if (mSupportedMtu == -1) {
return DEFAULT_MTU;
} else {
@@ -760,7 +772,7 @@ public class QtBluetoothLE {
}
// This function is called from Qt thread
- public synchronized boolean readRemoteRssi() {
+ synchronized boolean readRemoteRssi() {
if (mBluetoothGatt == null)
return false;
@@ -781,7 +793,7 @@ public class QtBluetoothLE {
}
// This function is called from Qt thread
- public synchronized boolean connect() {
+ synchronized boolean connect() {
BluetoothDevice mRemoteGattDevice;
if (mBluetoothAdapter == null) {
@@ -863,7 +875,7 @@ public class QtBluetoothLE {
}
// This function is called from Qt thread
- public synchronized void disconnect() {
+ synchronized void disconnect() {
if (mBluetoothGatt == null)
return;
@@ -871,7 +883,7 @@ public class QtBluetoothLE {
}
// This function is called from Qt thread
- public synchronized boolean discoverServices()
+ synchronized boolean discoverServices()
{
return mBluetoothGatt != null && mBluetoothGatt.discoverServices();
}
@@ -882,20 +894,20 @@ public class QtBluetoothLE {
}
private class GattEntry
{
- public GattEntryType type;
- public boolean valueKnown = false;
- public BluetoothGattService service = null;
- public BluetoothGattCharacteristic characteristic = null;
- public BluetoothGattDescriptor descriptor = null;
+ GattEntryType type;
+ boolean valueKnown = false;
+ BluetoothGattService service = null;
+ BluetoothGattCharacteristic characteristic = null;
+ BluetoothGattDescriptor descriptor = null;
/*
* endHandle defined for GattEntryType.Service and GattEntryType.CharacteristicValue
* If the type is service this is the value of the last Gatt entry belonging to the very
* same service. If the type is a char value it is the entries index inside
* the "entries" list.
*/
- public int endHandle = -1;
+ int endHandle = -1;
// pointer back to the handle that describes the service that this GATT entry belongs to
- public int associatedServiceHandle;
+ int associatedServiceHandle;
}
private enum IoJobType
@@ -908,10 +920,10 @@ public class QtBluetoothLE {
private class ReadWriteJob
{
- public GattEntry entry;
- public byte[] newValue;
- public int requestedWriteType;
- public IoJobType jobType;
+ GattEntry entry;
+ byte[] newValue;
+ int requestedWriteType;
+ IoJobType jobType;
}
// service uuid -> service handle mapping (there can be more than one service with same uuid)
@@ -1084,7 +1096,7 @@ public class QtBluetoothLE {
}
// This function is called from Qt thread
- public synchronized boolean discoverServiceDetails(String serviceUuid, boolean fullDiscovery)
+ synchronized boolean discoverServiceDetails(String serviceUuid, boolean fullDiscovery)
{
Log.d(TAG, "Discover service details for: " + serviceUuid + ", fullDiscovery: "
+ fullDiscovery + ", BluetoothGatt: " + (mBluetoothGatt != null));
@@ -1144,7 +1156,7 @@ public class QtBluetoothLE {
Returns the uuids of the services included by the given service. Otherwise returns null.
This function is called from Qt thread
*/
- public synchronized String includedServices(String serviceUuid)
+ synchronized String includedServices(String serviceUuid)
{
if (mBluetoothGatt == null)
return null;
@@ -1278,7 +1290,7 @@ public class QtBluetoothLE {
/* This function is called from Qt thread */
/*************************************************************/
- public synchronized boolean writeCharacteristic(int charHandle, byte[] newValue,
+ synchronized boolean writeCharacteristic(int charHandle, byte[] newValue,
int writeMode)
{
if (mBluetoothGatt == null)
@@ -1327,7 +1339,7 @@ public class QtBluetoothLE {
/* This function is called from Qt thread */
/*************************************************************/
- public synchronized boolean writeDescriptor(int descHandle, byte[] newValue)
+ synchronized boolean writeDescriptor(int descHandle, byte[] newValue)
{
if (mBluetoothGatt == null)
return false;
@@ -1363,7 +1375,7 @@ public class QtBluetoothLE {
/* This function is called from Qt thread */
/*************************************************************/
- public synchronized boolean readCharacteristic(int charHandle)
+ synchronized boolean readCharacteristic(int charHandle)
{
if (mBluetoothGatt == null)
return false;
@@ -1393,7 +1405,7 @@ public class QtBluetoothLE {
}
// This function is called from Qt thread
- public synchronized boolean readDescriptor(int descHandle)
+ synchronized boolean readDescriptor(int descHandle)
{
if (mBluetoothGatt == null)
return false;
@@ -1797,7 +1809,7 @@ public class QtBluetoothLE {
}
// This function is called from Qt thread
- public synchronized boolean requestConnectionUpdatePriority(double minimalInterval)
+ synchronized boolean requestConnectionUpdatePriority(double minimalInterval)
{
if (mBluetoothGatt == null)
return false;
@@ -1816,22 +1828,22 @@ public class QtBluetoothLE {
}
}
- public native void leConnectionStateChange(long qtObject, int wasErrorTransition, int newState);
- public native void leMtuChanged(long qtObject, int mtu);
- public native void leRemoteRssiRead(long qtObject, int rssi, boolean success);
- public native void leServicesDiscovered(long qtObject, int errorCode, String uuidList);
- public native void leServiceDetailDiscoveryFinished(long qtObject, final String serviceUuid,
+ native void leConnectionStateChange(long qtObject, int wasErrorTransition, int newState);
+ native void leMtuChanged(long qtObject, int mtu);
+ native void leRemoteRssiRead(long qtObject, int rssi, boolean success);
+ native void leServicesDiscovered(long qtObject, int errorCode, String uuidList);
+ native void leServiceDetailDiscoveryFinished(long qtObject, final String serviceUuid,
int startHandle, int endHandle);
- public native void leCharacteristicRead(long qtObject, String serviceUuid,
+ native void leCharacteristicRead(long qtObject, String serviceUuid,
int charHandle, String charUuid,
int properties, byte[] data);
- public native void leDescriptorRead(long qtObject, String serviceUuid, String charUuid,
+ native void leDescriptorRead(long qtObject, String serviceUuid, String charUuid,
int descHandle, String descUuid, byte[] data);
- public native void leCharacteristicWritten(long qtObject, int charHandle, byte[] newData,
+ native void leCharacteristicWritten(long qtObject, int charHandle, byte[] newData,
int errorCode);
- public native void leDescriptorWritten(long qtObject, int charHandle, byte[] newData,
+ native void leDescriptorWritten(long qtObject, int charHandle, byte[] newData,
int errorCode);
- public native void leCharacteristicChanged(long qtObject, int charHandle, byte[] newData);
- public native void leServiceError(long qtObject, int attributeHandle, int errorCode);
+ native void leCharacteristicChanged(long qtObject, int charHandle, byte[] newData);
+ native void leServiceError(long qtObject, int attributeHandle, int errorCode);
}
diff --git a/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothLEServer.java b/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothLEServer.java
index 94601403..ae557de6 100644
--- a/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothLEServer.java
+++ b/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothLEServer.java
@@ -33,7 +33,7 @@ import java.util.ListIterator;
import java.util.HashMap;
import java.util.UUID;
-public class QtBluetoothLEServer {
+class QtBluetoothLEServer {
private static final String TAG = "QtBluetoothGattServer";
/* Pointer to the Qt object that "owns" the Java object */
@@ -54,13 +54,13 @@ public class QtBluetoothLEServer {
private String mRemoteName = "";
// This function is called from Qt thread
- public synchronized String remoteName() {
+ synchronized String remoteName() {
return mRemoteName;
}
private String mRemoteAddress = "";
// This function is called from Qt thread
- public synchronized String remoteAddress() {
+ synchronized String remoteAddress() {
return mRemoteAddress;
}
@@ -84,12 +84,12 @@ public class QtBluetoothLEServer {
this.writes = new ArrayList<Pair<byte[], Integer>>();
}
// Returns true if this is a proper entry for given device + target
- public boolean match(BluetoothDevice device, Object target) {
+ boolean match(BluetoothDevice device, Object target) {
return remoteDevice.equals(device) && target.equals(target);
}
- public final BluetoothDevice remoteDevice; // Device that issued the writes
- public final Object target; // Characteristic or Descriptor
- public final List<Pair<byte[], Integer>> writes; // Value, offset
+ final BluetoothDevice remoteDevice; // Device that issued the writes
+ final Object target; // Characteristic or Descriptor
+ final List<Pair<byte[], Integer>> writes; // Value, offset
}
private final List<WriteEntry> mPendingPreparedWrites = new ArrayList<>();
@@ -152,7 +152,7 @@ public class QtBluetoothLEServer {
boolean isConnected = false;
}
- public void insertOrUpdate(BluetoothGattCharacteristic characteristic,
+ void insertOrUpdate(BluetoothGattCharacteristic characteristic,
BluetoothDevice device, byte[] newValue)
{
if (notificationStore.containsKey(characteristic)) {
@@ -192,7 +192,7 @@ public class QtBluetoothLEServer {
This function avoids that existing configurations are not acted
upon when the associated device is not connected.
*/
- public void markDeviceConnectivity(BluetoothDevice device, boolean isConnected)
+ void markDeviceConnectivity(BluetoothDevice device, boolean isConnected)
{
final Iterator<BluetoothGattCharacteristic> keys = notificationStore.keySet().iterator();
while (keys.hasNext()) {
@@ -247,7 +247,7 @@ public class QtBluetoothLEServer {
.fromString("00002902-0000-1000-8000-00805f9b34fb");
ClientCharacteristicManager clientCharacteristicManager = new ClientCharacteristicManager();
- public QtBluetoothLEServer(Context context)
+ QtBluetoothLEServer(Context context)
{
qtContext = context;
if (qtContext == null) {
@@ -284,7 +284,7 @@ public class QtBluetoothLEServer {
// If each variable would be protected individually, the amount of (nested) locking
// would become quite unreasonable
- public synchronized void handleOnConnectionStateChange(BluetoothDevice device,
+ synchronized void handleOnConnectionStateChange(BluetoothDevice device,
int status, int newState)
{
if (mGattServer == null) {
@@ -351,7 +351,7 @@ public class QtBluetoothLEServer {
leConnectionStateChange(qtObject, qtErrorCode, qtControllerState);
}
- public synchronized void handleOnServiceAdded(int status, BluetoothGattService service)
+ synchronized void handleOnServiceAdded(int status, BluetoothGattService service)
{
if (mGattServer == null) {
Log.w(TAG, "Ignoring service addition event, server is disconnected");
@@ -382,7 +382,7 @@ public class QtBluetoothLEServer {
}
}
- public synchronized void handleOnCharacteristicReadRequest(BluetoothDevice device,
+ synchronized void handleOnCharacteristicReadRequest(BluetoothDevice device,
int requestId, int offset,
BluetoothGattCharacteristic characteristic)
{
@@ -408,7 +408,7 @@ public class QtBluetoothLEServer {
}
}
- public synchronized void handleOnCharacteristicWriteRequest(BluetoothDevice device,
+ synchronized void handleOnCharacteristicWriteRequest(BluetoothDevice device,
int requestId,
BluetoothGattCharacteristic characteristic,
boolean preparedWrite, boolean responseNeeded,
@@ -460,7 +460,7 @@ public class QtBluetoothLEServer {
sendNotificationsOrIndications(characteristic);
}
- public synchronized void handleOnDescriptorReadRequest(BluetoothDevice device, int requestId,
+ synchronized void handleOnDescriptorReadRequest(BluetoothDevice device, int requestId,
int offset, BluetoothGattDescriptor descriptor)
{
if (mGattServer == null) {
@@ -490,7 +490,7 @@ public class QtBluetoothLEServer {
}
}
- public synchronized void handleOnDescriptorWriteRequest(BluetoothDevice device, int requestId,
+ synchronized void handleOnDescriptorWriteRequest(BluetoothDevice device, int requestId,
BluetoothGattDescriptor descriptor, boolean preparedWrite,
boolean responseNeeded, int offset, byte[] value)
{
@@ -543,7 +543,7 @@ public class QtBluetoothLEServer {
mGattServer.sendResponse(device, requestId, resultStatus, offset, value);
}
- public synchronized void handleOnExecuteWrite(BluetoothDevice device,
+ synchronized void handleOnExecuteWrite(BluetoothDevice device,
int requestId, boolean execute)
{
if (mGattServer == null) {
@@ -627,7 +627,7 @@ public class QtBluetoothLEServer {
mGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, null);
}
- public synchronized void handleOnMtuChanged(BluetoothDevice device, int mtu)
+ synchronized void handleOnMtuChanged(BluetoothDevice device, int mtu)
{
if (mSupportedMtu == mtu)
return;
@@ -706,12 +706,12 @@ public class QtBluetoothLEServer {
};
// This function is called from Qt thread
- public synchronized int mtu() {
+ synchronized int mtu() {
return mSupportedMtu;
}
// This function is called from Qt thread
- public synchronized boolean connectServer()
+ synchronized boolean connectServer()
{
if (mGattServer != null)
return true;
@@ -728,7 +728,7 @@ public class QtBluetoothLEServer {
}
// This function is called from Qt thread
- public synchronized void disconnectServer()
+ synchronized void disconnectServer()
{
if (mGattServer == null)
return;
@@ -744,7 +744,7 @@ public class QtBluetoothLEServer {
}
// This function is called from Qt thread
- public boolean startAdvertising(AdvertiseData advertiseData,
+ boolean startAdvertising(AdvertiseData advertiseData,
AdvertiseData scanResponse,
AdvertiseSettings settings)
{
@@ -775,7 +775,7 @@ public class QtBluetoothLEServer {
}
// This function is called from Qt thread
- public void stopAdvertising()
+ void stopAdvertising()
{
if (mLeAdvertiser == null)
return;
@@ -785,7 +785,7 @@ public class QtBluetoothLEServer {
}
// This function is called from Qt thread
- public synchronized void addService(BluetoothGattService service)
+ synchronized void addService(BluetoothGattService service)
{
if (!connectServer()) {
Log.w(TAG, "Server::addService: Cannot open GATT server");
@@ -854,7 +854,7 @@ public class QtBluetoothLEServer {
This function is called from the Qt thread.
*/
- public boolean writeCharacteristic(BluetoothGattService service, UUID charUuid, byte[] newValue)
+ boolean writeCharacteristic(BluetoothGattService service, UUID charUuid, byte[] newValue)
{
BluetoothGattCharacteristic foundChar = null;
List<BluetoothGattCharacteristic> charList = service.getCharacteristics();
@@ -900,7 +900,7 @@ public class QtBluetoothLEServer {
This function is called from the Qt thread.
*/
- public boolean writeDescriptor(BluetoothGattService service, UUID charUuid, UUID descUuid,
+ boolean writeDescriptor(BluetoothGattService service, UUID charUuid, UUID descUuid,
byte[] newValue)
{
BluetoothGattDescriptor foundDesc = null;
@@ -977,13 +977,13 @@ public class QtBluetoothLEServer {
}
};
- public native void leConnectionStateChange(long qtObject, int errorCode, int newState);
- public native void leMtuChanged(long qtObject, int mtu);
- public native void leServerAdvertisementError(long qtObject, int status);
- public native void leServerCharacteristicChanged(long qtObject,
+ native void leConnectionStateChange(long qtObject, int errorCode, int newState);
+ native void leMtuChanged(long qtObject, int mtu);
+ native void leServerAdvertisementError(long qtObject, int status);
+ native void leServerCharacteristicChanged(long qtObject,
BluetoothGattCharacteristic characteristic,
byte[] newValue);
- public native void leServerDescriptorWritten(long qtObject,
+ native void leServerDescriptorWritten(long qtObject,
BluetoothGattDescriptor descriptor,
byte[] newValue);
}
diff --git a/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothSocketServer.java b/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothSocketServer.java
index cc78c5d7..cc96eb31 100644
--- a/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothSocketServer.java
+++ b/src/android/bluetooth/src/org/qtproject/qt/android/bluetooth/QtBluetoothSocketServer.java
@@ -13,14 +13,14 @@ import java.io.IOException;
import java.util.UUID;
@SuppressWarnings("WeakerAccess")
-public class QtBluetoothSocketServer extends Thread
+class QtBluetoothSocketServer extends Thread
{
/* Pointer to the Qt object that "owns" the Java object */
@SuppressWarnings({"WeakerAccess", "CanBeFinal"})
long qtObject = 0;
@SuppressWarnings({"WeakerAccess", "CanBeFinal"})
- public boolean logEnabled = false;
+ boolean logEnabled = false;
@SuppressWarnings("WeakerAccess")
static Context qtContext = null;
@@ -35,13 +35,13 @@ public class QtBluetoothSocketServer extends Thread
private static final int QT_LISTEN_FAILED = 1;
private static final int QT_ACCEPT_FAILED = 2;
- public QtBluetoothSocketServer(Context context)
+ QtBluetoothSocketServer(Context context)
{
qtContext = context;
setName("QtSocketServerThread");
}
- public void setServiceDetails(String uuid, String serviceName, boolean isSecure)
+ void setServiceDetails(String uuid, String serviceName, boolean isSecure)
{
m_uuid = UUID.fromString(uuid);
m_serviceName = serviceName;
@@ -49,6 +49,7 @@ public class QtBluetoothSocketServer extends Thread
}
+ @Override
public void run()
{
BluetoothManager manager =
@@ -129,7 +130,7 @@ public class QtBluetoothSocketServer extends Thread
// If the Java thread was in the middle of the blocking accept() call, it will get
// interrupated by the close() call on the socket. After returning the run() will
// notice it has been interrupted and return from the run()
- public void close()
+ void close()
{
if (!isAlive())
return;
@@ -149,6 +150,6 @@ public class QtBluetoothSocketServer extends Thread
}
}
- public static native void errorOccurred(long qtObject, int errorCode);
- public static native void newSocket(long qtObject, BluetoothSocket socket);
+ static native void errorOccurred(long qtObject, int errorCode);
+ static native void newSocket(long qtObject, BluetoothSocket socket);
}
diff --git a/src/android/nfc/src/org/qtproject/qt/android/nfc/QtNfc.java b/src/android/nfc/src/org/qtproject/qt/android/nfc/QtNfc.java
index 9d8cae92..7753f182 100644
--- a/src/android/nfc/src/org/qtproject/qt/android/nfc/QtNfc.java
+++ b/src/android/nfc/src/org/qtproject/qt/android/nfc/QtNfc.java
@@ -17,7 +17,7 @@ import android.os.Parcelable;
import android.util.Log;
import android.content.pm.PackageManager;
-public class QtNfc
+class QtNfc
{
static private final String TAG = "QtNfc";
static private NfcAdapter m_adapter = null;
@@ -25,7 +25,7 @@ public class QtNfc
static private Context m_context = null;
static private Activity m_activity = null;
- static public void setContext(Context context)
+ static void setContext(Context context)
{
m_context = context;
if (context instanceof Activity) m_activity = (Activity) context;
@@ -52,13 +52,14 @@ public class QtNfc
flags);
}
- static public boolean startDiscovery()
+ static boolean startDiscovery()
{
if (m_adapter == null || m_activity == null
|| !m_activity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC))
return false;
m_activity.runOnUiThread(new Runnable() {
+ @Override
public void run() {
IntentFilter[] filters = new IntentFilter[3];
filters[0] = new IntentFilter();
@@ -90,13 +91,14 @@ public class QtNfc
return true;
}
- static public boolean stopDiscovery()
+ static boolean stopDiscovery()
{
if (m_adapter == null || m_activity == null
|| !m_activity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC))
return false;
m_activity.runOnUiThread(new Runnable() {
+ @Override
public void run() {
try {
m_adapter.disableForegroundDispatch(m_activity);
@@ -109,7 +111,7 @@ public class QtNfc
return true;
}
- static public boolean isEnabled()
+ static boolean isEnabled()
{
if (m_adapter == null) {
return false;
@@ -118,12 +120,12 @@ public class QtNfc
return m_adapter.isEnabled();
}
- static public boolean isSupported()
+ static boolean isSupported()
{
return (m_adapter != null);
}
- static public Intent getStartIntent()
+ static Intent getStartIntent()
{
Log.d(TAG, "getStartIntent");
if (m_activity == null) return null;
@@ -138,7 +140,7 @@ public class QtNfc
}
}
- static public Parcelable getTag(Intent intent)
+ static Parcelable getTag(Intent intent)
{
return intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
}
diff --git a/src/android/nfc/src/org/qtproject/qt/android/nfc/QtNfcBroadcastReceiver.java b/src/android/nfc/src/org/qtproject/qt/android/nfc/QtNfcBroadcastReceiver.java
index e70ec9a5..cd6b6a43 100644
--- a/src/android/nfc/src/org/qtproject/qt/android/nfc/QtNfcBroadcastReceiver.java
+++ b/src/android/nfc/src/org/qtproject/qt/android/nfc/QtNfcBroadcastReceiver.java
@@ -9,12 +9,12 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.nfc.NfcAdapter;
-public class QtNfcBroadcastReceiver extends BroadcastReceiver
+class QtNfcBroadcastReceiver extends BroadcastReceiver
{
final private long qtObject;
final private Context qtContext;
- public QtNfcBroadcastReceiver(long obj, Context context)
+ QtNfcBroadcastReceiver(long obj, Context context)
{
qtObject = obj;
qtContext = context;
@@ -22,16 +22,17 @@ public class QtNfcBroadcastReceiver extends BroadcastReceiver
qtContext.registerReceiver(this, filter);
}
- public void unregisterReceiver()
+ void unregisterReceiver()
{
qtContext.unregisterReceiver(this);
}
+ @Override
public void onReceive(Context context, Intent intent)
{
final int state = intent.getIntExtra(NfcAdapter.EXTRA_ADAPTER_STATE, NfcAdapter.STATE_OFF);
jniOnReceive(qtObject, state);
}
- public native void jniOnReceive(long qtObject, int state);
+ native void jniOnReceive(long qtObject, int state);
}
diff --git a/src/bluetooth/CMakeLists.txt b/src/bluetooth/CMakeLists.txt
index 54e7ac02..296e006c 100644
--- a/src/bluetooth/CMakeLists.txt
+++ b/src/bluetooth/CMakeLists.txt
@@ -46,7 +46,6 @@ qt_internal_add_module(Bluetooth
PRIVATE_MODULE_INTERFACE
Qt::CorePrivate
Qt::NetworkPrivate
- GENERATE_CPP_EXPORTS
)
#### Keys ignored in scope 1:.:.:bluetooth.pro:<TRUE>:
diff --git a/src/bluetooth/android/jni_android_p.h b/src/bluetooth/android/jni_android_p.h
index b94a847e..a8e98cf6 100644
--- a/src/bluetooth/android/jni_android_p.h
+++ b/src/bluetooth/android/jni_android_p.h
@@ -44,11 +44,7 @@ Q_DECLARE_JNI_CLASS(BluetoothGattCharacteristic, "android/bluetooth/BluetoothGat
Q_DECLARE_JNI_CLASS(BluetoothDevice, "android/bluetooth/BluetoothDevice")
Q_DECLARE_JNI_CLASS(IntentFilter, "android/content/IntentFilter")
Q_DECLARE_JNI_CLASS(AndroidContext, "android/content/Context")
-Q_DECLARE_JNI_CLASS(UUID, "java/util/UUID")
-Q_DECLARE_JNI_TYPE(ParcelableArray, "[Landroid/os/Parcelable;")
-Q_DECLARE_JNI_TYPE(ParcelUuidArray, "[Landroid/os/ParcelUuid;")
-Q_DECLARE_JNI_TYPE(StringArray, "[Ljava/lang/String;")
Q_DECLARE_JNI_CLASS(BluetoothManager, "android/bluetooth/BluetoothManager")
Q_DECLARE_JNI_CLASS(AdvertiseData, "android/bluetooth/le/AdvertiseData")
@@ -58,11 +54,21 @@ Q_DECLARE_JNI_CLASS(OutputStream, "java/io/OutputStream")
Q_DECLARE_JNI_CLASS(BluetoothSocket, "android/bluetooth/BluetoothSocket")
Q_DECLARE_JNI_CLASS(BroadcastReceiver, "android/content/BroadcastReceiver")
Q_DECLARE_JNI_CLASS(BluetoothClass, "android/bluetooth/BluetoothClass")
-Q_DECLARE_JNI_CLASS(Parcelable, "android/os/Parcelable")
-Q_DECLARE_JNI_CLASS(Intent, "android/content/Intent")
Q_DECLARE_JNI_CLASS(Bundle, "android/os/Bundle")
Q_DECLARE_JNI_CLASS(List, "java/util/List")
+#ifndef QT_DECLARE_JNI_CLASS_STANDARD_TYPES
+Q_DECLARE_JNI_CLASS(UUID, "java/util/UUID")
+Q_DECLARE_JNI_CLASS(String, "java/lang/String")
+Q_DECLARE_JNI_CLASS(Parcelable, "android/os/Parcelable")
+Q_DECLARE_JNI_CLASS(Intent, "android/content/Intent")
+#endif
+
+namespace QtJniTypes {
+using ParcelableArray = QJniArray<Parcelable>;
+using ParcelUuidArray = QJniArray<ParcelUuid>;
+}
+
// QLowEnergyHandle is a quint16, ensure it is interpreted as jint
template<>
constexpr auto QtJniTypes::Traits<QLowEnergyHandle>::signature()
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
index 298f720c..b56ff7e2 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
@@ -115,6 +115,7 @@ public:
}
void init()
{
+ m_watcher.AllowExtendedAdvertisements(true);
m_watcher.ScanningMode(BluetoothLEScanningMode::Active);
}
void start() {
diff --git a/src/bluetooth/qbluetoothlocaldevice_android.cpp b/src/bluetooth/qbluetoothlocaldevice_android.cpp
index 9dffeb8e..454aa415 100644
--- a/src/bluetooth/qbluetoothlocaldevice_android.cpp
+++ b/src/bluetooth/qbluetoothlocaldevice_android.cpp
@@ -388,24 +388,16 @@ QList<QBluetoothAddress> QBluetoothLocalDevice::connectedDevices() const
* returns a few connections of common profiles. The returned list is not complete either
* but at least it can complement our already detected connections.
*/
- QJniObject connectedDevices = QJniObject::callStaticMethod<QtJniTypes::StringArray>(
- QtJniTypes::Traits<QtJniTypes::QtBtBroadcastReceiver>::className(), "getConnectedDevices");
+ using namespace QtJniTypes;
- if (!connectedDevices.isValid())
- return d_ptr->connectedDevices;
+ const auto connectedDevices = QtBtBroadcastReceiver::callStaticMethod<String[]>("getConnectedDevices");
- jobjectArray connectedDevicesArray = connectedDevices.object<jobjectArray>();
- if (!connectedDevicesArray)
+ if (!connectedDevices.isValid())
return d_ptr->connectedDevices;
- QJniEnvironment env;
QList<QBluetoothAddress> knownAddresses = d_ptr->connectedDevices;
- QJniObject p;
-
- jint size = env->GetArrayLength(connectedDevicesArray);
- for (int i = 0; i < size; i++) {
- p = env->GetObjectArrayElement(connectedDevicesArray, i);
- QBluetoothAddress address(p.toString());
+ for (const auto &device : connectedDevices) {
+ QBluetoothAddress address(device.toString());
if (!address.isNull() && !knownAddresses.contains(address))
knownAddresses.append(address);
}
diff --git a/src/nfc/CMakeLists.txt b/src/nfc/CMakeLists.txt
index de2b927f..0c7ba00b 100644
--- a/src/nfc/CMakeLists.txt
+++ b/src/nfc/CMakeLists.txt
@@ -20,7 +20,6 @@ qt_internal_add_module(Nfc
QT_NO_CONTEXTLESS_CONNECT
PUBLIC_LIBRARIES
Qt::Core
- GENERATE_CPP_EXPORTS
)
## Scopes:
diff --git a/src/nfc/android/androidjninfc.cpp b/src/nfc/android/androidjninfc.cpp
index 3f226985..3936ca07 100644
--- a/src/nfc/android/androidjninfc.cpp
+++ b/src/nfc/android/androidjninfc.cpp
@@ -9,39 +9,32 @@ namespace QtNfc {
bool startDiscovery()
{
- return QJniObject::callStaticMethod<jboolean>(
- QtJniTypes::Traits<QtJniTypes::QtNfc>::className(), "startDiscovery");
+ return QtJniTypes::QtNfc::callStaticMethod<jboolean>("startDiscovery");
}
bool isEnabled()
{
- return QJniObject::callStaticMethod<jboolean>(
- QtJniTypes::Traits<QtJniTypes::QtNfc>::className(), "isEnabled");
+ return QtJniTypes::QtNfc::callStaticMethod<jboolean>("isEnabled");
}
bool isSupported()
{
- return QJniObject::callStaticMethod<jboolean>(
- QtJniTypes::Traits<QtJniTypes::QtNfc>::className(), "isSupported");
+ return QtJniTypes::QtNfc::callStaticMethod<jboolean>("isSupported");
}
bool stopDiscovery()
{
- return QJniObject::callStaticMethod<jboolean>(
- QtJniTypes::Traits<QtJniTypes::QtNfc>::className(), "stopDiscovery");
+ return QtJniTypes::QtNfc::callStaticMethod<jboolean>("stopDiscovery");
}
-QJniObject getStartIntent()
+QtJniTypes::Intent getStartIntent()
{
- return QJniObject::callStaticMethod<QtJniTypes::Intent>(
- QtJniTypes::Traits<QtJniTypes::QtNfc>::className(), "getStartIntent");
+ return QtJniTypes::QtNfc::callStaticMethod<QtJniTypes::Intent>("getStartIntent");
}
-QJniObject getTag(const QJniObject &intent)
+QtJniTypes::Parcelable getTag(const QtJniTypes::Intent &intent)
{
- return QJniObject::callStaticMethod<QtJniTypes::Parcellable>(
- QtJniTypes::Traits<QtJniTypes::QtNfc>::className(), "getTag",
- intent.object<QtJniTypes::Intent>());
+ return QtJniTypes::QtNfc::callStaticMethod<QtJniTypes::Parcelable>("getTag", intent);
}
} // namespace QtNfc
diff --git a/src/nfc/android/androidjninfc_p.h b/src/nfc/android/androidjninfc_p.h
index 476e0519..cfbbc007 100644
--- a/src/nfc/android/androidjninfc_p.h
+++ b/src/nfc/android/androidjninfc_p.h
@@ -24,19 +24,21 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_JNI_CLASS(QtNfc, "org/qtproject/qt/android/nfc/QtNfc")
Q_DECLARE_JNI_CLASS(QtNfcBroadcastReceiver, "org/qtproject/qt/android/nfc/QtNfcBroadcastReceiver")
-Q_DECLARE_JNI_TYPE(StringArray, "[Ljava/lang/String;")
+#ifndef QT_DECLARE_JNI_CLASS_STANDARD_TYPES
+Q_DECLARE_JNI_CLASS(String, "java/lang/String")
Q_DECLARE_JNI_CLASS(Intent, "android/content/Intent")
-Q_DECLARE_JNI_CLASS(Parcellable, "android/os/Parcelable")
+Q_DECLARE_JNI_CLASS(Parcelable, "android/os/Parcelable")
+#endif
Q_DECLARE_JNI_CLASS(NdefMessage, "android/nfc/NdefMessage")
namespace QtNfc {
bool startDiscovery();
bool stopDiscovery();
-QJniObject getStartIntent();
+QtJniTypes::Intent getStartIntent();
bool isEnabled();
bool isSupported();
-QJniObject getTag(const QJniObject &intent);
+QtJniTypes::Parcelable getTag(const QtJniTypes::Intent &intent);
} // namespace QtNfc
QT_END_NAMESPACE
diff --git a/src/nfc/android/androidmainnewintentlistener.cpp b/src/nfc/android/androidmainnewintentlistener.cpp
index cebf92da..e902a63c 100644
--- a/src/nfc/android/androidmainnewintentlistener.cpp
+++ b/src/nfc/android/androidmainnewintentlistener.cpp
@@ -21,16 +21,16 @@ QMainNfcNewIntentListener::~QMainNfcNewIntentListener()
QtAndroidPrivate::unregisterResumePauseListener(this);
}
-bool QMainNfcNewIntentListener::handleNewIntent(JNIEnv * /*env*/, jobject intent)
+bool QMainNfcNewIntentListener::handleNewIntent(JNIEnv * /*env*/, jobject intentObject)
{
+ QtJniTypes::Intent intent = intentObject;
// Only intents with a tag are relevant
if (!QtNfc::getTag(intent).isValid())
return false;
listenersLock.lockForRead();
- for (auto listener : std::as_const(listeners)) {
- listener->newIntent(QJniObject(intent));
- }
+ for (auto listener : std::as_const(listeners))
+ listener->newIntent(intent);
listenersLock.unlock();
return true;
}
@@ -39,10 +39,9 @@ bool QMainNfcNewIntentListener::registerListener(QAndroidNfcListenerInterface *l
{
static bool firstListener = true;
if (firstListener) {
- QJniObject intent = QtNfc::getStartIntent();
- if (intent.isValid()) {
+ QtJniTypes::Intent intent = QtNfc::getStartIntent();
+ if (intent.isValid())
listener->newIntent(intent);
- }
paused = static_cast<QGuiApplication*>(QGuiApplication::instance())->applicationState() != Qt::ApplicationActive;
}
firstListener = false;
diff --git a/src/nfc/qnearfieldmanager_android.cpp b/src/nfc/qnearfieldmanager_android.cpp
index 63cc8472..81b291f5 100644
--- a/src/nfc/qnearfieldmanager_android.cpp
+++ b/src/nfc/qnearfieldmanager_android.cpp
@@ -105,7 +105,11 @@ QByteArray QNearFieldManagerPrivateImpl::getUid(const QJniObject &intent)
return QByteArray();
QJniObject tag = QtNfc::getTag(intent);
- return getUidforTag(tag);
+ if (!tag.isValid())
+ return QByteArray();
+
+ QJniArray tagId = tag.callMethod<jbyte[]>("getId");
+ return tagId.toContainer();
}
void QNearFieldManagerPrivateImpl::onTargetDiscovered(QJniObject intent)
@@ -136,18 +140,4 @@ void QNearFieldManagerPrivateImpl::onTargetDestroyed(const QByteArray &uid)
detectedTargets.remove(uid);
}
-QByteArray QNearFieldManagerPrivateImpl::getUidforTag(const QJniObject &tag)
-{
- if (!tag.isValid())
- return QByteArray();
-
- QJniEnvironment env;
- QJniObject tagId = tag.callMethod<jbyteArray>("getId");
- QByteArray uid;
- jsize len = env->GetArrayLength(tagId.object<jbyteArray>());
- uid.resize(len);
- env->GetByteArrayRegion(tagId.object<jbyteArray>(), 0, len, reinterpret_cast<jbyte*>(uid.data()));
- return uid;
-}
-
QT_END_NAMESPACE
diff --git a/src/nfc/qnearfieldmanager_android_p.h b/src/nfc/qnearfieldmanager_android_p.h
index 76a5fd20..ef47ec3d 100644
--- a/src/nfc/qnearfieldmanager_android_p.h
+++ b/src/nfc/qnearfieldmanager_android_p.h
@@ -42,9 +42,6 @@ public:
void newIntent(QJniObject intent) override;
QByteArray getUid(const QJniObject &intent);
-protected:
- static QByteArray getUidforTag(const QJniObject &tag);
-
private:
bool detecting;
QNearFieldTarget::AccessMethod requestedMethod;
diff --git a/src/nfc/qnearfieldtarget.cpp b/src/nfc/qnearfieldtarget.cpp
index dbcca2bd..7ba8f4d7 100644
--- a/src/nfc/qnearfieldtarget.cpp
+++ b/src/nfc/qnearfieldtarget.cpp
@@ -90,6 +90,8 @@ QT_IMPL_METATYPE_EXTERN_TAGGED(QNearFieldTarget::RequestId, QNearFieldTarget__Re
\value CommandError Failed to send a command to the target.
\value TimeoutError The request could not be completed within the time
specified in waitForRequestCompleted().
+ \value UnsupportedTargetError The target used is unsupported. As example this can occur on missing
+ required entitlement and/or privacy settings from the client app.
*/
/*!
diff --git a/src/nfc/qnearfieldtarget.h b/src/nfc/qnearfieldtarget.h
index 0d67011d..711edabf 100644
--- a/src/nfc/qnearfieldtarget.h
+++ b/src/nfc/qnearfieldtarget.h
@@ -59,7 +59,8 @@ public:
NdefReadError,
NdefWriteError,
CommandError,
- TimeoutError
+ TimeoutError,
+ UnsupportedTargetError,
};
Q_ENUM(Error)
diff --git a/src/nfc/qnearfieldtarget_android.cpp b/src/nfc/qnearfieldtarget_android.cpp
index c7f842ae..0dcd602b 100644
--- a/src/nfc/qnearfieldtarget_android.cpp
+++ b/src/nfc/qnearfieldtarget_android.cpp
@@ -120,8 +120,8 @@ QNearFieldTarget::RequestId QNearFieldTargetPrivateImpl::readNdefMessages()
}
// Convert to byte array
- QJniObject ndefMessageBA = ndefMessage.callMethod<jbyteArray>("toByteArray");
- QByteArray ndefMessageQBA = jbyteArrayToQByteArray(ndefMessageBA.object<jbyteArray>());
+ QJniArray ndefMessageBA = ndefMessage.callMethod<jbyte[]>("toByteArray");
+ QByteArray ndefMessageQBA = ndefMessageBA.toContainer();
// Sending QNdefMessage, requestCompleted and exit.
QNdefMessage qNdefMessage = QNdefMessage::fromByteArray(ndefMessageQBA);
@@ -183,13 +183,8 @@ QNearFieldTarget::RequestId QNearFieldTargetPrivateImpl::sendCommand(const QByte
return requestId;
}
- // Making QByteArray
- QByteArray ba(command);
- jbyteArray jba = env->NewByteArray(ba.size());
- env->SetByteArrayRegion(jba, 0, ba.size(), reinterpret_cast<jbyte*>(ba.data()));
-
// Writing
- QJniObject myNewVal = tagTech.callMethod<jbyteArray>("transceive", jba);
+ QJniArray myNewVal = tagTech.callMethod<jbyte[]>("transceive", QJniArray(command));
if (!myNewVal.isValid()) {
// Some devices (Samsung, Huawei) throw an exception when the card is lost:
// "android.nfc.TagLostException: Tag was lost". But there seems to be a bug that
@@ -200,8 +195,7 @@ QNearFieldTarget::RequestId QNearFieldTargetPrivateImpl::sendCommand(const QByte
reportError(QNearFieldTarget::CommandError, requestId);
return requestId;
}
- QByteArray result = jbyteArrayToQByteArray(myNewVal.object<jbyteArray>());
- env->DeleteLocalRef(jba);
+ QByteArray result = myNewVal.toContainer();
setResponseForRequest(requestId, result, false);
@@ -242,9 +236,8 @@ QNearFieldTarget::RequestId QNearFieldTargetPrivateImpl::writeNdefMessages(const
// Making NdefMessage object
const QNdefMessage &message = messages.first();
QByteArray ba = message.toByteArray();
- QJniObject jba = env->NewByteArray(ba.size());
- env->SetByteArrayRegion(jba.object<jbyteArray>(), 0, ba.size(), reinterpret_cast<jbyte*>(ba.data()));
- QJniObject jmessage = QJniObject::construct<QtJniTypes::NdefMessage>(jba.object<jbyteArray>());
+ QJniArray jba(ba);
+ QtJniTypes::NdefMessage jmessage(jba);
if (!jmessage.isValid()) {
reportError(QNearFieldTarget::UnknownError, requestId);
return requestId;
@@ -332,7 +325,7 @@ void QNearFieldTargetPrivateImpl::updateTechList()
QJniObject tag = QtNfc::getTag(targetIntent);
Q_ASSERT_X(tag.isValid(), "updateTechList", "could not get Tag object");
- QJniObject techListArray = tag.callMethod<QtJniTypes::StringArray>("getTechList");
+ QJniArray techListArray = tag.callMethod<QtJniTypes::String[]>("getTechList");
if (!techListArray.isValid()) {
handleTargetLost();
return;
@@ -340,11 +333,8 @@ void QNearFieldTargetPrivateImpl::updateTechList()
// Converting tech list array to QStringList.
techList.clear();
- jsize techCount = env->GetArrayLength(techListArray.object<jobjectArray>());
- for (jsize i = 0; i < techCount; ++i) {
- QJniObject tech = env->GetObjectArrayElement(techListArray.object<jobjectArray>(), i);
- techList.append(tech.callMethod<jstring>("toString").toString());
- }
+ for (const auto &tech : techListArray)
+ techList.append(tech.toString());
}
void QNearFieldTargetPrivateImpl::updateType()
@@ -376,8 +366,8 @@ QNearFieldTarget::Type QNearFieldTargetPrivateImpl::getTagType() const
// Checking ATQA/SENS_RES
// xxx0 0000 xxxx xxxx: Identifies tag Type 1 platform
QJniObject nfca = getTagTechnology(NFCATECHNOLOGY);
- QJniObject atqaBA = nfca.callMethod<jbyteArray>("getAtqa");
- QByteArray atqaQBA = jbyteArrayToQByteArray(atqaBA.object<jbyteArray>());
+ QJniArray atqaBA = nfca.callMethod<jbyte[]>("getAtqa");
+ QByteArray atqaQBA = atqaBA.toContainer();
if (atqaQBA.isEmpty())
return QNearFieldTarget::ProprietaryTag;
if ((atqaQBA[0] & 0x1F) == 0x00)
@@ -482,13 +472,3 @@ bool QNearFieldTargetPrivateImpl::setCommandTimeout(int timeout)
env->CallVoidMethod(tagTech.object(), methodId, timeout);
return methodId && !env.checkAndClearExceptions();
}
-
-QByteArray QNearFieldTargetPrivateImpl::jbyteArrayToQByteArray(const jbyteArray &byteArray) const
-{
- QJniEnvironment env;
- QByteArray resultArray;
- jsize len = env->GetArrayLength(byteArray);
- resultArray.resize(len);
- env->GetByteArrayRegion(byteArray, 0, len, reinterpret_cast<jbyte*>(resultArray.data()));
- return resultArray;
-}
diff --git a/src/nfc/qnearfieldtarget_android_p.h b/src/nfc/qnearfieldtarget_android_p.h
index bdfe6b19..ff67f4ec 100644
--- a/src/nfc/qnearfieldtarget_android_p.h
+++ b/src/nfc/qnearfieldtarget_android_p.h
@@ -70,7 +70,6 @@ protected:
bool setTagTechnology(const QStringList &technologies);
bool connect();
bool setCommandTimeout(int timeout);
- QByteArray jbyteArrayToQByteArray(const jbyteArray &byteArray) const;
protected:
QJniObject targetIntent;
diff --git a/src/nfc/qnearfieldtarget_ios.mm b/src/nfc/qnearfieldtarget_ios.mm
index b058ad75..f49ad4ac 100644
--- a/src/nfc/qnearfieldtarget_ios.mm
+++ b/src/nfc/qnearfieldtarget_ios.mm
@@ -270,15 +270,19 @@ bool QNearFieldTargetPrivateImpl::connect()
id<NFCTag> tag = static_cast<id<NFCTag>>(nfcTag.get());
NFCTagReaderSession* session = tag.session;
[session connectToTag: tag completionHandler: ^(NSError* error){
- const bool success = error == nil;
- QMetaObject::invokeMethod(this, [this, success] {
+ const int errorCode = error == nil ? -1 : error.code;
+ QMetaObject::invokeMethod(this, [this, errorCode] {
requestInProgress = QNearFieldTarget::RequestId();
- if (success) {
+ if (errorCode == -1) {
connected = true;
onExecuteRequest();
} else {
const auto requestId = queue.dequeue().first;
- reportError(QNearFieldTarget::ConnectionError, requestId);
+ reportError(
+ errorCode == NFCReaderError::NFCReaderErrorSecurityViolation
+ ? QNearFieldTarget::UnsupportedTargetError
+ : QNearFieldTarget::ConnectionError,
+ requestId);
invalidate();
}
});