Merge b2g-inbound to m-c on a CLOSED TREE.
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 04 Dec 2013 17:34:18 -0500
changeset 158800 b17b26e6038a4988f9e5ee8f9720edd8003226a0
parent 158771 e8f983b8f5868c0a8cdf3620c17e28747efd260f (current diff)
parent 158799 5f24ae8e4caeaabd0194b95936215f994a188056 (diff)
child 158804 4b85621b0bbf43c655cb3a7801d3b726b48bfb5e
push id37085
push userryanvm@gmail.com
push dateWed, 04 Dec 2013 22:39:20 +0000
treeherdermozilla-inbound@1426ffa9caf2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge b2g-inbound to m-c on a CLOSED TREE.
dom/ipc/ContentChild.cpp
dom/ipc/ContentParent.cpp
--- a/b2g/config/gaia.json
+++ b/b2g/config/gaia.json
@@ -1,4 +1,4 @@
 {
-    "revision": "428cccdc7a3b4c40f40dda80b6031d26ac9d2d68", 
+    "revision": "adb7896ababd1ccb828e11b05909c0e9ca22594e", 
     "repo_path": "/integration/gaia-central"
 }
--- a/dom/bluetooth/BluetoothCommon.h
+++ b/dom/bluetooth/BluetoothCommon.h
@@ -14,49 +14,52 @@
 
 extern bool gBluetoothDebugFlag;
 
 #define SWITCH_BT_DEBUG(V) (gBluetoothDebugFlag = V)
 
 #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.
  */
 #define BT_WARNING(args...)                                          \
   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 \
   namespace mozilla { namespace dom { namespace bluetooth {
 #define END_BLUETOOTH_NAMESPACE \
   } /* namespace bluetooth */ } /* namespace dom */ } /* namespace mozilla */
 #define USING_BLUETOOTH_NAMESPACE \
   using namespace mozilla::dom::bluetooth;
--- a/dom/bluetooth/BluetoothProfileController.cpp
+++ b/dom/bluetooth/BluetoothProfileController.cpp
@@ -11,22 +11,21 @@
 #include "BluetoothHfpManager.h"
 #include "BluetoothHidManager.h"
 
 #include "BluetoothUtils.h"
 #include "mozilla/dom/bluetooth/BluetoothTypes.h"
 
 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(
                                    bool aConnect,
                                    const nsAString& aDeviceAddress,
                                    BluetoothReplyRunnable* aRunnable,
                                    BluetoothProfileControllerCallback aCallback,
                                    uint16_t aServiceUuid,
--- a/dom/bluetooth/BluetoothRilListener.cpp
+++ b/dom/bluetooth/BluetoothRilListener.cpp
@@ -374,18 +374,17 @@ BluetoothRilListener::ServiceChanged(uin
     mClientId = aClientId;
   } else {
     SelectClient();
   }
 
   // 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);
 }
 
 void
 BluetoothRilListener::EnumerateCalls()
 {
   nsCOMPtr<nsITelephonyProvider> provider =
     do_GetService(TELEPHONY_PROVIDER_CONTRACTID);
--- a/dom/bluetooth/bluedroid/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothHfpManager.cpp
@@ -66,16 +66,17 @@ namespace {
   // Dialer stops playing.
   static int sBusyToneInterval = 3700; //unit: ms
 } // anonymous namespace
 
 // Main thread task commands
 enum MainThreadTaskCmd {
   NOTIFY_CONN_STATE_CHANGED,
   NOTIFY_DIALER,
+  NOTIFY_SCO_VOLUME_CHANGED,
   POST_TASK_RESPOND_TO_BLDN,
   POST_TASK_CLOSE_SCO
 };
 
 static void
 ConnectionStateCallback(bthf_connection_state_t state, bt_bdaddr_t* bd_addr)
 {
   BT_HF_PROCESS_CB(ProcessConnectionState, state, bd_addr);
@@ -271,16 +272,26 @@ public:
 
     switch (mCommand) {
       case MainThreadTaskCmd::NOTIFY_CONN_STATE_CHANGED:
         sBluetoothHfpManager->NotifyConnectionStateChanged(mParameter);
         break;
       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(),
                           sWaitingForDialingInterval);
         break;
       case MainThreadTaskCmd::POST_TASK_CLOSE_SCO:
         MessageLoop::current()->
           PostDelayedTask(FROM_HERE, new CloseScoTask(),
@@ -502,17 +513,17 @@ BluetoothHfpManager::Notify(const hal::B
   mBattChg = (int) ceil(aBatteryInfo.level() * 5.0);
   UpdateDeviceCIND();
 }
 
 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;
 
   if (aState == BTHF_CONNECTION_STATE_CONNECTED) {
     BdAddressTypeToString(aBdAddress, mDeviceAddress);
     BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::NOTIFY_CONN_STATE_CHANGED,
                         NS_LITERAL_STRING(BLUETOOTH_HFP_STATUS_CHANGED_ID));
   } else if (aState == BTHF_CONNECTION_STATE_DISCONNECTED) {
@@ -521,17 +532,17 @@ BluetoothHfpManager::ProcessConnectionSt
                         NS_LITERAL_STRING(BLUETOOTH_HFP_STATUS_CHANGED_ID));
   }
 }
 
 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;
 
   if (aState == BTHF_AUDIO_STATE_CONNECTED ||
       aState == BTHF_AUDIO_STATE_DISCONNECTED) {
     BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::NOTIFY_CONN_STATE_CHANGED,
                         NS_LITERAL_STRING(BLUETOOTH_SCO_STATUS_CHANGED_ID));
   }
