mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 872907 - Patch 4: Implement NotifyStatusChagned() and NotifyAudioManager(), r=echou, r=mrbkap
This commit is contained in:
parent
e7d0099af2
commit
a6765ae76d
@ -24,7 +24,7 @@ using namespace mozilla;
|
||||
USING_BLUETOOTH_NAMESPACE
|
||||
|
||||
namespace {
|
||||
StaticAutoPtr<BluetoothA2dpManager> gBluetoothA2dpManager;
|
||||
StaticRefPtr<BluetoothA2dpManager> gBluetoothA2dpManager;
|
||||
StaticRefPtr<BluetoothA2dpManagerObserver> sA2dpObserver;
|
||||
bool gInShutdown = false;
|
||||
} // anonymous namespace
|
||||
@ -231,6 +231,8 @@ BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
|
||||
// Indicates if a stream is setup to a A2DP sink on the remote device.
|
||||
MOZ_ASSERT(value.type() == BluetoothValue::Tbool);
|
||||
mConnected = value.get_bool();
|
||||
NotifyStatusChanged();
|
||||
NotifyAudioManager();
|
||||
} else if (name.EqualsLiteral("Playing")) {
|
||||
// Indicates if a stream is active to a A2DP sink on the remote device.
|
||||
MOZ_ASSERT(value.type() == BluetoothValue::Tbool);
|
||||
@ -278,3 +280,65 @@ BluetoothA2dpManager::HandleSinkStateChanged(SinkState aState)
|
||||
|
||||
mSinkState = aState;
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothA2dpManager::NotifyStatusChanged()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
NS_NAMED_LITERAL_STRING(type, BLUETOOTH_A2DP_STATUS_CHANGED);
|
||||
InfallibleTArray<BluetoothNamedValue> parameters;
|
||||
|
||||
BluetoothValue v = mConnected;
|
||||
parameters.AppendElement(
|
||||
BluetoothNamedValue(NS_LITERAL_STRING("connected"), v));
|
||||
|
||||
v = mDeviceAddress;
|
||||
parameters.AppendElement(
|
||||
BluetoothNamedValue(NS_LITERAL_STRING("address"), v));
|
||||
|
||||
if (!BroadcastSystemMessage(type, parameters)) {
|
||||
NS_WARNING("Failed to broadcast system message to settings");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothA2dpManager::NotifyAudioManager()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
NS_ENSURE_TRUE_VOID(obs);
|
||||
|
||||
nsAutoString data;
|
||||
data.AppendInt(mConnected);
|
||||
|
||||
if (NS_FAILED(obs->NotifyObservers(this,
|
||||
BLUETOOTH_A2DP_STATUS_CHANGED,
|
||||
data.BeginReading()))) {
|
||||
NS_WARNING("Failed to notify bluetooth-a2dp-status-changed observsers!");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothA2dpManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
int aChannel)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothA2dpManager::OnUpdateSdpRecords(const nsAString& aDeviceAddress)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothA2dpManager::GetAddress(nsAString& aDeviceAddress)
|
||||
{
|
||||
aDeviceAddress = mDeviceAddress;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS0(BluetoothA2dpManager)
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define mozilla_dom_bluetooth_bluetootha2dpmanager_h__
|
||||
|
||||
#include "BluetoothCommon.h"
|
||||
#include "BluetoothProfileManagerBase.h"
|
||||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
@ -23,9 +24,11 @@ class BluetoothA2dpManagerObserver;
|
||||
class BluetoothValue;
|
||||
class BluetoothSocket;
|
||||
|
||||
class BluetoothA2dpManager
|
||||
class BluetoothA2dpManager : public BluetoothProfileManagerBase
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
static BluetoothA2dpManager* Get();
|
||||
~BluetoothA2dpManager();
|
||||
|
||||
@ -34,6 +37,11 @@ public:
|
||||
void HandleSinkPropertyChanged(const BluetoothSignal& aSignal);
|
||||
nsresult HandleShutdown();
|
||||
|
||||
virtual void OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
int aChannel) MOZ_OVERRIDE;
|
||||
virtual void GetAddress(nsAString& aDeviceAddress) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
BluetoothA2dpManager();
|
||||
bool Init();
|
||||
@ -41,6 +49,9 @@ private:
|
||||
|
||||
void HandleSinkStateChanged(SinkState aState);
|
||||
|
||||
void NotifyStatusChanged();
|
||||
void NotifyAudioManager();
|
||||
|
||||
bool mConnected;
|
||||
bool mPlaying;
|
||||
nsString mDeviceAddress;
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "BluetoothHfpManager.h"
|
||||
|
||||
#include "BluetoothA2dpManager.h"
|
||||
#include "BluetoothReplyRunnable.h"
|
||||
#include "BluetoothService.h"
|
||||
#include "BluetoothSocket.h"
|
||||
@ -62,7 +63,7 @@ using namespace mozilla::ipc;
|
||||
USING_BLUETOOTH_NAMESPACE
|
||||
|
||||
namespace {
|
||||
StaticAutoPtr<BluetoothHfpManager> gBluetoothHfpManager;
|
||||
StaticRefPtr<BluetoothHfpManager> gBluetoothHfpManager;
|
||||
StaticRefPtr<BluetoothHfpManagerObserver> sHfpObserver;
|
||||
bool gInShutdown = false;
|
||||
static const char kHfpCrlf[] = "\xd\xa";
|
||||
@ -526,7 +527,7 @@ BluetoothHfpManager::NotifyDialer(const nsAString& aCommand)
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothHfpManager::NotifyAudioManager(const nsAString& aAddress)
|
||||
BluetoothHfpManager::NotifyAudioManager(bool aStatus)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
@ -534,9 +535,12 @@ BluetoothHfpManager::NotifyAudioManager(const nsAString& aAddress)
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
NS_ENSURE_TRUE_VOID(obs);
|
||||
|
||||
if (NS_FAILED(obs->NotifyObservers(nullptr,
|
||||
nsAutoString data;
|
||||
data.AppendInt(aStatus);
|
||||
|
||||
if (NS_FAILED(obs->NotifyObservers(this,
|
||||
BLUETOOTH_SCO_STATUS_CHANGED,
|
||||
aAddress.BeginReading()))) {
|
||||
data.BeginReading()))) {
|
||||
NS_WARNING("Failed to notify bluetooth-sco-status-changed observsers!");
|
||||
}
|
||||
}
|
||||
@ -1114,6 +1118,10 @@ BluetoothHfpManager::Disconnect()
|
||||
mSocket->Disconnect();
|
||||
mSocket = nullptr;
|
||||
}
|
||||
|
||||
BluetoothA2dpManager* a2dp = BluetoothA2dpManager::Get();
|
||||
NS_ENSURE_TRUE_VOID(a2dp);
|
||||
a2dp->Disconnect();
|
||||
}
|
||||
|
||||
bool
|
||||
@ -1495,6 +1503,10 @@ BluetoothHfpManager::OnConnectSuccess(BluetoothSocket* aSocket)
|
||||
NotifyStatusChanged(NS_LITERAL_STRING("bluetooth-hfp-status-changed"));
|
||||
|
||||
ListenSco();
|
||||
|
||||
BluetoothA2dpManager* a2dp = BluetoothA2dpManager::Get();
|
||||
NS_ENSURE_TRUE_VOID(a2dp);
|
||||
a2dp->Connect(mDeviceAddress);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1623,7 +1635,7 @@ BluetoothHfpManager::OnScoConnectSuccess()
|
||||
mScoRunnable = nullptr;
|
||||
}
|
||||
|
||||
NotifyAudioManager(mDeviceAddress);
|
||||
NotifyAudioManager(true);
|
||||
NotifyStatusChanged(NS_LITERAL_STRING("bluetooth-sco-status-changed"));
|
||||
|
||||
mScoSocketStatus = mScoSocket->GetConnectionStatus();
|
||||
@ -1647,7 +1659,7 @@ BluetoothHfpManager::OnScoDisconnect()
|
||||
{
|
||||
if (mScoSocketStatus == SocketConnectionStatus::SOCKET_CONNECTED) {
|
||||
ListenSco();
|
||||
NotifyAudioManager(EmptyString());
|
||||
NotifyAudioManager(false);
|
||||
NotifyStatusChanged(NS_LITERAL_STRING("bluetooth-sco-status-changed"));
|
||||
}
|
||||
}
|
||||
@ -1752,3 +1764,6 @@ BluetoothHfpManager::IsScoConnected()
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS0(BluetoothHfpManager)
|
||||
|
||||
|
@ -55,6 +55,8 @@ class BluetoothHfpManager : public BluetoothSocketObserver
|
||||
, public BluetoothProfileManagerBase
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
static BluetoothHfpManager* Get();
|
||||
~BluetoothHfpManager();
|
||||
|
||||
@ -68,6 +70,7 @@ public:
|
||||
const nsAString& aServiceUuid,
|
||||
int aChannel) MOZ_OVERRIDE;
|
||||
virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) MOZ_OVERRIDE;
|
||||
virtual void GetAddress(nsAString& aDeviceAddress) MOZ_OVERRIDE;
|
||||
|
||||
void Connect(const nsAString& aDeviceAddress,
|
||||
const bool aIsHandsfree,
|
||||
@ -87,7 +90,6 @@ public:
|
||||
|
||||
bool IsConnected();
|
||||
bool IsScoConnected();
|
||||
void GetAddress(nsAString& aDeviceAddress);
|
||||
|
||||
private:
|
||||
class GetVolumeTask;
|
||||
@ -114,7 +116,7 @@ private:
|
||||
|
||||
void NotifyDialer(const nsAString& aCommand);
|
||||
void NotifyStatusChanged(const nsAString& aType);
|
||||
void NotifyAudioManager(const nsAString& aAddress);
|
||||
void NotifyAudioManager(bool aStatus);
|
||||
|
||||
bool SendCommand(const char* aCommand, uint32_t aValue = 0);
|
||||
bool SendLine(const char* aMessage);
|
||||
|
@ -86,7 +86,7 @@ static const uint32_t kUpdateProgressBase = 50 * 1024;
|
||||
*/
|
||||
static const uint32_t kPutRequestHeaderSize = 6;
|
||||
|
||||
StaticAutoPtr<BluetoothOppManager> sInstance;
|
||||
StaticRefPtr<BluetoothOppManager> sInstance;
|
||||
|
||||
/*
|
||||
* FIXME / Bug 806749
|
||||
@ -1508,6 +1508,8 @@ BluetoothOppManager::OnUpdateSdpRecords(const nsAString& aDeviceAddress)
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS0(BluetoothOppManager)
|
||||
|
||||
bool
|
||||
BluetoothOppManager::AcquireSdcardMountLock()
|
||||
{
|
||||
|
@ -29,6 +29,8 @@ class BluetoothOppManager : public BluetoothSocketObserver
|
||||
, public BluetoothProfileManagerBase
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/*
|
||||
* Channel of reserved services are fixed values, please check
|
||||
* function add_reserved_service_records() in
|
||||
@ -76,7 +78,6 @@ public:
|
||||
// Return true if there is an ongoing file-transfer session, please see
|
||||
// Bug 827267 for more information.
|
||||
bool IsTransferring();
|
||||
void GetAddress(nsAString& aDeviceAddress);
|
||||
|
||||
// Implement interface BluetoothSocketObserver
|
||||
void ReceiveSocketData(
|
||||
@ -90,6 +91,7 @@ public:
|
||||
const nsAString& aServiceUuid,
|
||||
int aChannel) MOZ_OVERRIDE;
|
||||
virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) MOZ_OVERRIDE;
|
||||
virtual void GetAddress(nsAString& aDeviceAddress) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
BluetoothOppManager();
|
||||
|
@ -13,14 +13,14 @@
|
||||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
class BluetoothProfileManagerBase
|
||||
class BluetoothProfileManagerBase : public nsISupports
|
||||
{
|
||||
public:
|
||||
virtual void OnGetServiceChannel(const nsAString& aDeviceAddress,
|
||||
const nsAString& aServiceUuid,
|
||||
int aChannel) = 0;
|
||||
|
||||
virtual void OnUpdateSdpRecords(const nsAString& aDeviceAddress) = 0;
|
||||
virtual void GetAddress(nsAString& aDeviceAddress) = 0;
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
Loading…
Reference in New Issue
Block a user