Bug 948337 - create BluetoothHfpManagerBase for audio manager access
authorBen Tian <btian@mozilla.com>
Mon, 13 Jan 2014 13:58:43 +0800
changeset 163254 04c0a98a6255977e052d812cc12819f85e4d89e3
parent 163253 977d6be3df401e327445fe6f30da6be230e65cd9
child 163255 689e99a56512ba15b81da53d9b2fc44ec008020c
push id25989
push usercbook@mozilla.com
push dateTue, 14 Jan 2014 14:44:35 +0000
treeherdermozilla-central@be9f41887791 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs948337
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 948337 - create BluetoothHfpManagerBase for audio manager access
dom/bluetooth/BluetoothHfpManagerBase.h
dom/bluetooth/bluedroid/BluetoothHfpManager.h
dom/bluetooth/bluez/BluetoothHfpManager.h
dom/system/gonk/AudioManager.cpp
dom/system/gonk/moz.build
new file mode 100644
--- /dev/null
+++ b/dom/bluetooth/BluetoothHfpManagerBase.h
@@ -0,0 +1,29 @@
+/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* 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/. */
+
+#ifndef mozilla_dom_bluetooth_bluetoothhfpmanagerbase_h__
+#define mozilla_dom_bluetooth_bluetoothhfpmanagerbase_h__
+
+#include "BluetoothProfileManagerBase.h"
+
+BEGIN_BLUETOOTH_NAMESPACE
+
+class BluetoothHfpManagerBase : public BluetoothProfileManagerBase
+{
+public:
+  /**
+   * Returns true if Sco is connected.
+   */
+  virtual bool IsScoConnected() = 0;
+};
+
+#define BT_DECL_HFP_MGR_BASE                  \
+  BT_DECL_PROFILE_MGR_BASE                    \
+  virtual bool IsScoConnected() MOZ_OVERRIDE;
+
+END_BLUETOOTH_NAMESPACE
+
+#endif  //#ifndef mozilla_dom_bluetooth_bluetoothhfpmanagerbase_h__
--- a/dom/bluetooth/bluedroid/BluetoothHfpManager.h
+++ b/dom/bluetooth/bluedroid/BluetoothHfpManager.h
@@ -6,17 +6,17 @@
 
 #ifndef mozilla_dom_bluetooth_bluetoothhfpmanager_h__
 #define mozilla_dom_bluetooth_bluetoothhfpmanager_h__
 
 #include <hardware/bluetooth.h>
 #include <hardware/bt_hf.h>
 
 #include "BluetoothCommon.h"
-#include "BluetoothProfileManagerBase.h"
+#include "BluetoothHfpManagerBase.h"
 #include "BluetoothRilListener.h"
 #include "BluetoothSocketObserver.h"
 #include "mozilla/ipc/UnixSocket.h"
 #include "mozilla/Hal.h"
 
 BEGIN_BLUETOOTH_NAMESPACE
 
 class BluetoothReplyRunnable;
@@ -66,34 +66,33 @@ public:
   bool IsActive();
 
   uint16_t mState;
   nsString mNumber;
   bthf_call_direction_t mDirection; // 0: outgoing call; 1: incoming call
   bthf_call_addrtype_t mType;
 };
 
-class BluetoothHfpManager : public BluetoothProfileManagerBase
+class BluetoothHfpManager : public BluetoothHfpManagerBase
                           , public BatteryObserver
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
-  BT_DECL_PROFILE_MGR_BASE
+  BT_DECL_HFP_MGR_BASE
   virtual void GetName(nsACString& aName)
   {
     aName.AssignLiteral("HFP/HSP");
   }
 
   static BluetoothHfpManager* Get();
   virtual ~BluetoothHfpManager();
 
   bool ConnectSco();
   bool DisconnectSco();
-  bool IsScoConnected();
 
   /**
    * @param aSend A boolean indicates whether we need to notify headset or not
    */
   void HandleCallStateChanged(uint32_t aCallIndex, uint16_t aCallState,
                               const nsAString& aError, const nsAString& aNumber,
                               const bool aIsOutgoing, const bool aIsConference,
                               bool aSend);
--- a/dom/bluetooth/bluez/BluetoothHfpManager.h
+++ b/dom/bluetooth/bluez/BluetoothHfpManager.h
@@ -3,17 +3,17 @@
 /* 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/. */
 
 #ifndef mozilla_dom_bluetooth_bluetoothhfpmanager_h__
 #define mozilla_dom_bluetooth_bluetoothhfpmanager_h__
 
 #include "BluetoothCommon.h"