@@ -547,31 +558,31 @@ BluetoothHfpManager::ProcessAnswerCall()
 void
 BluetoothHfpManager::ProcessHangupCall()
 {
   BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::NOTIFY_DIALER,
                       NS_LITERAL_STRING("CHUP"));
 }
 
 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);
 
   if (aType == BTHF_VOLUME_TYPE_MIC) {
     mCurrentVgm = aVolume;
   } else if (aType == BTHF_VOLUME_TYPE_SPK) {
     // Adjust volume by headset
     mReceiveVgsFlag = true;
     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);
   }
 }
 
 void
 BluetoothHfpManager::ProcessDtmfCmd(char aDtmf)
 {
   NS_ENSURE_TRUE_VOID(IsValidDtmf(aDtmf));
 
@@ -686,17 +697,17 @@ BluetoothHfpManager::ProcessAtClcc()
 
     SendCLCC(mCdmaSecondCall, 2);
   }
 }
 
 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 ==
     sBluetoothHfpInterface->at_response(BTHF_AT_RESPONSE_ERROR, 0));
 }
 
 void
 BluetoothHfpManager::NotifyConnectionStateChanged(const nsAString& aType)
@@ -951,18 +962,18 @@ BluetoothHfpManager::UpdatePhoneCIND(uin
   NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
 
   int numActive = GetNumberOfCalls(nsITelephonyProvider::CALL_STATE_CONNECTED);
   int numHeld = GetNumberOfCalls(nsITelephonyProvider::CALL_STATE_HELD);
   bthf_call_state_t bthfCallState = ConvertToBthfCallState(mCallSetupState);
   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(
       numActive, numHeld, bthfCallState, number.get(), type));
 }
 
 void
 BluetoothHfpManager::UpdateDeviceCIND()
@@ -1063,33 +1074,31 @@ BluetoothHfpManager::HandleCallStateChan
   switch (aCallState) {
     case nsITelephonyProvider::CALL_STATE_DIALING:
       // We've send Dialer a dialing request and this is the response.
       if (!mDialingRequestProcessed) {
         SendResponse(BTHF_AT_RESPONSE_OK);
         mDialingRequestProcessed = true;
       }
       break;
-
     case nsITelephonyProvider::CALL_STATE_DISCONNECTED:
       // -1 is necessary because call 0 is an invalid (padding) call object.
       if (mCurrentCallArray.Length() - 1 ==
           GetNumberOfCalls(nsITelephonyProvider::CALL_STATE_DISCONNECTED)) {
         // In order to let user hear busy tone via connected Bluetooth headset,
         // we postpone the timing of dropping SCO.
         if (aError.Equals(NS_LITERAL_STRING("BusyError"))) {
           // FIXME: UpdatePhoneCIND later since it causes SCO close but
           // Dialer is still playing busy tone via HF.
           BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::POST_TASK_CLOSE_SCO);
         }
 
         ResetCallArray();
       }
       break;
