Bug 956258 - [cleanup] Patch 2/2: reduce warnings and remove cancel_discovery() in SendFile(), r=echou
authorBen Tian <btian@mozilla.com>
Fri, 03 Jan 2014 17:25:04 +0800
changeset 162936 615964c59f003ec94f59120f52b538ffc21f78b6
parent 162935 1b22c75c10464d3ec68c2f4f81dd2337ad15d321
child 162937 f6deb65039b8e22815d31f17ff1d72ac3bbd937f
push id38342
push userryanvm@gmail.com
push dateFri, 10 Jan 2014 19:49:45 +0000
treeherdermozilla-inbound@18884bc50509 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechou
bugs956258
milestone29.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
Bug 956258 - [cleanup] Patch 2/2: reduce warnings and remove cancel_discovery() in SendFile(), r=echou
dom/bluetooth/bluedroid/BluetoothHfpManager.cpp
dom/bluetooth/bluedroid/BluetoothOppManager.h
dom/bluetooth/bluedroid/BluetoothSocket.cpp
dom/bluetooth/bluedroid/gonk/BluetoothServiceBluedroid.cpp
dom/bluetooth/bluez/BluetoothHfpManager.cpp
dom/bluetooth/bluez/BluetoothOppManager.h
--- a/dom/bluetooth/bluedroid/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothHfpManager.cpp
@@ -565,19 +565,22 @@ void
 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);
+
+    if (aVolume == mCurrentVgs) {
+      // Keep current volume
+      return;
+    }
 
     nsString data;
     data.AppendInt(aVolume);
     BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::NOTIFY_SCO_VOLUME_CHANGED, data);
   }
 }
 
 void
@@ -846,20 +849,17 @@ BluetoothHfpManager::HandleVoiceConnecti
   // Service
   nsString regState;
   voiceInfo->GetState(regState);
   mService = (regState.EqualsLiteral("registered")) ? 1 : 0;
 
   // Signal
   JS::Value value;
   voiceInfo->GetRelSignalStrength(&value);
-  if (!value.isNumber()) {
-    BT_WARNING("Failed to get relSignalStrength in BluetoothHfpManager");
-    return;
-  }
+  NS_ENSURE_TRUE_VOID(value.isNumber());
   mSignal = (int)ceil(value.toNumber() / 20.0);
 
   UpdateDeviceCIND();
 
   // Operator name
   nsCOMPtr<nsIDOMMozMobileNetworkInfo> network;
   voiceInfo->GetNetwork(getter_AddRefs(network));
   NS_ENSURE_TRUE_VOID(network);
--- a/dom/bluetooth/bluedroid/BluetoothOppManager.h
+++ b/dom/bluetooth/bluedroid/BluetoothOppManager.h
@@ -32,22 +32,16 @@ public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
   BT_DECL_PROFILE_MGR_BASE
   virtual void GetName(nsACString& aName)
   {
     aName.AssignLiteral("OPP");
   }
 
-  /*
-   * Channel of reserved services are fixed values, please check
-   * function add_reserved_service_records() in
-   * external/bluetooth/bluez/src/adapter.c for more information.
-   */
-  static const int DEFAULT_OPP_CHANNEL = 10;
   static const int MAX_PACKET_LENGTH = 0xFFFE;
 
   virtual ~BluetoothOppManager();
   static BluetoothOppManager* Get();
   void ClientDataHandler(mozilla::ipc::UnixSocketRawData* aMessage);
   void ServerDataHandler(mozilla::ipc::UnixSocketRawData* aMessage);
 
   bool Listen();
--- a/dom/bluetooth/bluedroid/BluetoothSocket.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothSocket.cpp
@@ -600,20 +600,22 @@ BluetoothSocket::Connect(const nsAString
   NS_ENSURE_TRUE(sBluetoothSocketInterface, false);
 
   bt_bdaddr_t remoteBdAddress;
   StringToBdAddressType(aDeviceAddress, &remoteBdAddress);
 
   // TODO: uuid as argument
   int fd;
   NS_ENSURE_TRUE(BT_STATUS_SUCCESS ==
-    sBluetoothSocketInterface->connect((bt_bdaddr_t *) &remoteBdAddress,
-                                       (btsock_type_t) BTSOCK_RFCOMM,
+    sBluetoothSocketInterface->connect(&remoteBdAddress,
+                                       BTSOCK_RFCOMM,
                                        UUID_OBEX_OBJECT_PUSH,
-                                       aChannel, &fd, (mAuth << 1) | mEncrypt),
+                                       aChannel,
+                                       &fd,
+                                       (mAuth << 1) | mEncrypt),
     false);
   NS_ENSURE_TRUE(fd >= 0, false);
 
   mIsServer = false;
   return CreateDroidSocket(fd);
 }
 
 bool
