|BluetoothServiceBluedroid::StopInternal| stores pointers to Bluetooth
managers in a static array. This is only filled on the first call, but
pointers change when re-enabling Bluetooth.
This patch changes the code to use a non-static array, so pointers to
Bluetooth managers are looked-up on each call to the method.
With this patch, |BluetoothSocket| cleans up its internal state
whenever a connection gets closed, either intentionally or from
an error. The socket can then be reused for a new connection.
If we try to destruct an open Bluetooth socket, we'd probably
leak the file descriptor or transition into an undefined state.
The destructor now asserts that the socket is closed.
|BluetoothSocket| currently stores the pointer to the socket interface
in a global static location. This pointer can become invalid if the
Bluetooth module get's disabled. Enabling Bluetooth again and calling
the socket interface would execute on undefined state. The current
implementation of the Bluedroid backend keeps the interface pointers
valid, so this problem doesn't happen in practice. It's still a bug,
though.
This patch changes |BluetoothSocket| to store the socket-interface
pointer internally. So it will acquire a new pointer for each socket.
The new method |Accept| of |BluetoothSocket| encapsulates the code
for accepting from a passive socket. Having this method will allow
for storing the socket interface in |BluetoothSocket| itself.
The current Bluetooth profile managers remove themselves from a number
of observer lists in their destructors. But |nsIObserverService| keeps
it's own reference to the managers, so the destructors never run. Con-
sequently the Bluetooth module nevers cleans up correctly.
This patch adds an explicit uninit method to each profile manager. It
removes the manager from the observer lists.
The use is init and deinit methods is currently inconsistent among
Bluetooth profile managers. This patch unifies all these methods and
integrates them into the Bluetooth service. Instances of the manager
classes are now unref'ed during Bluetooth shutdown.
In general, using an AutoJSAPI inited with an object is NOT the same as using
AutoSafeJSContext (or AutoJSAPI inited without an object) and then entering the
compartment of the object: the former will report exceptions to the global of
the object as it comes off the stack, while the latter will not. This only
really matters if we have an object from a window or worker global and hence
might fire error events, or report internal stuff to the web console.
The changes to initing with an object made in this bug are OK for the following
reasons:
1) dom/base/Console.cpp: Always clears its exception before coming off the stack.
2) dom/base/nsDOMClassInfo.cpp: Inits with a non-web global.
3) dom/base/nsFrameMessageManager.cpp: Inits with a non-web global.
4) dom/media/MediaPermissionGonk.cpp: We probably want the caller to notice if
anything here throws.
5) dom/xbl/nsXBLPrototypeBinding.cpp: Inits with a non-web global.
6) dom/xul/nsXULElement.cpp: Inits with a non-web global.
7) extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp: Inits with a non-web global.
8) ipc/testshell/XPCShellEnvironment.cpp: Inits with a non-web global.
The Bluetooth Opp manager requires the service channel of the remote
service to connect successfully. If the service channel isn't known,
it sends an SDP update request to get the value from the remote device.
The current code will still try to connect with an invalid service
channel. This patch fixes the issue by returning early after sending
the SDP update request.
Bluetooth's UUID arrays are sorted and stripped from duplicates. This code is
now executed in the client process. This reduces the amount of privilegued
code and accounts the required computation time to the process that actually
uses it.
The change also makes the IPDL interface a bit less fragile, as the client
does not expect sorted arrays from the chrome process. It's a detail of the
client's implementation that manifested itself in the interface.
This patch replaces Bluetooth's internal implmentation for starting
bluetoothd with the portable one provided by the HAL module. Gonk-
specific workarounds are preserved within HAL.
The PDU contains a pointer to the operation's result handler. If sending
fails, the result handler is supposed to handle an error. But the PDU
will go out of scope first and release the handler. The error delivery
then fails with a segmentation fault.