This commit is contained in:
Ryan VanderMeulen 2015-01-09 14:45:50 -05:00
Родитель 4b42b6328c 2b996c81ea
Коммит 9a378a0290
163 изменённых файлов: 2745 добавлений и 1057 удалений

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

@ -3,7 +3,7 @@
ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}
ac_add_options --enable-update-packaging
ac_add_options --with-l10n-base=../../l10n
ac_add_options --with-windows-version=601
ac_add_options --with-windows-version=603
export MOZILLA_OFFICIAL=1

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

@ -1,94 +0,0 @@
#!/usr/bin/perl -w
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
use Getopt::Long;
use strict;
use vars qw(
$OBJDIR
$SRCDIR
$TOPSRCDIR
$SCRIPTDIR
@TEMPLATE_FILE
$MILESTONE_FILE
$MILESTONE
$MILESTONE_NUM
@MILESTONE_PARTS
$MINI_VERSION
$MICRO_VERSION
$opt_debug
$opt_template
$opt_uaversion
$opt_symbolversion
$opt_help
);
$SCRIPTDIR = $0;
$SCRIPTDIR =~ s/[^\/]*$//;
push(@INC,$SCRIPTDIR);
require "Moz/Milestone.pm";
&GetOptions('topsrcdir=s' => \$TOPSRCDIR, 'srcdir=s' => \$SRCDIR, 'objdir=s' => \$OBJDIR, 'debug', 'help', 'template', 'uaversion', 'symbolversion');
if (defined($opt_help)) {
&usage();
exit;
}
if (defined($opt_template)) {
@TEMPLATE_FILE = @ARGV;
if ($opt_debug) {
print("TEMPLATE_FILE = --@TEMPLATE_FILE--\n");
}
}
if (!defined($SRCDIR)) { $SRCDIR = '.'; }
if (!defined($OBJDIR)) { $OBJDIR = '.'; }
$MILESTONE_FILE = "$TOPSRCDIR/config/milestone.txt";
@MILESTONE_PARTS = (0, 0, 0, 0);
#
# Grab milestone (top line of $MILESTONE_FILE that starts with a digit)
#
my $milestone = Moz::Milestone::getOfficialMilestone($MILESTONE_FILE);
if (@TEMPLATE_FILE) {
my $TFILE;
foreach $TFILE (@TEMPLATE_FILE) {
my $BUILT_FILE = "$OBJDIR/$TFILE";
$TFILE = "$SRCDIR/$TFILE.tmpl";
if (-e $TFILE) {
Moz::Milestone::build_file($TFILE,$BUILT_FILE);
} else {
warn("$0: No such file $TFILE!\n");
}
}
} elsif(defined($opt_uaversion)) {
# Only expose the major milestone in the UA string, hide the patch level
# (bugs 572659 and 870868).
my $uaversion = Moz::Milestone::getMilestoneMajor($milestone) . ".0";
print "$uaversion\n";
} elsif(defined($opt_symbolversion)) {
# Only expose major milestone and alpha version. Used for symbol versioning
# on Linux.
my $symbolversion = Moz::Milestone::getMilestoneMajor($milestone) .
Moz::Milestone::getMilestoneABWithNum($milestone);
print "$symbolversion\n";
} else {
print "$milestone\n";
}
sub usage() {
print <<END
`milestone.pl [--topsrcdir TOPSRCDIR] [--objdir OBJDIR] [--srcdir SRCDIR] --template [file list] --uaversion --symbolversion` # will build file list from .tmpl files
END
;
}

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

@ -5,7 +5,7 @@
# x.x.x.x
# x.x.x+
#
# Referenced by milestone.pl.
# Referenced by milestone.py.
# Hopefully I'll be able to automate replacement of *all*
# hardcoded milestones in the tree from these two files.
#--------------------------------------------------------

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

@ -290,6 +290,11 @@ if test -n "$gonkdir" ; then
AC_SUBST(MOZ_AUDIO_OFFLOAD)
AC_DEFINE(MOZ_AUDIO_OFFLOAD)
MOZ_FMP4=
MOZ_B2G_BT=1
MOZ_B2G_BT_BLUEDROID=1
if test -d "$gonkdir/system/bluetoothd"; then
MOZ_B2G_BT_DAEMON=1
fi
;;
*)
AC_MSG_ERROR([Unsupported platform version: $ANDROID_VERSION])
@ -1882,10 +1887,12 @@ case "$host" in
;;
esac
dnl ==============================================================
dnl Get mozilla version from central milestone file
MOZILLA_VERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir`
MOZILLA_UAVERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir -uaversion`
MOZILLA_SYMBOLVERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir -symbolversion`
dnl ==============================================================
MOZILLA_VERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir`
MOZILLA_UAVERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir --uaversion`
MOZILLA_SYMBOLVERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir --symbolversion`
dnl Get version of various core apps from the version files.
FIREFOX_VERSION=`cat $_topsrcdir/browser/config/version.txt`
@ -2149,7 +2156,7 @@ ia64*-hpux*)
MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
RC='$(WINDRES)'
# Use static libgcc and libstdc++
LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
LDFLAGS="$LDFLAGS -static"
NSPR_LDFLAGS="$NSPR_LDFLAGS -static-libgcc"
# Use temp file for windres (bug 213281)
RCFLAGS='-O coff --use-temp-file'

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

