Currently, BluetoothSocket leaks its file descriptor on close
operations. With this patch when Gecko closes an instance of
BluetoothSocket, the file descriptor is now closed as well.
This patch removes all code related to socket setup from Bluedroid's
BluetoothSocket. The socket setup is handled by BluetoothInterface;
transparantly to its users.
Since most of the socket setup is now hidden, a comment was added to
DroidSocketImpl that explains the connection phases in server and
client.
This patch moves the accept phase of Bluedroid's |Listen| to the
implementation of BluetoothInterface. |BluetoothInterface::Accept|
handles Bluedroid's socket-setup messages and executes the result
handler with the received file descriptor and data.
Bluedroid's internal socket setup transfers 2 messages and possibly
a file descriptor as the first data of a socket connection.
This patch moves the socket-setup code for the |Connect| call to
the implementation of BluetoothInterface. BluetoothSocket only
handles the socket setup of |Listen|, and general socket state.
In preparaton of moving the Bluedroid socket setup to BluetoothInterface,
this patch introduces connection states for Bluetooth sockets. There are
4 states,
- Disconnected,
- Listening,
- Connecting, and
- Connected.
All sockets start in Disconnected and transition to Connected via one
of the other states. Server socket transition through Listening, Client
sockets transition through Connecting. There is currently a lot of code
duplication in read and write methods. This will be cleaned up when the
connection setup is handled by BluetoothInterface.
The result-handler class contains a method for each interface
in the Core profile and a method for failed calls. The patch
also adds runnable classes that execute a result handler's
method on the main thread.
This patch adds classes around all Bluedroid interfaces that are
currently used by Gecko. These are Core, Socket, Handsfree, A2DP,
and AVRCP.
All arguments and return values are still Bluedroid types and
constants. Future patches will convert them to interface-neutral
artifacts.
Few marionette tests in unit-test set may navigate to specific URL and
wouldn't restore the URL of marionette client when the tests end.
Navigate the URL to default value before running Bluetooth test to make
sure the correctness of test.
Ensures that we can always receive that "enabled"/"disabled" event by
installing the event handler *before* we ever enable/disable Bluetooth. Or
we might just miss those events and get a timeout error.
Use BlueZ API 'CreateDevice' to update the SDP records of those
unknown devices. On the other hand, still use 'DiscoverServices'
to update SDP records of paired devices.
Few marionette tests in unit-test set may navigate to specific URL and
wouldn't restore the URL of marionette client when the tests end.
Navigate the URL to default value before running Bluetooth test to make
sure the correctness of test.