-
     default:
       break;
   }
 }
 
 PhoneType
 BluetoothHfpManager::GetPhoneType(const nsAString& aType)
 {
--- a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp
@@ -378,34 +378,34 @@ BluetoothOppManager::DiscardBlobsToSend(
 
   MOZ_ASSERT(!mBatches.IsEmpty());
   MOZ_ASSERT(!mIsServer);
 
   int length = (int) mBatches[0].mBlobs.Length();
   while (length > mCurrentBlobIndex + 1) {
     mBlob = mBatches[0].mBlobs[++mCurrentBlobIndex];
 
-    BT_LOGR("%s: idx %d", __FUNCTION__, mCurrentBlobIndex);
+    BT_LOGR("idx %d", mCurrentBlobIndex);
     ExtractBlobHeaders();
     StartFileTransfer();
     FileTransferComplete();
   }
 }
 
 bool
 BluetoothOppManager::ProcessNextBatch()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // Remove the processed batch.
   // A batch is processed if we've incremented mCurrentBlobIndex for it.
   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
   if (!mBatches.IsEmpty()) {
     ConnectInternal(mBatches[0].mDeviceAddress);
     return true;
   }
 
@@ -753,17 +753,17 @@ BluetoothOppManager::ComposePacket(uint8
     mPutFinalFlag = (aOpCode == ObexRequestCode::PutFinal);
   }
 
   int dataLength = aMessage->mSize - frameHeaderLength;
 
   // 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();
     FileTransferComplete();
 
     return false;
   }
 
@@ -1371,17 +1371,17 @@ BluetoothOppManager::NotifyAboutFileChan
   NS_ENSURE_TRUE_VOID(obs);
 
   obs->NotifyObservers(mDsFile, "file-watcher-notify", data.get());
 }
 
 void
 BluetoothOppManager::OnSocketConnectSuccess(BluetoothSocket* aSocket)
 {
-  BT_LOGR("%s: [%s]", __FUNCTION__, (mIsServer)? "server" : "client");
+  BT_LOGR("[%s]", (mIsServer)? "server" : "client");
   MOZ_ASSERT(aSocket);
 
   /**
    * If the created connection is an inbound connection, close server socket
    * because currently only one file-transfer session is allowed. After that,
    * we need to make sure that server socket would be nulled out.
    * As for outbound connections, we just notify the controller that it's done.
    */
@@ -1398,17 +1398,17 @@ BluetoothOppManager::OnSocketConnectSucc
   if (!mIsServer) {
     StartSendingNextFile();
   }
 }
 
 void
 BluetoothOppManager::OnSocketConnectError(BluetoothSocket* aSocket)
 {
-  BT_LOGR("%s: [%s]", __FUNCTION__, (mIsServer)? "server" : "client");
+  BT_LOGR("[%s]", (mIsServer)? "server" : "client");
 
   mServerSocket = nullptr;
   mSocket = nullptr;
 
   if (!mIsServer) {
     // Inform gaia of remaining blobs' sending failure
     DiscardBlobsToSend();
   }
@@ -1422,17 +1422,17 @@ BluetoothOppManager::OnSocketConnectErro
 void
 BluetoothOppManager::OnSocketDisconnect(BluetoothSocket* aSocket)
 {
   MOZ_ASSERT(aSocket);
   if (aSocket != mSocket) {
     // 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
    * closing socket without sending OBEX disconnect request first. So we
    * delete the broken file when we failed to receive a file from the remote,
    * and notify the transfer has been completed (but failed). We also call
    * AfterOppDisconnected here to ensure all variables will be cleaned.
    */
--- a/dom/bluetooth/bluedroid/BluetoothSocket.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothSocket.cpp
@@ -664,25 +664,25 @@ BluetoothSocket::ReceiveSocketInfo(nsAut
   }
   mReceivedSocketInfoLength += aMessage->mSize;
 
   size_t offset = 0;
   if (mReceivedSocketInfoLength == FIRST_SOCKET_INFO_MSG_LENGTH) {
     // 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);
     ReadBdAddress(aMessage->mData, &offset, mDeviceAddress);
     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) {
       OnConnectError();
       return true;
     }
 
     if (mIsServer) {
--- a/dom/bluetooth/bluedroid/gonk/BluetoothServiceBluedroid.cpp
+++ b/dom/bluetooth/bluedroid/gonk/BluetoothServiceBluedroid.cpp
@@ -100,31 +100,31 @@ public:
     prop.type = BT_PROPERTY_ADAPTER_SCAN_MODE;
     prop.val = (void*)&mode;
     prop.len = sizeof(mode);
 
     NS_ENSURE_TRUE(sBtInterface, NS_ERROR_FAILURE);
 
     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
     // we used BlueZ as backend.
     BluetoothService* bs = BluetoothService::Get();
     NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
 
     bs->AdapterAddedReceived();
     bs->TryFiringAdapterAdded();
 
     // 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;
   }
 };
 
 /**
  *  Static callback functions
@@ -267,17 +267,17 @@ BdAddressTypeToString(bt_bdaddr_t* aBdAd
   aRetBdAddress = NS_ConvertUTF8toUTF16((char*)bdstr);
 }
 
 static void
 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);
 
   {
     MonitorAutoLock lock(*sToggleBtMonitor);
     lock.Notify();
   }
 
@@ -668,26 +668,26 @@ bt_callbacks_t sBluetoothCallbacks =
  */
 static bool
 EnsureBluetoothHalLoad()
 {
   hw_module_t* module;
   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);
   sBtDevice = (bluetooth_device_t *)device;
   sBtInterface = sBtDevice->get_bluetooth_interface();
 
   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;
   }
 
   return true;
 }
 
 static nsresult
 StartStopGonkBluetooth(bool aShouldEnable)
