Backout 26407a874057 for causing Bug 937199.

This commit is contained in:
Gregor Wagner 2013-11-11 10:28:56 -08:00
parent 7548e3c86c
commit 5df0704249
6 changed files with 77 additions and 85 deletions

View File

@ -18,11 +18,6 @@ class BluetoothA2dpManager : public BluetoothProfileManagerBase
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
BT_DECL_PROFILE_MGR_BASE
virtual void GetName(nsACString& aName)
{
aName.AssignLiteral("A2DP");
}
enum SinkState {
SINK_UNKNOWN,
@ -37,6 +32,24 @@ public:
void ResetA2dp();
void ResetAvrcp();
// The following functions are inherited from BluetoothProfileManagerBase
virtual void OnGetServiceChannel(const nsAString& aDeviceAddress,
const nsAString& aServiceUuid,
int aChannel) MOZ_OVERRIDE;
virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) MOZ_OVERRIDE;
virtual void GetAddress(nsAString& aDeviceAddress) MOZ_OVERRIDE;
virtual bool IsConnected() MOZ_OVERRIDE;
virtual void Connect(const nsAString& aDeviceAddress,
BluetoothProfileController* aController) MOZ_OVERRIDE;
virtual void Disconnect(BluetoothProfileController* aController) MOZ_OVERRIDE;
virtual void OnConnect(const nsAString& aErrorStr) MOZ_OVERRIDE;
virtual void OnDisconnect(const nsAString& aErrorStr) MOZ_OVERRIDE;
virtual void GetName(nsACString& aName)
{
aName.AssignLiteral("A2DP");
}
// A2DP-specific functions
void HandleSinkPropertyChanged(const BluetoothSignal& aSignal);

View File

