|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.
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.
ObexHeaderSet::GetTarget copies the data associated with the
ObexHeaderId::Target id into a newly-allocated buffer. All callers of
this function, however, fail to free the buffer once they are done with it.
Instead of simply freeing the buffer in the caller, however, let's add
an API to ObexHeaderSet that gives direct access to the desired header.
Doing this means that we have direct access to the data--no copying
necessary--and we also make the caller slightly faster, since it no
longer has to verify that the appropriate header is there, followed by
re-searching for the header it already knows is there.
This patch improves the Bluetooth signal API by adding methods for
dealing with UUIDs and addresses directly. Callers have been converted
where possible.