@@ -707,17 +707,17 @@ StartStopGonkBluetooth(bool aShouldEnabl
 }
 
 static void
 ReplyStatusError(BluetoothReplyRunnable* aBluetoothReplyRunnable,
                  int aStatusCode, const nsAString& aCustomMsg)
 {
   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);
 
   if (aStatusCode == BT_STATUS_BUSY) {
     replyError.AppendLiteral(":BT_STATUS_BUSY");
   } else if (aStatusCode == BT_STATUS_NOT_READY) {
     replyError.AppendLiteral(":BT_STATUS_NOT_READY");
@@ -738,17 +738,17 @@ ReplyStatusError(BluetoothReplyRunnable*
 /**
  *  Member functions
  */
 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;
   }
 
   // Register all the bluedroid callbacks before enable() get called
   // It is required to register a2dp callbacks before a2dp media task starts up.
   BluetoothHfpManager::Get();
   BluetoothA2dpManager::Get();
 }
@@ -760,30 +760,30 @@ BluetoothServiceBluedroid::~BluetoothSer
 
 nsresult
 BluetoothServiceBluedroid::StartInternal()
 {
   MOZ_ASSERT(!NS_IsMainThread());
 
   nsresult ret = StartStopGonkBluetooth(true);
   if (NS_FAILED(ret)) {
-    BT_LOGR("Error: %s", __FUNCTION__);
+    BT_LOGR("Error");
   }
 
   return ret;
 }
 
 nsresult
 BluetoothServiceBluedroid::StopInternal()
 {
   MOZ_ASSERT(!NS_IsMainThread());
 
   nsresult ret = StartStopGonkBluetooth(false);
   if (NS_FAILED(ret)) {
-    BT_LOGR("Error: %s", __FUNCTION__);
+    BT_LOGR("Error");
   }
 
   return ret;
 }
 
 bool
 BluetoothServiceBluedroid::IsEnabledInternal()
 {
@@ -1356,29 +1356,56 @@ BluetoothServiceBluedroid::ConfirmReceiv
   }
 
   DispatchBluetoothReply(aRunnable, BluetoothValue(true), errorStr);
 }
 
 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
 BluetoothServiceBluedroid::SendMetaData(const nsAString& aTitle,
                                         const nsAString& aArtist,
                                         const nsAString& aAlbum,
                                         int64_t aMediaNumber,
                                         int64_t aTotalMediaCount,
--- a/dom/bluetooth/bluez/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluez/BluetoothHfpManager.cpp
@@ -815,17 +815,21 @@ BluetoothHfpManager::ReceiveSocketData(B
 
     nsresult rv;
     int vgm = atCommandValues[0].ToInteger(&rv);
     if (NS_FAILED(rv)) {
       BT_WARNING("Failed to extract microphone volume from bluetooth headset!");
       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) {
     SendLine("+CHLD: (0,1,2)");
   } else if (msg.Find("AT+CHLD=") != -1) {
     ParseAtCommand(msg, 8, atCommandValues);
 
     if (atCommandValues.IsEmpty()) {
@@ -890,20 +894,28 @@ BluetoothHfpManager::ReceiveSocketData(B
       BT_WARNING("Failed to extract volume value from bluetooth headset!");
       goto respond_with_ok;
     }
 
     if (newVgs == mCurrentVgs) {
       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
   } else if ((msg.Find("AT+BLDN") != -1) || (msg.Find("ATD>") != -1)) {
     // Dialer app of FFOS v1 does not have plan to support Memory Dailing.
     // However, in order to pass Bluetooth HFP certification, we still have to
     // make a call when we receive AT command 'ATD>n'.
     mDialingRequestProcessed = false;
--- a/dom/bluetooth/bluez/BluetoothOppManager.cpp
+++ b/dom/bluetooth/bluez/BluetoothOppManager.cpp
@@ -394,34 +394,34 @@ BluetoothOppManager::DiscardBlobsToSend(
 
   MOZ_ASSERT(!mBatches.IsEmpty());
   MOZ_ASSERT(!mIsServer);
 
   int length = (int) mBatches[0].mBlobs.Length();
   while (length > mCurrentBlobIndex + 1) {
     mBlob = mBatches[0].mBlobs[++mCurrentBlobIndex];
 
-    BT_LOGR("%s: idx %d", __FUNCTION__, mCurrentBlobIndex);
+    BT_LOGR("idx %d", mCurrentBlobIndex);
     ExtractBlobHeaders();
     StartFileTransfer();
     FileTransferComplete();
   }
 }
 
 bool
 BluetoothOppManager::ProcessNextBatch()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // Remove the processed batch.
   // A batch is processed if we've incremented mCurrentBlobIndex for it.
   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
   if (!mBatches.IsEmpty()) {
     ConnectInternal(mBatches[0].mDeviceAddress);
     return true;
   }
 
@@ -769,17 +769,17 @@ BluetoothOppManager::ComposePacket(uint8
     mPutFinalFlag = (aOpCode == ObexRequestCode::PutFinal);
   }
 
   int dataLength = aMessage->mSize - frameHeaderLength;
 
   // 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();
     FileTransferComplete();
 
     return false;
   }
 
@@ -1387,17 +1387,17 @@ BluetoothOppManager::NotifyAboutFileChan
   NS_ENSURE_TRUE_VOID(obs);
 
   obs->NotifyObservers(mDsFile, "file-watcher-notify", data.get());
 }
 
 void
 BluetoothOppManager::OnSocketConnectSuccess(BluetoothSocket* aSocket)
 {
-  BT_LOGR("%s: [%s]", __FUNCTION__, (mIsServer)? "server" : "client");
+  BT_LOGR("[%s]", (mIsServer)? "server" : "client");
   MOZ_ASSERT(aSocket);
 
   /**
    * If the created connection is an inbound connection, close another server
    * socket because currently only one file-transfer session is allowed. After
    * that, we need to make sure that both server socket would be nulled out.
    * As for outbound connections, we just notify the controller that it's done.
    */
@@ -1423,17 +1423,17 @@ BluetoothOppManager::OnSocketConnectSucc
   if (!mIsServer) {
     StartSendingNextFile();
   }
 }
 
 void
 BluetoothOppManager::OnSocketConnectError(BluetoothSocket* aSocket)
 {
-  BT_LOGR("%s: [%s]", __FUNCTION__, (mIsServer)? "server" : "client");
+  BT_LOGR("[%s]", (mIsServer)? "server" : "client");
 
   mRfcommSocket = nullptr;
   mL2capSocket = nullptr;
   mSocket = nullptr;
 
   if (!mIsServer) {
     // Inform gaia of remaining blobs' sending failure
     DiscardBlobsToSend();
@@ -1443,17 +1443,17 @@ BluetoothOppManager::OnSocketConnectErro
   if (!ProcessNextBatch()) {
     Listen();
   }
 }
 
 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) {
     // Do nothing when a listening server socket is closed.
     return;
   }
 
   /**
--- a/dom/bluetooth/bluez/linux/BluetoothDBusService.cpp
+++ b/dom/bluetooth/bluez/linux/BluetoothDBusService.cpp
@@ -41,16 +41,17 @@
 #include "mozilla/ipc/UnixSocket.h"
 #include "mozilla/ipc/DBusThread.h"
 #include "mozilla/ipc/DBusUtils.h"
 #include "mozilla/ipc/RawDBusConnection.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/NullPtr.h"
 #include "mozilla/StaticMutex.h"
 #include "mozilla/Util.h"
+
 #if defined(MOZ_WIDGET_GONK)
 #include "cutils/properties.h"
 #endif
 
 /**
  * Some rules for dealing with memory in DBus:
  * - A DBusError only needs to be deleted if it's been set, not just
  *   initialized. This is why LOG_AND_FREE... is called only when an error is
@@ -166,23 +167,42 @@ static const char* sBluetoothDBusSignals
   "type='signal',interface='org.bluez.Control'"
 };
 
 /**
  * DBus Connection held for the BluetoothCommandThread to use. Should never be
  * 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&);
 typedef bool (*FilterFunc)(const BluetoothValue&);
 
 BluetoothDBusService::BluetoothDBusService()
 {
   sStopBluetoothMonitor = new Monitor("BluetoothService.sStopBluetoothMonitor");
@@ -330,32 +350,56 @@ public:
     hid->HandleInputPropertyChanged(mSignal);
     return NS_OK;
   }
 
 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
 IsDBusMessageError(DBusMessage* aMsg, DBusError* aErr, nsAString& aErrorStr)
 {
   if (aErr && dbus_error_is_set(aErr)) {
     aErrorStr = NS_ConvertUTF8toUTF16(aErr->message);
     LOG_AND_FREE_DBUS_ERROR(aErr);
@@ -722,17 +766,17 @@ GetProperty(DBusMessageIter aIter, Prope
   } else if (!sAdapterNameIsReady &&
              aPropertyTypes == sAdapterProperties &&
              propertyName.EqualsLiteral("Name")) {
     MOZ_ASSERT(propertyValue.type() == BluetoothValue::TnsString);
 
     // Notify BluetoothManager whenever adapter name is ready.
     if (!propertyValue.get_nsString().IsEmpty()) {
       sAdapterNameIsReady = true;
-      NS_DispatchToMainThread(new TryFiringAdapterAddedTask());
+      NS_DispatchToMainThread(new TryFiringAdapterAddedRunnable(false));
     }
   }
 
   aProperties.AppendElement(BluetoothNamedValue(propertyName, propertyValue));
   return true;
 }
 
 static void
@@ -1300,16 +1344,18 @@ class PrepareAdapterRunnable : public ns
 {
 public:
   PrepareAdapterRunnable(const nsAString& aAdapterPath)
     : mAdapterPath(aAdapterPath)
   { }
 
   NS_IMETHOD Run()
   {
+    MOZ_ASSERT(NS_IsMainThread());
+
     static const dbus_uint32_t sServices[] = {
       BluetoothServiceClass::HANDSFREE_AG,
       BluetoothServiceClass::HEADSET_AG,
       BluetoothServiceClass::OBJECT_PUSH
     };
 
     MOZ_ASSERT(NS_IsMainThread());
 
@@ -1571,16 +1617,17 @@ EventFilter(DBusConnection* aConn, DBusM
     const char* str;
     if (!dbus_message_get_args(aMsg, &err,
                                DBUS_TYPE_OBJECT_PATH, &str,
                                DBUS_TYPE_INVALID)) {
       LOG_AND_FREE_DBUS_ERROR_WITH_MSG(&err, aMsg);
       errorStr.AssignLiteral("Cannot parse manager path!");
     } else {
       v = NS_ConvertUTF8toUTF16(str);
+      NS_DispatchToMainThread(new TryFiringAdapterAddedRunnable(true));
       NS_DispatchToMainThread(new PrepareAdapterRunnable(v.get_nsString()));
 
       /**
        * The adapter name isn't ready for the time being. Wait for the upcoming
        * signal PropertyChanged of adapter name, and then propagate signal
        * AdapterAdded to BluetoothManager.
        */
       return DBUS_HANDLER_RESULT_HANDLED;
@@ -3019,51 +3066,50 @@ BluetoothDBusService::ConfirmReceivingFi
 }
 
 void
 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);
   }
 }
 
 void
 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
 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
 BluetoothDBusService::SendMetaData(const nsAString& aTitle,
                                    const nsAString& aArtist,
                                    const nsAString& aAlbum,
                                    int64_t aMediaNumber,
                                    int64_t aTotalMediaCount,
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -1405,35 +1405,37 @@ ContentChild::RecvFilePathUpdate(const n
 }
 
 bool
 ContentChild::RecvFileSystemUpdate(const nsString& aFsName,
                                    const nsString& aVolumeName,
                                    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) {
         vs->UpdateVolume(volume);
     }
 #else
     // Remove warnings about unused arguments
     unused << aFsName;
     unused << aVolumeName;
     unused << aState;
     unused << aMountGeneration;
     unused << aIsMediaPresent;
     unused << aIsSharing;
+    unused << aIsFormatting;
 #endif
     return true;
 }
 
 bool
 ContentChild::RecvNotifyProcessPriorityChanged(
     const hal::ProcessPriority& aPriority)
 {
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -222,17 +222,18 @@ public:
                                     const nsString& aStorageName,
                                     const nsString& aPath,
                                     const nsCString& aReason);
     virtual bool RecvFileSystemUpdate(const nsString& aFsName,
                                       const nsString& aVolumeName,
                                       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;
 
     virtual bool RecvNotifyProcessPriorityChanged(const hal::ProcessPriority& aPriority);
     virtual bool RecvMinimizeMemoryUsage();
     virtual bool RecvCancelMinimizeMemoryUsage();
 
     virtual bool RecvLoadAndRegisterSheet(const URIParams& aURI, const uint32_t& aType);
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -1860,27 +1860,29 @@ ContentParent::Observe(nsISupports* aSub
         }
 
         nsString volName;
         nsString mountPoint;
         int32_t  state;
         int32_t  mountGeneration;
         bool     isMediaPresent;
         bool     isSharing;
+        bool     isFormatting;
 
         vol->GetName(volName);
         vol->GetMountPoint(mountPoint);
         vol->GetState(&state);
         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);
     }
 #endif
 #ifdef ACCESSIBILITY
     // Make sure accessibility is running in content process when accessibility
     // gets initiated in chrome process.
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -304,17 +304,17 @@ child:
     // Notify child that last-pb-context-exited notification was observed
     LastPrivateDocShellDestroyed();
 
     FilePathUpdate(nsString storageType, nsString storageName, nsString filepath,
                    nsCString reasons);
 
     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();
 
     NotifyProcessPriorityChanged(ProcessPriority priority);
     MinimizeMemoryUsage();
     CancelMinimizeMemoryUsage();
 