@ -80,11 +80,6 @@ class BluetoothHfpManager : public BluetoothSocketObserver
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
BT_DECL_PROFILE_MGR_BASE
virtual void GetName(nsACString& aName)
{
aName.AssignLiteral("HFP/HSP");
}
static BluetoothHfpManager* Get();
~BluetoothHfpManager();
@ -97,11 +92,27 @@ public:
virtual void OnSocketConnectError(BluetoothSocket* aSocket) MOZ_OVERRIDE;
virtual void OnSocketDisconnect(BluetoothSocket* aSocket) MOZ_OVERRIDE;
// The following functions are inherited from BluetoothProfileManagerBase
virtual void OnGetServiceChannel(const nsAString& aDeviceAddress,
const nsAString& aServiceUuid,
int aChannel) MOZ_OVERRIDE;
virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) MOZ_OVERRIDE;
virtual void GetAddress(nsAString& aDeviceAddress) MOZ_OVERRIDE;
virtual void Connect(const nsAString& aDeviceAddress,
BluetoothProfileController* aController) MOZ_OVERRIDE;
virtual void Disconnect(BluetoothProfileController* aController) MOZ_OVERRIDE;
virtual void OnConnect(const nsAString& aErrorStr) MOZ_OVERRIDE;
virtual void OnDisconnect(const nsAString& AErrorStr) MOZ_OVERRIDE;
virtual void GetName(nsACString& aName)
{
aName.AssignLiteral("HFP/HSP");
}
bool Listen();
bool ConnectSco(BluetoothReplyRunnable* aRunnable = nullptr);
bool DisconnectSco();
bool ListenSco();
bool IsScoConnected();
#ifdef MOZ_B2G_RIL
/**
@ -112,7 +123,12 @@ public:
const bool aIsOutgoing, bool aSend);
void HandleIccInfoChanged(uint32_t aClientId);
void HandleVoiceConnectionChanged(uint32_t aClientId);
#endif
bool IsConnected();
bool IsScoConnected();
#ifdef MOZ_B2G_RIL
// CDMA-specific functions
void UpdateSecondNumber(const nsAString& aNumber);
void AnswerWaitingCall();

View File

@ -18,15 +18,29 @@ class BluetoothHidManager : public BluetoothProfileManagerBase
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
BT_DECL_PROFILE_MGR_BASE
static BluetoothHidManager* Get();
~BluetoothHidManager();
// The following functions are inherited from BluetoothProfileManagerBase
virtual void OnGetServiceChannel(const nsAString& aDeviceAddress,
const nsAString& aServiceUuid,
int aChannel) MOZ_OVERRIDE;
virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) MOZ_OVERRIDE;
virtual void GetAddress(nsAString& aDeviceAddress) MOZ_OVERRIDE;
virtual bool IsConnected() MOZ_OVERRIDE;
virtual void Connect(const nsAString& aDeviceAddress,
BluetoothProfileController* aController) MOZ_OVERRIDE;
virtual void Disconnect(BluetoothProfileController* aController)
MOZ_OVERRIDE;
virtual void OnConnect(const nsAString& aErrorStr) MOZ_OVERRIDE;
virtual void OnDisconnect(const nsAString& aErrorStr) MOZ_OVERRIDE;
virtual void GetName(nsACString& aName)
{
aName.AssignLiteral("HID");
}
static BluetoothHidManager* Get();
~BluetoothHidManager();
// HID-specific functions
void HandleInputPropertyChanged(const BluetoothSignal& aSignal);

View File

@ -31,11 +31,6 @@ class BluetoothOppManager : public BluetoothSocketObserver
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
BT_DECL_PROFILE_MGR_BASE
virtual void GetName(nsACString& aName)
{
aName.AssignLiteral("OPP");
}
/*
* Channel of reserved services are fixed values, please check
@ -74,6 +69,25 @@ public:
virtual void OnSocketConnectError(BluetoothSocket* aSocket) MOZ_OVERRIDE;
virtual void OnSocketDisconnect(BluetoothSocket* aSocket) MOZ_OVERRIDE;
// The following functions are inherited from BluetoothProfileManagerBase
virtual void OnGetServiceChannel(const nsAString& aDeviceAddress,
const nsAString& aServiceUuid,
int aChannel) MOZ_OVERRIDE;
virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) MOZ_OVERRIDE;
virtual void GetAddress(nsAString& aDeviceAddress) MOZ_OVERRIDE;
virtual bool IsConnected() MOZ_OVERRIDE;
virtual void GetName(nsACString& aName)
{
aName.AssignLiteral("OPP");
}
virtual void Connect(const nsAString& aDeviceAddress,
BluetoothProfileController* aController) MOZ_OVERRIDE;
virtual void Disconnect(BluetoothProfileController* aController) MOZ_OVERRIDE;
virtual void OnConnect(const nsAString& aErrorStr) MOZ_OVERRIDE;
virtual void OnDisconnect(const nsAString& aErrorStr) MOZ_OVERRIDE;
private:
BluetoothOppManager();
bool Init();

View File

@ -70,20 +70,6 @@ public:
virtual void GetName(nsACString& aName) = 0;
};
#define BT_DECL_PROFILE_MGR_BASE \
public: \
virtual void OnGetServiceChannel(const nsAString& aDeviceAddress, \
const nsAString& aServiceUuid, \
int aChannel) MOZ_OVERRIDE; \
virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) MOZ_OVERRIDE; \
virtual void GetAddress(nsAString& aDeviceAddress) MOZ_OVERRIDE; \
virtual bool IsConnected() MOZ_OVERRIDE; \
virtual void Connect(const nsAString& aDeviceAddress, \
BluetoothProfileController* aController) MOZ_OVERRIDE; \
virtual void Disconnect(BluetoothProfileController* aController) MOZ_OVERRIDE; \
virtual void OnConnect(const nsAString& aErrorStr) MOZ_OVERRIDE; \
virtual void OnDisconnect(const nsAString& AErrorStr) MOZ_OVERRIDE; \
END_BLUETOOTH_NAMESPACE
#endif //#ifndef mozilla_dom_bluetooth_bluetoothprofilemanagerbase_h__

View File

@ -21,7 +21,6 @@
#include <hardware/bluetooth.h>
#include <hardware/hardware.h>
#include "BluetoothProfileController.h"
#include "BluetoothReplyRunnable.h"
#include "BluetoothUtils.h"
#include "BluetoothUuid.h"
@ -71,7 +70,6 @@ static nsString sAdapterBdName;
static uint32_t sAdapterDiscoverableTimeout;
static InfallibleTArray<nsString> sAdapterBondedAddressArray;
static InfallibleTArray<BluetoothNamedValue> sRemoteDevicesPack;
static nsTArray<nsRefPtr<BluetoothProfileController> > sControllerArray;
static nsTArray<nsRefPtr<BluetoothReplyRunnable> > sBondingRunnableArray;
static nsTArray<nsRefPtr<BluetoothReplyRunnable> > sChangeDiscoveryRunnableArray;
static nsTArray<nsRefPtr<BluetoothReplyRunnable> > sGetPairedDeviceRunnableArray;
@ -1081,55 +1079,13 @@ BluetoothServiceBluedroid::PrepareAdapterInternal()
return NS_OK;
}
static void
NextBluetoothProfileController()
{
sControllerArray[0] = nullptr;
sControllerArray.RemoveElementAt(0);
if (!sControllerArray.IsEmpty()) {
sControllerArray[0]->Start();
}
}
static void
ConnectDisconnect(bool aConnect, const nsAString& aDeviceAddress,
BluetoothReplyRunnable* aRunnable,
uint16_t aServiceUuid, uint32_t aCod = 0)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aRunnable);
BluetoothProfileController* controller =
new BluetoothProfileController(aConnect, aDeviceAddress, aRunnable,
NextBluetoothProfileController,
aServiceUuid, aCod);
sControllerArray.AppendElement(controller);
/**
* If the request is the first element of the quene, start from here. Note
* that other request is pushed into the quene and is popped out after the
* first one is completed. See NextBluetoothProfileController() for details.
*/
if (sControllerArray.Length() == 1) {
sControllerArray[0]->Start();
}
}
void
BluetoothServiceBluedroid::Connect(const nsAString& aDeviceAddress,
uint32_t aCod,
uint16_t aServiceUuid,
BluetoothReplyRunnable* aRunnable)
{
// TODO: Remove this error reply once Connect() is done in profile managers
if (aRunnable) {
DispatchBluetoothReply(aRunnable, BluetoothValue(),
NS_LITERAL_STRING(ERR_CONNECTION_FAILED));
return;
}
ConnectDisconnect(true, aDeviceAddress, aRunnable, aServiceUuid, aCod);
}
bool
@ -1143,14 +1099,7 @@ BluetoothServiceBluedroid::Disconnect(
const nsAString& aDeviceAddress, uint16_t aServiceUuid,
BluetoothReplyRunnable* aRunnable)
{
// TODO: Remove this error reply once Disconnect() is done in profile managers
if (aRunnable) {
DispatchBluetoothReply(aRunnable, BluetoothValue(),
NS_LITERAL_STRING(ERR_CONNECTION_FAILED));
return;
}
ConnectDisconnect(false, aDeviceAddress, aRunnable, aServiceUuid);
}
void