Bug 1160127 - Send HFP/A2DP profile disconnection notification, r=btian

This commit is contained in:
Shawn Huang 2015-05-11 11:47:31 +08:00
parent 1451a90b42
commit aaf4244628
5 changed files with 55 additions and 5 deletions

View File

@ -723,6 +723,19 @@ BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
}
}
/*
* Reset connection state to DISCONNECTED to handle backend error. The state
* change triggers UI status bar update as ordinary bluetooth turn-off sequence.
*/
void
BluetoothA2dpManager::HandleBackendError()
{
if (mSinkState != SinkState::SINK_DISCONNECTED) {
ConnectionStateNotification(A2DP_CONNECTION_STATE_DISCONNECTED,
mDeviceAddress);
}
}
void
BluetoothA2dpManager::NotifyConnectionStatusChanged()
{

View File

@ -63,6 +63,7 @@ public:
uint64_t GetTotalMediaNumber();
void GetTitle(nsAString& aTitle);
void GetArtist(nsAString& aArtist);
void HandleBackendError();
protected:
virtual ~BluetoothA2dpManager();

View File

@ -3140,17 +3140,30 @@ void
BluetoothServiceBluedroid::BackendErrorNotification(bool aCrashed)
{
MOZ_ASSERT(NS_IsMainThread());
// Recovery step 2 stop bluetooth
if (aCrashed) {
BT_LOGR("Set aRestart = true");
if (!aCrashed) {
return;
}
/*
* Reset following profile manager states for unexpected backend crash.
* - HFP: connection state and audio state
* - A2DP: connection state
*/
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
NS_ENSURE_TRUE_VOID(hfp);
hfp->HandleBackendError();
BluetoothA2dpManager* a2dp = BluetoothA2dpManager::Get();
NS_ENSURE_TRUE_VOID(a2dp);
a2dp->HandleBackendError();
sIsRestart = true;
BT_LOGR("Reocvery step2: stop bluetooth");
BT_LOGR("Recovery step2: stop bluetooth");
#ifdef MOZ_B2G_BT_API_V2
StopBluetooth(false, nullptr);
#else
StopBluetooth(false);
#endif
}
}
void

View File

@ -1121,6 +1121,26 @@ BluetoothHfpManager::ToggleCalls()
nsITelephonyService::CALL_STATE_CONNECTED;
}
/*
* Reset connection state and audio state to DISCONNECTED to handle backend
* error. The state change triggers UI status bar update as ordinary bluetooth
* turn-off sequence.
*/
void
BluetoothHfpManager::HandleBackendError()
{
MOZ_ASSERT(NS_IsMainThread());
if (mConnectionState != HFP_CONNECTION_STATE_DISCONNECTED) {
ConnectionStateNotification(HFP_CONNECTION_STATE_DISCONNECTED,
mDeviceAddress);
}
if (mAudioState != HFP_AUDIO_STATE_DISCONNECTED) {
AudioStateNotification(HFP_AUDIO_STATE_DISCONNECTED, mDeviceAddress);
}
}
class BluetoothHfpManager::ConnectAudioResultHandler final
: public BluetoothHandsfreeResultHandler
{

View File

@ -109,6 +109,9 @@ public:
void IgnoreWaitingCall();
void ToggleCalls();
// Handle unexpected backend crash
void HandleBackendError();
//
// Bluetooth notifications
//