--- a/dom/system/gonk/nsVolume.h
+++ b/dom/system/gonk/nsVolume.h
@@ -24,26 +24,27 @@ public:
 
   // This constructor is used by the UpdateVolumeRunnable constructor
   nsVolume(const Volume* aVolume);
 
   // This constructor is used by ContentChild::RecvFileSystemUpdate which is
   // 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),
       mMountGeneration(aMountGeneration),
       mMountLocked(false),
       mIsFake(false),
       mIsMediaPresent(aIsMediaPresent),
       mIsSharing(aIsSharing),
-      mIsFormatting(false)
+      mIsFormatting(aIsFormatting)
   {
   }
 
   // This constructor is used by nsVolumeService::FindAddVolumeByName, and
   // will be followed shortly by a Set call.
   nsVolume(const nsAString& aName)
     : mName(aName),
       mState(STATE_INIT),
--- a/dom/system/gonk/nsVolumeService.cpp
+++ b/dom/system/gonk/nsVolumeService.cpp
@@ -243,17 +243,18 @@ nsVolumeService::CreateOrGetVolumeByPath
   }
 
   // In order to support queries by the updater, we will fabricate a volume
   // from the pathname, so that the caller can determine the volume size.
   nsCOMPtr<nsIVolume> vol = new nsVolume(NS_LITERAL_STRING("fake"),
                                          aPath, nsIVolume::STATE_MOUNTED,
                                          -1    /* generation */,
                                          true  /* isMediaPresent*/,
-                                         false /* isSharing */);
+                                         false /* isSharing */,
+                                         false /* isFormatting */);
   vol.forget(aResult);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsVolumeService::GetVolumeNames(nsTArray<nsString>& aVolNames)
 {
   MonitorAutoLock autoLock(mArrayMonitor);
@@ -375,17 +376,18 @@ nsVolumeService::UpdateVolume(nsIVolume*
 
 NS_IMETHODIMP
 nsVolumeService::CreateFakeVolume(const nsAString& name, const nsAString& path)
 {
   if (XRE_GetProcessType() == GeckoProcessType_Default) {
     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());
     return NS_OK;
   }
 
   ContentChild::GetSingleton()->SendCreateFakeVolume(nsString(name), nsString(path));
   return NS_OK;