Bug 936711 - Fix crash which happened at disabling Bluetooth during reconnection, r=gyeh

This commit is contained in:
Eric Chou 2013-11-12 17:37:30 +08:00
Родитель 942b0940d4
Коммит 69782465dc
3 изменённых файлов: 29 добавлений и 8 удалений

Просмотреть файл

@ -166,7 +166,11 @@ BluetoothA2dpManager::Connect(const nsAString& aDeviceAddress,
mDeviceAddress = aDeviceAddress;
mController = aController;
bs->SendSinkMessage(aDeviceAddress, NS_LITERAL_STRING("Connect"));
if (NS_FAILED(bs->SendSinkMessage(aDeviceAddress,
NS_LITERAL_STRING("Connect")))) {
aController->OnConnect(NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
return;
}
}
void
@ -192,7 +196,11 @@ BluetoothA2dpManager::Disconnect(BluetoothProfileController* aController)
mController = aController;
bs->SendSinkMessage(mDeviceAddress, NS_LITERAL_STRING("Disconnect"));
if (NS_FAILED(bs->SendSinkMessage(mDeviceAddress,
NS_LITERAL_STRING("Disconnect")))) {
aController->OnDisconnect(NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
return;
}
}
void

Просмотреть файл

@ -125,7 +125,11 @@ BluetoothHidManager::Connect(const nsAString& aDeviceAddress,
mDeviceAddress = aDeviceAddress;
mController = aController;
bs->SendInputMessage(aDeviceAddress, NS_LITERAL_STRING("Connect"));
if (NS_FAILED(bs->SendInputMessage(aDeviceAddress,
NS_LITERAL_STRING("Connect")))) {
aController->OnConnect(NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
return;
}
}
void
@ -153,7 +157,11 @@ BluetoothHidManager::Disconnect(BluetoothProfileController* aController)
mController = aController;
bs->SendInputMessage(mDeviceAddress, NS_LITERAL_STRING("Disconnect"));
if (NS_FAILED(bs->SendInputMessage(mDeviceAddress,
NS_LITERAL_STRING("Disconnect")))) {
aController->OnDisconnect(NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
return;
}
}
void

Просмотреть файл

@ -2003,6 +2003,8 @@ BluetoothDBusService::SendAsyncDBusMessage(const nsAString& aObjectPath,
MOZ_ASSERT(!aObjectPath.IsEmpty());
MOZ_ASSERT(aInterface);
NS_ENSURE_TRUE(mConnection, NS_ERROR_FAILURE);
nsAutoPtr<BluetoothServiceClass> serviceClass(new BluetoothServiceClass());
if (!strcmp(aInterface, DBUS_SINK_IFACE)) {
*serviceClass = BluetoothServiceClass::A2DP;
@ -2587,12 +2589,15 @@ BluetoothDBusService::SetPairingConfirmationInternal(
static void
NextBluetoothProfileController()
{
sControllerArray[0] = nullptr;
MOZ_ASSERT(NS_IsMainThread());
// First, remove the task at the front which has been already done.
NS_ENSURE_FALSE_VOID(sControllerArray.IsEmpty());
sControllerArray.RemoveElementAt(0);
if (!sControllerArray.IsEmpty()) {
sControllerArray[0]->Start();
}
// Re-check if the task array is empty, if it's not, the next task will begin.
NS_ENSURE_FALSE_VOID(sControllerArray.IsEmpty());
sControllerArray[0]->Start();
}
static void