-#include "BluetoothProfileManagerBase.h"
+#include "BluetoothHfpManagerBase.h"
 #ifdef MOZ_B2G_RIL
 #include "BluetoothRilListener.h"
 #endif
 #include "BluetoothSocketObserver.h"
 #include "mozilla/ipc/UnixSocket.h"
 #include "mozilla/Hal.h"
 
 BEGIN_BLUETOOTH_NAMESPACE
@@ -70,23 +70,23 @@ public:
   bool mDirection; // true: incoming call; false: outgoing call
   bool mIsConference;
   nsString mNumber;
   int mType;
 };
 #endif // MOZ_B2G_RIL
 
 class BluetoothHfpManager : public BluetoothSocketObserver
-                          , public BluetoothProfileManagerBase
+                          , public BluetoothHfpManagerBase
                           , public BatteryObserver
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
-  BT_DECL_PROFILE_MGR_BASE
+  BT_DECL_HFP_MGR_BASE
   virtual void GetName(nsACString& aName)
   {
     aName.AssignLiteral("HFP/HSP");
   }
 
   static BluetoothHfpManager* Get();
   ~BluetoothHfpManager();
 
@@ -109,17 +109,16 @@ public:
    *
    * @param  aRunnable Indicate a BluetoothReplyRunnable to execute this
    *                   function. The default value is nullpter
    * @return <code>true</code> if SCO established successfully
    */
   bool ConnectSco(BluetoothReplyRunnable* aRunnable = nullptr);
   bool DisconnectSco();
   bool ListenSco();
-  bool IsScoConnected();
 
 #ifdef MOZ_B2G_RIL
   /**
    * @param aSend A boolean indicates whether we need to notify headset or not
    */
   void HandleCallStateChanged(uint32_t aCallIndex, uint16_t aCallState,
                               const nsAString& aError, const nsAString& aNumber,
                               const bool aIsOutgoing, const bool aIsConference,
--- a/dom/system/gonk/AudioManager.cpp
+++ b/dom/system/gonk/AudioManager.cpp
@@ -26,18 +26,17 @@
 #include "nsISettingsService.h"
 #include "nsPrintfCString.h"
 
 #include "mozilla/Hal.h"
 #include "mozilla/Services.h"
 #include "base/message_loop.h"
 
 #include "BluetoothCommon.h"
-#include "BluetoothProfileManagerBase.h"
-#include "BluetoothHfpManager.h"
+#include "BluetoothHfpManagerBase.h"
 
 #include "nsJSUtils.h"
 #include "nsCxPusher.h"
 #include "nsThreadUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 
 using namespace mozilla::dom::gonk;
@@ -225,18 +224,18 @@ InternalSetAudioRoutes(SwitchState aStat
 void
 AudioManager::HandleBluetoothStatusChanged(nsISupports* aSubject,
                                            const char* aTopic,
                                            const nsCString aAddress)
 {
 #ifdef MOZ_B2G_BT
   bool status;
   if (!strcmp(aTopic, BLUETOOTH_SCO_STATUS_CHANGED_ID)) {
-    BluetoothHfpManager* hfp =
-      static_cast<BluetoothHfpManager*>(aSubject);
+    BluetoothHfpManagerBase* hfp =
+      static_cast<BluetoothHfpManagerBase*>(aSubject);
     status = hfp->IsScoConnected();
   } else {
     BluetoothProfileManagerBase* profile =
       static_cast<BluetoothProfileManagerBase*>(aSubject);
     status = profile->IsConnected();
   }
 
   audio_policy_dev_state_t audioState = status ?
--- a/dom/system/gonk/moz.build
+++ b/dom/system/gonk/moz.build
@@ -95,26 +95,16 @@ if CONFIG['MOZ_NFC']:
         'Nfc.manifest',
         'NfcContentHelper.js',
     ]
     EXTRA_JS_MODULES += [
     'nfc_consts.js',
     'nfc_worker.js',
     ]
 
-# include different BluetoothHfpManager.h under dom/bluetooth/
-if CONFIG['MOZ_B2G_BT_BLUEZ']:
-    LOCAL_INCLUDES += [
-        '/dom/bluetooth/bluez',
-    ]
-elif CONFIG['MOZ_B2G_BT_BLUEDROID']:
-    LOCAL_INCLUDES += [
-        '/dom/bluetooth/bluedroid',
-    ]
-
 FAIL_ON_WARNINGS = True
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 LOCAL_INCLUDES += [
     '/content/events/src',
     '/dom/base',
     '/dom/bluetooth',