@@ -621,20 +623,22 @@ BluetoothSocket::Listen(int aChannel)
 {
   MOZ_ASSERT(NS_IsMainThread());
   NS_ENSURE_TRUE(sBluetoothSocketInterface, false);
 
   // TODO: uuid and service name as arguments
   nsAutoCString serviceName("OBEX Object Push");
   int fd;
   NS_ENSURE_TRUE(BT_STATUS_SUCCESS ==
-    sBluetoothSocketInterface->listen((btsock_type_t) BTSOCK_RFCOMM,
+    sBluetoothSocketInterface->listen(BTSOCK_RFCOMM,
                                       serviceName.get(),
                                       UUID_OBEX_OBJECT_PUSH,
-                                      aChannel, &fd, (mAuth << 1) | mEncrypt),
+                                      aChannel,
+                                      &fd,
+                                      (mAuth << 1) | mEncrypt),
     false);
   NS_ENSURE_TRUE(fd >= 0, false);
 
   mIsServer = true;
   return CreateDroidSocket(fd);
 }
 
 bool
--- a/dom/bluetooth/bluedroid/gonk/BluetoothServiceBluedroid.cpp
+++ b/dom/bluetooth/bluedroid/gonk/BluetoothServiceBluedroid.cpp
@@ -661,19 +661,22 @@ EnsureBluetoothHalLoad()
 
   return true;
 }
 
 static nsresult
 StartStopGonkBluetooth(bool aShouldEnable)
 {
   MOZ_ASSERT(!NS_IsMainThread());
+  NS_ENSURE_TRUE(sBtInterface, NS_ERROR_FAILURE);
 
-  NS_ENSURE_TRUE(sBtInterface, NS_ERROR_FAILURE);
-  NS_ENSURE_TRUE(sIsBtEnabled != aShouldEnable, NS_OK);
+  if (sIsBtEnabled == aShouldEnable) {
+    // Keep current enable status
+    return NS_OK;
+  }
 
   int ret = aShouldEnable ? sBtInterface->enable() : sBtInterface->disable();
   NS_ENSURE_TRUE(ret == BT_STATUS_SUCCESS, NS_ERROR_FAILURE);
 
   MonitorAutoLock lock(*sToggleBtMonitor);
   lock.Wait();
 
   return NS_OK;
@@ -1216,23 +1219,16 @@ BluetoothServiceBluedroid::Disconnect(
 void
 BluetoothServiceBluedroid::SendFile(const nsAString& aDeviceAddress,
                                     BlobParent* aBlobParent,
                                     BlobChild* aBlobChild,
                                     BluetoothReplyRunnable* aRunnable)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-  // Force to stop discovery, otherwise socket connecting would fail
-  if (!IsReady() || BT_STATUS_SUCCESS != sBtInterface->cancel_discovery()) {
-    NS_NAMED_LITERAL_STRING(errorStr, "Calling cancel_discovery() failed");
-    DispatchBluetoothReply(aRunnable, BluetoothValue(true), errorStr);
-    return;
-  }
-
   // Currently we only support one device sending one file at a time,
   // so we don't need aDeviceAddress here because the target device
   // has been determined when calling 'Connect()'. Nevertheless, keep
   // it for future use.
   BluetoothOppManager* opp = BluetoothOppManager::Get();
   nsAutoString errorStr;
   if (!opp || !opp->SendFile(aDeviceAddress, aBlobParent)) {
     errorStr.AssignLiteral("Calling SendFile() failed");
--- a/dom/bluetooth/bluez/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluez/BluetoothHfpManager.cpp
@@ -615,24 +615,20 @@ BluetoothHfpManager::HandleVoiceConnecti
   voiceInfo->GetState(regState);
   bool service = regState.EqualsLiteral("registered");
   if (service != sCINDItems[CINDType::SERVICE].value) {
     // Notify BluetoothRilListener of service change
     mListener->ServiceChanged(aClientId, service);
   }
   UpdateCIND(CINDType::SERVICE, service);
 
-  uint8_t signal;
   JS::Value value;
   voiceInfo->GetRelSignalStrength(&value);
-  if (!value.isNumber()) {
-    BT_WARNING("Failed to get relSignalStrength in BluetoothHfpManager");
-    return;
-  }
-  signal = ceil(value.toNumber() / 20.0);
+  NS_ENSURE_TRUE_VOID(value.isNumber());
+  uint8_t signal = ceil(value.toNumber() / 20.0);
   UpdateCIND(CINDType::SIGNAL, signal);
 
   /**
    * Possible return values for mode are:
    * - null (unknown): set mNetworkSelectionMode to 0 (auto)
    * - automatic: set mNetworkSelectionMode to 0 (auto)
    * - manual: set mNetworkSelectionMode to 1 (manual)
    */
--- a/dom/bluetooth/bluez/BluetoothOppManager.h
+++ b/dom/bluetooth/bluez/BluetoothOppManager.h
@@ -32,22 +32,16 @@ public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
   BT_DECL_PROFILE_MGR_BASE
   virtual void GetName(nsACString& aName)
   {
     aName.AssignLiteral("OPP");
   }
 
-  /*
-   * Channel of reserved services are fixed values, please check
-   * function add_reserved_service_records() in
-   * external/bluetooth/bluez/src/adapter.c for more information.
-   */
-  static const int DEFAULT_OPP_CHANNEL = 10;
   static const int MAX_PACKET_LENGTH = 0xFFFE;
 
   virtual ~BluetoothOppManager();
   static BluetoothOppManager* Get();
   void ClientDataHandler(mozilla::ipc::UnixSocketRawData* aMessage);
   void ServerDataHandler(mozilla::ipc::UnixSocketRawData* aMessage);
 
   bool Listen();