Merge b2g-inbound to m-c on a CLOSED TREE.

This commit is contained in:
Ryan VanderMeulen 2013-12-04 17:34:18 -05:00
commit f31a233588
17 changed files with 185 additions and 82 deletions

View File

@ -1,4 +1,4 @@
{
"revision": "428cccdc7a3b4c40f40dda80b6031d26ac9d2d68",
"revision": "adb7896ababd1ccb828e11b05909c0e9ca22594e",
"repo_path": "/integration/gaia-central"
}

View File

@ -19,22 +19,25 @@ extern bool gBluetoothDebugFlag;
#undef BT_LOG
#if defined(MOZ_WIDGET_GONK)
#include <android/log.h>
/**
* Prints 'D'EBUG build logs, which show in DEBUG build only when
* developer setting 'Bluetooth output in adb' is enabled.
*/
#define BT_LOGD(args...) \
#define BT_LOGD(msg, ...) \
do { \
if (gBluetoothDebugFlag) { \
__android_log_print(ANDROID_LOG_INFO, "GeckoBluetooth", args); \
__android_log_print(ANDROID_LOG_INFO, "GeckoBluetooth", \
"%s: " msg, __FUNCTION__, ##__VA_ARGS__); \
} \
} while(0)
/**
* Prints 'R'ELEASE build logs, which show in both RELEASE and DEBUG builds.
*/
#define BT_LOGR(args...) \
__android_log_print(ANDROID_LOG_INFO, "GeckoBluetooth", args) \
#define BT_LOGR(msg, ...) \
__android_log_print(ANDROID_LOG_INFO, "GeckoBluetooth", \
"%s: " msg, __FUNCTION__, ##__VA_ARGS__) \
/**
* Prints DEBUG build warnings, which show in DEBUG build only.
@ -43,15 +46,15 @@ extern bool gBluetoothDebugFlag;
NS_WARNING(nsPrintfCString(args).get()) \
#else
#define BT_LOGD(args, ...) \
#define BT_LOGD(msg, ...) \
do { \
if (gBluetoothDebugFlag) { \
printf(args, ##__VA_ARGS__); \
printf("%s: " msg, __FUNCTION__, ##__VA_ARGS__); \
} \
} while(0)
#define BT_LOGR(args, ...) printf(args, ##__VA_ARGS__)
#define BT_WARNING(args, ...) printf(args, ##__VA_ARGS__)
#define BT_LOGR(msg, ...) printf("%s: " msg, __FUNCTION__, ##__VA_ARGS__))
#define BT_WARNING(msg, ...) printf("%s: " msg, __FUNCTION__, ##__VA_ARGS__))
#endif
#define BEGIN_BLUETOOTH_NAMESPACE \

View File

@ -16,12 +16,11 @@
USING_BLUETOOTH_NAMESPACE
#define BT_LOGR_PROFILE(mgr, args...) \
do { \
nsCString name; \
mgr->GetName(name); \
BT_LOGR("%s: [%s] %s", __FUNCTION__, name.get(), \
nsPrintfCString(args).get()); \
#define BT_LOGR_PROFILE(mgr, msg, ...) \
do { \
nsCString name; \
mgr->GetName(name); \
BT_LOGR("[%s] " msg, name.get(), ##__VA_ARGS__); \
} while(0)
BluetoothProfileController::BluetoothProfileController(

View File

@ -379,8 +379,7 @@ BluetoothRilListener::ServiceChanged(uint32_t aClientId, bool aRegistered)
// Restart listening
ListenMobileConnAndIccInfo(true);
BT_LOGR("%s: %d client %d. new mClientId %d",
__FUNCTION__, aRegistered, aClientId,
BT_LOGR("%d client %d. new mClientId %d", aRegistered, aClientId,
(mClientId < mMobileConnListeners.Length()) ? mClientId : -1);
}

View File

@ -71,6 +71,7 @@ namespace {
enum MainThreadTaskCmd {
NOTIFY_CONN_STATE_CHANGED,
NOTIFY_DIALER,
NOTIFY_SCO_VOLUME_CHANGED,
POST_TASK_RESPOND_TO_BLDN,
POST_TASK_CLOSE_SCO
};
@ -276,6 +277,16 @@ public:
case MainThreadTaskCmd::NOTIFY_DIALER:
sBluetoothHfpManager->NotifyDialer(mParameter);
break;
case MainThreadTaskCmd::NOTIFY_SCO_VOLUME_CHANGED:
{
nsCOMPtr<nsIObserverService> os =
mozilla::services::GetObserverService();
NS_ENSURE_TRUE(os, NS_OK);
os->NotifyObservers(nullptr, "bluetooth-volume-change",
mParameter.get());
}
break;
case MainThreadTaskCmd::POST_TASK_RESPOND_TO_BLDN:
MessageLoop::current()->
PostDelayedTask(FROM_HERE, new RespondToBLDNTask(),
@ -507,7 +518,7 @@ void
BluetoothHfpManager::ProcessConnectionState(bthf_connection_state_t aState,
bt_bdaddr_t* aBdAddress)
{
BT_LOGR("%s: state %d", __FUNCTION__, aState);
BT_LOGR("state %d", aState);
mConnectionState = aState;
@ -526,7 +537,7 @@ void
BluetoothHfpManager::ProcessAudioState(bthf_audio_state_t aState,
bt_bdaddr_t* aBdAddress)
{
BT_LOGR("%s: state %d", __FUNCTION__, aState);
BT_LOGR("state %d", aState);
mAudioState = aState;
@ -552,7 +563,8 @@ BluetoothHfpManager::ProcessHangupCall()
}
void
BluetoothHfpManager::ProcessVolumeControl(bthf_volume_type_t aType, int aVolume)
BluetoothHfpManager::ProcessVolumeControl(bthf_volume_type_t aType,
int aVolume)
{
NS_ENSURE_TRUE_VOID(aVolume >= 0 && aVolume <= 15);
@ -564,9 +576,8 @@ BluetoothHfpManager::ProcessVolumeControl(bthf_volume_type_t aType, int aVolume)
NS_ENSURE_TRUE_VOID(aVolume != mCurrentVgs);
nsString data;
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
data.AppendInt(aVolume);
os->NotifyObservers(nullptr, "bluetooth-volume-change", data.get());
BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::NOTIFY_SCO_VOLUME_CHANGED, data);
}
}
@ -691,7 +702,7 @@ BluetoothHfpManager::ProcessAtClcc()
void
BluetoothHfpManager::ProcessUnknownAt(char *aAtString)
{
BT_LOGR("%s: [%s]", __FUNCTION__, aAtString);
BT_LOGR("[%s]", aAtString);
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
NS_ENSURE_TRUE_VOID(BT_STATUS_SUCCESS ==
@ -956,8 +967,8 @@ BluetoothHfpManager::UpdatePhoneCIND(uint32_t aCallIndex, bool aSend)
nsAutoCString number = NS_ConvertUTF16toUTF8(mCurrentCallArray[aCallIndex].mNumber);
bthf_call_addrtype_t type = mCurrentCallArray[aCallIndex].mType;
BT_LOGR("%s: [%d] state %d => BTHF: active[%d] held[%d] state[%d]",
__FUNCTION__, aCallIndex, callState, numActive, numHeld, bthfCallState);
BT_LOGR("[%d] state %d => BTHF: active[%d] held[%d] state[%d]",
aCallIndex, callState, numActive, numHeld, bthfCallState);
NS_ENSURE_TRUE_VOID(BT_STATUS_SUCCESS ==
sBluetoothHfpInterface->phone_state_change(
@ -1068,7 +1079,6 @@ BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex,
mDialingRequestProcessed = true;
}
break;
case nsITelephonyProvider::CALL_STATE_DISCONNECTED:
// -1 is necessary because call 0 is an invalid (padding) call object.
if (mCurrentCallArray.Length() - 1 ==
@ -1084,7 +1094,6 @@ BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex,
ResetCallArray();
}
break;
default:
break;
}

View File

@ -383,7 +383,7 @@ BluetoothOppManager::DiscardBlobsToSend()
while (length > mCurrentBlobIndex + 1) {
mBlob = mBatches[0].mBlobs[++mCurrentBlobIndex];
BT_LOGR("%s: idx %d", __FUNCTION__, mCurrentBlobIndex);
BT_LOGR("idx %d", mCurrentBlobIndex);
ExtractBlobHeaders();
StartFileTransfer();
FileTransferComplete();
@ -400,7 +400,7 @@ BluetoothOppManager::ProcessNextBatch()
if (mCurrentBlobIndex >= 0) {
ClearQueue();
mBatches.RemoveElementAt(0);
BT_LOGR("%s: REMOVE. %d remaining", __FUNCTION__, mBatches.Length());
BT_LOGR("REMOVE. %d remaining", mBatches.Length());
}
// Process the next batch
@ -758,7 +758,7 @@ BluetoothOppManager::ComposePacket(uint8_t aOpCode, UnixSocketRawData* aMessage)
// Check length before memcpy to prevent from memory pollution
if (dataLength < 0 ||
mPacketReceivedLength + dataLength > mPacketLength) {
BT_LOGR("%s: Received packet size is unreasonable", __FUNCTION__);
BT_LOGR("Received packet size is unreasonable");
ReplyToPut(mPutFinalFlag, false);
DeleteReceivedFile();
@ -1376,7 +1376,7 @@ BluetoothOppManager::NotifyAboutFileChange()
void
BluetoothOppManager::OnSocketConnectSuccess(BluetoothSocket* aSocket)
{
BT_LOGR("%s: [%s]", __FUNCTION__, (mIsServer)? "server" : "client");
BT_LOGR("[%s]", (mIsServer)? "server" : "client");
MOZ_ASSERT(aSocket);
/**
@ -1403,7 +1403,7 @@ BluetoothOppManager::OnSocketConnectSuccess(BluetoothSocket* aSocket)
void
BluetoothOppManager::OnSocketConnectError(BluetoothSocket* aSocket)
{
BT_LOGR("%s: [%s]", __FUNCTION__, (mIsServer)? "server" : "client");
BT_LOGR("[%s]", (mIsServer)? "server" : "client");
mServerSocket = nullptr;
mSocket = nullptr;
@ -1427,7 +1427,7 @@ BluetoothOppManager::OnSocketDisconnect(BluetoothSocket* aSocket)
// Do nothing when a listening server socket is closed.
return;
}
BT_LOGR("%s: [%s]", __FUNCTION__, (mIsServer) ? "client" : "server");
BT_LOGR("[%s]", (mIsServer) ? "client" : "server");
/**
* It is valid for a bluetooth device which is transfering file via OPP

View File

@ -669,7 +669,7 @@ BluetoothSocket::ReceiveSocketInfo(nsAutoPtr<UnixSocketRawData>& aMessage)
// 1st message: [channel:4]
int32_t channel = ReadInt32(aMessage->mData, &offset);
BT_LOGR("%s: channel %d", __FUNCTION__, channel);
BT_LOGR("channel %d", channel);
} else if (mReceivedSocketInfoLength == TOTAL_SOCKET_INFO_LENGTH) {
// 2nd message: [size:2][bd address:6][channel:4][connection status:4]
int16_t size = ReadInt16(aMessage->mData, &offset);
@ -677,7 +677,7 @@ BluetoothSocket::ReceiveSocketInfo(nsAutoPtr<UnixSocketRawData>& aMessage)
int32_t channel = ReadInt32(aMessage->mData, &offset);
int32_t connectionStatus = ReadInt32(aMessage->mData, &offset);
BT_LOGR("%s: size %d channel %d remote addr %s status %d", __FUNCTION__,
BT_LOGR("size %d channel %d remote addr %s status %d",
size, channel, NS_ConvertUTF16toUTF8(mDeviceAddress).get(), connectionStatus);
if (connectionStatus != 0) {

View File

@ -105,7 +105,7 @@ public:
int ret = sBtInterface->set_adapter_property(&prop);
if (ret != BT_STATUS_SUCCESS) {
BT_LOGR("%s: Fail to set: BT_SCAN_MODE_CONNECTABLE", __FUNCTION__);
BT_LOGR("Fail to set: BT_SCAN_MODE_CONNECTABLE");
}
// Try to fire event 'AdapterAdded' to fit the original behaviour when
@ -119,7 +119,7 @@ public:
// Trigger BluetoothOppManager to listen
BluetoothOppManager* opp = BluetoothOppManager::Get();
if (!opp || !opp->Listen()) {
BT_LOGR("%s: Fail to start BluetoothOppManager listening", __FUNCTION__);
BT_LOGR("Fail to start BluetoothOppManager listening");
}
return NS_OK;
@ -272,7 +272,7 @@ AdapterStateChangeCallback(bt_state_t aStatus)
{
MOZ_ASSERT(!NS_IsMainThread());
BT_LOGR("%s, BT_STATE:%d", __FUNCTION__, aStatus);
BT_LOGR("BT_STATE %d", aStatus);
sIsBtEnabled = (aStatus == BT_STATE_ON);
@ -673,7 +673,7 @@ EnsureBluetoothHalLoad()
hw_device_t* device;
int err = hw_get_module(BT_HARDWARE_MODULE_ID, (hw_module_t const**)&module);
if (err != 0) {
BT_LOGR("Error: %s ", strerror(err));
BT_LOGR("Error: %s", strerror(err));
return false;
}
module->methods->open(module, BT_HARDWARE_MODULE_ID, &device);
@ -682,7 +682,7 @@ EnsureBluetoothHalLoad()
int ret = sBtInterface->init(&sBluetoothCallbacks);
if (ret != BT_STATUS_SUCCESS) {
BT_LOGR("Error while setting the callbacks %s", __FUNCTION__);
BT_LOGR("Error while setting the callbacks");
sBtInterface = nullptr;
}
@ -712,7 +712,7 @@ ReplyStatusError(BluetoothReplyRunnable* aBluetoothReplyRunnable,
{
MOZ_ASSERT(aBluetoothReplyRunnable, "Reply runnable is nullptr");
BT_LOGR("%s: error code(%d)", __FUNCTION__, aStatusCode);
BT_LOGR("error code(%d)", aStatusCode);
nsAutoString replyError;
replyError.Assign(aCustomMsg);
@ -743,7 +743,7 @@ BluetoothServiceBluedroid::BluetoothServiceBluedroid()
sToggleBtMonitor = new Monitor("BluetoothService.sToggleBtMonitor");
if (!EnsureBluetoothHalLoad()) {
BT_LOGR("Error! Failed to load bluedroid library.\n");
BT_LOGR("Error! Failed to load bluedroid library.");
return;
}
@ -765,7 +765,7 @@ BluetoothServiceBluedroid::StartInternal()
nsresult ret = StartStopGonkBluetooth(true);
if (NS_FAILED(ret)) {
BT_LOGR("Error: %s", __FUNCTION__);
BT_LOGR("Error");
}
return ret;
@ -778,7 +778,7 @@ BluetoothServiceBluedroid::StopInternal()
nsresult ret = StartStopGonkBluetooth(false);
if (NS_FAILED(ret)) {
BT_LOGR("Error: %s", __FUNCTION__);
BT_LOGR("Error");
}
return ret;
@ -1361,19 +1361,46 @@ BluetoothServiceBluedroid::ConfirmReceivingFile(
void
BluetoothServiceBluedroid::ConnectSco(BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
if (!hfp || !hfp->ConnectSco()) {
NS_NAMED_LITERAL_STRING(replyError, "Calling ConnectSco() failed");
DispatchBluetoothReply(aRunnable, BluetoothValue(), replyError);
return;
}
DispatchBluetoothReply(aRunnable, BluetoothValue(true), EmptyString());
}
void
BluetoothServiceBluedroid::DisconnectSco(BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
if (!hfp || !hfp->DisconnectSco()) {
NS_NAMED_LITERAL_STRING(replyError, "Calling DisconnectSco() failed");
DispatchBluetoothReply(aRunnable, BluetoothValue(), replyError);
return;
}
DispatchBluetoothReply(aRunnable, BluetoothValue(true), EmptyString());
}
void
BluetoothServiceBluedroid::IsScoConnected(BluetoothReplyRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
if (!hfp) {
NS_NAMED_LITERAL_STRING(replyError, "Fail to get BluetoothHfpManager");
DispatchBluetoothReply(aRunnable, BluetoothValue(), replyError);
return;
}
DispatchBluetoothReply(aRunnable, hfp->IsScoConnected(), EmptyString());
}
void

View File

@ -820,7 +820,11 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket,
goto respond_with_ok;
}
NS_ASSERTION(vgm >= 0 && vgm <= 15, "Received invalid VGM value");
if (vgm < 0 || vgm > 15) {
BT_WARNING("Received invalid VGM value");
goto respond_with_ok;
}
mCurrentVgm = vgm;
#ifdef MOZ_B2G_RIL
} else if (msg.Find("AT+CHLD=?") != -1) {
@ -895,10 +899,18 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket,
goto respond_with_ok;
}
NS_ASSERTION(newVgs >= 0 && newVgs <= 15, "Received invalid VGS value");
if (newVgs < 0 || newVgs > 15) {
BT_WARNING("Received invalid VGS value");
goto respond_with_ok;
}
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (!os) {
BT_WARNING("Failed to get observer service!");
goto respond_with_ok;
}
nsString data;
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
data.AppendInt(newVgs);
os->NotifyObservers(nullptr, "bluetooth-volume-change", data.get());
#ifdef MOZ_B2G_RIL

View File

@ -399,7 +399,7 @@ BluetoothOppManager::DiscardBlobsToSend()
while (length > mCurrentBlobIndex + 1) {
mBlob = mBatches[0].mBlobs[++mCurrentBlobIndex];
BT_LOGR("%s: idx %d", __FUNCTION__, mCurrentBlobIndex);
BT_LOGR("idx %d", mCurrentBlobIndex);
ExtractBlobHeaders();
StartFileTransfer();
FileTransferComplete();
@ -416,7 +416,7 @@ BluetoothOppManager::ProcessNextBatch()
if (mCurrentBlobIndex >= 0) {
ClearQueue();
mBatches.RemoveElementAt(0);
BT_LOGR("%s: REMOVE. %d remaining", __FUNCTION__, mBatches.Length());
BT_LOGR("REMOVE. %d remaining", mBatches.Length());
}
// Process the next batch
@ -774,7 +774,7 @@ BluetoothOppManager::ComposePacket(uint8_t aOpCode, UnixSocketRawData* aMessage)
// Check length before memcpy to prevent from memory pollution
if (dataLength < 0 ||
mPacketReceivedLength + dataLength > mPacketLength) {
BT_LOGR("%s: Received packet size is unreasonable", __FUNCTION__);
BT_LOGR("Received packet size is unreasonable");
ReplyToPut(mPutFinalFlag, false);
DeleteReceivedFile();
@ -1392,7 +1392,7 @@ BluetoothOppManager::NotifyAboutFileChange()
void
BluetoothOppManager::OnSocketConnectSuccess(BluetoothSocket* aSocket)
{
BT_LOGR("%s: [%s]", __FUNCTION__, (mIsServer)? "server" : "client");
BT_LOGR("[%s]", (mIsServer)? "server" : "client");
MOZ_ASSERT(aSocket);
/**
@ -1428,7 +1428,7 @@ BluetoothOppManager::OnSocketConnectSuccess(BluetoothSocket* aSocket)
void
BluetoothOppManager::OnSocketConnectError(BluetoothSocket* aSocket)
{
BT_LOGR("%s: [%s]", __FUNCTION__, (mIsServer)? "server" : "client");
BT_LOGR("[%s]", (mIsServer)? "server" : "client");
mRfcommSocket = nullptr;
mL2capSocket = nullptr;
@ -1448,7 +1448,7 @@ BluetoothOppManager::OnSocketConnectError(BluetoothSocket* aSocket)
void
BluetoothOppManager::OnSocketDisconnect(BluetoothSocket* aSocket)
{
BT_LOGR("%s: [%s]", __FUNCTION__, (mIsServer)? "server" : "client");
BT_LOGR("[%s]", (mIsServer)? "server" : "client");
MOZ_ASSERT(aSocket);
if (aSocket != mSocket) {

View File

@ -46,6 +46,7 @@
#include "mozilla/NullPtr.h"
#include "mozilla/StaticMutex.h"
#include "mozilla/Util.h"
#if defined(MOZ_WIDGET_GONK)
#include "cutils/properties.h"
#endif
@ -171,13 +172,32 @@ static const char* sBluetoothDBusSignals[] =
* used by any other thread.
*/
static nsRefPtr<RawDBusConnection> gThreadConnection;
static nsDataHashtable<nsStringHashKey, DBusMessage* >* sPairingReqTable;
// Only A2DP and HID are authorized.
static nsTArray<uint32_t> sAuthorizedServiceClass;
// The object path of adpater which should be updated after switching Bluetooth.
static nsString sAdapterPath;
/**
* The adapter name may not be ready whenever event 'AdapterAdded' is received,
* so we'd like to wait for a bit.
*/
static bool sAdapterNameIsReady = false;
static int sWaitingForAdapterNameInterval = 1000; //unit: ms
// Keep the pairing requests.
static Atomic<int32_t> sIsPairing(0);
static nsDataHashtable<nsStringHashKey, DBusMessage* >* sPairingReqTable;
/**
* Disconnect all profiles before turning off Bluetooth. Please see Bug 891257
* for more details.
*/
static int sConnectedDeviceCount = 0;
static StaticAutoPtr<Monitor> sStopBluetoothMonitor;
// A quene for connect/disconnect request. See Bug 913372 for details.
static nsTArray<nsRefPtr<BluetoothProfileController> > sControllerArray;
typedef void (*UnpackFunc)(DBusMessage*, DBusError*, BluetoothValue&, nsAString&);
@ -335,22 +355,46 @@ private:
BluetoothSignal mSignal;
};
class TryFiringAdapterAddedTask : public nsRunnable
class TryFiringAdapterAddedTask : public Task
{
public:
NS_IMETHOD
Run()
void Run() MOZ_OVERRIDE
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
NS_ENSURE_TRUE_VOID(bs);
bs->AdapterAddedReceived();
bs->TryFiringAdapterAdded();
}
};
class TryFiringAdapterAddedRunnable : public nsRunnable
{
public:
TryFiringAdapterAddedRunnable(bool aDelay)
: mDelay(aDelay)
{ }
nsresult Run()
{
MOZ_ASSERT(NS_IsMainThread());
if (mDelay) {
MessageLoop::current()->
PostDelayedTask(FROM_HERE, new TryFiringAdapterAddedTask(),
sWaitingForAdapterNameInterval);
} else {
MessageLoop::current()->
PostTask(FROM_HERE, new TryFiringAdapterAddedTask());
}
return NS_OK;
}
private:
bool mDelay;
};
static bool
@ -727,7 +771,7 @@ GetProperty(DBusMessageIter aIter, Properties* aPropertyTypes,
// Notify BluetoothManager whenever adapter name is ready.
if (!propertyValue.get_nsString().IsEmpty()) {
sAdapterNameIsReady = true;
NS_DispatchToMainThread(new TryFiringAdapterAddedTask());
NS_DispatchToMainThread(new TryFiringAdapterAddedRunnable(false));
}
}
@ -1305,6 +1349,8 @@ public:
NS_IMETHOD Run()
{
MOZ_ASSERT(NS_IsMainThread());
static const dbus_uint32_t sServices[] = {
BluetoothServiceClass::HANDSFREE_AG,
BluetoothServiceClass::HEADSET_AG,
@ -1576,6 +1622,7 @@ EventFilter(DBusConnection* aConn, DBusMessage* aMsg, void* aData)
errorStr.AssignLiteral("Cannot parse manager path!");
} else {
v = NS_ConvertUTF8toUTF16(str);
NS_DispatchToMainThread(new TryFiringAdapterAddedRunnable(true));
NS_DispatchToMainThread(new PrepareAdapterRunnable(v.get_nsString()));
/**
@ -3024,10 +3071,8 @@ BluetoothDBusService::ConnectSco(BluetoothReplyRunnable* aRunnable)
MOZ_ASSERT(NS_IsMainThread());
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
NS_ENSURE_TRUE_VOID(hfp);
if (!hfp->ConnectSco(aRunnable)) {
NS_NAMED_LITERAL_STRING(replyError,
"SCO socket exists or HFP is not connected");
if (!hfp || !hfp->ConnectSco(aRunnable)) {
NS_NAMED_LITERAL_STRING(replyError, "Calling ConnectSco() failed");
DispatchBluetoothReply(aRunnable, BluetoothValue(), replyError);
}
}
@ -3038,16 +3083,13 @@ BluetoothDBusService::DisconnectSco(BluetoothReplyRunnable* aRunnable)
MOZ_ASSERT(NS_IsMainThread());
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
NS_ENSURE_TRUE_VOID(hfp);
if (hfp->DisconnectSco()) {
DispatchBluetoothReply(aRunnable,
BluetoothValue(true), NS_LITERAL_STRING(""));
if (!hfp || !hfp->DisconnectSco()) {
NS_NAMED_LITERAL_STRING(replyError, "Calling DisconnectSco() failed");
DispatchBluetoothReply(aRunnable, BluetoothValue(), replyError);
return;
}
NS_NAMED_LITERAL_STRING(replyError,
"SCO socket doesn't exist or HFP is not connected");
DispatchBluetoothReply(aRunnable, BluetoothValue(), replyError);
DispatchBluetoothReply(aRunnable, BluetoothValue(true), EmptyString());
}
void
@ -3056,9 +3098,13 @@ BluetoothDBusService::IsScoConnected(BluetoothReplyRunnable* aRunnable)
MOZ_ASSERT(NS_IsMainThread());
BluetoothHfpManager* hfp = BluetoothHfpManager::Get();
NS_ENSURE_TRUE_VOID(hfp);
DispatchBluetoothReply(aRunnable,
hfp->IsScoConnected(), EmptyString());
if (!hfp) {
NS_NAMED_LITERAL_STRING(replyError, "Fail to get BluetoothHfpManager");
DispatchBluetoothReply(aRunnable, BluetoothValue(), replyError);
return;
}
DispatchBluetoothReply(aRunnable, hfp->IsScoConnected(), EmptyString());
}
void

View File

@ -1410,12 +1410,13 @@ ContentChild::RecvFileSystemUpdate(const nsString& aFsName,
const int32_t& aState,
const int32_t& aMountGeneration,
const bool& aIsMediaPresent,
const bool& aIsSharing)
const bool& aIsSharing,
const bool& aIsFormatting)
{
#ifdef MOZ_WIDGET_GONK
nsRefPtr<nsVolume> volume = new nsVolume(aFsName, aVolumeName, aState,
aMountGeneration, aIsMediaPresent,
aIsSharing);
aIsSharing, aIsFormatting);
nsRefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton();
if (vs) {
@ -1429,6 +1430,7 @@ ContentChild::RecvFileSystemUpdate(const nsString& aFsName,
unused << aMountGeneration;
unused << aIsMediaPresent;
unused << aIsSharing;
unused << aIsFormatting;
#endif
return true;
}

View File

@ -227,7 +227,8 @@ public:
const int32_t& aState,
const int32_t& aMountGeneration,
const bool& aIsMediaPresent,
const bool& aIsSharing);
const bool& aIsSharing,
const bool& aIsFormatting);
virtual bool RecvNuwaFork() MOZ_OVERRIDE;

View File

@ -1865,6 +1865,7 @@ ContentParent::Observe(nsISupports* aSubject,
int32_t mountGeneration;
bool isMediaPresent;
bool isSharing;
bool isFormatting;
vol->GetName(volName);
vol->GetMountPoint(mountPoint);
@ -1872,10 +1873,11 @@ ContentParent::Observe(nsISupports* aSubject,
vol->GetMountGeneration(&mountGeneration);
vol->GetIsMediaPresent(&isMediaPresent);
vol->GetIsSharing(&isSharing);
vol->GetIsFormatting(&isFormatting);
unused << SendFileSystemUpdate(volName, mountPoint, state,
mountGeneration, isMediaPresent,
isSharing);
isSharing, isFormatting);
} else if (!strcmp(aTopic, "phone-state-changed")) {
nsString state(aData);
unused << SendNotifyPhoneStateChange(state);

View File

@ -309,7 +309,7 @@ child:
FileSystemUpdate(nsString fsName, nsString mountPoint, int32_t fsState,
int32_t mountGeneration, bool isMediaPresent,
bool isSharing);
bool isSharing, bool isFormatting);
// Ask the Nuwa process to create a new child process.
NuwaFork();

View File

@ -29,7 +29,8 @@ public:
// used to update the volume cache maintained in the child process.
nsVolume(const nsAString& aName, const nsAString& aMountPoint,
const int32_t& aState, const int32_t& aMountGeneration,
const bool& aIsMediaPresent, const bool& aIsSharing)
const bool& aIsMediaPresent, const bool& aIsSharing,
const bool& aIsFormatting)
: mName(aName),
mMountPoint(aMountPoint),
mState(aState),
@ -38,7 +39,7 @@ public:
mIsFake(false),
mIsMediaPresent(aIsMediaPresent),
mIsSharing(aIsSharing),
mIsFormatting(false)
mIsFormatting(aIsFormatting)
{
}

View File

@ -248,7 +248,8 @@ nsVolumeService::CreateOrGetVolumeByPath(const nsAString& aPath, nsIVolume** aRe
aPath, nsIVolume::STATE_MOUNTED,
-1 /* generation */,
true /* isMediaPresent*/,
false /* isSharing */);
false /* isSharing */,
false /* isFormatting */);
vol.forget(aResult);
return NS_OK;
}
@ -380,7 +381,8 @@ nsVolumeService::CreateFakeVolume(const nsAString& name, const nsAString& path)
nsRefPtr<nsVolume> vol = new nsVolume(name, path, nsIVolume::STATE_INIT,
-1 /* mountGeneration */,
true /* isMediaPresent */,
false /* isSharing */);
false /* isSharing */,
false /* isFormatting */);
vol->SetIsFake(true);
vol->LogState();
UpdateVolume(vol.get());