зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset dc164758f576 (bug 1220121)
This commit is contained in:
Родитель
d03ac03d02
Коммит
4b689b06f4
|
@ -1399,19 +1399,26 @@ private:
|
|||
void
|
||||
BluetoothServiceBluedroid::PinReplyInternal(
|
||||
const BluetoothAddress& aDeviceAddress, bool aAccept,
|
||||
const BluetoothPinCode& aPinCode, BluetoothReplyRunnable* aRunnable)
|
||||
const nsAString& aPinCode, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ENSURE_BLUETOOTH_IS_READY_VOID(aRunnable);
|
||||
|
||||
sBtInterface->PinReply(aDeviceAddress, aAccept, aPinCode,
|
||||
BluetoothPinCode pinCode;
|
||||
auto rv = StringToPinCode(aPinCode, pinCode);
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchReplyError(aRunnable, STATUS_PARM_INVALID);
|
||||
return;
|
||||
}
|
||||
|
||||
sBtInterface->PinReply(aDeviceAddress, aAccept, pinCode,
|
||||
new PinReplyResultHandler(aRunnable));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothServiceBluedroid::SetPinCodeInternal(
|
||||
const BluetoothAddress& aDeviceAddress, const BluetoothPinCode& aPinCode,
|
||||
const BluetoothAddress& aDeviceAddress, const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
// Legacy method used by BlueZ only.
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
virtual void
|
||||
PinReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aAccept,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
|
@ -97,7 +97,7 @@ public:
|
|||
BluetoothReplyRunnable* aRunnable);
|
||||
virtual void
|
||||
SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
|
|
|
@ -3247,7 +3247,7 @@ class SetPinCodeTask : public Task
|
|||
{
|
||||
public:
|
||||
SetPinCodeTask(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
const nsACString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
: mDeviceAddress(aDeviceAddress)
|
||||
, mPinCode(aPinCode)
|
||||
|
@ -3281,19 +3281,7 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
nsAutoString pinCodeStr;
|
||||
if (NS_FAILED(PinCodeToString(mPinCode, pinCodeStr))) {
|
||||
BT_WARNING("%s: Cannot convert pin code to string.", __FUNCTION__);
|
||||
dbus_message_unref(msg);
|
||||
dbus_message_unref(reply);
|
||||
errorStr.AssignLiteral("Cannot convert pin code to string.");
|
||||
DispatchBluetoothReply(mRunnable, v, errorStr);
|
||||
return;
|
||||
}
|
||||
|
||||
auto utf8PinCodeStr = NS_ConvertUTF16toUTF8(pinCodeStr);
|
||||
|
||||
const char* pinCode = utf8PinCodeStr.get();
|
||||
const char* pinCode = mPinCode.get();
|
||||
|
||||
if (!dbus_message_append_args(reply,
|
||||
DBUS_TYPE_STRING, &pinCode,
|
||||
|
@ -3314,14 +3302,14 @@ public:
|
|||
|
||||
private:
|
||||
const BluetoothAddress mDeviceAddress;
|
||||
const BluetoothPinCode mPinCode;
|
||||
const nsCString mPinCode;
|
||||
RefPtr<BluetoothReplyRunnable> mRunnable;
|
||||
};
|
||||
|
||||
void
|
||||
BluetoothDBusService::PinReplyInternal(
|
||||
const BluetoothAddress& aDeviceAddress, bool aAccept,
|
||||
const BluetoothPinCode& aPinCode, BluetoothReplyRunnable* aRunnable)
|
||||
const nsAString& aPinCode, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
// Legacy interface used by Bluedroid only.
|
||||
}
|
||||
|
@ -3336,10 +3324,12 @@ BluetoothDBusService::SspReplyInternal(
|
|||
|
||||
void
|
||||
BluetoothDBusService::SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
Task* task = new SetPinCodeTask(aDeviceAddress, aPinCode, aRunnable);
|
||||
Task* task = new SetPinCodeTask(aDeviceAddress,
|
||||
NS_ConvertUTF16toUTF8(aPinCode),
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
virtual void
|
||||
PinReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aAccept,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
virtual void
|
||||
|
@ -110,7 +110,7 @@ public:
|
|||
|
||||
virtual void
|
||||
SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
|
|
|
@ -674,24 +674,6 @@ struct BluetoothUuid {
|
|||
struct BluetoothPinCode {
|
||||
uint8_t mPinCode[16]; /* not \0-terminated */
|
||||
uint8_t mLength;
|
||||
|
||||
BluetoothPinCode()
|
||||
: mLength(0)
|
||||
{
|
||||
std::fill(mPinCode, mPinCode + MOZ_ARRAY_LENGTH(mPinCode), 0);
|
||||
}
|
||||
|
||||
bool operator==(const BluetoothPinCode& aRhs) const
|
||||
{
|
||||
MOZ_ASSERT(mLength <= MOZ_ARRAY_LENGTH(mPinCode));
|
||||
return (mLength == aRhs.mLength) &&
|
||||
std::equal(aRhs.mPinCode, aRhs.mPinCode + aRhs.mLength, mPinCode);
|
||||
}
|
||||
|
||||
bool operator!=(const BluetoothPinCode& aRhs) const
|
||||
{
|
||||
return !operator==(aRhs);
|
||||
}
|
||||
};
|
||||
|
||||
struct BluetoothServiceName {
|
||||
|
|
|
@ -244,7 +244,7 @@ public:
|
|||
virtual void
|
||||
PinReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aAccept,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
virtual void
|
||||
|
@ -258,7 +258,7 @@ public:
|
|||
*/
|
||||
virtual void
|
||||
SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) = 0;
|
||||
|
||||
/**
|
||||
|
|
|
@ -61,21 +61,6 @@ StringToAddress(const nsAString& aString, BluetoothAddress& aAddress)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
PinCodeToString(const BluetoothPinCode& aPinCode, nsAString& aString)
|
||||
{
|
||||
if (aPinCode.mLength > sizeof(aPinCode.mPinCode)) {
|
||||
BT_LOGR("Pin-code string too long");
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
aString = NS_ConvertUTF8toUTF16(
|
||||
nsCString(reinterpret_cast<const char*>(aPinCode.mPinCode),
|
||||
aPinCode.mLength));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
StringToPinCode(const nsAString& aString, BluetoothPinCode& aPinCode)
|
||||
{
|
||||
|
@ -84,7 +69,7 @@ StringToPinCode(const nsAString& aString, BluetoothPinCode& aPinCode)
|
|||
auto len = stringUTF8.Length();
|
||||
|
||||
if (len > sizeof(aPinCode.mPinCode)) {
|
||||
BT_LOGR("Pin-code string too long");
|
||||
BT_LOGR("Service-name string too long");
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,9 +37,6 @@ StringToAddress(const nsAString& aString, BluetoothAddress& aAddress);
|
|||
// Pin code/string conversion
|
||||
//
|
||||
|
||||
nsresult
|
||||
PinCodeToString(const BluetoothPinCode& aPinCode, nsAString& aString);
|
||||
|
||||
nsresult
|
||||
StringToPinCode(const nsAString& aString, BluetoothPinCode& aPinCode);
|
||||
|
||||
|
|
|
@ -86,15 +86,10 @@ BluetoothPairingHandle::SetPinCode(const nsAString& aPinCode, ErrorResult& aRv)
|
|||
promise,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
|
||||
BluetoothPinCode pinCode;
|
||||
BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(StringToPinCode(aPinCode, pinCode)),
|
||||
promise,
|
||||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
bs->PinReplyInternal(deviceAddress, true /* accept */, pinCode,
|
||||
bs->PinReplyInternal(deviceAddress, true /* accept */, aPinCode,
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
|
||||
return promise.forget();
|
||||
|
@ -159,8 +154,7 @@ BluetoothPairingHandle::Reject(ErrorResult& aRv)
|
|||
BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
if (mType.EqualsLiteral(PAIRING_REQ_TYPE_ENTERPINCODE)) { // Pin request
|
||||
bs->PinReplyInternal(deviceAddress, false /* aAccept */,
|
||||
BluetoothPinCode(),
|
||||
bs->PinReplyInternal(deviceAddress, false /* aAccept */, EmptyString(),
|
||||
new BluetoothVoidReplyRunnable(nullptr, promise));
|
||||
} else { // Ssp request
|
||||
BluetoothSspVariant variant;
|
||||
|
|
|
@ -221,9 +221,12 @@ BluetoothServiceChildProcess::UpdateSdpRecords(const BluetoothAddress& aDeviceAd
|
|||
void
|
||||
BluetoothServiceChildProcess::PinReplyInternal(
|
||||
const BluetoothAddress& aDeviceAddress, bool aAccept,
|
||||
const BluetoothPinCode& aPinCode, BluetoothReplyRunnable* aRunnable)
|
||||
const nsAString& aPinCode, BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, PinReplyRequest(aDeviceAddress, aAccept, aPinCode));
|
||||
SendRequest(aRunnable,
|
||||
PinReplyRequest(aDeviceAddress,
|
||||
aAccept,
|
||||
nsString(aPinCode)));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -238,10 +241,11 @@ BluetoothServiceChildProcess::SspReplyInternal(
|
|||
void
|
||||
BluetoothServiceChildProcess::SetPinCodeInternal(
|
||||
const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
SendRequest(aRunnable, SetPinCodeRequest(aDeviceAddress, aPinCode));
|
||||
SendRequest(aRunnable,
|
||||
SetPinCodeRequest(aDeviceAddress, nsString(aPinCode)));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -92,7 +92,7 @@ public:
|
|||
|
||||
virtual void
|
||||
SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
|
@ -109,7 +109,7 @@ public:
|
|||
virtual void
|
||||
PinReplyInternal(const BluetoothAddress& aDeviceAddress,
|
||||
bool aAccept,
|
||||
const BluetoothPinCode& aPinCode,
|
||||
const nsAString& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable) override;
|
||||
|
||||
virtual void
|
||||
|
|
|
@ -16,8 +16,6 @@ using mozilla::dom::bluetooth::BluetoothAddress
|
|||
from "mozilla/dom/bluetooth/BluetoothCommon.h";
|
||||
using mozilla::dom::bluetooth::BluetoothObjectType
|
||||
from "mozilla/dom/bluetooth/BluetoothCommon.h";
|
||||
using mozilla::dom::bluetooth::BluetoothPinCode
|
||||
from "mozilla/dom/bluetooth/BluetoothCommon.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -83,7 +81,7 @@ struct PinReplyRequest
|
|||
{
|
||||
BluetoothAddress address;
|
||||
bool accept;
|
||||
BluetoothPinCode pinCode;
|
||||
nsString pinCode;
|
||||
};
|
||||
|
||||
struct SspReplyRequest
|
||||
|
@ -96,7 +94,7 @@ struct SspReplyRequest
|
|||
struct SetPinCodeRequest
|
||||
{
|
||||
BluetoothAddress address;
|
||||
BluetoothPinCode pincode;
|
||||
nsString pincode;
|
||||
};
|
||||
|
||||
struct SetPasskeyRequest
|
||||
|
|
Загрузка…
Ссылка в новой задаче