mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 978809: Remove sToggleBtMonitor from Bluedroid backend, r=echou
When enabling or disabling Bluetooth, the Bluedroid backend waits on sToggleBtMonitor until a BT adapter has been activated. Once the monitor gets notified, the backend sends a ToggleBtAck runnable to the main thread. This patch removes sToggleBtMonitor from the Bluetooth Bluedroid backend. Instead of signalling the monitor's notification, the Bluedroid handler function sends the ToggleBtAck directly.
This commit is contained in:
parent
e7759d8ae3
commit
59813d6a1f
@ -55,7 +55,6 @@ static nsTArray<nsRefPtr<BluetoothReplyRunnable> > sGetDeviceRunnableArray;
|
||||
static nsTArray<nsRefPtr<BluetoothReplyRunnable> > sSetPropertyRunnableArray;
|
||||
static nsTArray<nsRefPtr<BluetoothReplyRunnable> > sUnbondingRunnableArray;
|
||||
static nsTArray<int> sRequestedDeviceCountArray;
|
||||
static StaticAutoPtr<Monitor> sToggleBtMonitor;
|
||||
|
||||
/**
|
||||
* Classes only used in this file
|
||||
@ -246,9 +245,11 @@ AdapterStateChangeCallback(bt_state_t aStatus)
|
||||
|
||||
sIsBtEnabled = (aStatus == BT_STATE_ON);
|
||||
|
||||
{
|
||||
MonitorAutoLock lock(*sToggleBtMonitor);
|
||||
lock.Notify();
|
||||
nsRefPtr<nsRunnable> runnable =
|
||||
new BluetoothService::ToggleBtAck(sIsBtEnabled);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sIsBtEnabled &&
|
||||
@ -670,15 +671,17 @@ StartStopGonkBluetooth(bool aShouldEnable)
|
||||
|
||||
if (sIsBtEnabled == aShouldEnable) {
|
||||
// Keep current enable status
|
||||
nsRefPtr<nsRunnable> runnable =
|
||||
new BluetoothService::ToggleBtAck(sIsBtEnabled);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int ret = aShouldEnable ? sBtInterface->enable() : sBtInterface->disable();
|
||||
NS_ENSURE_TRUE(ret == BT_STATUS_SUCCESS, NS_ERROR_FAILURE);
|
||||
|
||||
MonitorAutoLock lock(*sToggleBtMonitor);
|
||||
lock.Wait();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -716,8 +719,6 @@ ReplyStatusError(BluetoothReplyRunnable* aBluetoothReplyRunnable,
|
||||
*/
|
||||
BluetoothServiceBluedroid::BluetoothServiceBluedroid()
|
||||
{
|
||||
sToggleBtMonitor = new Monitor("BluetoothService.sToggleBtMonitor");
|
||||
|
||||
if (!EnsureBluetoothHalLoad()) {
|
||||
BT_LOGR("Error! Failed to load bluedroid library.");
|
||||
return;
|
||||
@ -731,7 +732,6 @@ BluetoothServiceBluedroid::BluetoothServiceBluedroid()
|
||||
|
||||
BluetoothServiceBluedroid::~BluetoothServiceBluedroid()
|
||||
{
|
||||
sToggleBtMonitor = nullptr;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -741,18 +741,14 @@ BluetoothServiceBluedroid::StartInternal()
|
||||
|
||||
nsresult ret = StartStopGonkBluetooth(true);
|
||||
if (NS_FAILED(ret)) {
|
||||
nsCOMPtr<nsIRunnable> ackTask = new BluetoothService::ToggleBtAck(false);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(ackTask))) {
|
||||
nsRefPtr<nsRunnable> runnable =
|
||||
new BluetoothService::ToggleBtAck(false);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
}
|
||||
BT_LOGR("Error");
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> ackTask = new BluetoothService::ToggleBtAck(true);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(ackTask))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -763,18 +759,14 @@ BluetoothServiceBluedroid::StopInternal()
|
||||
|
||||
nsresult ret = StartStopGonkBluetooth(false);
|
||||
if (NS_FAILED(ret)) {
|
||||
nsCOMPtr<nsIRunnable> ackTask = new BluetoothService::ToggleBtAck(true);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(ackTask))) {
|
||||
nsRefPtr<nsRunnable> runnable =
|
||||
new BluetoothService::ToggleBtAck(true);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
}
|
||||
BT_LOGR("Error");
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> ackTask = new BluetoothService::ToggleBtAck(false);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(ackTask))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user