blob: 10194ea4b85caa7ffaa04c68847c7067252f56c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// Copyright (C) 2023 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
package org.qtproject.qt.android.bluetooth;
import android.bluetooth.BluetoothGattDescriptor;
import android.os.Build;
import java.util.UUID;
public class QtBluetoothGattDescriptor extends BluetoothGattDescriptor {
public QtBluetoothGattDescriptor(UUID uuid, int permissions) {
super(uuid, permissions);
}
// Starting from API 33 Android Bluetooth deprecates descriptor local value caching by
// deprecating the getValue() and setValue() accessors. For peripheral role we store the value
// locally in the descriptor 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) {
if (Build.VERSION.SDK_INT >= 33) {
m_localValue = value;
return true;
} else {
return setValue(value);
}
}
public byte[] getLocalValue()
{
if (Build.VERSION.SDK_INT >= 33)
return m_localValue;
else
return getValue();
}
private byte[] m_localValue = null;
}
|