mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 984284 - [m-c] a2dp headset icon show on the notification bar, r=echou
This commit is contained in:
parent
e676e88c98
commit
f9d9512acb
@ -764,7 +764,7 @@ BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
|
||||
case SinkState::SINK_DISCONNECTED:
|
||||
// case 2: Connection attempt failed
|
||||
if (prevState == SinkState::SINK_CONNECTING) {
|
||||
OnConnect(NS_LITERAL_STRING("A2dpConnectionError"));
|
||||
OnConnect(NS_LITERAL_STRING(ERR_CONNECTION_FAILED));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,6 @@ public:
|
||||
|
||||
static BluetoothA2dpManager* Get();
|
||||
virtual ~BluetoothA2dpManager();
|
||||
void ResetA2dp();
|
||||
void ResetAvrcp();
|
||||
|
||||
// A2DP-specific functions
|
||||
void HandleSinkPropertyChanged(const BluetoothSignal& aSignal);
|
||||
@ -63,6 +61,9 @@ private:
|
||||
class SinkPropertyChangedHandler;
|
||||
BluetoothA2dpManager();
|
||||
bool Init();
|
||||
void ResetA2dp();
|
||||
void ResetAvrcp();
|
||||
|
||||
void HandleShutdown();
|
||||
void NotifyConnectionStatusChanged();
|
||||
|
||||
|
@ -760,7 +760,7 @@ BluetoothHfpManager::NotifyConnectionStateChanged(const nsAString& aType)
|
||||
// When the outgoing hfp connection fails, state changes to disconnected
|
||||
// state. Since bluedroid would not report connecting state, but only
|
||||
// report connected/disconnected.
|
||||
OnConnect(NS_LITERAL_STRING("SocketConnectionError"));
|
||||
OnConnect(NS_LITERAL_STRING(ERR_CONNECTION_FAILED));
|
||||
} else {
|
||||
OnDisconnect(EmptyString());
|
||||
}
|
||||
|
@ -295,6 +295,15 @@ BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
|
||||
NS_ENSURE_TRUE_VOID((newState != SinkState::SINK_UNKNOWN) &&
|
||||
(newState != mSinkState));
|
||||
|
||||
/**
|
||||
* Reject 'connected' state change if bluetooth is already disabled.
|
||||
* Sink state would be reset to 'disconnected' when bluetooth is disabled.
|
||||
*
|
||||
* See bug 984284 for more information about the edge case.
|
||||
*/
|
||||
NS_ENSURE_FALSE_VOID(newState == SinkState::SINK_CONNECTED &&
|
||||
mSinkState == SinkState::SINK_DISCONNECTED);
|
||||
|
||||
SinkState prevState = mSinkState;
|
||||
mSinkState = newState;
|
||||
|
||||
@ -325,13 +334,13 @@ BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
|
||||
case SinkState::SINK_DISCONNECTED:
|
||||
// case 2: Connection attempt failed
|
||||
if (prevState == SinkState::SINK_CONNECTING) {
|
||||
OnConnect(NS_LITERAL_STRING("A2dpConnectionError"));
|
||||
OnConnect(NS_LITERAL_STRING(ERR_CONNECTION_FAILED));
|
||||
break;
|
||||
}
|
||||
|
||||
// case 6: Disconnected from the remote device
|
||||
MOZ_ASSERT(prevState == SinkState::SINK_CONNECTED ||
|
||||
prevState == SinkState::SINK_PLAYING) ;
|
||||
prevState == SinkState::SINK_PLAYING);
|
||||
|
||||
mA2dpConnected = false;
|
||||
NotifyConnectionStatusChanged();
|
||||
|
@ -32,8 +32,6 @@ public:
|
||||
|
||||
static BluetoothA2dpManager* Get();
|
||||
virtual ~BluetoothA2dpManager();
|
||||
void ResetA2dp();
|
||||
void ResetAvrcp();
|
||||
|
||||
// A2DP-specific functions
|
||||
void HandleSinkPropertyChanged(const BluetoothSignal& aSignal);
|
||||
@ -60,6 +58,8 @@ public:
|
||||
private:
|
||||
BluetoothA2dpManager();
|
||||
bool Init();
|
||||
void ResetA2dp();
|
||||
void ResetAvrcp();
|
||||
|
||||
void HandleShutdown();
|
||||
void NotifyConnectionStatusChanged();
|
||||
|
@ -636,8 +636,7 @@ public:
|
||||
|
||||
BluetoothA2dpManager* a2dp = BluetoothA2dpManager::Get();
|
||||
NS_ENSURE_TRUE(a2dp, NS_ERROR_FAILURE);
|
||||
a2dp->ResetA2dp();
|
||||
a2dp->ResetAvrcp();
|
||||
a2dp->Reset();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1690,7 +1690,7 @@ BluetoothHfpManager::OnSocketConnectError(BluetoothSocket* aSocket)
|
||||
mHandsfreeSocket = nullptr;
|
||||
mHeadsetSocket = nullptr;
|
||||
|
||||
OnConnect(NS_LITERAL_STRING("SocketConnectionError"));
|
||||
OnConnect(NS_LITERAL_STRING(ERR_CONNECTION_FAILED));
|
||||
}
|
||||
|
||||
void
|
||||
@ -1758,7 +1758,7 @@ BluetoothHfpManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
MOZ_ASSERT(mSocket);
|
||||
|
||||
if (!mSocket->Connect(NS_ConvertUTF16toUTF8(aDeviceAddress), aChannel)) {
|
||||
OnConnect(NS_LITERAL_STRING("SocketConnectionError"));
|
||||
OnConnect(NS_LITERAL_STRING(ERR_CONNECTION_FAILED));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user