This patch replaces all instances of |nsAutoArrayPtr<>| in the Bluetooth
interfaces with |UniquePtr<[]>|.
In contrast to |nsAutoArrayPtr<>|, |UniquePtr<[]>| doesn't convert to the
underlying pointer type implicitly. This is a problem for the daemon-socket
runnable, which depend on this feature when calling their operations. To
solve this issue, the patch adds |ConvertArg| for each arguemnt, which does
the conversion explicitly.
The AVRCP passthough-command notification doesn't require |int| type
arguments. Using |uint8_t| is sufficient. This change is required to
prepare replacing |nsAutoArrayPtr<>| with |UniquePtr<[]>|.
|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.