diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2014-11-26 14:42:16 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2014-12-01 11:08:44 +0100 |
commit | ae3847db3a4cb17113372cb59955bdaffcec1bea (patch) | |
tree | c6d891274c34f765229c0cc59dfe168a1e770165 /src/bluetooth/qlowenergycontroller_android.cpp | |
parent | 68332a47fbcc124efedf73b106b7e06bfacd65fd (diff) |
Android: Implements QLEService::includedServices() and type()
Unfortunately it is not possible to say whether a service is
primary or secondary on Android. The platform doesn't expose this
information.
Change-Id: I9b0aad191308120d2d1992a5e7736b985a375e30
Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/bluetooth/qlowenergycontroller_android.cpp')
-rw-r--r-- | src/bluetooth/qlowenergycontroller_android.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/bluetooth/qlowenergycontroller_android.cpp b/src/bluetooth/qlowenergycontroller_android.cpp index 16298c96..25bd35d7 100644 --- a/src/bluetooth/qlowenergycontroller_android.cpp +++ b/src/bluetooth/qlowenergycontroller_android.cpp @@ -321,6 +321,32 @@ void QLowEnergyControllerPrivate::serviceDetailsDiscoveryFinished( pointer->startHandle = startHandle; pointer->endHandle = endHandle; + if (hub && hub->javaObject().isValid()) { + QAndroidJniObject uuid = QAndroidJniObject::fromString(serviceUuid); + QAndroidJniObject javaIncludes = hub->javaObject().callObjectMethod( + "includedServices", + "(Ljava/lang/String;)Ljava/lang/String;", + uuid.object<jstring>()); + if (javaIncludes.isValid()) { + const QStringList list = javaIncludes.toString() + .split(QStringLiteral(" "), + QString::SkipEmptyParts); + foreach (const QString &entry, list) { + const QBluetoothUuid service(entry); + if (service.isNull()) + return; + + pointer->includedServices.append(service); + + // update the type of the included service + QSharedPointer<QLowEnergyServicePrivate> otherService = + serviceList.value(service); + if (!otherService.isNull()) + otherService->type |= QLowEnergyService::IncludedService; + } + } + } + qCDebug(QT_BT_ANDROID) << "Service" << serviceUuid << "discovered (start:" << startHandle << "end:" << endHandle << ")" << pointer.data(); |