Bug 920551 - 2.i/2: fix Bluetooth. r=echou

This commit is contained in:
Vicamo Yang 2013-10-25 11:07:48 +08:00
Родитель 3dc0e9eff0
Коммит 581f882a3f
10 изменённых файлов: 122 добавлений и 5 удалений

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

@ -881,6 +881,7 @@ BluetoothAdapter::IsScoConnected(ErrorResult& aRv)
already_AddRefed<DOMRequest> already_AddRefed<DOMRequest>
BluetoothAdapter::AnswerWaitingCall(ErrorResult& aRv) BluetoothAdapter::AnswerWaitingCall(ErrorResult& aRv)
{ {
#ifdef MOZ_B2G_RIL
nsCOMPtr<nsPIDOMWindow> win = GetOwner(); nsCOMPtr<nsPIDOMWindow> win = GetOwner();
if (!win) { if (!win) {
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
@ -899,11 +900,16 @@ BluetoothAdapter::AnswerWaitingCall(ErrorResult& aRv)
bs->AnswerWaitingCall(results); bs->AnswerWaitingCall(results);
return request.forget(); return request.forget();
#else
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
return nullptr;
#endif // MOZ_B2G_RIL
} }
already_AddRefed<DOMRequest> already_AddRefed<DOMRequest>
BluetoothAdapter::IgnoreWaitingCall(ErrorResult& aRv) BluetoothAdapter::IgnoreWaitingCall(ErrorResult& aRv)
{ {
#ifdef MOZ_B2G_RIL
nsCOMPtr<nsPIDOMWindow> win = GetOwner(); nsCOMPtr<nsPIDOMWindow> win = GetOwner();
if (!win) { if (!win) {
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
@ -922,11 +928,16 @@ BluetoothAdapter::IgnoreWaitingCall(ErrorResult& aRv)
bs->IgnoreWaitingCall(results); bs->IgnoreWaitingCall(results);
return request.forget(); return request.forget();
#else
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
return nullptr;
#endif // MOZ_B2G_RIL
} }
already_AddRefed<DOMRequest> already_AddRefed<DOMRequest>
BluetoothAdapter::ToggleCalls(ErrorResult& aRv) BluetoothAdapter::ToggleCalls(ErrorResult& aRv)
{ {
#ifdef MOZ_B2G_RIL
nsCOMPtr<nsPIDOMWindow> win = GetOwner(); nsCOMPtr<nsPIDOMWindow> win = GetOwner();
if (!win) { if (!win) {
aRv.Throw(NS_ERROR_FAILURE); aRv.Throw(NS_ERROR_FAILURE);
@ -945,6 +956,10 @@ BluetoothAdapter::ToggleCalls(ErrorResult& aRv)
bs->ToggleCalls(results); bs->ToggleCalls(results);
return request.forget(); return request.forget();
#else
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
return nullptr;
#endif // MOZ_B2G_RIL
} }
already_AddRefed<DOMRequest> already_AddRefed<DOMRequest>

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

@ -15,19 +15,24 @@
#include "BluetoothUtils.h" #include "BluetoothUtils.h"
#include "BluetoothUuid.h" #include "BluetoothUuid.h"
#include "MobileConnection.h" #include "jsapi.h"
#include "mozilla/dom/bluetooth/BluetoothTypes.h" #include "mozilla/dom/bluetooth/BluetoothTypes.h"
#include "mozilla/Services.h" #include "mozilla/Services.h"
#include "mozilla/StaticPtr.h" #include "mozilla/StaticPtr.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsIAudioManager.h" #include "nsIAudioManager.h"
#include "nsIDOMIccInfo.h"
#include "nsIIccProvider.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsISettingsService.h" #include "nsISettingsService.h"
#include "nsServiceManagerUtils.h"
#ifdef MOZ_B2G_RIL
#include "nsIDOMIccInfo.h"
#include "nsIDOMMobileConnection.h"
#include "nsIIccProvider.h"
#include "nsIMobileConnectionProvider.h"
#include "nsITelephonyProvider.h" #include "nsITelephonyProvider.h"
#include "nsRadioInterfaceLayer.h" #include "nsRadioInterfaceLayer.h"
#include "nsServiceManagerUtils.h" #endif
/** /**
* BRSF bitmask of AG supported features. See 4.34.1 "Bluetooth Defined AT * BRSF bitmask of AG supported features. See 4.34.1 "Bluetooth Defined AT
@ -44,6 +49,7 @@
#define BRSF_BIT_EXTENDED_ERR_RESULT_CODES (1 << 8) #define BRSF_BIT_EXTENDED_ERR_RESULT_CODES (1 << 8)
#define BRSF_BIT_CODEC_NEGOTIATION (1 << 9) #define BRSF_BIT_CODEC_NEGOTIATION (1 << 9)
#ifdef MOZ_B2G_RIL
/** /**
* These constants are used in result code such as +CLIP and +CCWA. The value * These constants are used in result code such as +CLIP and +CCWA. The value
* of these constants is the same as TOA_INTERNATIONAL/TOA_UNKNOWN defined in * of these constants is the same as TOA_INTERNATIONAL/TOA_UNKNOWN defined in
@ -51,6 +57,7 @@
*/ */
#define TOA_UNKNOWN 0x81 #define TOA_UNKNOWN 0x81
#define TOA_INTERNATIONAL 0x91 #define TOA_INTERNATIONAL 0x91
#endif
#define CR_LF "\xd\xa"; #define CR_LF "\xd\xa";
@ -66,6 +73,7 @@ namespace {
bool sInShutdown = false; bool sInShutdown = false;
static const char kHfpCrlf[] = "\xd\xa"; static const char kHfpCrlf[] = "\xd\xa";
#ifdef MOZ_B2G_RIL
// Sending ringtone related // Sending ringtone related
static bool sStopSendingRingFlag = true; static bool sStopSendingRingFlag = true;
static int sRingInterval = 3000; //unit: ms static int sRingInterval = 3000; //unit: ms
@ -79,8 +87,10 @@ namespace {
// The mechanism should be revised once we know the exact time at which // The mechanism should be revised once we know the exact time at which
// Dialer stops playing. // Dialer stops playing.
static int sBusyToneInterval = 3700; //unit: ms static int sBusyToneInterval = 3700; //unit: ms
#endif // MOZ_B2G_RIL
} // anonymous namespace } // anonymous namespace
#ifdef MOZ_B2G_RIL
/* CallState for sCINDItems[CINDType::CALL].value /* CallState for sCINDItems[CINDType::CALL].value
* - NO_CALL: there are no calls in progress * - NO_CALL: there are no calls in progress
* - IN_PROGRESS: at least one call is in progress * - IN_PROGRESS: at least one call is in progress
@ -113,6 +123,7 @@ enum CallHeldState {
ONHOLD_ACTIVE, ONHOLD_ACTIVE,
ONHOLD_NOACTIVE ONHOLD_NOACTIVE
}; };
#endif // MOZ_B2G_RIL
typedef struct { typedef struct {
const char* name; const char* name;
@ -123,23 +134,27 @@ typedef struct {
enum CINDType { enum CINDType {
BATTCHG = 1, BATTCHG = 1,
#ifdef MOZ_B2G_RIL
CALL, CALL,
CALLHELD, CALLHELD,
CALLSETUP, CALLSETUP,
SERVICE, SERVICE,
SIGNAL, SIGNAL,
ROAM ROAM
#endif
}; };
static CINDItem sCINDItems[] = { static CINDItem sCINDItems[] = {
{}, {},
{"battchg", "0-5", 5, true}, {"battchg", "0-5", 5, true},
#ifdef MOZ_B2G_RIL
{"call", "0,1", CallState::NO_CALL, true}, {"call", "0,1", CallState::NO_CALL, true},
{"callheld", "0-2", CallHeldState::NO_CALLHELD, true}, {"callheld", "0-2", CallHeldState::NO_CALLHELD, true},
{"callsetup", "0-3", CallSetupState::NO_CALLSETUP, true}, {"callsetup", "0-3", CallSetupState::NO_CALLSETUP, true},
{"service", "0,1", 0, true}, {"service", "0,1", 0, true},
{"signal", "0-5", 0, true}, {"signal", "0-5", 0, true},
{"roam", "0,1", 0, true} {"roam", "0,1", 0, true}
#endif
}; };
class BluetoothHfpManager::GetVolumeTask : public nsISettingsServiceCallback class BluetoothHfpManager::GetVolumeTask : public nsISettingsServiceCallback
@ -206,6 +221,7 @@ BluetoothHfpManager::Notify(const hal::BatteryInformation& aBatteryInfo)
} }
} }
#ifdef MOZ_B2G_RIL
class BluetoothHfpManager::RespondToBLDNTask : public Task class BluetoothHfpManager::RespondToBLDNTask : public Task
{ {
private: private:
@ -265,6 +281,7 @@ private:
nsString mNumber; nsString mNumber;
int mType; int mType;
}; };
#endif // MOZ_B2G_RIL
class BluetoothHfpManager::CloseScoTask : public Task class BluetoothHfpManager::CloseScoTask : public Task
{ {
@ -277,6 +294,7 @@ private:
} }
}; };
#ifdef MOZ_B2G_RIL
static bool static bool
IsValidDtmf(const char aChar) { IsValidDtmf(const char aChar) {
// Valid DTMF: [*#0-9ABCD] // Valid DTMF: [*#0-9ABCD]
@ -319,6 +337,7 @@ Call::IsActive()
{ {
return (mState == nsITelephonyProvider::CALL_STATE_CONNECTED); return (mState == nsITelephonyProvider::CALL_STATE_CONNECTED);
} }
#endif // MOZ_B2G_RIL
/** /**
* BluetoothHfpManager * BluetoothHfpManager
@ -328,6 +347,7 @@ BluetoothHfpManager::BluetoothHfpManager()
Reset(); Reset();
} }
#ifdef MOZ_B2G_RIL
void void
BluetoothHfpManager::ResetCallArray() BluetoothHfpManager::ResetCallArray()
{ {
@ -341,35 +361,44 @@ BluetoothHfpManager::ResetCallArray()
mCdmaSecondCall.Reset(); mCdmaSecondCall.Reset();
} }
} }
#endif // MOZ_B2G_RIL
void void
BluetoothHfpManager::Reset() BluetoothHfpManager::Reset()
{ {
#ifdef MOZ_B2G_RIL
sStopSendingRingFlag = true; sStopSendingRingFlag = true;
sCINDItems[CINDType::CALL].value = CallState::NO_CALL; sCINDItems[CINDType::CALL].value = CallState::NO_CALL;
sCINDItems[CINDType::CALLSETUP].value = CallSetupState::NO_CALLSETUP; sCINDItems[CINDType::CALLSETUP].value = CallSetupState::NO_CALLSETUP;
sCINDItems[CINDType::CALLHELD].value = CallHeldState::NO_CALLHELD; sCINDItems[CINDType::CALLHELD].value = CallHeldState::NO_CALLHELD;
#endif
for (uint8_t i = 1; i < ArrayLength(sCINDItems); i++) { for (uint8_t i = 1; i < ArrayLength(sCINDItems); i++) {
sCINDItems[i].activated = true; sCINDItems[i].activated = true;
} }
#ifdef MOZ_B2G_RIL
mCCWA = false; mCCWA = false;
mCLIP = false; mCLIP = false;
mDialingRequestProcessed = true;
#endif
mCMEE = false; mCMEE = false;
mCMER = false; mCMER = false;
mReceiveVgsFlag = false; mReceiveVgsFlag = false;
mDialingRequestProcessed = true;
#ifdef MOZ_B2G_RIL
// We disable BSIR by default as it requires OEM implement BT SCO + SPEAKER // We disable BSIR by default as it requires OEM implement BT SCO + SPEAKER
// output audio path in audio driver. OEM can enable BSIR by setting // output audio path in audio driver. OEM can enable BSIR by setting
// mBSIR=true here. // mBSIR=true here.
// //
// Please see Bug 878728 for more information. // Please see Bug 878728 for more information.
mBSIR = false; mBSIR = false;
#endif
mController = nullptr; mController = nullptr;
#ifdef MOZ_B2G_RIL
ResetCallArray(); ResetCallArray();
#endif
} }
bool bool
@ -388,11 +417,13 @@ BluetoothHfpManager::Init()
hal::RegisterBatteryObserver(this); hal::RegisterBatteryObserver(this);
#ifdef MOZ_B2G_RIL
mListener = new BluetoothRilListener(); mListener = new BluetoothRilListener();
if (!mListener->StartListening()) { if (!mListener->StartListening()) {
BT_WARNING("Failed to start listening RIL"); BT_WARNING("Failed to start listening RIL");
return false; return false;
} }
#endif
nsCOMPtr<nsISettingsService> settings = nsCOMPtr<nsISettingsService> settings =
do_GetService("@mozilla.org/settingsService;1"); do_GetService("@mozilla.org/settingsService;1");
@ -419,10 +450,12 @@ BluetoothHfpManager::Init()
BluetoothHfpManager::~BluetoothHfpManager() BluetoothHfpManager::~BluetoothHfpManager()
{ {
#ifdef MOZ_B2G_RIL
if (!mListener->StopListening()) { if (!mListener->StopListening()) {
BT_WARNING("Failed to stop listening RIL"); BT_WARNING("Failed to stop listening RIL");
} }
mListener = nullptr; mListener = nullptr;
#endif
nsCOMPtr<nsIObserverService> obs = services::GetObserverService(); nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
NS_ENSURE_TRUE_VOID(obs); NS_ENSURE_TRUE_VOID(obs);
@ -488,6 +521,7 @@ BluetoothHfpManager::NotifyConnectionStatusChanged(const nsAString& aType)
DispatchStatusChangedEvent(eventName, mDeviceAddress, status); DispatchStatusChangedEvent(eventName, mDeviceAddress, status);
} }
#ifdef MOZ_B2G_RIL
void void
BluetoothHfpManager::NotifyDialer(const nsAString& aCommand) BluetoothHfpManager::NotifyDialer(const nsAString& aCommand)
{ {
@ -504,6 +538,7 @@ BluetoothHfpManager::NotifyDialer(const nsAString& aCommand)
BT_WARNING("Failed to broadcast system message to dialer"); BT_WARNING("Failed to broadcast system message to dialer");
} }
} }
#endif // MOZ_B2G_RIL
void void
BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData) BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
@ -553,6 +588,7 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
} }
} }
#ifdef MOZ_B2G_RIL
void void
BluetoothHfpManager::HandleVoiceConnectionChanged() BluetoothHfpManager::HandleVoiceConnectionChanged()
{ {
@ -638,6 +674,7 @@ BluetoothHfpManager::HandleIccInfoChanged()
NS_ENSURE_TRUE_VOID(gsmIccInfo); NS_ENSURE_TRUE_VOID(gsmIccInfo);
gsmIccInfo->GetMsisdn(mMsisdn); gsmIccInfo->GetMsisdn(mMsisdn);
} }
#endif // MOZ_B2G_RIL
void void
BluetoothHfpManager::HandleShutdown() BluetoothHfpManager::HandleShutdown()
@ -665,6 +702,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket,
// For more information, please refer to 4.34.1 "Bluetooth Defined AT // For more information, please refer to 4.34.1 "Bluetooth Defined AT
// Capabilities" in Bluetooth hands-free profile 1.6 // Capabilities" in Bluetooth hands-free profile 1.6
if (msg.Find("AT+BRSF=") != -1) { if (msg.Find("AT+BRSF=") != -1) {
#ifdef MOZ_B2G_RIL
uint32_t brsf = BRSF_BIT_ABILITY_TO_REJECT_CALL | uint32_t brsf = BRSF_BIT_ABILITY_TO_REJECT_CALL |
BRSF_BIT_ENHANCED_CALL_STATUS; BRSF_BIT_ENHANCED_CALL_STATUS;
@ -677,6 +715,9 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket,
if (mBSIR) { if (mBSIR) {
brsf |= BRSF_BIT_IN_BAND_RING_TONE; brsf |= BRSF_BIT_IN_BAND_RING_TONE;
} }
#else
uint32_t brsf = 0;
#endif // MOZ_B2G_RIL
SendCommand("+BRSF: ", brsf); SendCommand("+BRSF: ", brsf);
} else if (msg.Find("AT+CIND=?") != -1) { } else if (msg.Find("AT+CIND=?") != -1) {
@ -717,6 +758,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket,
// AT+CMEE = 1: use numeric <err> // AT+CMEE = 1: use numeric <err>
// AT+CMEE = 2: use verbose <err> // AT+CMEE = 2: use verbose <err>
mCMEE = !atCommandValues[0].EqualsLiteral("0"); mCMEE = !atCommandValues[0].EqualsLiteral("0");
#ifdef MOZ_B2G_RIL
} else if (msg.Find("AT+COPS=") != -1) { } else if (msg.Find("AT+COPS=") != -1) {
ParseAtCommand(msg, 8, atCommandValues); ParseAtCommand(msg, 8, atCommandValues);
@ -755,6 +797,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket,
message += atCommandValues[0].get()[0]; message += atCommandValues[0].get()[0];
NotifyDialer(NS_ConvertUTF8toUTF16(message)); NotifyDialer(NS_ConvertUTF8toUTF16(message));
} }
#endif // MOZ_B2G_RIL
} else if (msg.Find("AT+VGM=") != -1) { } else if (msg.Find("AT+VGM=") != -1) {
ParseAtCommand(msg, 7, atCommandValues); ParseAtCommand(msg, 7, atCommandValues);
@ -772,6 +815,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket,
NS_ASSERTION(vgm >= 0 && vgm <= 15, "Received invalid VGM value"); NS_ASSERTION(vgm >= 0 && vgm <= 15, "Received invalid VGM value");
mCurrentVgm = vgm; mCurrentVgm = vgm;
#ifdef MOZ_B2G_RIL
} else if (msg.Find("AT+CHLD=?") != -1) { } else if (msg.Find("AT+CHLD=?") != -1) {
SendLine("+CHLD: (0,1,2)"); SendLine("+CHLD: (0,1,2)");
} else if (msg.Find("AT+CHLD=") != -1) { } else if (msg.Find("AT+CHLD=") != -1) {
@ -822,6 +866,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket,
SendLine("ERROR"); SendLine("ERROR");
return; return;
} }
#endif // MOZ_B2G_RIL
} else if (msg.Find("AT+VGS=") != -1) { } else if (msg.Find("AT+VGS=") != -1) {
// Adjust volume by headset // Adjust volume by headset
mReceiveVgsFlag = true; mReceiveVgsFlag = true;
@ -849,6 +894,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket,
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService(); nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
data.AppendInt(newVgs); data.AppendInt(newVgs);
os->NotifyObservers(nullptr, "bluetooth-volume-change", data.get()); os->NotifyObservers(nullptr, "bluetooth-volume-change", data.get());
#ifdef MOZ_B2G_RIL
} else if ((msg.Find("AT+BLDN") != -1) || (msg.Find("ATD>") != -1)) { } else if ((msg.Find("AT+BLDN") != -1) || (msg.Find("ATD>") != -1)) {
// Dialer app of FFOS v1 does not have plan to support Memory Dailing. // Dialer app of FFOS v1 does not have plan to support Memory Dailing.
// However, in order to pass Bluetooth HFP certification, we still have to // However, in order to pass Bluetooth HFP certification, we still have to
@ -974,6 +1020,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket,
// Ignore requests to activate/deactivate mandatory indicators // Ignore requests to activate/deactivate mandatory indicators
} }
} }
#endif // MOZ_B2G_RIL
} else { } else {
nsCString warningMsg; nsCString warningMsg;
warningMsg.Append(NS_LITERAL_CSTRING("Unsupported AT command: ")); warningMsg.Append(NS_LITERAL_CSTRING("Unsupported AT command: "));
@ -1099,6 +1146,7 @@ BluetoothHfpManager::Disconnect(BluetoothProfileController* aController)
mSocket = nullptr; mSocket = nullptr;
} }
#ifdef MOZ_B2G_RIL
void void
BluetoothHfpManager::SendCCWA(const nsAString& aNumber, int aType) BluetoothHfpManager::SendCCWA(const nsAString& aNumber, int aType)
{ {
@ -1160,6 +1208,7 @@ BluetoothHfpManager::SendCLCC(const Call& aCall, int aIndex)
return SendLine(message.get()); return SendLine(message.get());
} }
#endif // MOZ_B2G_RIL
bool bool
BluetoothHfpManager::SendLine(const char* aMessage) BluetoothHfpManager::SendLine(const char* aMessage)
@ -1225,6 +1274,7 @@ BluetoothHfpManager::SendCommand(const char* aCommand, uint32_t aValue)
message.AppendLiteral(","); message.AppendLiteral(",");
} }
} }
#ifdef MOZ_B2G_RIL
} else if (!strcmp(aCommand, "+CLCC: ")) { } else if (!strcmp(aCommand, "+CLCC: ")) {
bool rv = true; bool rv = true;
uint32_t callNumbers = mCurrentCallArray.Length(); uint32_t callNumbers = mCurrentCallArray.Length();
@ -1241,6 +1291,7 @@ BluetoothHfpManager::SendCommand(const char* aCommand, uint32_t aValue)
} }
return rv; return rv;
#endif // MOZ_B2G_RIL
} else { } else {
message.AppendInt(aValue); message.AppendInt(aValue);
} }
@ -1248,6 +1299,7 @@ BluetoothHfpManager::SendCommand(const char* aCommand, uint32_t aValue)
return SendLine(message.get()); return SendLine(message.get());
} }
#ifdef MOZ_B2G_RIL
void void
BluetoothHfpManager::UpdateCIND(uint8_t aType, uint8_t aValue, bool aSend) BluetoothHfpManager::UpdateCIND(uint8_t aType, uint8_t aValue, bool aSend)
{ {
@ -1528,12 +1580,15 @@ BluetoothHfpManager::ToggleCalls()
nsITelephonyProvider::CALL_STATE_HELD : nsITelephonyProvider::CALL_STATE_HELD :
nsITelephonyProvider::CALL_STATE_CONNECTED; nsITelephonyProvider::CALL_STATE_CONNECTED;
} }
#endif // MOZ_B2G_RIL
void void
BluetoothHfpManager::OnSocketConnectSuccess(BluetoothSocket* aSocket) BluetoothHfpManager::OnSocketConnectSuccess(BluetoothSocket* aSocket)
{ {
MOZ_ASSERT(aSocket); MOZ_ASSERT(aSocket);
#ifdef MOZ_B2G_RIL
MOZ_ASSERT(mListener); MOZ_ASSERT(mListener);
#endif
// Success to create a SCO socket // Success to create a SCO socket
if (aSocket == mScoSocket) { if (aSocket == mScoSocket) {
@ -1562,10 +1617,12 @@ BluetoothHfpManager::OnSocketConnectSuccess(BluetoothSocket* aSocket)
mHandsfreeSocket = nullptr; mHandsfreeSocket = nullptr;
} }
#ifdef MOZ_B2G_RIL
// Enumerate current calls // Enumerate current calls
mListener->EnumerateCalls(); mListener->EnumerateCalls();
mFirstCKPD = true; mFirstCKPD = true;
#endif
// Cache device path for NotifySettings() since we can't get socket address // Cache device path for NotifySettings() since we can't get socket address
// when a headset disconnect with us // when a headset disconnect with us

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

@ -9,7 +9,9 @@
#include "BluetoothCommon.h" #include "BluetoothCommon.h"
#include "BluetoothProfileManagerBase.h" #include "BluetoothProfileManagerBase.h"
#ifdef MOZ_B2G_RIL
#include "BluetoothRilListener.h" #include "BluetoothRilListener.h"
#endif
#include "BluetoothSocketObserver.h" #include "BluetoothSocketObserver.h"
#include "mozilla/ipc/UnixSocket.h" #include "mozilla/ipc/UnixSocket.h"
#include "mozilla/Hal.h" #include "mozilla/Hal.h"
@ -18,6 +20,8 @@ BEGIN_BLUETOOTH_NAMESPACE
class BluetoothReplyRunnable; class BluetoothReplyRunnable;
class BluetoothSocket; class BluetoothSocket;
#ifdef MOZ_B2G_RIL
class Call; class Call;
/** /**
@ -67,6 +71,7 @@ public:
nsString mNumber; nsString mNumber;
int mType; int mType;
}; };
#endif // MOZ_B2G_RIL
class BluetoothHfpManager : public BluetoothSocketObserver class BluetoothHfpManager : public BluetoothSocketObserver
, public BluetoothProfileManagerBase , public BluetoothProfileManagerBase
@ -109,6 +114,7 @@ public:
bool DisconnectSco(); bool DisconnectSco();
bool ListenSco(); bool ListenSco();
#ifdef MOZ_B2G_RIL
/** /**
* @param aSend A boolean indicates whether we need to notify headset or not * @param aSend A boolean indicates whether we need to notify headset or not
*/ */
@ -117,26 +123,33 @@ public:
const bool aIsOutgoing, bool aSend); const bool aIsOutgoing, bool aSend);
void HandleIccInfoChanged(); void HandleIccInfoChanged();
void HandleVoiceConnectionChanged(); void HandleVoiceConnectionChanged();
#endif
bool IsConnected(); bool IsConnected();
bool IsScoConnected(); bool IsScoConnected();
#ifdef MOZ_B2G_RIL
// CDMA-specific functions // CDMA-specific functions
void UpdateSecondNumber(const nsAString& aNumber); void UpdateSecondNumber(const nsAString& aNumber);
void AnswerWaitingCall(); void AnswerWaitingCall();
void IgnoreWaitingCall(); void IgnoreWaitingCall();
void ToggleCalls(); void ToggleCalls();
#endif
private: private:
class CloseScoTask; class CloseScoTask;
class GetVolumeTask; class GetVolumeTask;
#ifdef MOZ_B2G_RIL
class RespondToBLDNTask; class RespondToBLDNTask;
class SendRingIndicatorTask; class SendRingIndicatorTask;
#endif
friend class CloseScoTask; friend class CloseScoTask;
friend class GetVolumeTask; friend class GetVolumeTask;
#ifdef MOZ_B2G_RIL
friend class RespondToBLDNTask; friend class RespondToBLDNTask;
friend class SendRingIndicatorTask; friend class SendRingIndicatorTask;
#endif
friend class BluetoothHfpManagerObserver; friend class BluetoothHfpManagerObserver;
BluetoothHfpManager(); BluetoothHfpManager();
@ -146,41 +159,55 @@ private:
bool Init(); bool Init();
void Notify(const hal::BatteryInformation& aBatteryInfo); void Notify(const hal::BatteryInformation& aBatteryInfo);
void Reset(); void Reset();
#ifdef MOZ_B2G_RIL
void ResetCallArray(); void ResetCallArray();
uint32_t FindFirstCall(uint16_t aState); uint32_t FindFirstCall(uint16_t aState);
uint32_t GetNumberOfCalls(uint16_t aState); uint32_t GetNumberOfCalls(uint16_t aState);
PhoneType GetPhoneType(const nsAString& aType); PhoneType GetPhoneType(const nsAString& aType);
#endif
void NotifyConnectionStatusChanged(const nsAString& aType); void NotifyConnectionStatusChanged(const nsAString& aType);
void NotifyDialer(const nsAString& aCommand); void NotifyDialer(const nsAString& aCommand);
#ifdef MOZ_B2G_RIL
void SendCCWA(const nsAString& aNumber, int aType); void SendCCWA(const nsAString& aNumber, int aType);
bool SendCLCC(const Call& aCall, int aIndex); bool SendCLCC(const Call& aCall, int aIndex);
#endif
bool SendCommand(const char* aCommand, uint32_t aValue = 0); bool SendCommand(const char* aCommand, uint32_t aValue = 0);
bool SendLine(const char* aMessage); bool SendLine(const char* aMessage);
#ifdef MOZ_B2G_RIL
void UpdateCIND(uint8_t aType, uint8_t aValue, bool aSend = true); void UpdateCIND(uint8_t aType, uint8_t aValue, bool aSend = true);
#endif
void OnScoConnectSuccess(); void OnScoConnectSuccess();
void OnScoConnectError(); void OnScoConnectError();
void OnScoDisconnect(); void OnScoDisconnect();
int mCurrentVgs; int mCurrentVgs;
int mCurrentVgm; int mCurrentVgm;
#ifdef MOZ_B2G_RIL
bool mBSIR; bool mBSIR;
bool mCCWA; bool mCCWA;
bool mCLIP; bool mCLIP;
#endif
bool mCMEE; bool mCMEE;
bool mCMER; bool mCMER;
#ifdef MOZ_B2G_RIL
bool mFirstCKPD; bool mFirstCKPD;
int mNetworkSelectionMode; int mNetworkSelectionMode;
PhoneType mPhoneType; PhoneType mPhoneType;
#endif
bool mReceiveVgsFlag; bool mReceiveVgsFlag;
#ifdef MOZ_B2G_RIL
bool mDialingRequestProcessed; bool mDialingRequestProcessed;
#endif
nsString mDeviceAddress; nsString mDeviceAddress;
#ifdef MOZ_B2G_RIL
nsString mMsisdn; nsString mMsisdn;
nsString mOperatorName; nsString mOperatorName;
nsTArray<Call> mCurrentCallArray; nsTArray<Call> mCurrentCallArray;
nsAutoPtr<BluetoothRilListener> mListener; nsAutoPtr<BluetoothRilListener> mListener;
#endif
nsRefPtr<BluetoothReplyRunnable> mRunnable; nsRefPtr<BluetoothReplyRunnable> mRunnable;
nsRefPtr<BluetoothProfileController> mController; nsRefPtr<BluetoothProfileController> mController;
nsRefPtr<BluetoothReplyRunnable> mScoRunnable; nsRefPtr<BluetoothReplyRunnable> mScoRunnable;
@ -199,8 +226,10 @@ private:
nsRefPtr<BluetoothSocket> mScoSocket; nsRefPtr<BluetoothSocket> mScoSocket;
SocketConnectionStatus mScoSocketStatus; SocketConnectionStatus mScoSocketStatus;
#ifdef MOZ_B2G_RIL
// CDMA-specific variable // CDMA-specific variable
Call mCdmaSecondCall; Call mCdmaSecondCall;
#endif
}; };
END_BLUETOOTH_NAMESPACE END_BLUETOOTH_NAMESPACE

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

@ -266,6 +266,7 @@ public:
virtual void virtual void
IsScoConnected(BluetoothReplyRunnable* aRunnable) = 0; IsScoConnected(BluetoothReplyRunnable* aRunnable) = 0;
#ifdef MOZ_B2G_RIL
virtual void virtual void
AnswerWaitingCall(BluetoothReplyRunnable* aRunnable) = 0; AnswerWaitingCall(BluetoothReplyRunnable* aRunnable) = 0;
@ -274,6 +275,7 @@ public:
virtual void virtual void
ToggleCalls(BluetoothReplyRunnable* aRunnable) = 0; ToggleCalls(BluetoothReplyRunnable* aRunnable) = 0;
#endif
virtual void virtual void
SendMetaData(const nsAString& aTitle, SendMetaData(const nsAString& aTitle,

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

@ -226,12 +226,14 @@ BluetoothParent::RecvPBluetoothRequestConstructor(
return actor->DoRequest(aRequest.get_DisconnectScoRequest()); return actor->DoRequest(aRequest.get_DisconnectScoRequest());
case Request::TIsScoConnectedRequest: case Request::TIsScoConnectedRequest:
return actor->DoRequest(aRequest.get_IsScoConnectedRequest()); return actor->DoRequest(aRequest.get_IsScoConnectedRequest());
#ifdef MOZ_B2G_RIL
case Request::TAnswerWaitingCallRequest: case Request::TAnswerWaitingCallRequest:
return actor->DoRequest(aRequest.get_AnswerWaitingCallRequest()); return actor->DoRequest(aRequest.get_AnswerWaitingCallRequest());
case Request::TIgnoreWaitingCallRequest: case Request::TIgnoreWaitingCallRequest:
return actor->DoRequest(aRequest.get_IgnoreWaitingCallRequest()); return actor->DoRequest(aRequest.get_IgnoreWaitingCallRequest());
case Request::TToggleCallsRequest: case Request::TToggleCallsRequest:
return actor->DoRequest(aRequest.get_ToggleCallsRequest()); return actor->DoRequest(aRequest.get_ToggleCallsRequest());
#endif
case Request::TSendMetaDataRequest: case Request::TSendMetaDataRequest:
return actor->DoRequest(aRequest.get_SendMetaDataRequest()); return actor->DoRequest(aRequest.get_SendMetaDataRequest());
case Request::TSendPlayStatusRequest: case Request::TSendPlayStatusRequest:
@ -581,6 +583,7 @@ BluetoothRequestParent::DoRequest(const IsScoConnectedRequest& aRequest)
return true; return true;
} }
#ifdef MOZ_B2G_RIL
bool bool
BluetoothRequestParent::DoRequest(const AnswerWaitingCallRequest& aRequest) BluetoothRequestParent::DoRequest(const AnswerWaitingCallRequest& aRequest)
{ {
@ -613,6 +616,7 @@ BluetoothRequestParent::DoRequest(const ToggleCallsRequest& aRequest)
return true; return true;
} }
#endif // MOZ_B2G_RIL
bool bool
BluetoothRequestParent::DoRequest(const SendMetaDataRequest& aRequest) BluetoothRequestParent::DoRequest(const SendMetaDataRequest& aRequest)

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

@ -190,6 +190,7 @@ protected:
bool bool
DoRequest(const IsScoConnectedRequest& aRequest); DoRequest(const IsScoConnectedRequest& aRequest);
#ifdef MOZ_B2G_RIL
bool bool
DoRequest(const AnswerWaitingCallRequest& aRequest); DoRequest(const AnswerWaitingCallRequest& aRequest);
@ -198,6 +199,7 @@ protected:
bool bool
DoRequest(const ToggleCallsRequest& aRequest); DoRequest(const ToggleCallsRequest& aRequest);
#endif
bool bool
DoRequest(const SendMetaDataRequest& aRequest); DoRequest(const SendMetaDataRequest& aRequest);

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

@ -328,6 +328,7 @@ BluetoothServiceChildProcess::IsScoConnected(BluetoothReplyRunnable* aRunnable)
SendRequest(aRunnable, IsScoConnectedRequest()); SendRequest(aRunnable, IsScoConnectedRequest());
} }
#ifdef MOZ_B2G_RIL
void void
BluetoothServiceChildProcess::AnswerWaitingCall( BluetoothServiceChildProcess::AnswerWaitingCall(
BluetoothReplyRunnable* aRunnable) BluetoothReplyRunnable* aRunnable)
@ -348,6 +349,7 @@ BluetoothServiceChildProcess::ToggleCalls(
{ {
SendRequest(aRunnable, ToggleCallsRequest()); SendRequest(aRunnable, ToggleCallsRequest());
} }
#endif // MOZ_B2G_RIL
void void
BluetoothServiceChildProcess::SendMetaData(const nsAString& aTitle, BluetoothServiceChildProcess::SendMetaData(const nsAString& aTitle,

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

@ -149,6 +149,7 @@ public:
virtual void virtual void
IsScoConnected(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; IsScoConnected(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
#ifdef MOZ_B2G_RIL
virtual void virtual void
AnswerWaitingCall(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; AnswerWaitingCall(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
@ -157,6 +158,7 @@ public:
virtual void virtual void
ToggleCalls(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; ToggleCalls(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
#endif
virtual void virtual void
SendMetaData(const nsAString& aTitle, SendMetaData(const nsAString& aTitle,

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

@ -2631,6 +2631,7 @@ BluetoothDBusService::IsConnected(const uint16_t aServiceUuid)
return profile->IsConnected(); return profile->IsConnected();
} }
#ifdef MOZ_B2G_RIL
void void
BluetoothDBusService::AnswerWaitingCall(BluetoothReplyRunnable* aRunnable) BluetoothDBusService::AnswerWaitingCall(BluetoothReplyRunnable* aRunnable)
{ {
@ -2663,6 +2664,7 @@ BluetoothDBusService::ToggleCalls(BluetoothReplyRunnable* aRunnable)
DispatchBluetoothReply(aRunnable, BluetoothValue(true), EmptyString()); DispatchBluetoothReply(aRunnable, BluetoothValue(true), EmptyString());
} }
#endif // MOZ_B2G_RIL
class OnUpdateSdpRecordsRunnable : public nsRunnable class OnUpdateSdpRecordsRunnable : public nsRunnable
{ {

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

@ -135,6 +135,7 @@ public:
virtual void virtual void
IsScoConnected(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; IsScoConnected(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
#ifdef MOZ_B2G_RIL
virtual void virtual void
AnswerWaitingCall(BluetoothReplyRunnable* aRunnable); AnswerWaitingCall(BluetoothReplyRunnable* aRunnable);
@ -143,6 +144,7 @@ public:
virtual void virtual void
ToggleCalls(BluetoothReplyRunnable* aRunnable); ToggleCalls(BluetoothReplyRunnable* aRunnable);
#endif
virtual void virtual void
SendMetaData(const nsAString& aTitle, SendMetaData(const nsAString& aTitle,