Bug 1155082: Share BluetoothUUID.{cpp,h} between Bluetooth v1 and v2, r=btian
authorThomas Zimmermann <tdz@users.sourceforge.net>
Fri, 17 Apr 2015 17:45:05 +0200
changeset 239734 68368c996a67663f61f12ec0da6a39a802bd8013
parent 239733 9be6e8044ca3dd8427ec29dae9da7334a436c35f
child 239735 d404c326b5c83f4de07756cb661bad21aeb2bd70
push id58624
push userryanvm@gmail.com
push dateFri, 17 Apr 2015 20:13:10 +0000
treeherdermozilla-inbound@549422b4460b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbtian
bugs1155082, 1015819
milestone40.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 1155082: Share BluetoothUUID.{cpp,h} between Bluetooth v1 and v2, r=btian BluetoothUUID of v1 and v2 are the same, except for bug 1015819 in v1. So this patch moves the v1 variant to a shared location and removes the v2 variant completely.
CLOBBER
dom/bluetooth/BluetoothUuid.cpp
dom/bluetooth/BluetoothUuid.h
dom/bluetooth/bluetooth1/BluetoothUuid.cpp
dom/bluetooth/bluetooth1/BluetoothUuid.h
dom/bluetooth/bluetooth2/BluetoothUuid.cpp
dom/bluetooth/bluetooth2/BluetoothUuid.h
dom/bluetooth/moz.build
--- a/CLOBBER
+++ b/CLOBBER
@@ -17,13 +17,13 @@
 #
 # Modifying this file will now automatically clobber the buildbot machines \o/
 #
 
 # Are you updating CLOBBER because you think it's needed for your WebIDL
 # changes to stick? As of bug 928195, this shouldn't be necessary! Please
 # don't change CLOBBER for WebIDL changes any more.
 
-Bug 1154235: Merge BluetoothUtils.{cpp,h} variants into single file
+Bug 1155082: Merge BluetoothUUID.{cpp,h} variants into single file
 
 This patch set renames and removes source files. This requires updating
 the build system's dependency information from scratch. The issue has
 been reported in bug 1154232.
rename from dom/bluetooth/bluetooth1/BluetoothUuid.cpp
rename to dom/bluetooth/BluetoothUuid.cpp
rename from dom/bluetooth/bluetooth1/BluetoothUuid.h
rename to dom/bluetooth/BluetoothUuid.h
deleted file mode 100644
--- a/dom/bluetooth/bluetooth2/BluetoothUuid.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/* -*- 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/. */
-
-#include "BluetoothUuid.h"
-
-#include "BluetoothA2dpManager.h"
-#include "BluetoothHfpManager.h"
-#include "BluetoothHidManager.h"
-#include "BluetoothOppManager.h"
-
-USING_BLUETOOTH_NAMESPACE
-
-void
-BluetoothUuidHelper::GetString(BluetoothServiceClass aServiceClass,
-                               nsAString& aRetUuidStr)
-{
-  aRetUuidStr.Truncate();
-
-  aRetUuidStr.AppendLiteral("0000");
-  aRetUuidStr.AppendInt(aServiceClass, 16);
-  aRetUuidStr.AppendLiteral("-0000-1000-8000-00805F9B34FB");
-}
-
-BluetoothServiceClass
-BluetoothUuidHelper::GetBluetoothServiceClass(const nsAString& aUuidStr)
-{
-  // An example of input UUID string: 0000110D-0000-1000-8000-00805F9B34FB
-  MOZ_ASSERT(aUuidStr.Length() == 36);
-
-  /**
-   * Extract uuid16 from input UUID string and return a value of enum
-   * BluetoothServiceClass. If we failed to recognize the value,
-   * BluetoothServiceClass::UNKNOWN is returned.
-   */
-  BluetoothServiceClass retValue = BluetoothServiceClass::UNKNOWN;
-  nsString uuid(Substring(aUuidStr, 4, 4));
-
-  nsresult rv;
-  int32_t integer = uuid.ToInteger(&rv, 16);
-  NS_ENSURE_SUCCESS(rv, retValue);
-
-  return GetBluetoothServiceClass(integer);
-}
-
-BluetoothServiceClass
-BluetoothUuidHelper::GetBluetoothServiceClass(uint16_t aServiceUuid)
-{
-  BluetoothServiceClass retValue = BluetoothServiceClass::UNKNOWN;
-  switch (aServiceUuid) {
-    case BluetoothServiceClass::A2DP:
-    case BluetoothServiceClass::HANDSFREE:
-    case BluetoothServiceClass::HANDSFREE_AG:
-    case BluetoothServiceClass::HEADSET:
-    case BluetoothServiceClass::HEADSET_AG:
-    case BluetoothServiceClass::HID:
-    case BluetoothServiceClass::OBJECT_PUSH:
-      retValue = (BluetoothServiceClass)aServiceUuid;
-  }
-  return retValue;
-}
-
-BluetoothProfileManagerBase*
-BluetoothUuidHelper::GetBluetoothProfileManager(uint16_t aServiceUuid)
-{
-  BluetoothProfileManagerBase* profile;
-  BluetoothServiceClass serviceClass = GetBluetoothServiceClass(aServiceUuid);
-  switch (serviceClass) {
-    case BluetoothServiceClass::HANDSFREE:
-    case BluetoothServiceClass::HEADSET:
-      profile = BluetoothHfpManager::Get();
-      break;
-    case BluetoothServiceClass::HID:
-      profile = BluetoothHidManager::Get();
-      break;
-    case BluetoothServiceClass::A2DP:
-      profile = BluetoothA2dpManager::Get();
-      break;
-    case BluetoothServiceClass::OBJECT_PUSH:
-      profile = BluetoothOppManager::Get();
-      break;
-    default:
-      profile = nullptr;
-  }
-  return profile;
-}
deleted file mode 100644
--- a/dom/bluetooth/bluetooth2/BluetoothUuid.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* -*- 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_bluetoothuuid_h__
-#define mozilla_dom_bluetooth_bluetoothuuid_h__
-
-#include "BluetoothCommon.h"
-
-BEGIN_BLUETOOTH_NAMESPACE
-
-class BluetoothProfileManagerBase;
-
-/*
- * Service classes and Profile Identifiers
- *
- * Supported Bluetooth services for v1 are listed as below.
- *
- * The value of each service class is defined in "AssignedNumbers/Service
- * Discovery Protocol (SDP)/Service classes and Profile Identifiers" in the
- * Bluetooth Core Specification.
- */
-enum BluetoothServiceClass
-{
-  A2DP          = 0x110D,
-  HANDSFREE     = 0x111E,
-  HANDSFREE_AG  = 0x111F,
-  HEADSET       = 0x1108,
-  HEADSET_AG    = 0x1112,
-  HID           = 0x1124,
-  OBJECT_PUSH   = 0x1105,
-  UNKNOWN       = 0x0000
-};
-
-class BluetoothUuidHelper
-{
-public:
-  /**
-   * Get a 128-bit uuid string calculated from a 16-bit service class UUID and
-   * BASE_UUID
-   *
-   * @param aServiceClassUuid  16-bit service class UUID
-   * @param aRetUuidStr  out parameter, 128-bit uuid string
-   */
-  static void
-  GetString(BluetoothServiceClass aServiceClassUuid, nsAString& aRetUuidStr);
-
-  /**
-   * Convert a 128-bit uuid string to a value of BluetoothServiceClass
-   *
-   * @param aUuidStr  128-bit uuid string
-   * @return  a value of BluetoothServiceClass
-   */
-  static BluetoothServiceClass
-  GetBluetoothServiceClass(const nsAString& aUuidStr);
-
-  static BluetoothServiceClass
-  GetBluetoothServiceClass(uint16_t aServiceUuid);
-
-  static BluetoothProfileManagerBase*
-  GetBluetoothProfileManager(uint16_t aServiceUuid);
-};
-
-// TODO/qdot: Move these back into gonk and make the service handler deal with
-// it there.
-//
-// Gotten from reading the "u8" values in B2G/external/bluez/src/adapter.c
-// These were hardcoded into android
-enum BluetoothReservedChannels {
-  CHANNEL_DIALUP_NETWORK = 1,
-  CHANNEL_HANDSFREE_AG   = 10,
-  CHANNEL_HEADSET_AG     = 11,
-  CHANNEL_OPUSH          = 12,
-  CHANNEL_SIM_ACCESS     = 15,
-  CHANNEL_PBAP_PSE       = 19,
-  CHANNEL_FTP            = 20,
-  CHANNEL_OPUSH_L2CAP    = 5255
-};
-
-END_BLUETOOTH_NAMESPACE
-
-#endif
--- a/dom/bluetooth/moz.build
+++ b/dom/bluetooth/moz.build
@@ -8,17 +8,18 @@ if CONFIG['MOZ_B2G_BT']:
 
     #
     # Generic code
     #
 
     SOURCES += [
         'BluetoothInterface.cpp',
         'BluetoothInterfaceHelpers.cpp',
-        'BluetoothUtils.cpp'
+        'BluetoothUtils.cpp',
+        'BluetoothUuid.cpp'
     ]
 
     if CONFIG['MOZ_B2G_BT_API_V2']:
         SOURCES += [
             'bluetooth2/BluetoothAdapter.cpp',
             'bluetooth2/BluetoothClassOfDevice.cpp',
             'bluetooth2/BluetoothDevice.cpp',
             'bluetooth2/BluetoothDiscoveryHandle.cpp',
@@ -28,17 +29,16 @@ if CONFIG['MOZ_B2G_BT']:
             'bluetooth2/BluetoothGattService.cpp',
             'bluetooth2/BluetoothHidManager.cpp',
             'bluetooth2/BluetoothManager.cpp',
             'bluetooth2/BluetoothPairingHandle.cpp',
             'bluetooth2/BluetoothPairingListener.cpp',
             'bluetooth2/BluetoothProfileController.cpp',
             'bluetooth2/BluetoothReplyRunnable.cpp',
             'bluetooth2/BluetoothService.cpp',
-            'bluetooth2/BluetoothUuid.cpp',
             'bluetooth2/ipc/BluetoothChild.cpp',
             'bluetooth2/ipc/BluetoothParent.cpp',
             'bluetooth2/ipc/BluetoothServiceChildProcess.cpp',
             'bluetooth2/ObexBase.cpp'
         ]
         if CONFIG['MOZ_B2G_RIL']:
             SOURCES += [
                 'bluetooth2/BluetoothRilListener.cpp',
@@ -53,17 +53,16 @@ if CONFIG['MOZ_B2G_BT']:
             'bluetooth1/BluetoothAdapter.cpp',
             'bluetooth1/BluetoothDevice.cpp',
             'bluetooth1/BluetoothHidManager.cpp',
             'bluetooth1/BluetoothManager.cpp',
             'bluetooth1/BluetoothProfileController.cpp',
             'bluetooth1/BluetoothPropertyContainer.cpp',
             'bluetooth1/BluetoothReplyRunnable.cpp',
             'bluetooth1/BluetoothService.cpp',
-            'bluetooth1/BluetoothUuid.cpp',
             'bluetooth1/ipc/BluetoothChild.cpp',
             'bluetooth1/ipc/BluetoothParent.cpp',
             'bluetooth1/ipc/BluetoothServiceChildProcess.cpp',
             'bluetooth1/ObexBase.cpp'
         ]
         if CONFIG['MOZ_B2G_RIL']:
             SOURCES += [
                 'bluetooth1/BluetoothRilListener.cpp',