From b074cb8a42d9f4ea83806617b5a58d06b68739c7 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Thu, 20 Aug 2015 08:34:30 +0000 Subject: bluez: peername: find a device before creating it. To enable reading peername for known devices even if org.bluez.Adapter.CreateDevice has security restrictions, call org.bluez.Adapter.FindDevice first and CreateDevice only if the device isn't already known. The change is needed due to runtime security checks on Jolla devices, but reordering the calls does no harm when used with upstream bluetoothd. Change-Id: I4a86840487a8b4c90759044b7c995815c77a7609 Task-number: MER#1225 Done-by: Hannu Mallat Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothsocket_bluez.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/bluetooth/qbluetoothsocket_bluez.cpp b/src/bluetooth/qbluetoothsocket_bluez.cpp index 51bc5179..6947e9d0 100644 --- a/src/bluetooth/qbluetoothsocket_bluez.cpp +++ b/src/bluetooth/qbluetoothsocket_bluez.cpp @@ -407,13 +407,13 @@ QString QBluetoothSocketPrivate::peerName() const OrgBluezAdapterInterface adapter(QStringLiteral("org.bluez"), reply.value().path(), QDBusConnection::systemBus()); - QDBusPendingReply deviceObjectPath = adapter.CreateDevice(peerAddress); + QDBusPendingReply deviceObjectPath = adapter.FindDevice(peerAddress); deviceObjectPath.waitForFinished(); if (deviceObjectPath.isError()) { - if (deviceObjectPath.error().name() != QStringLiteral("org.bluez.Error.AlreadyExists")) + if (deviceObjectPath.error().name() != QStringLiteral("org.bluez.Error.DoesNotExist")) return QString(); - deviceObjectPath = adapter.FindDevice(peerAddress); + deviceObjectPath = adapter.CreateDevice(peerAddress); deviceObjectPath.waitForFinished(); if (deviceObjectPath.isError()) return QString(); -- cgit v1.2.3