@ -195,6 +195,7 @@
#include "mozilla/dom/EncodingUtils.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/URLSearchParams.h"
#include "nsPerformance.h"
#ifdef MOZ_TOOLKIT_SEARCH
#include "nsIBrowserSearchService.h"
@ -859,6 +860,7 @@ nsDocShell::nsDocShell():
mInvisible(false),
mHasLoadedNonBlankURI(false),
mDefaultLoadFlags(nsIRequest::LOAD_NORMAL),
mBlankTiming(false),
mFrameType(eFrameTypeRegular),
mOwnOrContainingAppId(nsIScriptSecurityManager::UNKNOWN_APP_ID),
mParentCharsetSource(0),
@ -1770,11 +1772,22 @@ nsDocShell::FirePageHideNotification(bool aIsUnload)
void
nsDocShell::MaybeInitTiming()
{
if (mTiming) {
if (mTiming && !mBlankTiming) {
return;
}
mTiming = new nsDOMNavigationTiming();
if (mScriptGlobal && mBlankTiming) {
nsPIDOMWindow* innerWin = mScriptGlobal->GetCurrentInnerWindow();
if (innerWin && innerWin->GetPerformance()) {
mTiming = innerWin->GetPerformance()->GetDOMTiming();
mBlankTiming = false;
}
}
if (!mTiming) {
mTiming = new nsDOMNavigationTiming();
}
mTiming->NotifyNavigationStart();
}
@ -7869,6 +7882,7 @@ nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
// have one before entering this function.
if (!hadTiming) {
mTiming = nullptr;
mBlankTiming = true;
}
return rv;

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

@ -929,6 +929,11 @@ protected:
nsRefPtr<nsDOMNavigationTiming> mTiming;
// This flag means that mTiming has been initialized but nulled out.
// We will check the innerWin's timing before creating a new one
// in MaybeInitTiming()
bool mBlankTiming;
// Are we a regular frame, a browser frame, or an app frame?
FrameType mFrameType;

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

@ -185,11 +185,11 @@ DOMTimeMilliSec
nsPerformanceTiming::RedirectStart()
{
if (!IsInitialized()) {
return mZeroTime;
return 0;
}
// We have to check if all the redirect URIs had the same origin (since there
// is no check in RedirectStartHighRes())
if (mAllRedirectsSameOrigin) {
if (mAllRedirectsSameOrigin && mRedirectCount) {
return static_cast<int64_t>(RedirectStartHighRes());
}
return 0;
@ -218,11 +218,11 @@ DOMTimeMilliSec
nsPerformanceTiming::RedirectEnd()
{
if (!IsInitialized()) {
return mZeroTime;
return 0;
}
// We have to check if all the redirect URIs had the same origin (since there
// is no check in RedirectEndHighRes())
if (mAllRedirectsSameOrigin) {
if (mAllRedirectsSameOrigin && mRedirectCount) {
return static_cast<int64_t>(RedirectEndHighRes());
}
return 0;

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

@ -235,6 +235,22 @@ struct BluetoothProperty {
BluetoothRemoteInfo mRemoteInfo;
};
/* Physical transport for GATT connections to remote dual-mode devices */
enum BluetoothTransport {
TRANSPORT_AUTO, /* No preference of physical transport */
TRANSPORT_BREDR, /* Prefer BR/EDR transport */
TRANSPORT_LE /* Prefer LE transport */
};
struct BluetoothActivityEnergyInfo {
uint8_t mStatus;
uint8_t mStackState; /* stack reported state */
uint64_t mTxTime; /* in ms */
uint64_t mRxTime; /* in ms */
uint64_t mIdleTime; /* in ms */
uint64_t mEnergyUsed; /* a product of mA, V and ms */
};
enum BluetoothSocketType {
RFCOMM = 1,
SCO = 2,
@ -306,6 +322,12 @@ enum BluetoothHandsfreeNetworkState {
HFP_NETWORK_STATE_AVAILABLE
};
enum BluetoothHandsfreeWbsConfig {
HFP_WBS_NONE, /* Neither CVSD nor mSBC codec, but other optional codec.*/
HFP_WBS_NO, /* CVSD */
HFP_WBS_YES /* mSBC */
};
enum BluetoothHandsfreeNRECState {
HFP_NREC_STOPPED,
HFP_NREC_STARTED

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

@ -80,59 +80,72 @@ public:
{ }
virtual void
VoiceRecognitionNotification(BluetoothHandsfreeVoiceRecognitionState aState)
VoiceRecognitionNotification(BluetoothHandsfreeVoiceRecognitionState aState,
const nsAString& aBdAddr)
{ }
virtual void
AnswerCallNotification()
AnswerCallNotification(const nsAString& aBdAddr)
{ }
virtual void
HangupCallNotification()
HangupCallNotification(const nsAString& aBdAddr)
{ }
virtual void
VolumeNotification(BluetoothHandsfreeVolumeType aType, int aVolume)
VolumeNotification(BluetoothHandsfreeVolumeType aType,
int aVolume,
const nsAString& aBdAddr)
{ }
virtual void
DialCallNotification(const nsAString& aNumber)
DialCallNotification(const nsAString& aNumber,
const nsAString& aBdAddr)
{ }
virtual void
DtmfNotification(char aDtmf)
DtmfNotification(char aDtmf,
const nsAString& aBdAddr)
{ }
virtual void
NRECNotification(BluetoothHandsfreeNRECState aNrec)
NRECNotification(BluetoothHandsfreeNRECState aNrec,
const nsAString& aBdAddr)
{ }
virtual void
CallHoldNotification(BluetoothHandsfreeCallHoldType aChld)
WbsNotification(BluetoothHandsfreeWbsConfig aWbs,
const nsAString& aBdAddr)
{ }
virtual void
CnumNotification()
CallHoldNotification(BluetoothHandsfreeCallHoldType aChld,
const nsAString& aBdAddr)
{ }
virtual void
CindNotification()
CnumNotification(const nsAString& aBdAddr)
{ }
virtual void
CopsNotification()
CindNotification(const nsAString& aBdAddr)
{ }
virtual void
ClccNotification()
CopsNotification(const nsAString& aBdAddr)
{ }
virtual void
UnknownAtNotification(const nsACString& aAtString)
ClccNotification(const nsAString& aBdAddr)
{ }
virtual void
KeyPressedNotification()
UnknownAtNotification(const nsACString& aAtString,
const nsAString& aBdAddr)
{ }
virtual void
KeyPressedNotification(const nsAString& aBdAddr)
{ }
protected:
@ -173,6 +186,8 @@ public:
virtual void AtResponse() { }
virtual void ClccResponse() { }
virtual void PhoneStateChange() { }
virtual void ConfigureWbs() { }
};
class BluetoothHandsfreeInterface
@ -180,7 +195,7 @@ class BluetoothHandsfreeInterface
public:
virtual void Init(
BluetoothHandsfreeNotificationHandler* aNotificationHandler,
BluetoothHandsfreeResultHandler* aRes) = 0;
int aMaxNumClients, BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void Cleanup(BluetoothHandsfreeResultHandler* aRes) = 0;
/* Connect / Disconnect */
@ -196,12 +211,15 @@ public:
/* Voice Recognition */
virtual void StartVoiceRecognition(BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void StopVoiceRecognition(BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void StartVoiceRecognition(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void StopVoiceRecognition(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0;
/* Volume */
virtual void VolumeControl(BluetoothHandsfreeVolumeType aType, int aVolume,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0;
/* Device status */
@ -213,15 +231,17 @@ public:
/* Responses */
virtual void CopsResponse(const char* aCops,
virtual void CopsResponse(const char* aCops, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void CindResponse(int aSvc, int aNumActive, int aNumHeld,
BluetoothHandsfreeCallState aCallSetupState,
int aSignal, int aRoam, int aBattChg,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void FormattedAtResponse(const char* aRsp,
virtual void FormattedAtResponse(const char* aRsp, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void AtResponse(BluetoothHandsfreeAtResponse aResponseCode, int aErrorCode,
virtual void AtResponse(BluetoothHandsfreeAtResponse aResponseCode,
int aErrorCode, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0;
virtual void ClccResponse(int aIndex, BluetoothHandsfreeCallDirection aDir,
BluetoothHandsfreeCallState aState,
@ -229,6 +249,7 @@ public:
BluetoothHandsfreeCallMptyType aMpty,
const nsAString& aNumber,
BluetoothHandsfreeCallAddressType aType,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes) = 0;
/* Phone State */
@ -239,6 +260,11 @@ public:
BluetoothHandsfreeCallAddressType aType,
BluetoothHandsfreeResultHandler* aRes) = 0;
/* Wide Band Speech */
virtual void ConfigureWbs(const nsAString& aBdAddr,
BluetoothHandsfreeWbsConfig aConfig,
BluetoothHandsfreeResultHandler* aRes) = 0;
protected:
BluetoothHandsfreeInterface();
virtual ~BluetoothHandsfreeInterface();
@ -263,6 +289,12 @@ public:
const nsAString& aBdAddr)
{ }
virtual void
AudioConfigNotification(const nsAString& aBdAddr,
uint32_t aSampleRate,
uint8_t aChannelCount)
{ }
protected:
BluetoothA2dpNotificationHandler()
{ }
@ -495,6 +527,9 @@ public:
virtual void LeTestModeNotification(BluetoothStatus aStatus,
uint16_t aNumPackets) { }
virtual void EnergyInfoNotification(const BluetoothActivityEnergyInfo& aInfo)
{ }
protected:
BluetoothNotificationHandler()
{ }
@ -535,6 +570,8 @@ public:
virtual void RemoveBond() { }
virtual void CancelBond() { }
virtual void GetConnectionState() { }
virtual void PinReply() { }
virtual void SspReply() { }
@ -542,6 +579,8 @@ public:
virtual void DutModeSend() { }
virtual void LeTestMode() { }
virtual void ReadEnergyInfo() { }
};
class BluetoothInterface
@ -591,12 +630,18 @@ public:
/* Bonds */
virtual void CreateBond(const nsAString& aBdAddr,
BluetoothTransport aTransport,
BluetoothResultHandler* aRes) = 0;
virtual void RemoveBond(const nsAString& aBdAddr,
BluetoothResultHandler* aRes) = 0;
virtual void CancelBond(const nsAString& aBdAddr,
BluetoothResultHandler* aRes) = 0;
/* Connection */
virtual void GetConnectionState(const nsAString& aBdAddr,
BluetoothResultHandler* aRes) = 0;
/* Authentication */
virtual void PinReply(const nsAString& aBdAddr, bool aAccept,
@ -619,6 +664,10 @@ public:
virtual void LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
BluetoothResultHandler* aRes) = 0;
/* Energy Info */
virtual void ReadEnergyInfo(BluetoothResultHandler* aRes) = 0;
/* Profile Interfaces */
virtual BluetoothSocketInterface* GetBluetoothSocketInterface() = 0;

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

@ -75,6 +75,12 @@ struct BluetoothA2dpHALCallback
BluetoothA2dpAudioState, const nsAString&>
AudioStateNotification;
typedef BluetoothNotificationHALRunnable3<
A2dpNotificationHandlerWrapper, void,
nsString, uint32_t, uint8_t,
const nsAString&, uint32_t, uint8_t>
AudioConfigNotification;
// Bluedroid A2DP callbacks
static void
@ -92,6 +98,16 @@ struct BluetoothA2dpHALCallback
&BluetoothA2dpNotificationHandler::AudioStateNotification,
aState, aBdAddr);
}
#if ANDROID_VERSION >= 21
static void
AudioConfig(bt_bdaddr_t *aBdAddr, uint32_t aSampleRate, uint8_t aChannelCount)
{
AudioConfigNotification::Dispatch(
&BluetoothA2dpNotificationHandler::AudioConfigNotification,
aBdAddr, aSampleRate, aChannelCount);
}
#endif
};
// Interface
@ -115,7 +131,10 @@ BluetoothA2dpHALInterface::Init(
static btav_callbacks_t sCallbacks = {
sizeof(sCallbacks),
BluetoothA2dpHALCallback::ConnectionState,
BluetoothA2dpHALCallback::AudioState
BluetoothA2dpHALCallback::AudioState,
#if ANDROID_VERSION >= 21
BluetoothA2dpHALCallback::AudioConfig
#endif
};
sA2dpNotificationHandler = aNotificationHandler;

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

@ -14,6 +14,8 @@ BEGIN_BLUETOOTH_NAMESPACE
// A2DP module
//
const int BluetoothDaemonA2dpModule::MAX_NUM_CLIENTS = 1;
BluetoothA2dpNotificationHandler*
BluetoothDaemonA2dpModule::sNotificationHandler;
@ -260,6 +262,52 @@ BluetoothDaemonA2dpModule::AudioStateNtf(
AudioStateInitOp(aPDU));
}
// Init operator class for AudioConfigNotification
class BluetoothDaemonA2dpModule::AudioConfigInitOp MOZ_FINAL
: private PDUInitOp
{
public:
AudioConfigInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (nsString& aArg1, uint32_t aArg2, uint8_t aArg3) const
{
BluetoothDaemonPDU& pdu = GetPDU();
/* Read address */
nsresult rv = UnpackPDU(
pdu, UnpackConversion<BluetoothAddress, nsAString>(aArg1));
if (NS_FAILED(rv)) {
return rv;
}
/* Read sample rate */
rv = UnpackPDU(pdu, aArg2);
if (NS_FAILED(rv)) {
return rv;
}
/* Read channel count */
rv = UnpackPDU(pdu, aArg3);
if (NS_FAILED(rv)) {
return rv;
}
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonA2dpModule::AudioConfigNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
AudioConfigNotification::Dispatch(
&BluetoothA2dpNotificationHandler::AudioConfigNotification,
AudioConfigInitOp(aPDU));
}
void
BluetoothDaemonA2dpModule::HandleNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU,
@ -269,6 +317,9 @@ BluetoothDaemonA2dpModule::HandleNtf(
const BluetoothDaemonPDUHeader&, BluetoothDaemonPDU&) = {
INIT_ARRAY_AT(0, &BluetoothDaemonA2dpModule::ConnectionStateNtf),
INIT_ARRAY_AT(1, &BluetoothDaemonA2dpModule::AudioStateNtf),
#if ANDROID_VERSION >= 21
INIT_ARRAY_AT(2, &BluetoothDaemonA2dpModule::AudioConfigNtf),
#endif
};
MOZ_ASSERT(!NS_IsMainThread());
@ -342,7 +393,7 @@ BluetoothDaemonA2dpInterface::Init(
}
nsresult rv = mModule->RegisterModule(BluetoothDaemonA2dpModule::SERVICE_ID,
0x00, res);
0x00, BluetoothDaemonA2dpModule::MAX_NUM_CLIENTS, res);
if (NS_FAILED(rv) && aRes) {
DispatchError(aRes, STATUS_FAIL);
}

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

@ -28,9 +28,12 @@ public:
OPCODE_DISCONNECT = 0x02
};
static const int MAX_NUM_CLIENTS;
virtual nsresult Send(BluetoothDaemonPDU* aPDU, void* aUserData) = 0;
virtual nsresult RegisterModule(uint8_t aId, uint8_t aMode,
uint32_t aMaxNumClients,
BluetoothSetupResultHandler* aRes) = 0;
virtual nsresult UnregisterModule(uint8_t aId,
@ -102,8 +105,14 @@ protected:
const nsAString&>
AudioStateNotification;
class AudioStateInitOp;
typedef BluetoothNotificationRunnable3<NotificationHandlerWrapper, void,
nsString, uint32_t, uint8_t,
const nsAString&, uint32_t, uint8_t>
AudioConfigNotification;
class ConnectionStateInitOp;
class AudioStateInitOp;
class AudioConfigInitOp;
void ConnectionStateNtf(const BluetoothDaemonPDUHeader& aHeader,
BluetoothDaemonPDU& aPDU);
@ -111,6 +120,9 @@ protected:
void AudioStateNtf(const BluetoothDaemonPDUHeader& aHeader,
BluetoothDaemonPDU& aPDU);
void AudioConfigNtf(const BluetoothDaemonPDUHeader& aHeader,
BluetoothDaemonPDU& aPDU);
void HandleNtf(const BluetoothDaemonPDUHeader& aHeader,
BluetoothDaemonPDU& aPDU,
void* aUserData);

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

@ -14,6 +14,8 @@ BEGIN_BLUETOOTH_NAMESPACE
// AVRCP module
//
const int BluetoothDaemonAvrcpModule::MAX_NUM_CLIENTS = 1;
BluetoothAvrcpNotificationHandler*
BluetoothDaemonAvrcpModule::sNotificationHandler;
@ -887,7 +889,8 @@ BluetoothDaemonAvrcpInterface::Init(
}
nsresult rv = mModule->RegisterModule(
BluetoothDaemonAvrcpModule::SERVICE_ID, 0x00, res);
BluetoothDaemonAvrcpModule::SERVICE_ID,
BluetoothDaemonAvrcpModule::MAX_NUM_CLIENTS, 0x00, res);
if (NS_FAILED(rv) && aRes) {
DispatchError(aRes, STATUS_FAIL);

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

@ -60,9 +60,12 @@ public:
#endif
};
static const int MAX_NUM_CLIENTS;
virtual nsresult Send(BluetoothDaemonPDU* aPDU, void* aUserData) = 0;
virtual nsresult RegisterModule(uint8_t aId, uint8_t aMode,
uint32_t aMaxNumClients,
BluetoothSetupResultHandler* aRes) = 0;
virtual nsresult UnregisterModule(uint8_t aId,

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

@ -17,6 +17,11 @@ BEGIN_BLUETOOTH_NAMESPACE
BluetoothHandsfreeNotificationHandler*
BluetoothDaemonHandsfreeModule::sNotificationHandler;
#if ANDROID_VERSION < 21
nsString BluetoothDaemonHandsfreeModule::sConnectedDeviceAddress(
NS_ConvertUTF8toUTF16(BLUETOOTH_ADDRESS_NONE));
#endif
void
BluetoothDaemonHandsfreeModule::SetNotificationHandler(
BluetoothHandsfreeNotificationHandler* aNotificationHandler)
@ -147,15 +152,23 @@ BluetoothDaemonHandsfreeModule::DisconnectAudioCmd(
nsresult
BluetoothDaemonHandsfreeModule::StartVoiceRecognitionCmd(
BluetoothHandsfreeResultHandler* aRes)
const nsAString& aRemoteAddr, BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(NS_IsMainThread());
nsAutoPtr<BluetoothDaemonPDU> pdu(
new BluetoothDaemonPDU(SERVICE_ID, OPCODE_START_VOICE_RECOGNITION,
0)); // No payload
6)); // Address (BlueZ 5.25)
nsresult rv = Send(pdu, aRes);
nsresult rv;
#if ANDROID_VERSION >= 21
rv = PackPDU(
PackConversion<nsAString, BluetoothAddress>(aRemoteAddr), *pdu);
if (NS_FAILED(rv)) {
return rv;
}
#endif
rv = Send(pdu, aRes);
if (NS_FAILED(rv)) {
return rv;
}
@ -165,15 +178,23 @@ BluetoothDaemonHandsfreeModule::StartVoiceRecognitionCmd(
nsresult
BluetoothDaemonHandsfreeModule::StopVoiceRecognitionCmd(
BluetoothHandsfreeResultHandler* aRes)
const nsAString& aRemoteAddr, BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(NS_IsMainThread());
nsAutoPtr<BluetoothDaemonPDU> pdu(
new BluetoothDaemonPDU(SERVICE_ID, OPCODE_STOP_VOICE_RECOGNITION,
0)); // No payload
6)); // Address (BlueZ 5.25)
nsresult rv = Send(pdu, aRes);
nsresult rv;
#if ANDROID_VERSION >= 21
rv = PackPDU(
PackConversion<nsAString, BluetoothAddress>(aRemoteAddr), *pdu);
if (NS_FAILED(rv)) {
return rv;
}
#endif
rv = Send(pdu, aRes);
if (NS_FAILED(rv)) {
return rv;
}
@ -184,16 +205,23 @@ BluetoothDaemonHandsfreeModule::StopVoiceRecognitionCmd(
nsresult
BluetoothDaemonHandsfreeModule::VolumeControlCmd(
BluetoothHandsfreeVolumeType aType, int aVolume,
BluetoothHandsfreeResultHandler* aRes)
const nsAString& aRemoteAddr, BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(NS_IsMainThread());
nsAutoPtr<BluetoothDaemonPDU> pdu(
new BluetoothDaemonPDU(SERVICE_ID, OPCODE_VOLUME_CONTROL,
1 + // Volume type
1)); // Volume
1 + // Volume
6)); // Address (BlueZ 5.25)
#if ANDROID_VERSION >= 21
nsresult rv = PackPDU(
aType, PackConversion<int, uint8_t>(aVolume),
PackConversion<nsAString, BluetoothAddress>(aRemoteAddr), *pdu);
#else
nsresult rv = PackPDU(aType, PackConversion<int, uint8_t>(aVolume), *pdu);
#endif
if (NS_FAILED(rv)) {
return rv;
}
@ -236,15 +264,23 @@ BluetoothDaemonHandsfreeModule::DeviceStatusNotificationCmd(
nsresult
BluetoothDaemonHandsfreeModule::CopsResponseCmd(
const char* aCops, BluetoothHandsfreeResultHandler* aRes)
const char* aCops, const nsAString& aRemoteAddr,
BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(NS_IsMainThread());
nsAutoPtr<BluetoothDaemonPDU> pdu(
new BluetoothDaemonPDU(SERVICE_ID, OPCODE_COPS_RESPONSE,
0)); // Dynamically allocated
0 + // Dynamically allocated
6)); // Address (BlueZ 5.25)
#if ANDROID_VERSION >= 21
nsresult rv = PackPDU(
PackCString0(nsDependentCString(aCops)),
PackConversion<nsAString, BluetoothAddress>(aRemoteAddr), *pdu);
#else
nsresult rv = PackPDU(PackCString0(nsDependentCString(aCops)), *pdu);
#endif
if (NS_FAILED(rv)) {
return rv;
}
@ -261,6 +297,7 @@ BluetoothDaemonHandsfreeModule::CindResponseCmd(
int aSvc, int aNumActive, int aNumHeld,
BluetoothHandsfreeCallState aCallSetupState,
int aSignal, int aRoam, int aBattChg,
const nsAString& aRemoteAddr,
BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(NS_IsMainThread());
@ -273,8 +310,20 @@ BluetoothDaemonHandsfreeModule::CindResponseCmd(
1 + // Call state
1 + // Signal strength
1 + // Roaming
1)); // Battery level
1 + // Battery level
6)); // Address (BlueZ 5.25)
#if ANDROID_VERSION >= 21
nsresult rv = PackPDU(
PackConversion<int, uint8_t>(aSvc),
PackConversion<int, uint8_t>(aNumActive),
PackConversion<int, uint8_t>(aNumHeld),
aCallSetupState,
PackConversion<int, uint8_t>(aSignal),
PackConversion<int, uint8_t>(aRoam),
PackConversion<int, uint8_t>(aBattChg),
PackConversion<nsAString, BluetoothAddress>(aRemoteAddr), *pdu);
#else
nsresult rv = PackPDU(PackConversion<int, uint8_t>(aSvc),
PackConversion<int, uint8_t>(aNumActive),
PackConversion<int, uint8_t>(aNumHeld),
@ -282,6 +331,7 @@ BluetoothDaemonHandsfreeModule::CindResponseCmd(
PackConversion<int, uint8_t>(aSignal),
PackConversion<int, uint8_t>(aRoam),
PackConversion<int, uint8_t>(aBattChg), *pdu);
#endif
if (NS_FAILED(rv)) {
return rv;
}
@ -295,15 +345,23 @@ BluetoothDaemonHandsfreeModule::CindResponseCmd(
nsresult
BluetoothDaemonHandsfreeModule::FormattedAtResponseCmd(
const char* aRsp, BluetoothHandsfreeResultHandler* aRes)
const char* aRsp, const nsAString& aRemoteAddr,
BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(NS_IsMainThread());
nsAutoPtr<BluetoothDaemonPDU> pdu(
new BluetoothDaemonPDU(SERVICE_ID, OPCODE_FORMATTED_AT_RESPONSE,
0)); // Dynamically allocated
0 + // Dynamically allocated
6)); // Address (BlueZ 5.25)
#if ANDROID_VERSION >= 21
nsresult rv = PackPDU(
PackCString0(nsDependentCString(aRsp)),
PackConversion<nsAString, BluetoothAddress>(aRemoteAddr), *pdu);
#else
nsresult rv = PackPDU(PackCString0(nsDependentCString(aRsp)), *pdu);
#endif
if (NS_FAILED(rv)) {
return rv;
}
@ -318,17 +376,24 @@ BluetoothDaemonHandsfreeModule::FormattedAtResponseCmd(
nsresult
BluetoothDaemonHandsfreeModule::AtResponseCmd(
BluetoothHandsfreeAtResponse aResponseCode, int aErrorCode,
BluetoothHandsfreeResultHandler* aRes)
const nsAString& aRemoteAddr, BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(NS_IsMainThread());
nsAutoPtr<BluetoothDaemonPDU> pdu(
new BluetoothDaemonPDU(SERVICE_ID, OPCODE_AT_RESPONSE,
1 + // AT Response code
1)); // Error code
1 + // Error code
6)); // Address (BlueZ 5.25)
#if ANDROID_VERSION >= 21
nsresult rv = PackPDU(
aResponseCode, PackConversion<int, uint8_t>(aErrorCode),
PackConversion<nsAString, BluetoothAddress>(aRemoteAddr), *pdu);
#else
nsresult rv = PackPDU(aResponseCode,
PackConversion<int, uint8_t>(aErrorCode), *pdu);
#endif
if (NS_FAILED(rv)) {
return rv;
}
@ -346,7 +411,7 @@ BluetoothDaemonHandsfreeModule::ClccResponseCmd(
BluetoothHandsfreeCallDirection aDir, BluetoothHandsfreeCallState aState,
BluetoothHandsfreeCallMode aMode, BluetoothHandsfreeCallMptyType aMpty,
const nsAString& aNumber, BluetoothHandsfreeCallAddressType aType,
BluetoothHandsfreeResultHandler* aRes)
const nsAString& aRemoteAddr, BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(NS_IsMainThread());
@ -360,11 +425,20 @@ BluetoothDaemonHandsfreeModule::ClccResponseCmd(
1 + // Call mode
1 + // Call MPTY
1 + // Address type
number.Length() + 1)); // Number string + \0
number.Length() + 1 + // Number string + \0
6)); // Address (BlueZ 5.25)
#if ANDROID_VERSION >= 21
nsresult rv = PackPDU(
PackConversion<int, uint8_t>(aIndex),
aDir, aState, aMode, aMpty, aType,
PackCString0(number),
PackConversion<nsAString, BluetoothAddress>(aRemoteAddr), *pdu);
#else
nsresult rv = PackPDU(PackConversion<int, uint8_t>(aIndex),
aDir, aState, aMode, aMpty, aType,
PackCString0(number), *pdu);
#endif
if (NS_FAILED(rv)) {
return rv;
}
@ -409,6 +483,19 @@ BluetoothDaemonHandsfreeModule::PhoneStateChangeCmd(
return NS_OK;
}
nsresult
BluetoothDaemonHandsfreeModule::ConfigureWbsCmd(
const nsAString& aBdAddr,
BluetoothHandsfreeWbsConfig aConfig,
BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(NS_IsMainThread());
// TODO: to be implemented
return NS_ERROR_NOT_IMPLEMENTED;
}
// Responses
//
@ -662,6 +749,14 @@ public:
if (NS_FAILED(rv)) {
return rv;
}
#if ANDROID_VERSION < 21
if (aArg1 == HFP_CONNECTION_STATE_CONNECTED) {
sConnectedDeviceAddress = aArg2;
} else if (aArg1 == HFP_CONNECTION_STATE_DISCONNECTED) {
sConnectedDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
}
#endif
WarnAboutTrailingData();
return NS_OK;
}
@ -686,8 +781,7 @@ public:
{ }
nsresult
operator () (BluetoothHandsfreeAudioState& aArg1,
nsString& aArg2) const
operator () (BluetoothHandsfreeAudioState& aArg1, nsString& aArg2) const
{
BluetoothDaemonPDU& pdu = GetPDU();
@ -717,31 +811,121 @@ BluetoothDaemonHandsfreeModule::AudioStateNtf(
AudioStateInitOp(aPDU));
}
// Init operator class for VoiceRecognitionNotification
class BluetoothDaemonHandsfreeModule::VoiceRecognitionInitOp MOZ_FINAL
: private PDUInitOp
{
public:
VoiceRecognitionInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (BluetoothHandsfreeVoiceRecognitionState& aArg1,
nsString& aArg2) const
{
BluetoothDaemonPDU& pdu = GetPDU();
/* Read state */
nsresult rv = UnpackPDU(pdu, aArg1);
if (NS_FAILED(rv)) {
return rv;
}
/* Read address */
#if ANDROID_VERSION >= 21
rv = UnpackPDU(
pdu, UnpackConversion<BluetoothAddress, nsAString>(aArg2));
if (NS_FAILED(rv)) {
return rv;
}
#else
aArg2 = sConnectedDeviceAddress;
#endif
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::VoiceRecognitionNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
VoiceRecognitionNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::VoiceRecognitionNotification,
UnpackPDUInitOp(aPDU));
VoiceRecognitionInitOp(aPDU));
}
// Init operator class for AnswerCallNotification
class BluetoothDaemonHandsfreeModule::AnswerCallInitOp MOZ_FINAL
: private PDUInitOp
{
public:
AnswerCallInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (nsString& aArg1) const
{
/* Read address */
#if ANDROID_VERSION >= 21
nsresult rv = UnpackPDU(
GetPDU(), UnpackConversion<BluetoothAddress, nsAString>(aArg1));
if (NS_FAILED(rv)) {
return rv;
}
#else
aArg1 = sConnectedDeviceAddress;
#endif
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::AnswerCallNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
AnswerCallNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::AnswerCallNotification,
UnpackPDUInitOp(aPDU));
AnswerCallInitOp(aPDU));
}
// Init operator class for HangupCallNotification
class BluetoothDaemonHandsfreeModule::HangupCallInitOp MOZ_FINAL
: private PDUInitOp
{
public:
HangupCallInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (nsString& aArg1) const
{
/* Read address */
#if ANDROID_VERSION >= 21
nsresult rv = UnpackPDU(
GetPDU(), UnpackConversion<BluetoothAddress, nsAString>(aArg1));
if (NS_FAILED(rv)) {
return rv;
}
#else
aArg1 = sConnectedDeviceAddress;
#endif
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::HangupCallNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
HangupCallNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::HangupCallNotification,
UnpackPDUInitOp(aPDU));
HangupCallInitOp(aPDU));
}
// Init operator class for VolumeNotification
@ -754,7 +938,8 @@ public:
{ }
nsresult
operator () (BluetoothHandsfreeVolumeType& aArg1, int& aArg2) const
operator () (BluetoothHandsfreeVolumeType& aArg1, int& aArg2,
nsString& aArg3) const
{
BluetoothDaemonPDU& pdu = GetPDU();
@ -769,6 +954,17 @@ public:
if (NS_FAILED(rv)) {
return rv;
}
/* Read address */
#if ANDROID_VERSION >= 21
rv = UnpackPDU(
pdu, UnpackConversion<BluetoothAddress, nsAString>(aArg3));
if (NS_FAILED(rv)) {
return rv;
}
#else
aArg3 = sConnectedDeviceAddress;
#endif
WarnAboutTrailingData();
return NS_OK;
}
@ -793,10 +989,27 @@ public:
{ }
nsresult
operator () (nsString& aArg1) const
operator () (nsString& aArg1, nsString& aArg2) const
{
BluetoothDaemonPDU& pdu = GetPDU();
nsresult rv;
/* Read address
* It's a little weird to parse aArg2(aBdAddr) before parsing
* aArg1(aNumber), but this order is defined in BlueZ 5.25 anyway.
*/
#if ANDROID_VERSION >= 21
rv = UnpackPDU(
pdu, UnpackConversion<BluetoothAddress, nsAString>(aArg2));
if (NS_FAILED(rv)) {
return rv;
}
#else
aArg2 = sConnectedDeviceAddress;
#endif
/* Read number */
nsresult rv = UnpackPDU(GetPDU(), UnpackString0(aArg1));
rv = UnpackPDU(pdu, UnpackString0(aArg1));
if (NS_FAILED(rv)) {
return rv;
}
@ -814,67 +1027,280 @@ BluetoothDaemonHandsfreeModule::DialCallNtf(
DialCallInitOp(aPDU));
}
// Init operator class for DtmfNotification
class BluetoothDaemonHandsfreeModule::DtmfInitOp MOZ_FINAL
: private PDUInitOp
{
public:
DtmfInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (char& aArg1, nsString& aArg2) const
{
BluetoothDaemonPDU& pdu = GetPDU();
/* Read tone */
nsresult rv = UnpackPDU(pdu, aArg1);
if (NS_FAILED(rv)) {
return rv;
}
/* Read address */
#if ANDROID_VERSION >= 21
rv = UnpackPDU(
pdu, UnpackConversion<BluetoothAddress, nsAString>(aArg2));
if (NS_FAILED(rv)) {
return rv;
}
#else
aArg2 = sConnectedDeviceAddress;
#endif
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::DtmfNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
DtmfNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::DtmfNotification,
UnpackPDUInitOp(aPDU));
DtmfInitOp(aPDU));
}
// Init operator class for NRECNotification
class BluetoothDaemonHandsfreeModule::NRECInitOp MOZ_FINAL
: private PDUInitOp
{
public:
NRECInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (BluetoothHandsfreeNRECState& aArg1, nsString& aArg2) const
{
BluetoothDaemonPDU& pdu = GetPDU();
/* Read state */
nsresult rv = UnpackPDU(pdu, aArg1);
if (NS_FAILED(rv)) {
return rv;
}
/* Read address */
#if ANDROID_VERSION >= 21
rv = UnpackPDU(
pdu, UnpackConversion<BluetoothAddress, nsAString>(aArg2));
if (NS_FAILED(rv)) {
return rv;
}
#else
aArg2 = sConnectedDeviceAddress;
#endif
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::NRECNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
NRECNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::NRECNotification,
UnpackPDUInitOp(aPDU));
NRECInitOp(aPDU));
}
// Init operator class for CallHoldNotification
class BluetoothDaemonHandsfreeModule::CallHoldInitOp MOZ_FINAL
: private PDUInitOp
{
public:
CallHoldInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (BluetoothHandsfreeCallHoldType& aArg1, nsString& aArg2) const
{
BluetoothDaemonPDU& pdu = GetPDU();
/* Read type */
nsresult rv = UnpackPDU(pdu, aArg1);
if (NS_FAILED(rv)) {
return rv;
}
/* Read address */
#if ANDROID_VERSION >= 21
rv = UnpackPDU(
pdu, UnpackConversion<BluetoothAddress, nsAString>(aArg2));
if (NS_FAILED(rv)) {
return rv;
}
#else
aArg2 = sConnectedDeviceAddress;
#endif
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::CallHoldNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
CallHoldNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CallHoldNotification,
UnpackPDUInitOp(aPDU));
CallHoldInitOp(aPDU));
}
// Init operator class for CnumNotification
class BluetoothDaemonHandsfreeModule::CnumInitOp MOZ_FINAL
: private PDUInitOp
{
public:
CnumInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (nsString& aArg1) const
{
/* Read address */
#if ANDROID_VERSION >= 21
nsresult rv = UnpackPDU(
GetPDU(), UnpackConversion<BluetoothAddress, nsAString>(aArg1));
if (NS_FAILED(rv)) {
return rv;
}
#else
aArg1 = sConnectedDeviceAddress;
#endif
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::CnumNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
CnumNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CnumNotification,
UnpackPDUInitOp(aPDU));
CnumInitOp(aPDU));
}
// Init operator class for CindNotification
class BluetoothDaemonHandsfreeModule::CindInitOp MOZ_FINAL
: private PDUInitOp
{
public:
CindInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (nsString& aArg1) const
{
/* Read address */
#if ANDROID_VERSION >= 21
nsresult rv = UnpackPDU(
GetPDU(), UnpackConversion<BluetoothAddress, nsAString>(aArg1));
if (NS_FAILED(rv)) {
return rv;
}
#else
aArg1 = sConnectedDeviceAddress;
#endif
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::CindNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
CindNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CindNotification,
UnpackPDUInitOp(aPDU));
CindInitOp(aPDU));
}
// Init operator class for CopsNotification
class BluetoothDaemonHandsfreeModule::CopsInitOp MOZ_FINAL
: private PDUInitOp
{
public:
CopsInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (nsString& aArg1) const
{
/* Read address */
#if ANDROID_VERSION >= 21
nsresult rv = UnpackPDU(
GetPDU(), UnpackConversion<BluetoothAddress, nsAString>(aArg1));
if (NS_FAILED(rv)) {
return rv;
}
#else
aArg1 = sConnectedDeviceAddress;
#endif
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::CopsNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
CopsNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CopsNotification,
UnpackPDUInitOp(aPDU));
CopsInitOp(aPDU));
}
// Init operator class for ClccNotification
class BluetoothDaemonHandsfreeModule::ClccInitOp MOZ_FINAL
: private PDUInitOp
{
public:
ClccInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (nsString& aArg1) const
{
/* Read address */
#if ANDROID_VERSION >= 21
nsresult rv = UnpackPDU(
GetPDU(), UnpackConversion<BluetoothAddress, nsAString>(aArg1));
if (NS_FAILED(rv)) {
return rv;
}
#else
aArg1 = sConnectedDeviceAddress;
#endif
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::ClccNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
ClccNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::ClccNotification,
UnpackPDUInitOp(aPDU));
ClccInitOp(aPDU));
}
// Init operator class for UnknownAtNotification
@ -887,10 +1313,27 @@ public:
{ }
nsresult
operator () (nsCString& aArg1) const
operator () (nsCString& aArg1, nsString& aArg2) const
{
BluetoothDaemonPDU& pdu = GetPDU();
nsresult rv;
/* Read address
* It's a little weird to parse aArg2(aBdAddr) before parsing
* aArg1(aAtString), but this order is defined in BlueZ 5.25 anyway.
*/
#if ANDROID_VERSION >= 21
rv = UnpackPDU(
pdu, UnpackConversion<BluetoothAddress, nsAString>(aArg2));
if (NS_FAILED(rv)) {
return rv;
}
#else
aArg2 = sConnectedDeviceAddress;
#endif
/* Read string */
nsresult rv = UnpackPDU(GetPDU(), UnpackCString0(aArg1));
rv = UnpackPDU(pdu, UnpackCString0(aArg1));
if (NS_FAILED(rv)) {
return rv;
}
@ -908,13 +1351,40 @@ BluetoothDaemonHandsfreeModule::UnknownAtNtf(
UnknownAtInitOp(aPDU));
}
// Init operator class for KeyPressedNotification
class BluetoothDaemonHandsfreeModule::KeyPressedInitOp MOZ_FINAL
: private PDUInitOp
{
public:
KeyPressedInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (nsString& aArg1) const
{
/* Read address */
#if ANDROID_VERSION >= 21
nsresult rv = UnpackPDU(
GetPDU(), UnpackConversion<BluetoothAddress, nsAString>(aArg1));
if (NS_FAILED(rv)) {
return rv;
}
#else
aArg1 = sConnectedDeviceAddress;
#endif
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonHandsfreeModule::KeyPressedNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
KeyPressedNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::KeyPressedNotification,
UnpackPDUInitOp(aPDU));
KeyPressedInitOp(aPDU));
}
void
@ -997,7 +1467,7 @@ private:
void
BluetoothDaemonHandsfreeInterface::Init(
BluetoothHandsfreeNotificationHandler* aNotificationHandler,
BluetoothHandsfreeResultHandler* aRes)
int aMaxNumClients, BluetoothHandsfreeResultHandler* aRes)
{
// Set notification handler _before_ registering the module. It could
// happen that we receive notifications, before the result handler runs.
@ -1013,7 +1483,8 @@ BluetoothDaemonHandsfreeInterface::Init(
}
nsresult rv = mModule->RegisterModule(
BluetoothDaemonHandsfreeModule::SERVICE_ID, MODE_NARROWBAND_SPEECH, res);
BluetoothDaemonHandsfreeModule::SERVICE_ID, MODE_NARROWBAND_SPEECH,
aMaxNumClients, res);
if (NS_FAILED(rv) && aRes) {
DispatchError(aRes, STATUS_FAIL);
@ -1110,32 +1581,32 @@ BluetoothDaemonHandsfreeInterface::DisconnectAudio(
void
BluetoothDaemonHandsfreeInterface::StartVoiceRecognition(
BluetoothHandsfreeResultHandler* aRes)
const nsAString& aBdAddr, BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(mModule);
mModule->StartVoiceRecognitionCmd(aRes);
mModule->StartVoiceRecognitionCmd(aBdAddr, aRes);
}
void
BluetoothDaemonHandsfreeInterface::StopVoiceRecognition(
BluetoothHandsfreeResultHandler* aRes)
const nsAString& aBdAddr, BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(mModule);
mModule->StopVoiceRecognitionCmd(aRes);
mModule->StopVoiceRecognitionCmd(aBdAddr, aRes);
}
/* Volume */
void
BluetoothDaemonHandsfreeInterface::VolumeControl(
BluetoothHandsfreeVolumeType aType, int aVolume,
BluetoothHandsfreeVolumeType aType, int aVolume, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(mModule);
mModule->VolumeControlCmd(aType, aVolume, aRes);
mModule->VolumeControlCmd(aType, aVolume, aBdAddr, aRes);
}
/* Device status */
@ -1156,11 +1627,12 @@ BluetoothDaemonHandsfreeInterface::DeviceStatusNotification(
void
BluetoothDaemonHandsfreeInterface::CopsResponse(
const char* aCops, BluetoothHandsfreeResultHandler* aRes)
const char* aCops, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(mModule);
mModule->CopsResponseCmd(aCops, aRes);
mModule->CopsResponseCmd(aCops, aBdAddr, aRes);
}
void
@ -1168,31 +1640,32 @@ BluetoothDaemonHandsfreeInterface::CindResponse(
int aSvc, int aNumActive, int aNumHeld,
BluetoothHandsfreeCallState aCallSetupState,
int aSignal, int aRoam, int aBattChg,
BluetoothHandsfreeResultHandler* aRes)
const nsAString& aBdAddr, BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(mModule);
mModule->CindResponseCmd(aSvc, aNumActive, aNumHeld, aCallSetupState,
aSignal, aRoam, aBattChg, aRes);
aSignal, aRoam, aBattChg, aBdAddr, aRes);
}
void
BluetoothDaemonHandsfreeInterface::FormattedAtResponse(
const char* aRsp, BluetoothHandsfreeResultHandler* aRes)
const char* aRsp, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(mModule);
mModule->FormattedAtResponseCmd(aRsp, aRes);
mModule->FormattedAtResponseCmd(aRsp, aBdAddr, aRes);
}
void
BluetoothDaemonHandsfreeInterface::AtResponse(
BluetoothHandsfreeAtResponse aResponseCode, int aErrorCode,
BluetoothHandsfreeResultHandler* aRes)
const nsAString& aBdAddr, BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(mModule);
mModule->AtResponseCmd(aResponseCode, aErrorCode, aRes);
mModule->AtResponseCmd(aResponseCode, aErrorCode, aBdAddr, aRes);
}
void
@ -1203,12 +1676,13 @@ BluetoothDaemonHandsfreeInterface::ClccResponse(
BluetoothHandsfreeCallMptyType aMpty,
const nsAString& aNumber,
BluetoothHandsfreeCallAddressType aType,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(mModule);
mModule->ClccResponseCmd(aIndex, aDir, aState, aMode, aMpty, aNumber,
aType, aRes);
aType, aBdAddr, aRes);
}
/* Phone State */
@ -1227,6 +1701,18 @@ BluetoothDaemonHandsfreeInterface::PhoneStateChange(
aType, aRes);
}
/* Wide Band Speech */
void
BluetoothDaemonHandsfreeInterface::ConfigureWbs(
const nsAString& aBdAddr, BluetoothHandsfreeWbsConfig aConfig,
BluetoothHandsfreeResultHandler* aRes)
{
MOZ_ASSERT(mModule);
mModule->ConfigureWbsCmd(aBdAddr, aConfig, aRes);
}
void
BluetoothDaemonHandsfreeInterface::DispatchError(
BluetoothHandsfreeResultHandler* aRes, BluetoothStatus aStatus)

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

