mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1134821: Detect default Bluetooth backend, r=shuang
This patch adds code to select the default Bluetooth backend from a list of supported ones, by detecting the backend's availability. Some devices are missing bluetoothd support. With the patch, bluetoothd can be the default backend, but unsupportive devices fall back to in- Gecko Bluedroid.
This commit is contained in:
parent
b0c20457d4
commit
30b68c77dd
@ -95,29 +95,43 @@ BluetoothInterface*
|
||||
BluetoothInterface::GetInstance()
|
||||
{
|
||||
#if ANDROID_VERSION >= 17
|
||||
/* We pick a default backend from the available ones. The branches
|
||||
* are ordered by preference.
|
||||
/* We pick a default backend from the available ones. The options are
|
||||
* ordered by preference. If a backend is supported but not available
|
||||
* on the current system, we pick the next one. The selected default
|
||||
* can be overriden manually by storing the respective string in the
|
||||
* system property 'ro.moz.bluetooth.backend'.
|
||||
*/
|
||||
#ifdef MOZ_B2G_BT_BLUEDROID
|
||||
static const char sDefaultBackend[] = "bluedroid";
|
||||
#else
|
||||
#ifdef MOZ_B2G_BT_DAEMON
|
||||
static const char sDefaultBackend[] = "bluetoothd";
|
||||
#else
|
||||
static const char* const sDefaultBackend = nullptr;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Here's where we decide which implementation to use. Currently
|
||||
* there is only Bluedroid and the Bluetooth daemon, but others are
|
||||
* possible. Having multiple interfaces built-in and selecting the
|
||||
* correct one at runtime is also an option.
|
||||
*/
|
||||
static const char* const sDefaultBackend[] = {
|
||||
#ifdef MOZ_B2G_BT_DAEMON
|
||||
"bluetoothd",
|
||||
#endif
|
||||
#ifdef MOZ_B2G_BT_BLUEDROID
|
||||
"bluedroid",
|
||||
#endif
|
||||
nullptr // no default backend; must be final element in array
|
||||
};
|
||||
|
||||
const char* defaultBackend;
|
||||
|
||||
for (size_t i = 0; i < MOZ_ARRAY_LENGTH(sDefaultBackend); ++i) {
|
||||
|
||||
/* select current backend */
|
||||
defaultBackend = sDefaultBackend[i];
|
||||
|
||||
if (defaultBackend) {
|
||||
if (!strcmp(defaultBackend, "bluetoothd") &&
|
||||
access("/init.bluetooth.rc", F_OK) == -1) {
|
||||
continue; /* bluetoothd not available */
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
char value[PROPERTY_VALUE_MAX];
|
||||
int len;
|
||||
|
||||
len = property_get("ro.moz.bluetooth.backend", value, sDefaultBackend);
|
||||
len = property_get("ro.moz.bluetooth.backend", value, defaultBackend);
|
||||
if (len < 0) {
|
||||
BT_WARNING("No Bluetooth backend available.");
|
||||
return nullptr;
|
||||
@ -125,6 +139,12 @@ BluetoothInterface::GetInstance()
|
||||
|
||||
const nsDependentCString backend(value, len);
|
||||
|
||||
/* Here's where we decide which implementation to use. Currently
|
||||
* there is only Bluedroid and the Bluetooth daemon, but others are
|
||||
* possible. Having multiple interfaces built-in and selecting the
|
||||
* correct one at runtime is also an option.
|
||||
*/
|
||||
|
||||
#ifdef MOZ_B2G_BT_BLUEDROID
|
||||
if (backend.LowerCaseEqualsLiteral("bluedroid")) {
|
||||
return BluetoothHALInterface::GetInstance();
|
||||
|
Loading…
Reference in New Issue
Block a user