Fix : device_get_ida is failed 67/186667/1
authorSeungyoun Ju <sy39.ju@samsung.com>
Mon, 13 Aug 2018 08:34:18 +0000 (17:34 +0900)
committerSeungyoun Ju <sy39.ju@samsung.com>
Mon, 13 Aug 2018 08:42:46 +0000 (17:42 +0900)
[Problem] device_get_ida returns unsupported error code for paired RPA device
[Cause & Measure] Paired RPA device's bdaddr type can be public because
 device.bdaddr has identity address. But old condition assumes that bdaddr
 type should be random. So unsupported error code is returned. This fix
 checks each case and returns proper error codd or result.

Change-Id: I435a354d956a6208129e83cbad32a0b594aec39a

src/device.c

index 363ce9f..1a9181c 100644 (file)
@@ -4190,21 +4190,30 @@ static DBusMessage *device_get_ida(DBusConnection *conn, DBusMessage *msg,
        if (device == NULL)
                return btd_error_invalid_args(msg);
 
-       if (!device->le)
-               return btd_error_not_supported(msg);
-
-       if (device->bdaddr_type != BDADDR_LE_RANDOM)
+       if (!device->le) {
+               error("It doesn't support LE");
                return btd_error_not_supported(msg);
+       }
 
        if (device->rpa) {
+               // There is the first RPA. So it's paired device.
                if (device->bredr)
                        ba2str(device->rpa, device_idaddr);
                else
                        ba2str(&device->bdaddr, device_idaddr);
-       } else if ((device->bdaddr.b[5] >> 6) == 0x01)
+       } else if (device->bdaddr_type != BDADDR_LE_RANDOM) {
+               // device->bdaddr is identity address.
+               ba2str(&device->bdaddr, device_idaddr);
+       } else if ((device->bdaddr.b[5] >> 6) == 0x01) {
+               // RPA but it's not paired
                return btd_error_does_not_exist(msg);
-       else
+       } else if ((device->bdaddr.b[5] >> 6) == 0x03) {
+               // Static Random address
+               ba2str(&device->bdaddr, device_idaddr);
+       } else {
+               // Non-RPA case
                return btd_error_not_supported(msg);
+       }
 
        reply = dbus_message_new_method_return(msg);
        if (!reply)