@ -43,6 +43,7 @@ public:
virtual nsresult Send(BluetoothDaemonPDU* aPDU, void* aUserData) = 0;
virtual nsresult RegisterModule(uint8_t aId, uint8_t aMode,
uint32_t aMaxNumClients,
BluetoothSetupResultHandler* aRes) = 0;
virtual nsresult UnregisterModule(uint8_t aId,
@ -66,12 +67,15 @@ public:
/* Voice Recognition */
nsresult StartVoiceRecognitionCmd(BluetoothHandsfreeResultHandler* aRes);
nsresult StopVoiceRecognitionCmd(BluetoothHandsfreeResultHandler* aRes);
nsresult StartVoiceRecognitionCmd(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
nsresult StopVoiceRecognitionCmd(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
/* Volume */
nsresult VolumeControlCmd(BluetoothHandsfreeVolumeType aType, int aVolume,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
/* Device status */
@ -84,16 +88,17 @@ public:
/* Responses */
nsresult CopsResponseCmd(const char* aCops,
nsresult CopsResponseCmd(const char* aCops, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
nsresult CindResponseCmd(int aSvc, int aNumActive, int aNumHeld,
BluetoothHandsfreeCallState aCallSetupState,
int aSignal, int aRoam, int aBattChg,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
nsresult FormattedAtResponseCmd(const char* aRsp,
nsresult FormattedAtResponseCmd(const char* aRsp, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
nsresult AtResponseCmd(BluetoothHandsfreeAtResponse aResponseCode,
int aErrorCode,
int aErrorCode, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
nsresult ClccResponseCmd(int aIndex, BluetoothHandsfreeCallDirection aDir,
BluetoothHandsfreeCallState aState,
@ -101,6 +106,7 @@ public:
BluetoothHandsfreeCallMptyType aMpty,
const nsAString& aNumber,
BluetoothHandsfreeCallAddressType aType,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
/* Phone State */
@ -111,6 +117,12 @@ public:
BluetoothHandsfreeCallAddressType aType,
BluetoothHandsfreeResultHandler* aRes);
/* Wide Band Speech */
nsresult ConfigureWbsCmd(const nsAString& aBdAddr,
BluetoothHandsfreeWbsConfig aConfig,
BluetoothHandsfreeResultHandler* aRes);
protected:
nsresult Send(BluetoothDaemonPDU* aPDU,
BluetoothHandsfreeResultHandler* aRes);
@ -213,60 +225,93 @@ protected:
const nsAString&>
AudioStateNotification;
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
BluetoothHandsfreeVoiceRecognitionState>
typedef BluetoothNotificationRunnable2<NotificationHandlerWrapper, void,
BluetoothHandsfreeVoiceRecognitionState, nsString,
BluetoothHandsfreeVoiceRecognitionState, const nsAString&>
VoiceRecognitionNotification;
typedef BluetoothNotificationRunnable0<NotificationHandlerWrapper, void>
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
nsString,
const nsAString&>
AnswerCallNotification;
typedef BluetoothNotificationRunnable0<NotificationHandlerWrapper, void>
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
nsString,
const nsAString&>
HangupCallNotification;
typedef BluetoothNotificationRunnable2<NotificationHandlerWrapper, void,
BluetoothHandsfreeVolumeType, int>
typedef BluetoothNotificationRunnable3<NotificationHandlerWrapper, void,
BluetoothHandsfreeVolumeType, int, nsString,
BluetoothHandsfreeVolumeType, int, const nsAString&>
VolumeNotification;
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
nsString, const nsAString&>
typedef BluetoothNotificationRunnable2<NotificationHandlerWrapper, void,
nsString, nsString,
const nsAString&, const nsAString&>
DialCallNotification;
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
char>
typedef BluetoothNotificationRunnable2<NotificationHandlerWrapper, void,
char, nsString,
char, const nsAString&>
DtmfNotification;
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
BluetoothHandsfreeNRECState>
typedef BluetoothNotificationRunnable2<NotificationHandlerWrapper, void,
BluetoothHandsfreeNRECState, nsString,
BluetoothHandsfreeNRECState, const nsAString&>
NRECNotification;
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
BluetoothHandsfreeCallHoldType>
typedef BluetoothNotificationRunnable2<NotificationHandlerWrapper, void,
BluetoothHandsfreeCallHoldType, nsString,
BluetoothHandsfreeCallHoldType, const nsAString&>
CallHoldNotification;
typedef BluetoothNotificationRunnable0<NotificationHandlerWrapper, void>
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
nsString,
const nsAString&>
CnumNotification;
typedef BluetoothNotificationRunnable0<NotificationHandlerWrapper, void>
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
nsString,
const nsAString&>
CindNotification;
typedef BluetoothNotificationRunnable0<NotificationHandlerWrapper, void>
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
nsString,
const nsAString&>
CopsNotification;
typedef BluetoothNotificationRunnable0<NotificationHandlerWrapper, void>
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
nsString,
const nsAString&>
ClccNotification;
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
nsCString, const nsACString&>
typedef BluetoothNotificationRunnable2<NotificationHandlerWrapper, void,
nsCString, nsString,
const nsACString&, const nsAString&>
UnknownAtNotification;
typedef BluetoothNotificationRunnable0<NotificationHandlerWrapper, void>
typedef BluetoothNotificationRunnable1<NotificationHandlerWrapper, void,
nsString,
const nsAString&>
KeyPressedNotification;
class AudioStateInitOp;
class ConnectionStateInitOp;
class AudioStateInitOp;
class VoiceRecognitionInitOp;
class AnswerCallInitOp;
class HangupCallInitOp;
class VolumeInitOp;
class DialCallInitOp;
class DtmfInitOp;
class NRECInitOp;
class CallHoldInitOp;
class CnumInitOp;
class CindInitOp;
class CopsInitOp;
class ClccInitOp;
class VolumeInitOp;
class UnknownAtInitOp;
class KeyPressedInitOp;
void ConnectionStateNtf(const BluetoothDaemonPDUHeader& aHeader,
BluetoothDaemonPDU& aPDU);
@ -321,6 +366,14 @@ protected:
void* aUserData);
static BluetoothHandsfreeNotificationHandler* sNotificationHandler;
#if ANDROID_VERSION < 21
/* |sConnectedDeviceAddress| stores Bluetooth device address of the
* connected device. Before BlueZ 5.25, we maintain this address by ourselves
* through ConnectionStateNtf(); after BlueZ 5.25, every callback carries
* this address directly so we don't have to keep it.
*/
static nsString sConnectedDeviceAddress;
#endif
};
class BluetoothDaemonHandsfreeInterface MOZ_FINAL
@ -341,7 +394,7 @@ public:
void Init(
BluetoothHandsfreeNotificationHandler* aNotificationHandler,
BluetoothHandsfreeResultHandler* aRes);
int aMaxNumClients, BluetoothHandsfreeResultHandler* aRes);
void Cleanup(BluetoothHandsfreeResultHandler* aRes);
/* Connect / Disconnect */
@ -357,12 +410,15 @@ public:
/* Voice Recognition */
void StartVoiceRecognition(BluetoothHandsfreeResultHandler* aRes);
void StopVoiceRecognition(BluetoothHandsfreeResultHandler* aRes);
void StartVoiceRecognition(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void StopVoiceRecognition(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
/* Volume */
void VolumeControl(BluetoothHandsfreeVolumeType aType, int aVolume,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
/* Device status */
@ -374,15 +430,17 @@ public:
/* Responses */
void CopsResponse(const char* aCops,
void CopsResponse(const char* aCops, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void CindResponse(int aSvc, int aNumActive, int aNumHeld,
BluetoothHandsfreeCallState aCallSetupState,
int aSignal, int aRoam, int aBattChg,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void FormattedAtResponse(const char* aRsp,
void FormattedAtResponse(const char* aRsp, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void AtResponse(BluetoothHandsfreeAtResponse aResponseCode, int aErrorCode,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void ClccResponse(int aIndex, BluetoothHandsfreeCallDirection aDir,
BluetoothHandsfreeCallState aState,
@ -390,6 +448,7 @@ public:
BluetoothHandsfreeCallMptyType aMpty,
const nsAString& aNumber,
BluetoothHandsfreeCallAddressType aType,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
/* Phone State */
@ -400,6 +459,11 @@ public:
BluetoothHandsfreeCallAddressType aType,
BluetoothHandsfreeResultHandler* aRes);
/* Wide Band Speech */
void ConfigureWbs(const nsAString& aBdAddr,
BluetoothHandsfreeWbsConfig aConfig,
BluetoothHandsfreeResultHandler* aRes);
private:
void DispatchError(BluetoothHandsfreeResultHandler* aRes,
BluetoothStatus aStatus);

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

@ -1265,6 +1265,12 @@ PackPDU(ControlPlayStatus aIn, BluetoothDaemonPDU& aPDU)
return PackPDU(PackConversion<ControlPlayStatus, uint8_t>(aIn), aPDU);
}
nsresult
PackPDU(BluetoothTransport aIn, BluetoothDaemonPDU& aPDU)
{
return PackPDU(PackConversion<BluetoothTransport, uint8_t>(aIn), aPDU);
}
//
// Unpacking
//

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

@ -421,6 +421,9 @@ PackPDU(BluetoothScanMode aIn, BluetoothDaemonPDU& aPDU);
nsresult
PackPDU(ControlPlayStatus aIn, BluetoothDaemonPDU& aPDU);
nsresult
PackPDU(BluetoothTransport aIn, BluetoothDaemonPDU& aPDU);
/* |PackConversion| is a helper for packing converted values. Pass
* an instance of this structure to |PackPDU| to convert a value from
* the input type to the output type and and write it to the PDU.
@ -618,6 +621,45 @@ PackPDU(const T1& aIn1, const T2& aIn2, const T3& aIn3,
return PackPDU(aIn7, aPDU);
}
template <typename T1, typename T2, typename T3,
typename T4, typename T5, typename T6,
typename T7, typename T8>
inline nsresult
PackPDU(const T1& aIn1, const T2& aIn2, const T3& aIn3,
const T4& aIn4, const T5& aIn5, const T6& aIn6,
const T7& aIn7, const T8& aIn8, BluetoothDaemonPDU& aPDU)
{
nsresult rv = PackPDU(aIn1, aPDU);
if (NS_FAILED(rv)) {
return rv;
}
rv = PackPDU(aIn2, aPDU);
if (NS_FAILED(rv)) {
return rv;
}
rv = PackPDU(aIn3, aPDU);
if (NS_FAILED(rv)) {
return rv;
}
rv = PackPDU(aIn4, aPDU);
if (NS_FAILED(rv)) {
return rv;
}
rv = PackPDU(aIn5, aPDU);
if (NS_FAILED(rv)) {
return rv;
}
rv = PackPDU(aIn6, aPDU);
if (NS_FAILED(rv)) {
return rv;
}
rv = PackPDU(aIn7, aPDU);
if (NS_FAILED(rv)) {
return rv;
}
return PackPDU(aIn8, aPDU);
}
//
// Unpacking
//

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

@ -31,13 +31,18 @@ public:
//
nsresult RegisterModuleCmd(uint8_t aId, uint8_t aMode,
uint32_t aMaxNumClients,
BluetoothSetupResultHandler* aRes)
{
MOZ_ASSERT(NS_IsMainThread());
nsAutoPtr<BluetoothDaemonPDU> pdu(new BluetoothDaemonPDU(0x00, 0x01, 0));
#if ANDROID_VERSION >= 21
nsresult rv = PackPDU(aId, aMode, aMaxNumClients, *pdu);
#else
nsresult rv = PackPDU(aId, aMode, *pdu);
#endif
if (NS_FAILED(rv)) {
return rv;
}
@ -188,6 +193,9 @@ static BluetoothNotificationHandler* sNotificationHandler;
class BluetoothDaemonCoreModule
{
public:
static const int MAX_NUM_CLIENTS;
virtual nsresult Send(BluetoothDaemonPDU* aPDU, void* aUserData) = 0;
nsresult EnableCmd(BluetoothResultHandler* aRes)
@ -406,14 +414,20 @@ public:
}
nsresult CreateBondCmd(const nsAString& aBdAddr,
BluetoothTransport aTransport,
BluetoothResultHandler* aRes)
{
MOZ_ASSERT(NS_IsMainThread());
nsAutoPtr<BluetoothDaemonPDU> pdu(new BluetoothDaemonPDU(0x01, 0x0d, 0));
#if ANDROID_VERSION >= 21
nsresult rv = PackPDU(
PackConversion<nsAString, BluetoothAddress>(aBdAddr), aTransport, *pdu);
#else
nsresult rv = PackPDU(
PackConversion<nsAString, BluetoothAddress>(aBdAddr), *pdu);
#endif
if (NS_FAILED(rv)) {
return rv;
}
@ -1402,6 +1416,8 @@ private:
//
// - |HandleSvc|,
//
const int BluetoothDaemonCoreModule::MAX_NUM_CLIENTS = 1;
// which is called by |BluetoothDaemonProtcol| to hand over received
// PDUs into a module.
//
@ -1417,7 +1433,7 @@ class BluetoothDaemonProtocol MOZ_FINAL
public:
BluetoothDaemonProtocol(BluetoothDaemonConnection* aConnection);
nsresult RegisterModule(uint8_t aId, uint8_t aMode,
nsresult RegisterModule(uint8_t aId, uint8_t aMode, uint32_t aMaxNumClients,
BluetoothSetupResultHandler* aRes) MOZ_OVERRIDE;
nsresult UnregisterModule(uint8_t aId,
@ -1464,9 +1480,11 @@ BluetoothDaemonProtocol::BluetoothDaemonProtocol(
nsresult
BluetoothDaemonProtocol::RegisterModule(uint8_t aId, uint8_t aMode,
uint32_t aMaxNumClients,
BluetoothSetupResultHandler* aRes)
{
return BluetoothDaemonSetupModule::RegisterModuleCmd(aId, aMode, aRes);
return BluetoothDaemonSetupModule::RegisterModuleCmd(aId, aMode,
aMaxNumClients, aRes);
}
nsresult
@ -1746,7 +1764,8 @@ public:
if (!mRegisteredSocketModule) {
mRegisteredSocketModule = true;
// Init, step 4: Register Socket module
mInterface->mProtocol->RegisterModuleCmd(0x02, 0x00, this);
mInterface->mProtocol->RegisterModuleCmd(0x02, 0x00,
BluetoothDaemonSocketModule::MAX_NUM_CLIENTS, this);
} else if (mRes) {
// Init, step 5: Signal success to caller
mRes->Init();
@ -1785,7 +1804,8 @@ BluetoothDaemonInterface::OnConnectSuccess(enum Channel aChannel)
// Init, step 3: Register Core module
nsresult rv = mProtocol->RegisterModuleCmd(
0x01, 0x00, new InitResultHandler(this, res));
0x01, 0x00, BluetoothDaemonCoreModule::MAX_NUM_CLIENTS,
new InitResultHandler(this, res));
if (NS_FAILED(rv) && res) {
DispatchError(res, STATUS_FAIL);
}
@ -2017,10 +2037,11 @@ BluetoothDaemonInterface::CancelDiscovery(BluetoothResultHandler* aRes)
void
BluetoothDaemonInterface::CreateBond(const nsAString& aBdAddr,
BluetoothTransport aTransport,
BluetoothResultHandler* aRes)
{
static_cast<BluetoothDaemonCoreModule*>
(mProtocol)->CreateBondCmd(aBdAddr, aRes);
(mProtocol)->CreateBondCmd(aBdAddr, aTransport, aRes);
}
void
@ -2039,6 +2060,15 @@ BluetoothDaemonInterface::CancelBond(const nsAString& aBdAddr,
(mProtocol)->CancelBondCmd(aBdAddr, aRes);
}
/* Connection */
void
BluetoothDaemonInterface::GetConnectionState(const nsAString& aBdAddr,
BluetoothResultHandler* aRes)
{
// NO-OP: no corresponding interface of current BlueZ
}
/* Authentication */
void
@ -2090,6 +2120,14 @@ BluetoothDaemonInterface::LeTestMode(uint16_t aOpcode, uint8_t* aBuf,
(mProtocol)->LeTestModeCmd(aOpcode, aBuf, aLen, aRes);
}
/* Energy Information */
void
BluetoothDaemonInterface::ReadEnergyInfo(BluetoothResultHandler* aRes)
{
// NO-OP: no corresponding interface of current BlueZ
}
void
BluetoothDaemonInterface::DispatchError(BluetoothResultHandler* aRes,
BluetoothStatus aStatus)

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

@ -71,10 +71,16 @@ public:
/* Bonds */
void CreateBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
void CreateBond(const nsAString& aBdAddr, BluetoothTransport aTransport,
BluetoothResultHandler* aRes);
void RemoveBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
void CancelBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
/* Connection */
void GetConnectionState(const nsAString& aBdAddr,
BluetoothResultHandler* aRes);
/* Authentication */
void PinReply(const nsAString& aBdAddr, bool aAccept,
@ -96,6 +102,10 @@ public:
void LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
BluetoothResultHandler* aRes);
/* Energy Information */
void ReadEnergyInfo(BluetoothResultHandler* aRes);
/* Profile Interfaces */
BluetoothSocketInterface* GetBluetoothSocketInterface() MOZ_OVERRIDE;

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

@ -15,6 +15,8 @@ BEGIN_BLUETOOTH_NAMESPACE
// Socket module
//
const int BluetoothDaemonSocketModule::MAX_NUM_CLIENTS = 1;
// Commands
//

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

@ -20,6 +20,8 @@ class BlutoothDaemonInterface;
class BluetoothDaemonSocketModule
{
public:
static const int MAX_NUM_CLIENTS;
virtual nsresult Send(BluetoothDaemonPDU* aPDU, void* aUserData) = 0;
// Commands

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

@ -211,6 +211,39 @@ Convert(const btrc_player_settings_t& aIn, BluetoothAvrcpPlayerSettings& aOut)
}
#endif // ANDROID_VERSION >= 18
#if ANDROID_VERSION >= 21
nsresult
Convert(const bt_activity_energy_info& aIn, BluetoothActivityEnergyInfo& aOut)
{
nsresult rv = Convert(aIn.status, aOut.mStatus);
if (NS_FAILED(rv)) {
return rv;
}
rv = Convert(aIn.ctrl_state, aOut.mStackState);
if (NS_FAILED(rv)) {
return rv;
}
rv = Convert(aIn.tx_time, aOut.mTxTime);
if (NS_FAILED(rv)) {
return rv;
}
rv = Convert(aIn.rx_time, aOut.mRxTime);
if (NS_FAILED(rv)) {
return rv;
}
rv = Convert(aIn.idle_time, aOut.mIdleTime);
if (NS_FAILED(rv)) {
return rv;
}
rv = Convert(aIn.energy_used, aOut.mEnergyUsed);
if (NS_FAILED(rv)) {
return rv;
}
return NS_OK;
}
#endif // ANDROID_VERSION >= 21
nsresult
Convert(const bt_property_t& aIn, BluetoothProperty& aOut)
{

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

@ -765,6 +765,56 @@ Convert(btrc_remote_features_t aIn, unsigned long& aOut)
}
#endif // ANDROID_VERSION >= 19
#if ANDROID_VERSION >= 21
inline nsresult
Convert(BluetoothTransport aIn, int& aOut)
{
static const int sTransport[] = {
CONVERT(TRANSPORT_AUTO, 0),
CONVERT(TRANSPORT_BREDR, 1),
CONVERT(TRANSPORT_LE, 2)
};
if (NS_WARN_IF(aIn >= MOZ_ARRAY_LENGTH(sTransport))) {
return NS_ERROR_ILLEGAL_VALUE;
}
aOut = sTransport[aIn];
return NS_OK;
}
nsresult
Convert(const bt_activity_energy_info& aIn, BluetoothActivityEnergyInfo& aOut);
inline nsresult
Convert(bthf_wbs_config_t aIn, BluetoothHandsfreeWbsConfig& aOut)
{
static const BluetoothHandsfreeWbsConfig sWbsConfig[] = {
CONVERT(BTHF_WBS_NONE, HFP_WBS_NONE),
CONVERT(BTHF_WBS_NO, HFP_WBS_NO),
CONVERT(BTHF_WBS_YES, HFP_WBS_YES)
};
if (NS_WARN_IF(aIn >= MOZ_ARRAY_LENGTH(sWbsConfig))) {
return NS_ERROR_ILLEGAL_VALUE;
}
aOut = sWbsConfig[aIn];
return NS_OK;
}
inline nsresult
Convert(BluetoothHandsfreeWbsConfig aIn, bthf_wbs_config_t& aOut)
{
static const bthf_wbs_config_t sWbsConfig[] = {
CONVERT(HFP_WBS_NONE, BTHF_WBS_NONE),
CONVERT(HFP_WBS_NO, BTHF_WBS_NO),
CONVERT(HFP_WBS_YES, BTHF_WBS_YES)
};
if (NS_WARN_IF(aIn >= MOZ_ARRAY_LENGTH(sWbsConfig))) {
return NS_ERROR_ILLEGAL_VALUE;
}
aOut = sWbsConfig[aIn];
return NS_OK;
}
#endif // ANDROID_VERSION >= 21
/* |ConvertArray| is a helper for converting arrays. Pass an
* instance of this structure as the first argument to |Convert|
* to convert an array. The output type has to support the array

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

@ -176,6 +176,11 @@ struct BluetoothCallback
BluetoothStatus, uint16_t>
LeTestModeNotification;
typedef BluetoothNotificationHALRunnable1<NotificationHandlerWrapper, void,
BluetoothActivityEnergyInfo,
const BluetoothActivityEnergyInfo&>
EnergyInfoNotification;
// Bluedroid callbacks
static const bt_property_t*
@ -313,8 +318,57 @@ struct BluetoothCallback
&BluetoothNotificationHandler::LeTestModeNotification,
aStatus, aNumPackets);
}
#if ANDROID_VERSION >= 21
static void
EnergyInfo(bt_activity_energy_info* aEnergyInfo)
{
if (NS_WARN_IF(!aEnergyInfo)) {
return;
}
EnergyInfoNotification::Dispatch(
&BluetoothNotificationHandler::EnergyInfoNotification,
*aEnergyInfo);
}
#endif
};
#if ANDROID_VERSION >= 21
struct BluetoothOsCallout
{
static bool
SetWakeAlarm(uint64_t aDelayMilliseconds,
bool aShouldWake,
void (* aAlarmCallback)(void*),
void* aData)
{
// FIXME: need to be implemented in later patches
// HAL wants to manage an wake_alarm but Gecko cannot fulfill it for now.
// Simply pass the request until a proper implementation has been added.
return true;
}
static int
AcquireWakeLock(const char* aLockName)
{
// FIXME: need to be implemented in later patches
// HAL wants to manage an wake_lock but Gecko cannot fulfill it for now.
// Simply pass the request until a proper implementation has been added.
return BT_STATUS_SUCCESS;
}
static int
ReleaseWakeLock(const char* aLockName)
{
// FIXME: need to be implemented in later patches
// HAL wants to manage an wake_lock but Gecko cannot fulfill it for now.
// Simply pass the request until a proper implementation has been added.
return BT_STATUS_SUCCESS;
}
};
#endif
// Interface
//
@ -409,14 +463,35 @@ BluetoothHALInterface::Init(
BluetoothCallback::ThreadEvt,
BluetoothCallback::DutModeRecv,
#if ANDROID_VERSION >= 18
BluetoothCallback::LeTestMode
BluetoothCallback::LeTestMode,
#endif
#if ANDROID_VERSION >= 21
BluetoothCallback::EnergyInfo
#endif
};
#if ANDROID_VERSION >= 21
static bt_os_callouts_t sBluetoothOsCallouts = {
sizeof(sBluetoothOsCallouts),
BluetoothOsCallout::SetWakeAlarm,
BluetoothOsCallout::AcquireWakeLock,
BluetoothOsCallout::ReleaseWakeLock
};
#endif
sNotificationHandler = aNotificationHandler;
int status = mInterface->init(&sBluetoothCallbacks);
#if ANDROID_VERSION >= 21
if (status == BT_STATUS_SUCCESS) {
status = mInterface->set_os_callouts(&sBluetoothOsCallouts);
if (status != BT_STATUS_SUCCESS) {
mInterface->cleanup();
}
}
#endif
if (aRes) {
DispatchBluetoothHALResult(aRes, &BluetoothResultHandler::Init,
ConvertDefault(status, STATUS_FAIL));
@ -665,13 +740,22 @@ BluetoothHALInterface::CancelDiscovery(BluetoothResultHandler* aRes)
void
BluetoothHALInterface::CreateBond(const nsAString& aBdAddr,
BluetoothTransport aTransport,
BluetoothResultHandler* aRes)
{
bt_bdaddr_t bdAddr;
int status;
#if ANDROID_VERSION >= 21
int transport = 0; /* TRANSPORT_AUTO */
if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr)) &&
NS_SUCCEEDED(Convert(aTransport, transport))) {
status = mInterface->create_bond(&bdAddr, transport);
#else
if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) {
status = mInterface->create_bond(&bdAddr);
#endif
} else {
status = BT_STATUS_PARM_INVALID;
}
@ -723,6 +807,33 @@ BluetoothHALInterface::CancelBond(const nsAString& aBdAddr,
}
}
/* Connection */
void
BluetoothHALInterface::GetConnectionState(const nsAString& aBdAddr,
BluetoothResultHandler* aRes)
{
int status;
#if ANDROID_VERSION >= 21
bt_bdaddr_t bdAddr;
if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) {
status = mInterface->get_connection_state(&bdAddr);
} else {
status = BT_STATUS_PARM_INVALID;
}
#else
status = BT_STATUS_UNSUPPORTED;
#endif
if (aRes) {
DispatchBluetoothHALResult(aRes,
&BluetoothResultHandler::GetConnectionState,
ConvertDefault(status, STATUS_FAIL));
}
}
/* Authentication */
void
@ -831,6 +942,23 @@ BluetoothHALInterface::LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
}
}
/* Energy Information */
void
BluetoothHALInterface::ReadEnergyInfo(BluetoothResultHandler* aRes)
{
#if ANDROID_VERSION >= 21
int status = mInterface->read_energy_info();
#else
int status = BT_STATUS_UNSUPPORTED;
#endif
if (aRes) {
DispatchBluetoothHALResult(aRes,
&BluetoothResultHandler::ReadEnergyInfo,
ConvertDefault(status, STATUS_FAIL));
}
}
/* Profile Interfaces */
template <class T>

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

@ -59,10 +59,16 @@ public:
/* Bonds */
void CreateBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
void CreateBond(const nsAString& aBdAddr, BluetoothTransport aTransport,
BluetoothResultHandler* aRes);
void RemoveBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
void CancelBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes);
/* Connection */
void GetConnectionState(const nsAString& aBdAddr,
BluetoothResultHandler* aRes);
/* Authentication */
void PinReply(const nsAString& aBdAddr, bool aAccept,
@ -84,6 +90,10 @@ public:
void LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen,
BluetoothResultHandler* aRes);
/* Energy Information */
void ReadEnergyInfo(BluetoothResultHandler* aRes);
/* Profile Interfaces */
BluetoothSocketInterface* GetBluetoothSocketInterface();

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

@ -75,62 +75,84 @@ struct BluetoothHandsfreeHALCallback
BluetoothHandsfreeAudioState, const nsAString&>
AudioStateNotification;
typedef BluetoothNotificationHALRunnable1<
typedef BluetoothNotificationHALRunnable2<
HandsfreeNotificationHandlerWrapper, void,
BluetoothHandsfreeVoiceRecognitionState>
BluetoothHandsfreeVoiceRecognitionState, nsString,
BluetoothHandsfreeVoiceRecognitionState, const nsAString&>
VoiceRecognitionNotification;
typedef BluetoothNotificationHALRunnable0<
HandsfreeNotificationHandlerWrapper, void>
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void,
nsString, const nsAString&>
AnswerCallNotification;
typedef BluetoothNotificationHALRunnable0<
HandsfreeNotificationHandlerWrapper, void>
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void,
nsString, const nsAString&>
HangupCallNotification;
typedef BluetoothNotificationHALRunnable3<
HandsfreeNotificationHandlerWrapper, void,
BluetoothHandsfreeVolumeType, int, nsString,
BluetoothHandsfreeVolumeType, int, const nsAString&>
VolumeNotification;
typedef BluetoothNotificationHALRunnable2<
HandsfreeNotificationHandlerWrapper, void,
BluetoothHandsfreeVolumeType, int>
VolumeNotification;
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void, nsString, const nsAString&>
nsString, nsString, const nsAString&, const nsAString&>
DialCallNotification;
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void, char>
typedef BluetoothNotificationHALRunnable2<
HandsfreeNotificationHandlerWrapper, void,
char, nsString, char, const nsAString&>
DtmfNotification;
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void, BluetoothHandsfreeNRECState>
typedef BluetoothNotificationHALRunnable2<
HandsfreeNotificationHandlerWrapper, void,
BluetoothHandsfreeNRECState, nsString,
BluetoothHandsfreeNRECState, const nsAString&>
NRECNotification;
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void, BluetoothHandsfreeCallHoldType>
typedef BluetoothNotificationHALRunnable2<
HandsfreeNotificationHandlerWrapper, void,
BluetoothHandsfreeWbsConfig, nsString,
BluetoothHandsfreeWbsConfig, const nsAString&>
WbsNotification;
typedef BluetoothNotificationHALRunnable2<
HandsfreeNotificationHandlerWrapper, void,
BluetoothHandsfreeCallHoldType, nsString,
BluetoothHandsfreeCallHoldType, const nsAString&>
CallHoldNotification;
typedef BluetoothNotificationHALRunnable0<
HandsfreeNotificationHandlerWrapper, void>
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void,
nsString, const nsAString&>
CnumNotification;
typedef BluetoothNotificationHALRunnable0<
HandsfreeNotificationHandlerWrapper, void>
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void,
nsString, const nsAString&>
CindNotification;
typedef BluetoothNotificationHALRunnable0<
HandsfreeNotificationHandlerWrapper, void>
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void,
nsString, const nsAString&>
CopsNotification;
typedef BluetoothNotificationHALRunnable0<
HandsfreeNotificationHandlerWrapper, void>
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void,
nsString, const nsAString&>
ClccNotification;
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void, nsCString, const nsACString&>
typedef BluetoothNotificationHALRunnable2<
HandsfreeNotificationHandlerWrapper, void,
nsCString, nsString, const nsACString&, const nsAString&>
UnknownAtNotification;
typedef BluetoothNotificationHALRunnable0<
HandsfreeNotificationHandlerWrapper, void>
typedef BluetoothNotificationHALRunnable1<
HandsfreeNotificationHandlerWrapper, void,
nsString, const nsAString&>
KeyPressedNotification;
// Bluedroid Handsfree callbacks
@ -138,6 +160,16 @@ struct BluetoothHandsfreeHALCallback
static void
ConnectionState(bthf_connection_state_t aState, bt_bdaddr_t* aBdAddr)
{
#if ANDROID_VERSION < 21
if (aState == BTHF_CONNECTION_STATE_CONNECTED && aBdAddr) {
memcpy(&sConnectedDeviceAddress, aBdAddr,
sizeof(sConnectedDeviceAddress));
} else if (aState == BTHF_CONNECTION_STATE_DISCONNECTED) {
memset(&sConnectedDeviceAddress, 0,
sizeof(sConnectedDeviceAddress));
}
#endif
ConnectionStateNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::ConnectionStateNotification,
aState, aBdAddr);
@ -151,108 +183,284 @@ struct BluetoothHandsfreeHALCallback
aState, aBdAddr);
}
#if ANDROID_VERSION >= 21
static void
VoiceRecognition(bthf_vr_state_t aState, bt_bdaddr_t* aBdAddr)
{
VoiceRecognitionNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::VoiceRecognitionNotification,
aState, aBdAddr);
}
#else
static void
VoiceRecognition(bthf_vr_state_t aState)
{
VoiceRecognitionNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::VoiceRecognitionNotification,
aState);
aState, &sConnectedDeviceAddress);
}
#endif
#if ANDROID_VERSION >= 21
static void
AnswerCall(bt_bdaddr_t* aBdAddr)
{
AnswerCallNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::AnswerCallNotification,
aBdAddr);
}
#else
static void
AnswerCall()
{
AnswerCallNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::AnswerCallNotification);
&BluetoothHandsfreeNotificationHandler::AnswerCallNotification,
&sConnectedDeviceAddress);
}
#endif
#if ANDROID_VERSION >= 21
static void
HangupCall(bt_bdaddr_t* aBdAddr)
{
HangupCallNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::HangupCallNotification,
aBdAddr);
}
#else
static void
HangupCall()
{
HangupCallNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::HangupCallNotification);
&BluetoothHandsfreeNotificationHandler::HangupCallNotification,
&sConnectedDeviceAddress);
}
#endif
#if ANDROID_VERSION >= 21
static void
Volume(bthf_volume_type_t aType, int aVolume, bt_bdaddr_t* aBdAddr)
{
VolumeNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::VolumeNotification,
aType, aVolume, aBdAddr);
}
#else
static void
Volume(bthf_volume_type_t aType, int aVolume)
{
VolumeNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::VolumeNotification,
aType, aVolume);
aType, aVolume, &sConnectedDeviceAddress);
}
#endif
#if ANDROID_VERSION >= 21
static void
DialCall(char* aNumber, bt_bdaddr_t* aBdAddr)
{
DialCallNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::DialCallNotification,
aNumber, aBdAddr);
}
#else
static void
DialCall(char* aNumber)
{
DialCallNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::DialCallNotification, aNumber);
&BluetoothHandsfreeNotificationHandler::DialCallNotification,
aNumber, &sConnectedDeviceAddress);
}
#endif
#if ANDROID_VERSION >= 21
static void
Dtmf(char aDtmf, bt_bdaddr_t* aBdAddr)
{
DtmfNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::DtmfNotification,
aDtmf, aBdAddr);
}
#else
static void
Dtmf(char aDtmf)
{
DtmfNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::DtmfNotification, aDtmf);
&BluetoothHandsfreeNotificationHandler::DtmfNotification,
aDtmf, &sConnectedDeviceAddress);
}
#endif
#if ANDROID_VERSION >= 21
static void
NoiseReductionEchoCancellation(bthf_nrec_t aNrec, bt_bdaddr_t* aBdAddr)
{
NRECNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::NRECNotification,
aNrec, aBdAddr);
}
#else
static void
NoiseReductionEchoCancellation(bthf_nrec_t aNrec)
{
NRECNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::NRECNotification, aNrec);
&BluetoothHandsfreeNotificationHandler::NRECNotification,
aNrec, &sConnectedDeviceAddress);
}
#endif
#if ANDROID_VERSION >= 21
static void
WideBandSpeech(bthf_wbs_config_t aWbs, bt_bdaddr_t* aBdAddr)
{
WbsNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::WbsNotification,
aWbs, aBdAddr);
}
#endif
#if ANDROID_VERSION >= 21
static void
CallHold(bthf_chld_type_t aChld, bt_bdaddr_t* aBdAddr)
{
CallHoldNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CallHoldNotification,
aChld, aBdAddr);
}
#else
static void
CallHold(bthf_chld_type_t aChld)
{
CallHoldNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CallHoldNotification, aChld);
&BluetoothHandsfreeNotificationHandler::CallHoldNotification,
aChld, &sConnectedDeviceAddress);
}
#endif
#if ANDROID_VERSION >= 21
static void
Cnum(bt_bdaddr_t* aBdAddr)
{
CnumNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CnumNotification,
aBdAddr);
}
#else
static void
Cnum()
{
CnumNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CnumNotification);
&BluetoothHandsfreeNotificationHandler::CnumNotification,
&sConnectedDeviceAddress);
}
#endif
#if ANDROID_VERSION >= 21
static void
Cind(bt_bdaddr_t* aBdAddr)
{
CindNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CindNotification,
aBdAddr);
}
#else
static void
Cind()
{
CindNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CindNotification);
&BluetoothHandsfreeNotificationHandler::CindNotification,
&sConnectedDeviceAddress);
}
#endif
#if ANDROID_VERSION >= 21
static void
Cops(bt_bdaddr_t* aBdAddr)
{
CopsNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CopsNotification,
aBdAddr);
}
#else
static void
Cops()
{
CopsNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::CopsNotification);
&BluetoothHandsfreeNotificationHandler::CopsNotification,
&sConnectedDeviceAddress);
}
#endif
#if ANDROID_VERSION >= 21
static void
Clcc(bt_bdaddr_t* aBdAddr)
{
ClccNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::ClccNotification,
aBdAddr);
}
#else
static void
Clcc()
{
ClccNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::ClccNotification);
&BluetoothHandsfreeNotificationHandler::ClccNotification,
&sConnectedDeviceAddress);
}
#endif
#if ANDROID_VERSION >= 21
static void
UnknownAt(char* aAtString, bt_bdaddr_t* aBdAddr)
{
UnknownAtNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::UnknownAtNotification,
aAtString, aBdAddr);
}
#else
static void
UnknownAt(char* aAtString)
{
UnknownAtNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::UnknownAtNotification,
aAtString);
aAtString, &sConnectedDeviceAddress);
}
#endif
#if ANDROID_VERSION >= 21
static void
KeyPressed(bt_bdaddr_t* aBdAddr)
{
KeyPressedNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::KeyPressedNotification,
aBdAddr);
}
#else
static void
KeyPressed()
{
KeyPressedNotification::Dispatch(
&BluetoothHandsfreeNotificationHandler::KeyPressedNotification);
&BluetoothHandsfreeNotificationHandler::KeyPressedNotification,
&sConnectedDeviceAddress);
}
#endif
#if ANDROID_VERSION < 21
/* |sConnectedDeviceAddress| stores Bluetooth device address of the
* connected device. Before Android Lollipop, we maintain this address by
* ourselves through ConnectionState(); after Android Lollipop, every callback
* carries this address directly so we don't have to keep it.
*/
static bt_bdaddr_t sConnectedDeviceAddress;
#endif
};
#if ANDROID_VERSION < 21
bt_bdaddr_t BluetoothHandsfreeHALCallback::sConnectedDeviceAddress = {
{0, 0, 0, 0, 0, 0}
};
#endif
// Interface
//
@ -269,7 +477,7 @@ BluetoothHandsfreeHALInterface::~BluetoothHandsfreeHALInterface()
void
BluetoothHandsfreeHALInterface::Init(
BluetoothHandsfreeNotificationHandler* aNotificationHandler,
BluetoothHandsfreeResultHandler* aRes)
int aMaxNumClients, BluetoothHandsfreeResultHandler* aRes)
{
static bthf_callbacks_t sCallbacks = {
sizeof(sCallbacks),
@ -282,6 +490,9 @@ BluetoothHandsfreeHALInterface::Init(
BluetoothHandsfreeHALCallback::DialCall,
BluetoothHandsfreeHALCallback::Dtmf,
BluetoothHandsfreeHALCallback::NoiseReductionEchoCancellation,
#if ANDROID_VERSION >= 21
BluetoothHandsfreeHALCallback::WideBandSpeech,
#endif
BluetoothHandsfreeHALCallback::CallHold,
BluetoothHandsfreeHALCallback::Cnum,
BluetoothHandsfreeHALCallback::Cind,
@ -293,7 +504,11 @@ BluetoothHandsfreeHALInterface::Init(
sHandsfreeNotificationHandler = aNotificationHandler;
#if ANDROID_VERSION >= 21
bt_status_t status = mInterface->init(&sCallbacks, aMaxNumClients);
#else
bt_status_t status = mInterface->init(&sCallbacks);
#endif
if (aRes) {
DispatchBluetoothHandsfreeHALResult(
@ -400,9 +615,22 @@ BluetoothHandsfreeHALInterface::DisconnectAudio(
void
BluetoothHandsfreeHALInterface::StartVoiceRecognition(
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status = mInterface->start_voice_recognition();
bt_status_t status;
#if ANDROID_VERSION >= 21
bt_bdaddr_t bdAddr;
if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) {
status = mInterface->start_voice_recognition(&bdAddr);
} else {
status = BT_STATUS_PARM_INVALID;
}
#else
status = mInterface->start_voice_recognition();
#endif
if (aRes) {
DispatchBluetoothHandsfreeHALResult(
@ -413,9 +641,22 @@ BluetoothHandsfreeHALInterface::StartVoiceRecognition(
void
BluetoothHandsfreeHALInterface::StopVoiceRecognition(
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status = mInterface->stop_voice_recognition();
bt_status_t status;
#if ANDROID_VERSION >= 21
bt_bdaddr_t bdAddr;
if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) {
status = mInterface->stop_voice_recognition(&bdAddr);
} else {
status = BT_STATUS_PARM_INVALID;
}
#else
status = mInterface->stop_voice_recognition();
#endif
if (aRes) {
DispatchBluetoothHandsfreeHALResult(
@ -428,14 +669,22 @@ BluetoothHandsfreeHALInterface::StopVoiceRecognition(
void
BluetoothHandsfreeHALInterface::VolumeControl(
BluetoothHandsfreeVolumeType aType, int aVolume,
BluetoothHandsfreeVolumeType aType, int aVolume, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status;
bthf_volume_type_t type = BTHF_VOLUME_TYPE_SPK;
#if ANDROID_VERSION >= 21
bt_bdaddr_t bdAddr;
if (NS_SUCCEEDED(Convert(aType, type)) &&
NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) {
status = mInterface->volume_control(type, aVolume, &bdAddr);
#else
if (NS_SUCCEEDED(Convert(aType, type))) {
status = mInterface->volume_control(type, aVolume);
#endif
} else {
status = BT_STATUS_PARM_INVALID;
}
@ -478,9 +727,22 @@ BluetoothHandsfreeHALInterface::DeviceStatusNotification(
void
BluetoothHandsfreeHALInterface::CopsResponse(
const char* aCops, BluetoothHandsfreeResultHandler* aRes)
const char* aCops, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status = mInterface->cops_response(aCops);
bt_status_t status;
#if ANDROID_VERSION >= 21
bt_bdaddr_t bdAddr;
if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) {
status = mInterface->cops_response(aCops, &bdAddr);
} else {
status = BT_STATUS_PARM_INVALID;
}
#else
status = mInterface->cops_response(aCops);
#endif
if (aRes) {
DispatchBluetoothHandsfreeHALResult(
@ -494,15 +756,26 @@ BluetoothHandsfreeHALInterface::CindResponse(
int aSvc, int aNumActive, int aNumHeld,
BluetoothHandsfreeCallState aCallSetupState,
int aSignal, int aRoam, int aBattChg,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status;
bthf_call_state_t callSetupState = BTHF_CALL_STATE_ACTIVE;
#if ANDROID_VERSION >= 21
bt_bdaddr_t bdAddr;
if (NS_SUCCEEDED(Convert(aCallSetupState, callSetupState)) &&
NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) {
status = mInterface->cind_response(aSvc, aNumActive, aNumHeld,
callSetupState, aSignal,
aRoam, aBattChg, &bdAddr);
#else
if (NS_SUCCEEDED(Convert(aCallSetupState, callSetupState))) {
status = mInterface->cind_response(aSvc, aNumActive, aNumHeld,
callSetupState, aSignal,
aRoam, aBattChg);
#endif
} else {
status = BT_STATUS_PARM_INVALID;
}
@ -516,9 +789,22 @@ BluetoothHandsfreeHALInterface::CindResponse(
void
BluetoothHandsfreeHALInterface::FormattedAtResponse(
const char* aRsp, BluetoothHandsfreeResultHandler* aRes)
const char* aRsp, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status = mInterface->formatted_at_response(aRsp);
bt_status_t status;
#if ANDROID_VERSION >= 21
bt_bdaddr_t bdAddr;
if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) {
status = mInterface->formatted_at_response(aRsp, &bdAddr);
} else {
status = BT_STATUS_PARM_INVALID;
}
#else
status = mInterface->formatted_at_response(aRsp);
#endif
if (aRes) {
DispatchBluetoothHandsfreeHALResult(
@ -530,13 +816,22 @@ BluetoothHandsfreeHALInterface::FormattedAtResponse(
void
BluetoothHandsfreeHALInterface::AtResponse(
BluetoothHandsfreeAtResponse aResponseCode, int aErrorCode,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status;
bthf_at_response_t responseCode = BTHF_AT_RESPONSE_ERROR;
#if ANDROID_VERSION >= 21
bt_bdaddr_t bdAddr;
if (NS_SUCCEEDED(Convert(aResponseCode, responseCode)) &&
NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) {
status = mInterface->at_response(responseCode, aErrorCode, &bdAddr);
#else
if (NS_SUCCEEDED(Convert(aResponseCode, responseCode))) {
status = mInterface->at_response(responseCode, aErrorCode);
#endif
} else {
status = BT_STATUS_PARM_INVALID;
}
@ -557,6 +852,7 @@ BluetoothHandsfreeHALInterface::ClccResponse(
BluetoothHandsfreeCallMptyType aMpty,
const nsAString& aNumber,
BluetoothHandsfreeCallAddressType aType,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status;
@ -566,6 +862,19 @@ BluetoothHandsfreeHALInterface::ClccResponse(
bthf_call_mpty_type_t mpty = BTHF_CALL_MPTY_TYPE_SINGLE;
bthf_call_addrtype_t type = BTHF_CALL_ADDRTYPE_UNKNOWN;
#if ANDROID_VERSION >= 21
bt_bdaddr_t bdAddr;
if (NS_SUCCEEDED(Convert(aDir, dir)) &&
NS_SUCCEEDED(Convert(aState, state)) &&
NS_SUCCEEDED(Convert(aMode, mode)) &&
NS_SUCCEEDED(Convert(aMpty, mpty)) &&
NS_SUCCEEDED(Convert(aType, type)) &&
NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) {
status = mInterface->clcc_response(aIndex, dir, state, mode, mpty,
NS_ConvertUTF16toUTF8(aNumber).get(),
type, &bdAddr);
#else
if (NS_SUCCEEDED(Convert(aDir, dir)) &&
NS_SUCCEEDED(Convert(aState, state)) &&
NS_SUCCEEDED(Convert(aMode, mode)) &&
@ -574,6 +883,7 @@ BluetoothHandsfreeHALInterface::ClccResponse(
status = mInterface->clcc_response(aIndex, dir, state, mode, mpty,
NS_ConvertUTF16toUTF8(aNumber).get(),
type);
#endif
} else {
status = BT_STATUS_PARM_INVALID;
}
@ -613,4 +923,35 @@ BluetoothHandsfreeHALInterface::PhoneStateChange(int aNumActive, int aNumHeld,
}
}
/* Wide Band Speech */
void
BluetoothHandsfreeHALInterface::ConfigureWbs(
const nsAString& aBdAddr,
BluetoothHandsfreeWbsConfig aConfig,
BluetoothHandsfreeResultHandler* aRes)
{
bt_status_t status;
#if ANDROID_VERSION >= 21
bt_bdaddr_t bdAddr;
bthf_wbs_config_t wbsConfig;
if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr)) &&
NS_SUCCEEDED(Convert(aConfig, wbsConfig))) {
status = mInterface->configure_wbs(&bdAddr, wbsConfig);
} else {
status = BT_STATUS_PARM_INVALID;
}
#else
status = BT_STATUS_UNSUPPORTED;
#endif
if (aRes) {
DispatchBluetoothHandsfreeHALResult(
aRes, &BluetoothHandsfreeResultHandler::ConfigureWbs,
ConvertDefault(status, STATUS_FAIL));
}
}
END_BLUETOOTH_NAMESPACE

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

@ -23,6 +23,7 @@ public:
friend class BluetoothHALInterface;
void Init(BluetoothHandsfreeNotificationHandler* aNotificationHandler,
int aMaxNumClients,
BluetoothHandsfreeResultHandler* aRes);
void Cleanup(BluetoothHandsfreeResultHandler* aRes);
@ -39,12 +40,15 @@ public:
/* Voice Recognition */
void StartVoiceRecognition(BluetoothHandsfreeResultHandler* aRes);
void StopVoiceRecognition(BluetoothHandsfreeResultHandler* aRes);
void StartVoiceRecognition(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void StopVoiceRecognition(const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
/* Volume */
void VolumeControl(BluetoothHandsfreeVolumeType aType, int aVolume,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
/* Device status */
@ -56,15 +60,16 @@ public:
/* Responses */
void CopsResponse(const char* aCops,
void CopsResponse(const char* aCops, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void CindResponse(int aSvc, int aNumActive, int aNumHeld,
BluetoothHandsfreeCallState aCallSetupState, int aSignal,
int aRoam, int aBattChg,
int aRoam, int aBattChg, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void FormattedAtResponse(const char* aRsp,
void FormattedAtResponse(const char* aRsp, const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void AtResponse(BluetoothHandsfreeAtResponse aResponseCode, int aErrorCode,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
void ClccResponse(int aIndex, BluetoothHandsfreeCallDirection aDir,
BluetoothHandsfreeCallState aState,
@ -72,6 +77,7 @@ public:
BluetoothHandsfreeCallMptyType aMpty,
const nsAString& aNumber,
BluetoothHandsfreeCallAddressType aType,
const nsAString& aBdAddr,
BluetoothHandsfreeResultHandler* aRes);
/* Phone State */
@ -82,6 +88,12 @@ public:
BluetoothHandsfreeCallAddressType aType,
BluetoothHandsfreeResultHandler* aRes);
/* Wide Band Speech */
void ConfigureWbs(const nsAString& aBdAddr,
BluetoothHandsfreeWbsConfig aConfig,
BluetoothHandsfreeResultHandler* aRes);
protected:
BluetoothHandsfreeHALInterface(const bthf_interface_t* aInterface);
~BluetoothHandsfreeHALInterface();

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

@ -693,7 +693,7 @@ BluetoothServiceBluedroid::CreatePairedDeviceInternal(
sBondingRunnableArray.AppendElement(aRunnable);
sBtInterface->CreateBond(aDeviceAddress,
sBtInterface->CreateBond(aDeviceAddress, TRANSPORT_AUTO,
new CreateBondResultHandler(aRunnable));
return NS_OK;
@ -1623,3 +1623,12 @@ BluetoothServiceBluedroid::LeTestModeNotification(BluetoothStatus aStatus,
// FIXME: This will be implemented in the later patchset
}
void
BluetoothServiceBluedroid::EnergyInfoNotification(
const BluetoothActivityEnergyInfo& aInfo)
{
MOZ_ASSERT(NS_IsMainThread());
// FIXME: This will be implemented in the later patchset
}

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

@ -212,6 +212,9 @@ public:
virtual void LeTestModeNotification(BluetoothStatus aStatus,
uint16_t aNumPackets) MOZ_OVERRIDE;
virtual void EnergyInfoNotification(
const BluetoothActivityEnergyInfo& aInfo) MOZ_OVERRIDE;
protected:
static nsresult StartGonkBluetooth();
static nsresult StopGonkBluetooth();

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

@ -57,6 +57,8 @@ namespace {
static int sBusyToneInterval = 3700; //unit: ms
} // anonymous namespace
const int BluetoothHfpManager::MAX_NUM_CLIENTS = 1;
static bool
IsValidDtmf(const char aChar) {
// Valid DTMF: [*#0-9ABCD]
@ -308,7 +310,7 @@ public:
{
BluetoothHfpManager* hfpManager = BluetoothHfpManager::Get();
mInterface->Init(hfpManager, this);
mInterface->Init(hfpManager, BluetoothHfpManager::MAX_NUM_CLIENTS, this);
}
private:
@ -638,8 +640,9 @@ BluetoothHfpManager::HandleVolumeChanged(nsISupports* aSubject)
// Only send volume back when there's a connected headset
if (IsConnected()) {
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
sBluetoothHfpInterface->VolumeControl(HFP_VOLUME_TYPE_SPEAKER, mCurrentVgs,
new VolumeControlResultHandler());
sBluetoothHfpInterface->VolumeControl(
HFP_VOLUME_TYPE_SPEAKER, mCurrentVgs, mDeviceAddress,
new VolumeControlResultHandler());
}
}
@ -767,7 +770,7 @@ BluetoothHfpManager::SendCLCC(Call& aCall, int aIndex)
sBluetoothHfpInterface->ClccResponse(
aIndex, aCall.mDirection, callState, HFP_CALL_MODE_VOICE,
HFP_CALL_MPTY_TYPE_SINGLE, aCall.mNumber,
aCall.mType, new ClccResponseResultHandler());
aCall.mType, mDeviceAddress, new ClccResponseResultHandler());
}
class FormattedAtResponseResultHandler MOZ_FINAL
@ -787,7 +790,7 @@ BluetoothHfpManager::SendLine(const char* aMessage)
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
sBluetoothHfpInterface->FormattedAtResponse(
aMessage, new FormattedAtResponseResultHandler());
aMessage, mDeviceAddress, new FormattedAtResponseResultHandler());
}
class AtResponseResultHandler MOZ_FINAL
@ -807,7 +810,7 @@ BluetoothHfpManager::SendResponse(BluetoothHandsfreeAtResponse aResponseCode)
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
sBluetoothHfpInterface->AtResponse(
aResponseCode, 0, new AtResponseResultHandler());
aResponseCode, 0, mDeviceAddress, new AtResponseResultHandler());
}
class PhoneStateChangeResultHandler MOZ_FINAL
@ -1361,7 +1364,7 @@ BluetoothHfpManager::AudioStateNotification(
}
void
BluetoothHfpManager::AnswerCallNotification()
BluetoothHfpManager::AnswerCallNotification(const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1369,7 +1372,7 @@ BluetoothHfpManager::AnswerCallNotification()
}
void
BluetoothHfpManager::HangupCallNotification()
BluetoothHfpManager::HangupCallNotification(const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1378,7 +1381,7 @@ BluetoothHfpManager::HangupCallNotification()
void
BluetoothHfpManager::VolumeNotification(
BluetoothHandsfreeVolumeType aType, int aVolume)
BluetoothHandsfreeVolumeType aType, int aVolume, const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1405,7 +1408,7 @@ BluetoothHfpManager::VolumeNotification(
}
void
BluetoothHfpManager::DtmfNotification(char aDtmf)
BluetoothHfpManager::DtmfNotification(char aDtmf, const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1417,7 +1420,8 @@ BluetoothHfpManager::DtmfNotification(char aDtmf)
}
void
BluetoothHfpManager::CallHoldNotification(BluetoothHandsfreeCallHoldType aChld)
BluetoothHfpManager::CallHoldNotification(BluetoothHandsfreeCallHoldType aChld,
const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1435,7 +1439,8 @@ BluetoothHfpManager::CallHoldNotification(BluetoothHandsfreeCallHoldType aChld)
NotifyDialer(NS_ConvertUTF8toUTF16(message));
}
void BluetoothHfpManager::DialCallNotification(const nsAString& aNumber)
void BluetoothHfpManager::DialCallNotification(const nsAString& aNumber,
const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1476,7 +1481,7 @@ void BluetoothHfpManager::DialCallNotification(const nsAString& aNumber)
}
void
BluetoothHfpManager::CnumNotification()
BluetoothHfpManager::CnumNotification(const nsAString& aBdAddress)
{
static const uint8_t sAddressType[] {
[HFP_CALL_ADDRESS_TYPE_UNKNOWN] = 0x81,
@ -1510,7 +1515,7 @@ public:
};
void
BluetoothHfpManager::CindNotification()
BluetoothHfpManager::CindNotification(const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1521,9 +1526,11 @@ BluetoothHfpManager::CindNotification()
BluetoothHandsfreeCallState callState =
ConvertToBluetoothHandsfreeCallState(GetCallSetupState());
sBluetoothHfpInterface->CindResponse(mService, numActive, numHeld,
callState, mSignal, mRoam, mBattChg,
new CindResponseResultHandler());
sBluetoothHfpInterface->CindResponse(
mService, numActive, numHeld,
callState, mSignal, mRoam, mBattChg,
aBdAddress,
new CindResponseResultHandler());
}
class CopsResponseResultHandler MOZ_FINAL
@ -1538,7 +1545,7 @@ public:
};
void
BluetoothHfpManager::CopsNotification()
BluetoothHfpManager::CopsNotification(const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1546,11 +1553,11 @@ BluetoothHfpManager::CopsNotification()
sBluetoothHfpInterface->CopsResponse(
NS_ConvertUTF16toUTF8(mOperatorName).get(),
new CopsResponseResultHandler());
aBdAddress, new CopsResponseResultHandler());
}
void
BluetoothHfpManager::ClccNotification()
BluetoothHfpManager::ClccNotification(const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1571,7 +1578,8 @@ BluetoothHfpManager::ClccNotification()
}
void
BluetoothHfpManager::UnknownAtNotification(const nsACString& aAtString)
BluetoothHfpManager::UnknownAtNotification(const nsACString& aAtString,
const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1581,7 +1589,7 @@ BluetoothHfpManager::UnknownAtNotification(const nsACString& aAtString)
}
void
BluetoothHfpManager::KeyPressedNotification()
BluetoothHfpManager::KeyPressedNotification(const nsAString& aBdAddress)
{
MOZ_ASSERT(NS_IsMainThread());

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

@ -77,6 +77,8 @@ class BluetoothHfpManager : public BluetoothHfpManagerBase
public:
BT_DECL_HFP_MGR_BASE
static const int MAX_NUM_CLIENTS;
void OnConnectError();
void OnDisconnectError();
@ -117,19 +119,24 @@ public:
const nsAString& aBdAddress) MOZ_OVERRIDE;
void AudioStateNotification(BluetoothHandsfreeAudioState aState,
const nsAString& aBdAddress) MOZ_OVERRIDE;
void AnswerCallNotification() MOZ_OVERRIDE;
void HangupCallNotification() MOZ_OVERRIDE;
void AnswerCallNotification(const nsAString& aBdAddress) MOZ_OVERRIDE;
void HangupCallNotification(const nsAString& aBdAddress) MOZ_OVERRIDE;
void VolumeNotification(BluetoothHandsfreeVolumeType aType,
int aVolume) MOZ_OVERRIDE;
void DtmfNotification(char aDtmf) MOZ_OVERRIDE;
void CallHoldNotification(BluetoothHandsfreeCallHoldType aChld) MOZ_OVERRIDE;
void DialCallNotification(const nsAString& aNumber) MOZ_OVERRIDE;
void CnumNotification() MOZ_OVERRIDE;
void CindNotification() MOZ_OVERRIDE;
void CopsNotification() MOZ_OVERRIDE;
void ClccNotification() MOZ_OVERRIDE;
void UnknownAtNotification(const nsACString& aAtString) MOZ_OVERRIDE;
void KeyPressedNotification() MOZ_OVERRIDE;
int aVolume,
const nsAString& aBdAddress) MOZ_OVERRIDE;
void DtmfNotification(char aDtmf,
const nsAString& aBdAddress) MOZ_OVERRIDE;
void CallHoldNotification(BluetoothHandsfreeCallHoldType aChld,
const nsAString& aBdAddress) MOZ_OVERRIDE;
void DialCallNotification(const nsAString& aNumber,
const nsAString& aBdAddress) MOZ_OVERRIDE;
void CnumNotification(const nsAString& aBdAddress) MOZ_OVERRIDE;
void CindNotification(const nsAString& aBdAddress) MOZ_OVERRIDE;
void CopsNotification(const nsAString& aBdAddress) MOZ_OVERRIDE;
void ClccNotification(const nsAString& aBdAddress) MOZ_OVERRIDE;
void UnknownAtNotification(const nsACString& aAtString,
const nsAString& aBdAddress) MOZ_OVERRIDE;
void KeyPressedNotification(const nsAString& aBdAddress) MOZ_OVERRIDE;
private:
class GetVolumeTask;

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

@ -10852,6 +10852,14 @@ FactoryOp::CheckPermission(ContentParent* aContentParent,
return rv;
}
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
if (persistenceType == PERSISTENCE_TYPE_PERSISTENT &&
!QuotaManager::IsOriginWhitelistedForPersistentStorage(origin) &&
!isApp) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
}
#endif
PermissionRequestBase::PermissionValue permission;
if (QuotaManager::IsFirstPromptRequired(persistenceType, origin, isApp)) {

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

@ -152,8 +152,6 @@ skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 931116
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 931116
[test_deleteDatabase_interactions.html]
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 931116
[test_disabled_quota_prompt.html]
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 931116
[test_error_events_abort_transactions.html]
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # Bug 931116
[test_event_propagation.html]

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

@ -1,120 +0,0 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html>
<head>
<title>Indexed Database Property Test</title>
<script type="text/javascript"
src="/tests/SimpleTest/SimpleTest.js">
</script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="text/javascript;version=1.7">
function addDataTo(objectStore)
{
const dataSize = 51200;
let buffer = new ArrayBuffer(dataSize);
for (let view = new Uint8Array(buffer), i = 0; i < dataSize; i++) {
view[i] = parseInt(Math.random() * 255)
}
let request = objectStore.put(buffer);
request.onerror = function(event) {
is(request.error.name,
"QuotaExceededError",
"correct error set on request");
SimpleTest.expectUncaughtException(true);
event.stopPropagation();
};
request.onsuccess = function() {
is(request.error, null, "no error yet, adding another value");
addDataTo(objectStore);
};
}
function testSteps()
{
const databaseName = window.location.pathname;
const databaseVersion = 1;
const databaseStorage = "persistent";
const objectStoreName = "foo";
info("setting quota pref");
SpecialPowers.pushPrefEnv({ set: [["dom.indexedDB.warningQuota", 2]] },
continueToNextStep);
yield undefined;
info("opening database");
let request = indexedDB.open(databaseName, {version: databaseVersion,
storage: databaseStorage});
request.onerror = errorHandler;
request.onupgradeneeded = grabEventAndContinueHandler;
request.onsuccess = unexpectedSuccessHandler;
let event = yield undefined;
info("creating object store");
let db = event.target.result;
db.onerror = errorHandler;
db.onversionchange = function(event) {
is(event.oldVersion, databaseVersion, "got correct oldVersion");
is(event.newVersion, null, "got correct newVersion");
db.close();
};
let objectStore = db.createObjectStore(objectStoreName,
{ autoIncrement: true });
request.onupgradeneeded = unexpectedSuccessHandler;
request.onsuccess = grabEventAndContinueHandler;
event = yield undefined;
info("making transaction");
let transaction = db.transaction(objectStoreName, "readwrite");
transaction.onabort = grabEventAndContinueHandler;
transaction.oncomplete = unexpectedSuccessHandler;
addDataTo(transaction.objectStore(objectStoreName));
info("adding until quota limit is reached");
event = yield undefined;
SimpleTest.expectUncaughtException(false);
is(transaction.error.name,
"QuotaExceededError",
"correct error set on transaction");
info("deleting database");
request = indexedDB.deleteDatabase(databaseName);
request.onerror = errorHandler;
request.onsuccess = grabEventAndContinueHandler;
event = yield undefined;
info("resetting quota pref");
SpecialPowers.popPrefEnv(continueToNextStep);
yield undefined;
finishTest();
yield undefined;
}
</script>
<script type="text/javascript;version=1.7" src="helpers.js"></script>
</head>
<body onload="runTest(true);"></body>
</html>

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

@ -31,6 +31,19 @@
for (let storage of storages) {
let request = indexedDB.open(name, { version: version,
storage: storage });
if (storage == "persistent" &&
SpecialPowers.Services.appinfo.widgetToolkit == "android") {
request.onerror = expectedErrorHandler("InvalidStateError");
request.onupgradeneeded = unexpectedSuccessHandler;
request.onsuccess = unexpectedSuccessHandler;
let event = yield undefined;
is(event.type, "error", "Got corrent event type");
continue;
}
request.onerror = errorHandler;
request.onupgradeneeded = grabEventAndContinueHandler;
request.onsuccess = grabEventAndContinueHandler;

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

@ -796,20 +796,6 @@ SanitizeOriginString(nsCString& aOrigin)
aOrigin.ReplaceChar(kReplaceChars, '+');
}
// The first prompt and quota tracking is not required for these origins in
// persistent storage.
bool
IsPersistentOriginWhitelisted(const nsACString& aOrigin)
{
if (aOrigin.EqualsLiteral(kChromeOrigin) ||
aOrigin.EqualsLiteral(kAboutHomeOrigin) ||
StringBeginsWith(aOrigin, nsDependentCString(kIndexedDBOriginPrefix))) {
return true;
}
return false;
}
nsresult
CloneStoragePath(nsIFile* aBaseDir,
const nsACString& aStorageName,
@ -2721,6 +2707,21 @@ QuotaManager::GetInfoForChrome(nsACString* aGroup,
}
}
// static
bool
QuotaManager::IsOriginWhitelistedForPersistentStorage(const nsACString& aOrigin)
{
// The first prompt and quota tracking is not required for these origins in
// persistent storage.
if (aOrigin.EqualsLiteral(kChromeOrigin) ||
aOrigin.EqualsLiteral(kAboutHomeOrigin) ||
StringBeginsWith(aOrigin, nsDependentCString(kIndexedDBOriginPrefix))) {
return true;
}
return false;
}
// static
bool
QuotaManager::IsTreatedAsPersistent(PersistenceType aPersistenceType,
@ -2744,7 +2745,7 @@ QuotaManager::IsFirstPromptRequired(PersistenceType aPersistenceType,
return false;
}
return !IsPersistentOriginWhitelisted(aOrigin);
return !IsOriginWhitelistedForPersistentStorage(aOrigin);
}
// static
@ -2758,7 +2759,7 @@ QuotaManager::IsQuotaEnforced(PersistenceType aPersistenceType,
return true;
}
if (IsPersistentOriginWhitelisted(aOrigin)) {
if (IsOriginWhitelistedForPersistentStorage(aOrigin)) {
return false;
}
@ -3135,8 +3136,9 @@ QuotaManager::LockedQuotaIsLifted()
MOZ_ASSERT(mCurrentWindowIndex != BAD_TLS_INDEX);
#if 1
// XXX For now we always fail the quota prompt.
return false;
// XXX We disabled the second (quota) prompt. All related code is going away
// soon.
return true;
#else
nsPIDOMWindow* window =
static_cast<nsPIDOMWindow*>(PR_GetThreadPrivate(mCurrentWindowIndex));
@ -4776,7 +4778,8 @@ StorageDirectoryHelper::CreateOrUpgradeMetadataFiles()
}
// Move whitelisted origins to new persistent storage.
if (IsPersistentOriginWhitelisted(originProps.mSpec)) {
if (QuotaManager::IsOriginWhitelistedForPersistentStorage(
originProps.mSpec)) {
if (!permanentStorageDir) {
permanentStorageDir =
do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);

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

@ -315,6 +315,9 @@ public:
bool* aIsApp,
bool* aHasUnlimStoragePerm);
static bool
IsOriginWhitelistedForPersistentStorage(const nsACString& aOrigin);
static bool
IsTreatedAsPersistent(PersistenceType aPersistenceType,
bool aIsApp);

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

@ -35,6 +35,7 @@ support-files =
res8.resource
res8.resource^headers^
resource_timing.js
navigation_timing.html
[test_497898.html]
skip-if = ((buildapp == 'mulet' || buildapp == 'b2g') && toolkit != 'gonk') || toolkit == 'android' #Bug 931116, b2g desktop specific, initial triage
@ -93,3 +94,5 @@ skip-if = buildapp == 'mulet' || toolkit == 'android' #CRASH_SUTAGENT
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage
[test_windowedhistoryframes.html]
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage
[test_navigation_timing.html]
skip-if = buildapp == 'b2g' || buildapp == 'mulet'

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

@ -0,0 +1,100 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
var timingParams = [
"navigationStart",
"unloadEventStart",
"unloadEventEnd",
"redirectStart",
"redirectEnd",
"fetchStart",
"domainLookupStart",
"domainLookupEnd",
"connectStart",
"connectEnd",
"requestStart",
"responseStart",
"responseEnd",
"domLoading",
"domInteractive",
"domContentLoadedEventStart",
"domContentLoadedEventEnd",
"domComplete",
"loadEventStart",
"loadEventEnd"
];
function is(received, expected, message) {
window.opener.is(received, expected, message);
}
function isnot(received, notExpected, message) {
window.opener.isnot(received, notExpected, message);
}
window.onload = function() {
if (location.href.indexOf("_blank") != -1) {
test_blank();
return;
}
if (location.href.indexOf("_self") != -1) {
test_self();
return;
}
}
function checkTimingValues(expectedValues) {
for (var name of timingParams) {
if (name in expectedValues) {
is(window.performance.timing[name], expectedValues[name], name+" should be "+expectedValues[name]);
} else {
isnot(window.performance.timing[name], 0, name+" should not be 0");
}
}
}
function test_blank() {
// We set a timeout to make sure this is run after onload is called
setTimeout(function(){
// When loading the page in _blank, unloadEvent and redirect timestamps should be 0
var expectedValues = { "unloadEventStart": 0, "unloadEventEnd": 0, "redirectStart": 0, "redirectEnd": 0 };
checkTimingValues(expectedValues);
// change location in order to test a _self load
window.location.href = "navigation_timing.html?x=1#_self";
}, 0);
}
function test_self() {
// We set a timeout to make sure this is run after onload is called
setTimeout(function(){
// When simply loading in _self, redirect timestamps should be 0 (unloadEventStart/End != 0)
var expectedValues = { "redirectStart": 0, "redirectEnd": 0 };
checkTimingValues(expectedValues);
window.opener.finishTests();
}, 0);
}
</script>
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=1099092"
title="Navigation timing">
Bug #1099092 - Navigation Timing has incorrect values when page is load via link with target=_blank attribute
</a>
<p id="display"></p>
</body>
</html>

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

@ -0,0 +1,36 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=822480
-->
<head>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<pre id="test">
<script type="application/javascript">
var subwindow = null;
window.onload = function() {
SimpleTest.waitForExplicitFinish();
subwindow = window.open("navigation_timing.html?x=0#_blank", "_blank");
}
function finishTests() {
subwindow.close();
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>

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

@ -1461,10 +1461,10 @@ gfxFontFamily::FindFontForChar(GlobalFontMatch *aMatchData)
}
bool needsBold;
gfxFontStyle normal;
gfxFontEntry *fe = FindFontForStyle(
(aMatchData->mStyle == nullptr) ? *aMatchData->mStyle : normal,
needsBold);
gfxFontEntry *fe =
FindFontForStyle(aMatchData->mStyle ? *aMatchData->mStyle
: gfxFontStyle(),
needsBold);
if (fe && !fe->SkipDuringSystemFallback()) {
int32_t rank = 0;

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

@ -290,7 +290,7 @@ AsmJSModule::finish(ExclusiveContext *cx, TokenStream &tokenStream, MacroAssembl
// The global data section sits immediately after the executable (and
// other) data allocated by the MacroAssembler, so ensure it is
// SIMD-aligned.
pod.codeBytes_ = AlignBytes(masm.bytesNeeded(), SimdStackAlignment);
pod.codeBytes_ = AlignBytes(masm.bytesNeeded(), SimdMemoryAlignment);
// The entire region is allocated via mmap/VirtualAlloc which requires
// units of pages.

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

@ -272,7 +272,7 @@ static const struct ParamPair {
};
// Keep this in sync with above params.
#define GC_PARAMETER_ARGS_LIST "maxBytes, maxMallocBytes, gcBytes, gcNumber, sliceTimeBudget, or markStackLimit"
#define GC_PARAMETER_ARGS_LIST "maxBytes, maxMallocBytes, gcBytes, gcNumber, sliceTimeBudget, markStackLimit, minEmptyChunkCount or maxEmptyChunkCount"
static bool
GCParameter(JSContext *cx, unsigned argc, Value *vp)

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

@ -236,9 +236,9 @@ fi
dnl ==============================================================
dnl Get mozilla version from central milestone file
dnl ==============================================================
MOZILLA_VERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir`
MOZILLA_UAVERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir -uaversion`
MOZILLA_SYMBOLVERSION=`$PERL $srcdir/config/milestone.pl -topsrcdir $srcdir -symbolversion`
MOZILLA_VERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir`
MOZILLA_UAVERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir --uaversion`
MOZILLA_SYMBOLVERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir --symbolversion`
AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
@ -1700,7 +1700,7 @@ ia64*-hpux*)
MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
RC='$(WINDRES)'
# Use static libgcc and libstdc++
LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++"
LDFLAGS="$LDFLAGS -static"
# Use temp file for windres (bug 213281)
RCFLAGS='-O coff --use-temp-file'
# mingw doesn't require kernel32, user32, and advapi32 explicitly

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

@ -2216,7 +2216,7 @@ ConvertToJS(JSContext* cx,
// ctypes.int8_t, UInt8Array to ctypes.uint8_t, etc.
bool CanConvertTypedArrayItemTo(JSObject *baseType, JSObject *valObj, JSContext *cx) {
TypeCode baseTypeCode = CType::GetTypeCode(baseType);
if (baseTypeCode == TYPE_void_t) {
if (baseTypeCode == TYPE_void_t || baseTypeCode == TYPE_char) {
return true;
}
TypeCode elementTypeCode;
@ -2249,6 +2249,7 @@ bool CanConvertTypedArrayItemTo(JSObject *baseType, JSObject *valObj, JSContext
default:
return false;
}
return elementTypeCode == baseTypeCode;
}
@ -2451,9 +2452,13 @@ ImplicitConvert(JSContext* cx,
}
break;
} else if (val.isObject() && JS_IsArrayBufferObject(valObj)) {
// Convert ArrayBuffer to pointer without any copy. Just as with C
// arrays, we make no effort to keep the ArrayBuffer alive. This
// functionality will be removed for all but arguments in bug 1080262.
// Convert ArrayBuffer to pointer without any copy. This is only valid
// when converting an argument to a function call, as it is possible for
// the pointer to be invalidated by anything that runs JS code. (It is
// invalid to invoke JS code from a ctypes function call.)
if (!isArgument) {
return TypeError(cx, "arraybuffer pointer", val);
}
void* ptr;
{
JS::AutoCheckCannotGC nogc;
@ -2464,12 +2469,15 @@ ImplicitConvert(JSContext* cx,
}
*static_cast<void**>(buffer) = ptr;
break;
} if (val.isObject() && JS_IsArrayBufferViewObject(valObj)) {
// Same as ArrayBuffer, above, though note that this will take the offset
// of the view into account.
} else if (val.isObject() && JS_IsArrayBufferViewObject(valObj)) {
// Same as ArrayBuffer, above, though note that this will take the
// offset of the view into account.
if(!CanConvertTypedArrayItemTo(baseType, valObj, cx)) {
return TypeError(cx, "typed array with the appropriate type", val);
}
if (!isArgument) {
return TypeError(cx, "typed array pointer", val);
}
void* ptr;
{
JS::AutoCheckCannotGC nogc;

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

@ -197,27 +197,16 @@ def main(argv):
# The full test list is ready. Now create copies for each JIT configuration.
job_list = []
test_flags = []
if options.tbpl:
# Running all bits would take forever. Instead, we test a few interesting combinations.
for test in test_list:
for variant in TBPL_FLAGS:
new_test = test.copy()
new_test.jitflags.extend(variant)
job_list.append(new_test)
test_flags = TBPL_FLAGS
elif options.ion:
flags = [['--baseline-eager'], ['--ion-eager', '--ion-offthread-compile=off']]
for test in test_list:
for variant in flags:
new_test = test.copy()
new_test.jitflags.extend(variant)
job_list.append(new_test)
test_flags = [['--baseline-eager'], ['--ion-eager', '--ion-offthread-compile=off']]
else:
jitflags_list = jittests.parse_jitflags(options)
for test in test_list:
for jitflags in jitflags_list:
new_test = test.copy()
new_test.jitflags.extend(jitflags)
job_list.append(new_test)
test_flags = jittests.parse_jitflags(options)
job_list = [ _ for test in test_list for _ in test.copy_variants(test_flags) ]
if options.ignore_timeouts:
read_all = False

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
function f(stdlib, foreign, buffer)

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
/* -*- Mode: javascript; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 ; js-indent-level : 2 ; js-curly-indent-offset: 0 -*- */
/* vim: set ts=4 et sw=4 tw=80: */

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
/* -*- Mode: javascript; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 ; js-indent-level : 2 ; js-curly-indent-offset: 0 -*- */
/* vim: set ts=2 et sw=2 tw=80: */

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
var JSMSG_ILLEGAL_CHARACTER = "illegal character";
function test_reflect(code) {

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
if (!this.SharedArrayBuffer || !this.SharedInt32Array || !this.Atomics)
quit();

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
load(libdir + "asserts.js");

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
// Test a big fat asm.js module. First load/compile/cache bullet.js in a
// separate process and then load it again in this process, which should be a
// cache hit.

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
setCachingEnabled(true);

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
load(libdir + "asserts.js");

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
var code = asmCompile(USE_ASM + "function g() { return 42 } return g");

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
assertAsmTypeFail(USE_ASM + "function f(i,j,k) { i=i|0;j=+j;k=+k; return (i+(j+k))|0 } return f");

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
assertAsmTypeFail(USE_ASM + "function f(i,j) { i=i|0;j=+j; if (i) return j; return j } return f");

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
assertAsmTypeFail(USE_ASM + "function f() { var i=0,j=0.0; return (i+j)|0 } return f");

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
load(libdir + "asserts.js");

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i,j) {i=i|0;j=j|0; u32[((i<<2)+32 & 0xffff)>>2] = j } return f');

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
const TO_FLOAT32 = "var toF = glob.Math.fround;";
const HEAP32 = "var f32 = new glob.Float32Array(heap);";

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
assertEq(asmLink(asmCompile(USE_ASM + "function f() { return 1.1 } return f"))(), 1.1);

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
assertAsmTypeFail('imp', USE_ASM + "function f() {} var imp=[f]; return f");

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
load(libdir + "asserts.js");

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
assertAsmTypeFail('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[0>>2] = 4.0; return i32[0>>2]|0; } return f');

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
// This test should not assert.
function asmModule(g, foreign, heap) {

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + 'asm.js');
assertAsmTypeFail(USE_ASM + 'function f(d) { d=+d; var e=0; e=d; return +e } return f');

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
function testUnary(f, g) {

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
function testUniqueness(asmJSModule) {
var f = asmJSModule();
var g = asmJSModule();

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
load(libdir + "asserts.js");

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
if (!isAsmJSCompilationAvailable())

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
// Bug 894781
function m(stdlib)
{

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
load(libdir + "asserts.js");

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
setCachingEnabled(true);
(function() {

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
load(libdir + "asserts.js");

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
assertAsmDirectiveFail("'use asm'");

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
var body =

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

@ -1,3 +1,4 @@
// |jit-test| test-also-noasmjs
load(libdir + "asm.js");
setIonCheckGraphCoherency(false);

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

@ -0,0 +1,6 @@
function f() {
let(x) yield x;
}
var g = f();
g.next();
g.close();

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

@ -0,0 +1,9 @@
function f(x, y) {
for (var i=0; i<40; i++) {
var stack = getBacktrace({args: true, locals: true, thisprops: true});
assertEq(stack.contains("f(x = "), true);
assertEq(stack.contains("this = "), true);
backtrace();
}
}
f(1, 2);

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

@ -3003,6 +3003,17 @@ static const VMFunction PopBlockScopeInfo = FunctionInfo<PopBlockScopeFn>(jit::P
bool
BaselineCompiler::emit_JSOP_POPBLOCKSCOPE()
{
#ifdef DEBUG
// The static block scope ends right before this op. Assert we generated
// JIT code for the previous op, so that pcForNativeOffset does not
// incorrectly return this pc instead of the previous one and confuse
// ScopeIter::settle. TODO: remove this when bug 1118826 lands.
PCMappingEntry &prevEntry = pcMappingEntries_[pcMappingEntries_.length() - 2];
PCMappingEntry &curEntry = pcMappingEntries_[pcMappingEntries_.length() - 1];
MOZ_ASSERT(curEntry.pcOffset == script->pcToOffset(pc));
MOZ_ASSERT(curEntry.nativeOffset > prevEntry.nativeOffset);
#endif
// Call a stub to pop the block from the block chain.
prepareVMCall();
@ -3018,8 +3029,12 @@ static const VMFunction DebugLeaveBlockInfo = FunctionInfo<DebugLeaveBlockFn>(ji
bool
BaselineCompiler::emit_JSOP_DEBUGLEAVEBLOCK()
{
if (!compileDebugInstrumentation_)
if (!compileDebugInstrumentation_) {
// See the comment in emit_JSOP_POPBLOCKSCOPE.
if (*GetNextPc(pc) == JSOP_POPBLOCKSCOPE)
masm.nop();
return true;
}
prepareVMCall();
masm.loadBaselineFramePtr(BaselineFrameReg, R0.scratchReg());

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

@ -264,6 +264,13 @@ JSONSpewer::spewMDef(MDefinition *def)
integerValue(use.def()->id());
endList();
if (!def->isLowered()) {
beginListProperty("memInputs");
if (def->dependency())
integerValue(def->dependency()->id());
endList();
}
bool isTruncated = false;
if (def->isAdd() || def->isSub() || def->isMod() || def->isMul() || def->isDiv())
isTruncated = static_cast<MBinaryArithInstruction*>(def)->isTruncated();

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

@ -550,15 +550,15 @@ LMoveGroup::add(LAllocation *from, LAllocation *to, LDefinition::Type type)
if (LDefinition(type).isSimdType()) {
if (from->isMemory()) {
if (from->isArgument())
MOZ_ASSERT(from->toArgument()->index() % SimdStackAlignment == 0);
MOZ_ASSERT(from->toArgument()->index() % SimdMemoryAlignment == 0);
else
MOZ_ASSERT(from->toStackSlot()->slot() % SimdStackAlignment == 0);
MOZ_ASSERT(from->toStackSlot()->slot() % SimdMemoryAlignment == 0);
}
if (to->isMemory()) {
if (to->isArgument())
MOZ_ASSERT(to->toArgument()->index() % SimdStackAlignment == 0);
MOZ_ASSERT(to->toArgument()->index() % SimdMemoryAlignment == 0);
else
MOZ_ASSERT(to->toStackSlot()->slot() % SimdStackAlignment == 0);
MOZ_ASSERT(to->toStackSlot()->slot() % SimdMemoryAlignment == 0);
}
}
#endif

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

@ -153,9 +153,14 @@ static const uint32_t CodeAlignment = 8;
// here such that it is accessible from the entire codebase. Once full support
// for SIMD is reached on all tier-1 platforms, this constant can be deleted.
static const bool SupportsSimd = false;
static const uint32_t SimdStackAlignment = 8;
static const uint32_t SimdMemoryAlignment = 8;
static const uint32_t AsmJSStackAlignment = SimdStackAlignment;
static_assert(CodeAlignment % SimdMemoryAlignment == 0,
"Code alignment should be larger than any of the alignment which are used for "
"the constant sections of the code buffer. Thus it should be larger than the "
"alignment for SIMD constants.");
static const uint32_t AsmJSStackAlignment = SimdMemoryAlignment;
static const Scale ScalePointer = TimesFour;

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

@ -170,9 +170,9 @@ static const uint32_t CodeAlignment = 4;
static const bool SupportsSimd = false;
// TODO this is just a filler to prevent a build failure. The MIPS SIMD
// alignment requirements still need to be explored.
static const uint32_t SimdStackAlignment = 8;
static const uint32_t SimdMemoryAlignment = 8;
static const uint32_t AsmJSStackAlignment = SimdStackAlignment;
static const uint32_t AsmJSStackAlignment = SimdMemoryAlignment;
static const Scale ScalePointer = TimesFour;

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

@ -15,7 +15,7 @@ namespace js {
namespace jit {
static const bool SupportsSimd = false;
static const uint32_t SimdStackAlignment = 4; // Make it 4 to avoid a bunch of div-by-zero warnings
static const uint32_t SimdMemoryAlignment = 4; // Make it 4 to avoid a bunch of div-by-zero warnings
static const uint32_t AsmJSStackAlignment = 4;
class Registers

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

@ -310,8 +310,8 @@ CodeGeneratorX86Shared::visitAsmJSPassStackArg(LAsmJSPassStackArg *ins)
case MIRType_Float32:
masm.storeDouble(ToFloatRegister(ins->arg()), dst);
return;
// StackPointer is SimdStackAlignment-aligned and ABIArgGenerator guarantees stack
// offsets are SimdStackAlignment-aligned.
// StackPointer is SIMD-aligned and ABIArgGenerator guarantees
// stack offsets are SIMD-aligned.
case MIRType_Int32x4:
masm.storeAlignedInt32x4(ToFloatRegister(ins->arg()), dst);
return;

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

@ -34,7 +34,7 @@ ABIArgGenerator::next(MIRType type)
// On Win64, >64 bit args need to be passed by reference, but asm.js
// doesn't allow passing SIMD values to FFIs. The only way to reach
// here is asm to asm calls, so we can break the ABI here.
stackOffset_ = AlignBytes(stackOffset_, SimdStackAlignment);
stackOffset_ = AlignBytes(stackOffset_, SimdMemoryAlignment);
current_ = ABIArg(stackOffset_);
stackOffset_ += Simd128DataSize;
} else {
@ -86,7 +86,7 @@ ABIArgGenerator::next(MIRType type)
case MIRType_Int32x4:
case MIRType_Float32x4:
if (floatRegIndex_ == NumFloatArgRegs) {
stackOffset_ = AlignBytes(stackOffset_, SimdStackAlignment);
stackOffset_ = AlignBytes(stackOffset_, SimdMemoryAlignment);
current_ = ABIArg(stackOffset_);
stackOffset_ += Simd128DataSize;
break;

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

@ -178,16 +178,21 @@ static MOZ_CONSTEXPR_VAR Register OsrFrameReg = IntArgReg3;
static MOZ_CONSTEXPR_VAR Register PreBarrierReg = rdx;
static const uint32_t ABIStackAlignment = 16;
static const uint32_t CodeAlignment = 8;
static const uint32_t CodeAlignment = 16;
// This boolean indicates whether we support SIMD instructions flavoured for
// this architecture or not. Rather than a method in the LIRGenerator, it is
// here such that it is accessible from the entire codebase. Once full support
// for SIMD is reached on all tier-1 platforms, this constant can be deleted.
static const bool SupportsSimd = true;
static const uint32_t SimdStackAlignment = 16;
static const uint32_t SimdMemoryAlignment = 16;
static const uint32_t AsmJSStackAlignment = SimdStackAlignment;
static_assert(CodeAlignment % SimdMemoryAlignment == 0,
"Code alignment should be larger than any of the alignment which are used for "
"the constant sections of the code buffer. Thus it should be larger than the "
"alignment for SIMD constants.");
static const uint32_t AsmJSStackAlignment = SimdMemoryAlignment;
static const Scale ScalePointer = TimesEight;

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

@ -160,7 +160,7 @@ MacroAssemblerX64::finish()
// SIMD memory values must be suitably aligned.
if (!simds_.empty())
masm.align(SimdStackAlignment);
masm.align(SimdMemoryAlignment);
for (size_t i = 0; i < simds_.length(); i++) {
SimdData &v = simds_[i];
bind(&v.uses);

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

@ -34,8 +34,8 @@ ABIArgGenerator::next(MIRType type)
case MIRType_Float32x4:
// SIMD values aren't passed in or out of C++, so we can make up
// whatever internal ABI we like. visitAsmJSPassArg assumes
// SimdStackAlignment.
stackOffset_ = AlignBytes(stackOffset_, SimdStackAlignment);
// SimdMemoryAlignment.
stackOffset_ = AlignBytes(stackOffset_, SimdMemoryAlignment);
current_ = ABIArg(stackOffset_);
stackOffset_ += Simd128DataSize;
break;

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

@ -108,16 +108,21 @@ static const uint32_t ABIStackAlignment = 16;
#else
static const uint32_t ABIStackAlignment = 4;
#endif
static const uint32_t CodeAlignment = 8;
static const uint32_t CodeAlignment = 16;
// This boolean indicates whether we support SIMD instructions flavoured for
// this architecture or not. Rather than a method in the LIRGenerator, it is
// here such that it is accessible from the entire codebase. Once full support
// for SIMD is reached on all tier-1 platforms, this constant can be deleted.
static const bool SupportsSimd = true;
static const uint32_t SimdStackAlignment = 16;
static const uint32_t SimdMemoryAlignment = 16;
static const uint32_t AsmJSStackAlignment = SimdStackAlignment;
static_assert(CodeAlignment % SimdMemoryAlignment == 0,
"Code alignment should be larger than any of the alignment which are used for "
"the constant sections of the code buffer. Thus it should be larger than the "
"alignment for SIMD constants.");
static const uint32_t AsmJSStackAlignment = SimdMemoryAlignment;
struct ImmTag : public Imm32
{

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

@ -187,7 +187,7 @@ MacroAssemblerX86::finish()
// SIMD memory values must be suitably aligned.
if (!simds_.empty())
masm.align(SimdStackAlignment);
masm.align(SimdMemoryAlignment);
for (size_t i = 0; i < simds_.length(); i++) {
CodeLabel cl(simds_[i].uses);
SimdData &v = simds_[i];

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

@ -664,6 +664,9 @@ FormatValue(JSContext *cx, const Value &vArg, JSAutoByteString &bytes)
{
RootedValue v(cx, vArg);
if (v.isMagic(JS_OPTIMIZED_OUT))
return "[unavailable]";
/*
* We could use Maybe<AutoCompartment> here, but G++ can't quite follow
* that, and warns about uninitialized members being used in the
@ -738,7 +741,10 @@ FormatFrame(JSContext *cx, const ScriptFrameIter &iter, char *buf, int num,
} else if (script->argsObjAliasesFormals() && iter.hasArgsObj()) {
arg = iter.argsObj().arg(i);
} else {
arg = iter.unaliasedActual(i, DONT_CHECK_ALIASING);
if (iter.hasUsableAbstractFramePtr())
arg = iter.unaliasedActual(i, DONT_CHECK_ALIASING);
else
arg = MagicValue(JS_OPTIMIZED_OUT);
}
JSAutoByteString valueBytes;

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

@ -113,6 +113,7 @@ class Test:
# limits is not considered a failure.
self.valgrind = False # True means run under valgrind
self.tz_pacific = False # True means force Pacific time for the test
self.test_also_noasmjs = False # True means run with and without asm.js enabled.
self.expect_error = '' # Errors to expect and consider passing
self.expect_status = 0 # Exit status to expect from shell
@ -125,10 +126,28 @@ class Test:
t.allow_overrecursed = self.allow_overrecursed
t.valgrind = self.valgrind
t.tz_pacific = self.tz_pacific
t.test_also_noasmjs = self.test_also_noasmjs
t.expect_error = self.expect_error
t.expect_status = self.expect_status
return t
def copy_and_extend_jitflags(self, variant):
t = self.copy()
t.jitflags.extend(variant)
return t
def copy_variants(self, variants):
# If the tests are flagged with the |jit-test| test-also-noasmjs flags, then
# we duplicate the variants such that the test can be used both with the
# interpreter and asmjs. This is a simple way to check for differential
# behaviour.
if self.test_also_noasmjs:
variants = variants + [['--no-asmjs']]
# For each list of jit flags, make a copy of the test.
return [ self.copy_and_extend_jitflags(v) for v in variants ]
COOKIE = '|jit-test|'
CacheDir = JS_CACHE_DIR
@ -175,6 +194,8 @@ class Test:
test.valgrind = options.valgrind
elif name == 'tz-pacific':
test.tz_pacific = True
elif name == 'test-also-noasmjs':
test.test_also_noasmjs = True
elif name == 'ion-eager':
test.jitflags.append('--ion-eager')
elif name == 'dump-bytecode':

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

@ -174,16 +174,18 @@ js::NativeObject::checkShapeConsistency()
MOZ_ASSERT(shape->hasTable());
ShapeTable &table = shape->table();
for (uint32_t fslot = table.freelist; fslot != SHAPE_INVALID_SLOT;
fslot = getSlot(fslot).toPrivateUint32()) {
for (uint32_t fslot = table.freeList();
fslot != SHAPE_INVALID_SLOT;
fslot = getSlot(fslot).toPrivateUint32())
{
MOZ_ASSERT(fslot < slotSpan());
}
for (int n = throttle; --n >= 0 && shape->parent; shape = shape->parent) {
MOZ_ASSERT_IF(lastProperty() != shape, !shape->hasTable());
Shape **spp = table.search(shape->propid(), false);
MOZ_ASSERT(SHAPE_FETCH(spp) == shape);
ShapeTable::Entry &entry = table.search(shape->propid(), false);
MOZ_ASSERT(entry.shape() == shape);
}
shape = lastProperty();
@ -203,8 +205,8 @@ js::NativeObject::checkShapeConsistency()
ShapeTable &table = shape->table();
MOZ_ASSERT(shape->parent);
for (Shape::Range<NoGC> r(shape); !r.empty(); r.popFront()) {
Shape **spp = table.search(r.front().propid(), false);
MOZ_ASSERT(SHAPE_FETCH(spp) == &r.front());
ShapeTable::Entry &entry = table.search(r.front().propid(), false);
MOZ_ASSERT(entry.shape() == &r.front());
}
}
if (prev) {
@ -280,8 +282,8 @@ Shape *
js::NativeObject::lookup(ExclusiveContext *cx, jsid id)
{
MOZ_ASSERT(isNative());
Shape **spp;
return Shape::search(cx, lastProperty(), id, &spp);
ShapeTable::Entry *entry;
return Shape::search(cx, lastProperty(), id, &entry);
}
Shape *
@ -953,7 +955,7 @@ NativeObject::allocSlot(ExclusiveContext *cx, HandleNativeObject obj, uint32_t *
*/
if (obj->inDictionaryMode()) {
ShapeTable &table = obj->lastProperty()->table();
uint32_t last = table.freelist;
uint32_t last = table.freeList();
if (last != SHAPE_INVALID_SLOT) {
#ifdef DEBUG
MOZ_ASSERT(last < slot);
@ -964,7 +966,7 @@ NativeObject::allocSlot(ExclusiveContext *cx, HandleNativeObject obj, uint32_t *
*slotp = last;
const Value &vref = obj->getSlot(last);
table.freelist = vref.toPrivateUint32();
table.setFreeList(vref.toPrivateUint32());
obj->setSlot(last, UndefinedValue());
return true;
}
@ -989,7 +991,8 @@ NativeObject::freeSlot(uint32_t slot)
MOZ_ASSERT(slot < slotSpan());
if (inDictionaryMode()) {
uint32_t &last = lastProperty()->table().freelist;
ShapeTable &table = lastProperty()->table();
uint32_t last = table.freeList();
/* Can't afford to check the whole freelist, but let's check the head. */
MOZ_ASSERT_IF(last != SHAPE_INVALID_SLOT, last < slotSpan() && last != slot);
@ -1001,7 +1004,7 @@ NativeObject::freeSlot(uint32_t slot)
if (JSSLOT_FREE(getClass()) <= slot) {
MOZ_ASSERT_IF(last != SHAPE_INVALID_SLOT, last < slotSpan());
setSlot(slot, PrivateUint32Value(last));
last = slot;
table.setFreeList(slot);
return;
}
}

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

@ -689,7 +689,7 @@ class NativeObject : public JSObject
static Shape *
addPropertyInternal(ExclusiveContext *cx, HandleNativeObject obj, HandleId id,
JSPropertyOp getter, JSStrictPropertyOp setter,
uint32_t slot, unsigned attrs, unsigned flags, Shape **spp,
uint32_t slot, unsigned attrs, unsigned flags, ShapeTable::Entry *entry,
bool allowDictionary);
void fillInAfterSwap(JSContext *cx, const Vector<Value> &values, void *priv);

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

@ -700,8 +700,8 @@ StaticBlockObject::addVar(ExclusiveContext *cx, Handle<StaticBlockObject*> block
*redeclared = false;
/* Inline NativeObject::addProperty in order to trap the redefinition case. */
Shape **spp;
if (Shape::search(cx, block->lastProperty(), id, &spp, true)) {
ShapeTable::Entry *entry;
if (Shape::search(cx, block->lastProperty(), id, &entry, true)) {
*redeclared = true;
return nullptr;
}
@ -719,7 +719,7 @@ StaticBlockObject::addVar(ExclusiveContext *cx, Handle<StaticBlockObject*> block
slot,
propFlags,
/* attrs = */ 0,
spp,
entry,
/* allowDictionary = */ false);
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше