Bug 830213 - Modify function NotifyStatusChanged in BluetoothHfpManager, r=echou

This commit is contained in:
Gina Yeh 2013-05-11 14:06:16 +08:00
parent e9f60f611f
commit 7082133dd8
2 changed files with 16 additions and 6 deletions

View File

@ -462,15 +462,22 @@ BluetoothHfpManager::Get()
}
void
BluetoothHfpManager::NotifySettings()
BluetoothHfpManager::NotifyStatusChanged(const nsAString& aType)
{
nsString type, name;
BluetoothValue v;
InfallibleTArray<BluetoothNamedValue> parameters;
type.AssignLiteral("bluetooth-hfp-status-changed");
type = aType;
name.AssignLiteral("connected");
v = IsConnected();
if (type.EqualsLiteral("bluetooth-hfp-status-changed")) {
v = IsConnected();
} else if (type.EqualsLiteral("bluetooth-sco-status-changed")) {
v = IsScoConnected();
} else {
NS_WARNING("Wrong type for NotifyStatusChanged");
return;
}
parameters.AppendElement(BluetoothNamedValue(name, v));
name.AssignLiteral("address");
@ -1410,7 +1417,7 @@ BluetoothHfpManager::OnConnectSuccess(BluetoothSocket* aSocket)
// Cache device path for NotifySettings() since we can't get socket address
// when a headset disconnect with us
mSocket->GetAddress(mDeviceAddress);
NotifySettings();
NotifyStatusChanged(NS_LITERAL_STRING("bluetooth-hfp-status-changed"));
ListenSco();
}
@ -1461,7 +1468,7 @@ BluetoothHfpManager::OnDisconnect(BluetoothSocket* aSocket)
DisconnectSco();
Listen();
NotifySettings();
NotifyStatusChanged(NS_LITERAL_STRING("bluetooth-hfp-status-changed"));
Reset();
}
@ -1503,6 +1510,7 @@ BluetoothHfpManager::OnScoConnectSuccess()
}
NotifyAudioManager(mDeviceAddress);
NotifyStatusChanged(NS_LITERAL_STRING("bluetooth-sco-status-changed"));
mScoSocketStatus = mScoSocket->GetConnectionStatus();
}
@ -1526,6 +1534,7 @@ BluetoothHfpManager::OnScoDisconnect()
if (mScoSocketStatus == SocketConnectionStatus::SOCKET_CONNECTED) {
ListenSco();
NotifyAudioManager(EmptyString());
NotifyStatusChanged(NS_LITERAL_STRING("bluetooth-sco-status-changed"));
}
}
@ -1577,6 +1586,7 @@ BluetoothHfpManager::ConnectSco(BluetoothReplyRunnable* aRunnable)
NS_ENSURE_TRUE(bs, false);
nsresult rv = bs->GetScoSocket(mDeviceAddress, true, false, mScoSocket);
mScoSocketStatus = mSocket->GetConnectionStatus();
return NS_SUCCEEDED(rv);
}

View File

@ -110,7 +110,7 @@ private:
void ResetCallArray();
void NotifyDialer(const nsAString& aCommand);
void NotifySettings();
void NotifyStatusChanged(const nsAString& aType);
void NotifyAudioManager(const nsAString& aAddress);
bool SendCommand(const char* aCommand, uint8_t aValue = 0);