Closed Bug 791650 Opened 7 years ago Closed 7 years ago

[b2g-bluetooth] 'Connected' attribute in device should a 2-byte array

Categories

(Core :: DOM: Device Interfaces, defect)

ARM
Gonk (Firefox OS)
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla18

People

(Reporter: gyeh, Assigned: gyeh)

Details

(Whiteboard: [LOE:S])

Attachments

(1 file, 3 obsolete files)

The BlueZ has been updated last month and the 'Connected' attribute in device is changed into an 2-byte array, instead of a boolean value. Please refer to the log under B2G/external/bluetooth/bluez.

The value of first byte is 0 when the device is disconnected and is 1 when the device is connected. The second byte is reserved for disconnection reason.
Whiteboard: [LOE:S]
(In reply to Gina Yeh from comment #0)
> The BlueZ has been updated last month and the 'Connected' attribute in
> device is changed into an 2-byte array, instead of a boolean value. Please
> refer to the log under B2G/external/bluetooth/bluez.
> 
> The value of first byte is 0 when the device is disconnected and is 1 when
> the device is connected. The second byte is reserved for disconnection
> reason.

Add more information here. 

Today we found that the process of GetPairedDevices did not fire req.onsuccess(), so gaia couldn't get correct device objects, and that's what this issue is about.

When configuring B2G for otoro, the default remote repo of BlueZ is not AOSP but CodeAurora. There is a revision of device.c of BlueZ in August, and it changed the type of property "Connected" from boolean to a 2-byte array, like Gina mentioned above. So we either not to pull code from CodeAurora or revise for it.

This "Connected" property represents low-level ACL connection. Currently, we don't really care about the reason why connection lost.
Comment on attachment 661758 [details] [diff] [review]
v1: 'Connected' attribute in device should a 2-byte array

Review of attachment 661758 [details] [diff] [review]:
-----------------------------------------------------------------

Ok, pretty obvious why we need this, but landing it irrevocably breaks desktop. Do we possibly want platform guards here, i.e. check for MOZ_WIDGET_GONK to use array, otherwise keep it a boolean?

::: dom/bluetooth/BluetoothDevice.cpp
@@ +115,5 @@
>    } else if (name.EqualsLiteral("Icon")) {
>      mIcon = value.get_nsString();
>    } else if (name.EqualsLiteral("Connected")) {
> +    InfallibleTArray<nsString> arr = value.get_ArrayOfnsString();
> +    mConnected = arr[0][0] - '0';

== '1' instead of - '0', easier to understand among other things.
Attachment #661758 - Flags: review?(kyle)
This patch follows Comment 3.

MOZ_WIDGET_GONK is checked for using array for 'Connected' attribute. Otherwise, a boolean value is expected.
Attachment #661758 - Attachment is obsolete: true
Attachment #662079 - Flags: review?(kyle)
Add uint8_t[] in BluetoothValue for byte array.
Attachment #662079 - Attachment is obsolete: true
Attachment #662079 - Flags: review?(kyle)
Attachment #662105 - Flags: review?(kyle)
Comment on attachment 662105 [details] [diff] [review]
v3: 'Connected' attribute in device should a 2-byte array

Review of attachment 662105 [details] [diff] [review]:
-----------------------------------------------------------------

Awesome. Looks good, and should keep us safe on both platforms.

::: dom/bluetooth/BluetoothDevice.cpp
@@ +116,5 @@
>      mIcon = value.get_nsString();
>    } else if (name.EqualsLiteral("Connected")) {
> +#ifdef MOZ_WIDGET_GONK
> +    // Connected is an 2-byte array
> +    // arr[0]: boolean value, true means connected, flase means disconnected

super-nit: false
Attachment #662105 - Flags: review?(kyle) → review+
https://hg.mozilla.org/mozilla-central/rev/c9c8d79d3419
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla18
You need to log in before you can comment on or make changes to this bug.