Backed out changeset 1ebe50bb4fad (bug 1220121)

This commit is contained in:
Carsten "Tomcat" Book 2015-11-11 12:06:46 +01:00
Родитель ecd9413df1
Коммит ecf2991010
11 изменённых файлов: 72 добавлений и 58 удалений

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

@ -70,6 +70,32 @@ USING_BLUETOOTH_NAMESPACE
static BluetoothInterface* sBtInterface;
static nsTArray<RefPtr<BluetoothProfileController> > sControllerArray;
/*
* Static methods
*/
ControlPlayStatus
BluetoothServiceBluedroid::PlayStatusStringToControlPlayStatus(
const nsAString& aPlayStatus)
{
ControlPlayStatus playStatus = ControlPlayStatus::PLAYSTATUS_UNKNOWN;
if (aPlayStatus.EqualsLiteral("STOPPED")) {
playStatus = ControlPlayStatus::PLAYSTATUS_STOPPED;
} else if (aPlayStatus.EqualsLiteral("PLAYING")) {
playStatus = ControlPlayStatus::PLAYSTATUS_PLAYING;
} else if (aPlayStatus.EqualsLiteral("PAUSED")) {
playStatus = ControlPlayStatus::PLAYSTATUS_PAUSED;
} else if (aPlayStatus.EqualsLiteral("FWD_SEEK")) {
playStatus = ControlPlayStatus::PLAYSTATUS_FWD_SEEK;
} else if (aPlayStatus.EqualsLiteral("REV_SEEK")) {
playStatus = ControlPlayStatus::PLAYSTATUS_REV_SEEK;
} else if (aPlayStatus.EqualsLiteral("ERROR")) {
playStatus = ControlPlayStatus::PLAYSTATUS_ERROR;
}
return playStatus;
}
class BluetoothServiceBluedroid::EnableResultHandler final
: public BluetoothResultHandler
{
@ -1926,12 +1952,15 @@ BluetoothServiceBluedroid::SendMetaData(const nsAString& aTitle,
void
BluetoothServiceBluedroid::SendPlayStatus(
int64_t aDuration, int64_t aPosition, ControlPlayStatus aPlayStatus,
int64_t aDuration, int64_t aPosition,
const nsAString& aPlayStatus,
BluetoothReplyRunnable* aRunnable)
{
BluetoothAvrcpManager* avrcp = BluetoothAvrcpManager::Get();
if (avrcp) {
avrcp->UpdatePlayStatus(aDuration, aPosition, aPlayStatus);
ControlPlayStatus playStatus =
PlayStatusStringToControlPlayStatus(aPlayStatus);
avrcp->UpdatePlayStatus(aDuration, aPosition, playStatus);
}
DispatchReplySuccess(aRunnable);
}

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

@ -255,7 +255,7 @@ public:
virtual void
SendPlayStatus(int64_t aDuration,
int64_t aPosition,
ControlPlayStatus aPlayStatus,
const nsAString& aPlayStatus,
BluetoothReplyRunnable* aRunnable) override;
virtual void
@ -486,6 +486,9 @@ protected:
static nsresult StartGonkBluetooth();
static nsresult StopGonkBluetooth();
static ControlPlayStatus PlayStatusStringToControlPlayStatus(
const nsAString& aPlayStatus);
static void ConnectDisconnect(bool aConnect,
const BluetoothAddress& aDeviceAddress,
BluetoothReplyRunnable* aRunnable,

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

@ -4044,6 +4044,27 @@ BluetoothDBusService::SendMetaData(const nsAString& aTitle,
aMediaNumber, aTotalMediaCount, aDuration);
}
static ControlPlayStatus
PlayStatusStringToControlPlayStatus(const nsAString& aPlayStatus)
{
ControlPlayStatus playStatus = ControlPlayStatus::PLAYSTATUS_UNKNOWN;
if (aPlayStatus.EqualsLiteral("STOPPED")) {
playStatus = ControlPlayStatus::PLAYSTATUS_STOPPED;
} else if (aPlayStatus.EqualsLiteral("PLAYING")) {
playStatus = ControlPlayStatus::PLAYSTATUS_PLAYING;
} else if (aPlayStatus.EqualsLiteral("PAUSED")) {
playStatus = ControlPlayStatus::PLAYSTATUS_PAUSED;
} else if (aPlayStatus.EqualsLiteral("FWD_SEEK")) {
playStatus = ControlPlayStatus::PLAYSTATUS_FWD_SEEK;
} else if (aPlayStatus.EqualsLiteral("REV_SEEK")) {
playStatus = ControlPlayStatus::PLAYSTATUS_REV_SEEK;
} else if (aPlayStatus.EqualsLiteral("ERROR")) {
playStatus = ControlPlayStatus::PLAYSTATUS_ERROR;
}
return playStatus;
}
class SendPlayStatusTask : public Task
{
public:
@ -4098,7 +4119,7 @@ private:
void
BluetoothDBusService::SendPlayStatus(int64_t aDuration,
int64_t aPosition,
ControlPlayStatus aPlayStatus,
const nsAString& aPlayStatus,
BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
@ -4109,7 +4130,9 @@ BluetoothDBusService::SendPlayStatus(int64_t aDuration,
return;
}
if (aPlayStatus == ControlPlayStatus::PLAYSTATUS_UNKNOWN) {
ControlPlayStatus playStatus =
PlayStatusStringToControlPlayStatus(aPlayStatus);
if (playStatus == ControlPlayStatus::PLAYSTATUS_UNKNOWN) {
DispatchBluetoothReply(aRunnable, BluetoothValue(),
NS_LITERAL_STRING("Invalid play status"));
return;
@ -4132,9 +4155,9 @@ BluetoothDBusService::SendPlayStatus(int64_t aDuration,
return;
}
if (aPlayStatus != avrcp->GetPlayStatus()) {
if (playStatus != avrcp->GetPlayStatus()) {
UpdateNotification(ControlEventId::EVENT_PLAYBACK_STATUS_CHANGED,
aPlayStatus);
playStatus);
} else if (aPosition != avrcp->GetPosition()) {
UpdateNotification(ControlEventId::EVENT_PLAYBACK_POS_CHANGED, aPosition);
}
@ -4145,11 +4168,11 @@ BluetoothDBusService::SendPlayStatus(int64_t aDuration,
Task* task = new SendPlayStatusTask(deviceAddress,
aDuration,
aPosition,
aPlayStatus,
playStatus,
aRunnable);
DispatchToDBusThread(task);
avrcp->UpdatePlayStatus(aDuration, aPosition, aPlayStatus);
avrcp->UpdatePlayStatus(aDuration, aPosition, playStatus);
}
static void

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

@ -268,7 +268,7 @@ public:
virtual void
SendPlayStatus(int64_t aDuration,
int64_t aPosition,
ControlPlayStatus aPlayStatus,
const nsAString& aPlayStatus,
BluetoothReplyRunnable* aRunnable) override;
virtual void

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

@ -421,7 +421,7 @@ public:
virtual void
SendPlayStatus(int64_t aDuration,
int64_t aPosition,
ControlPlayStatus aPlayStatus,
const nsAString& aPlayStatus,
BluetoothReplyRunnable* aRunnable) = 0;
virtual void

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

@ -97,31 +97,6 @@ StringToPinCode(const nsAString& aString, BluetoothPinCode& aPinCode)
return NS_OK;
}
nsresult
StringToControlPlayStatus(const nsAString& aString,
ControlPlayStatus& aPlayStatus)
{
if (aString.EqualsLiteral("STOPPED")) {
aPlayStatus = ControlPlayStatus::PLAYSTATUS_STOPPED;
} else if (aString.EqualsLiteral("PLAYING")) {
aPlayStatus = ControlPlayStatus::PLAYSTATUS_PLAYING;
} else if (aString.EqualsLiteral("PAUSED")) {
aPlayStatus = ControlPlayStatus::PLAYSTATUS_PAUSED;
} else if (aString.EqualsLiteral("FWD_SEEK")) {
aPlayStatus = ControlPlayStatus::PLAYSTATUS_FWD_SEEK;
} else if (aString.EqualsLiteral("REV_SEEK")) {
aPlayStatus = ControlPlayStatus::PLAYSTATUS_REV_SEEK;
} else if (aString.EqualsLiteral("ERROR")) {
aPlayStatus = ControlPlayStatus::PLAYSTATUS_ERROR;
} else {
BT_LOGR("Invalid play status: %s", NS_ConvertUTF16toUTF8(aString).get());
aPlayStatus = ControlPlayStatus::PLAYSTATUS_UNKNOWN;
return NS_ERROR_ILLEGAL_VALUE;
}
return NS_OK;
}
nsresult
StringToPropertyType(const nsAString& aString, BluetoothPropertyType& aType)
{

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

@ -43,14 +43,6 @@ PinCodeToString(const BluetoothPinCode& aPinCode, nsAString& aString);
nsresult
StringToPinCode(const nsAString& aString, BluetoothPinCode& aPinCode);
//
// Play status/string conversion
//
nsresult
StringToControlPlayStatus(const nsAString& aString,
ControlPlayStatus& aPlayStatus);
//
// Property type/string conversion
//

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

@ -2008,13 +2008,6 @@ BluetoothAdapter::SendMediaMetaData(
return nullptr;
}
ControlPlayStatus playStatus;
auto rv = StringToControlPlayStatus(aMediaPlayStatus.mPlayStatus, playStatus);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
}
RefPtr<DOMRequest> request = new DOMRequest(win);
RefPtr<BluetoothReplyRunnable> results =
new BluetoothVoidReplyRunnable(request);
@ -2056,7 +2049,7 @@ BluetoothAdapter::SendMediaPlayStatus(
}
bs->SendPlayStatus(aMediaPlayStatus.mDuration,
aMediaPlayStatus.mPosition,
playStatus,
aMediaPlayStatus.mPlayStatus,
results);
return request.forget();

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

@ -541,11 +541,12 @@ BluetoothServiceChildProcess::SendMetaData(const nsAString& aTitle,
void
BluetoothServiceChildProcess::SendPlayStatus(int64_t aDuration,
int64_t aPosition,
ControlPlayStatus aPlayStatus,
const nsAString& aPlayStatus,
BluetoothReplyRunnable* aRunnable)
{
SendRequest(aRunnable,
SendPlayStatusRequest(aDuration, aPosition, aPlayStatus));
SendPlayStatusRequest(aDuration, aPosition,
nsString(aPlayStatus)));
}
void

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

@ -267,7 +267,7 @@ public:
virtual void
SendPlayStatus(int64_t aDuration,
int64_t aPosition,
ControlPlayStatus aPlayStatus,
const nsAString& aPlayStatus,
BluetoothReplyRunnable* aRunnable) override;
virtual void

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

@ -18,8 +18,6 @@ using mozilla::dom::bluetooth::BluetoothObjectType
from "mozilla/dom/bluetooth/BluetoothCommon.h";
using mozilla::dom::bluetooth::BluetoothPinCode
from "mozilla/dom/bluetooth/BluetoothCommon.h";
using mozilla::dom::bluetooth::ControlPlayStatus
from "mozilla/dom/bluetooth/BluetoothCommon.h";
namespace mozilla {
namespace dom {
@ -270,7 +268,7 @@ struct SendPlayStatusRequest
{
int64_t duration;
int64_t position;
ControlPlayStatus playStatus;
nsString playStatus;
};
struct ConnectGattClientRequest