Closed Bug 782588 Opened 13 years ago Closed 13 years ago

[b2g-bluetooth] mozBluetooth is not a singleton

Categories

(Core :: DOM: Device Interfaces, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla18

People

(Reporter: jj.evelyn, Assigned: bent.mozilla)

References

Details

(Whiteboard: [LOE:M])

Attachments

(1 file)

In System app, if we call mozBluetooth.setEnabled(true), mozBluetooth.enabled will be true in nsIDOMDOMRequest onsuccess callback, but mozBluetooth.enabled won't be changed (still false) on Settings app at the moment.
Assignee: nobody → echou
Currently, system and settings are two applications which have called window.navigator.mozBluetooth.setEnabled() to toggle Bluetooth. However, because they are different 'window' object, so they will create different BluetoothManager object. That's why the value of window.navigator.mozBluetooth.enabled in system is not the same as in settings.
The problem with "enabled" is that it's the only variable we work with that's not backed by the actual operating system (in this case, bluez/dbus). In every other case, any time we change a property, it's send to the system via a dbus call, and relayed back to us via a dbus signal. Since ALL objects on all windows are registered for the signal, they all get updated. There's a couple of things we could do here. Easiest would be to stop caching the enabled value and ALWAYS call bluedroid's "isEnabled" function (name may actually be different but you get the idea). We could move to watching another DBus variable for enabled (I'm all for validity via "do we have any adapters available" by checking the DBus Manager object's ListAdapters function, as that also fixes bug 764559).
I'll implement choice one first, then I'll try to figure out if there's any other solutions for bug 764559.
Whiteboard: [LOE:M]
I've got this Eric!
Assignee: echou → bent.mozilla
(In reply to ben turner [:bent] from comment #4) > I've got this Eric! No problem, thanks! :D
Attached patch Patch, v1Splinter Review
Ok, this makes gaia tip work like it's supposed to (in-process). This patch does a few things: 1. Loads the bluetooth service at startup. It reads the settings to see if bluetooth is enabled and then starts the firmware load if it is. 2. Makes the bluetooth service watch for the settings changes to enable or disable bluetooth rather than each individual manager object. Notifies all live managers when the enabled/disabled value changes successfully so that they can fire events. 3. Moves the IsEnabled logic into the service so that managers can't get out of sync. There's a little cleanup along the way but nothing too egregious (I hope).
Attachment #658761 - Flags: review?(kyle)
Comment on attachment 658761 [details] [diff] [review] Patch, v1 Oh, and it fixes some shutdown ordering and safety problems that I found along the way.
Attachment #658761 - Flags: review?(kyle) → review+
/builds/slave/m-in-ics-armv7a-gecko-dbg/build/dom/bluetooth/BluetoothService.cpp:289: error: 'class nsISettingsService' has no member named 'GetLock' Hoisted by your own petard! :)
Aaaand there was a missing debug-only include in the gonk stuff. Grumble. https://hg.mozilla.org/integration/mozilla-inbound/rev/de6286cb4539
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla18
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: