Merge "Use one type for UUID (2/5)" am: 5a234f0022 am: cd2b33e139
am: ceea7d883b

Change-Id: I8fefecb4cb860570a62af532b77a2dff8b9e863e
diff --git a/include/hardware/ble_scanner.h b/include/hardware/ble_scanner.h
index 2d3ec82..ddd251a 100644
--- a/include/hardware/ble_scanner.h
+++ b/include/hardware/ble_scanner.h
@@ -88,8 +88,8 @@
   /** Configure a scan filter condition  */
   virtual void ScanFilterAddRemove(int action, int filt_type, int filt_index,
                                    int company_id, int company_id_mask,
-                                   const bt_uuid_t *p_uuid,
-                                   const bt_uuid_t *p_uuid_mask,
+                                   const bluetooth::Uuid *p_uuid,
+                                   const bluetooth::Uuid *p_uuid_mask,
                                    const RawAddress *bd_addr, char addr_type,
                                    std::vector<uint8_t> data,
                                    std::vector<uint8_t> p_mask,
diff --git a/include/hardware/bluetooth.h b/include/hardware/bluetooth.h
index f57872d..d6f6e3e 100644
--- a/include/hardware/bluetooth.h
+++ b/include/hardware/bluetooth.h
@@ -24,6 +24,7 @@
 
 #include <hardware/hardware.h>
 
+#include <bluetooth/uuid.h>
 #include <raw_address.h>
 
 __BEGIN_DECLS
@@ -127,15 +128,10 @@
     BT_ACL_STATE_DISCONNECTED
 } bt_acl_state_t;
 
-/** Bluetooth 128-bit UUID */
-typedef struct {
-   uint8_t uu[16];
-} bt_uuid_t;
-
 /** Bluetooth SDP service record */
 typedef struct
 {
-   bt_uuid_t uuid;
+   bluetooth::Uuid uuid;
    uint16_t channel;
    char name[256]; // what's the maximum length
 } bt_service_record_t;
@@ -171,94 +167,95 @@
 
 /* Bluetooth Adapter and Remote Device property types */
 typedef enum {
-    /* Properties common to both adapter and remote device */
-    /**
-     * Description - Bluetooth Device Name
-     * Access mode - Adapter name can be GET/SET. Remote device can be GET
-     * Data type   - bt_bdname_t
-     */
-    BT_PROPERTY_BDNAME = 0x1,
-    /**
-     * Description - Bluetooth Device Address
-     * Access mode - Only GET.
-     * Data type   - RawAddress
-     */
-    BT_PROPERTY_BDADDR,
-    /**
-     * Description - Bluetooth Service 128-bit UUIDs
-     * Access mode - Only GET.
-     * Data type   - Array of bt_uuid_t (Array size inferred from property length).
-     */
-    BT_PROPERTY_UUIDS,
-    /**
-     * Description - Bluetooth Class of Device as found in Assigned Numbers
-     * Access mode - Only GET.
-     * Data type   - uint32_t.
-     */
-    BT_PROPERTY_CLASS_OF_DEVICE,
-    /**
-     * Description - Device Type - BREDR, BLE or DUAL Mode
-     * Access mode - Only GET.
-     * Data type   - bt_device_type_t
-     */
-    BT_PROPERTY_TYPE_OF_DEVICE,
-    /**
-     * Description - Bluetooth Service Record
-     * Access mode - Only GET.
-     * Data type   - bt_service_record_t
-     */
-    BT_PROPERTY_SERVICE_RECORD,
+  /* Properties common to both adapter and remote device */
+  /**
+   * Description - Bluetooth Device Name
+   * Access mode - Adapter name can be GET/SET. Remote device can be GET
+   * Data type   - bt_bdname_t
+   */
+  BT_PROPERTY_BDNAME = 0x1,
+  /**
+   * Description - Bluetooth Device Address
+   * Access mode - Only GET.
+   * Data type   - RawAddress
+   */
+  BT_PROPERTY_BDADDR,
+  /**
+   * Description - Bluetooth Service 128-bit UUIDs
+   * Access mode - Only GET.
+   * Data type   - Array of bluetooth::Uuid (Array size inferred from property
+   *               length).
+   */
+  BT_PROPERTY_UUIDS,
+  /**
+   * Description - Bluetooth Class of Device as found in Assigned Numbers
+   * Access mode - Only GET.
+   * Data type   - uint32_t.
+   */
+  BT_PROPERTY_CLASS_OF_DEVICE,
+  /**
+   * Description - Device Type - BREDR, BLE or DUAL Mode
+   * Access mode - Only GET.
+   * Data type   - bt_device_type_t
+   */
+  BT_PROPERTY_TYPE_OF_DEVICE,
+  /**
+   * Description - Bluetooth Service Record
+   * Access mode - Only GET.
+   * Data type   - bt_service_record_t
+   */
+  BT_PROPERTY_SERVICE_RECORD,
 
-    /* Properties unique to adapter */
-    /**
-     * Description - Bluetooth Adapter scan mode
-     * Access mode - GET and SET
-     * Data type   - bt_scan_mode_t.
-     */
-    BT_PROPERTY_ADAPTER_SCAN_MODE,
-    /**
-     * Description - List of bonded devices
-     * Access mode - Only GET.
-     * Data type   - Array of RawAddress of the bonded remote devices
-     *               (Array size inferred from property length).
-     */
-    BT_PROPERTY_ADAPTER_BONDED_DEVICES,
-    /**
-     * Description - Bluetooth Adapter Discovery timeout (in seconds)
-     * Access mode - GET and SET
-     * Data type   - uint32_t
-     */
-    BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
+  /* Properties unique to adapter */
+  /**
+   * Description - Bluetooth Adapter scan mode
+   * Access mode - GET and SET
+   * Data type   - bt_scan_mode_t.
+   */
+  BT_PROPERTY_ADAPTER_SCAN_MODE,
+  /**
+   * Description - List of bonded devices
+   * Access mode - Only GET.
+   * Data type   - Array of RawAddress of the bonded remote devices
+   *               (Array size inferred from property length).
+   */
+  BT_PROPERTY_ADAPTER_BONDED_DEVICES,
+  /**
+   * Description - Bluetooth Adapter Discovery timeout (in seconds)
+   * Access mode - GET and SET
+   * Data type   - uint32_t
+   */
+  BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
 
-    /* Properties unique to remote device */
-    /**
-     * Description - User defined friendly name of the remote device
-     * Access mode - GET and SET
-     * Data type   - bt_bdname_t.
-     */
-    BT_PROPERTY_REMOTE_FRIENDLY_NAME,
-    /**
-     * Description - RSSI value of the inquired remote device
-     * Access mode - Only GET.
-     * Data type   - int32_t.
-     */
-    BT_PROPERTY_REMOTE_RSSI,
-    /**
-     * Description - Remote version info
-     * Access mode - SET/GET.
-     * Data type   - bt_remote_version_t.
-     */
+  /* Properties unique to remote device */
+  /**
+   * Description - User defined friendly name of the remote device
+   * Access mode - GET and SET
+   * Data type   - bt_bdname_t.
+   */
+  BT_PROPERTY_REMOTE_FRIENDLY_NAME,
+  /**
+   * Description - RSSI value of the inquired remote device
+   * Access mode - Only GET.
+   * Data type   - int32_t.
+   */
+  BT_PROPERTY_REMOTE_RSSI,
+  /**
+   * Description - Remote version info
+   * Access mode - SET/GET.
+   * Data type   - bt_remote_version_t.
+   */
 
-    BT_PROPERTY_REMOTE_VERSION_INFO,
+  BT_PROPERTY_REMOTE_VERSION_INFO,
 
-    /**
-     * Description - Local LE features
-     * Access mode - GET.
-     * Data type   - bt_local_le_features_t.
-     */
-    BT_PROPERTY_LOCAL_LE_FEATURES,
+  /**
+   * Description - Local LE features
+   * Access mode - GET.
+   * Data type   - bt_local_le_features_t.
+   */
+  BT_PROPERTY_LOCAL_LE_FEATURES,
 
-    BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF,
+  BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF,
 } bt_property_type_t;
 
 /** Bluetooth Adapter Property data structure */
@@ -501,8 +498,8 @@
                                       const bt_property_t *property);
 
     /** Get Remote Device's service record  for the given UUID */
-    int (*get_remote_service_record)(RawAddress *remote_addr,
-                                     bt_uuid_t *uuid);
+    int (*get_remote_service_record)(const RawAddress& remote_addr,
+                                     const bluetooth::Uuid& uuid);
 
     /** Start SDP to get remote services */
     int (*get_remote_services)(RawAddress *remote_addr);
diff --git a/include/hardware/bt_common_types.h b/include/hardware/bt_common_types.h
index 8d13ed4..1deae27 100644
--- a/include/hardware/bt_common_types.h
+++ b/include/hardware/bt_common_types.h
@@ -24,6 +24,8 @@
 
 #include "bluetooth.h"
 
+#include <bluetooth/uuid.h>
+
 typedef struct
 {
     uint8_t  client_if;
@@ -53,7 +55,7 @@
 typedef struct
 {
     uint16_t             id;
-    bt_uuid_t           uuid;
+    bluetooth::Uuid      uuid;
     bt_gatt_db_attribute_type_t type;
     uint16_t            attribute_handle;
 
diff --git a/include/hardware/bt_gatt_client.h b/include/hardware/bt_gatt_client.h
index cafc2da..1ec9744 100644
--- a/include/hardware/bt_gatt_client.h
+++ b/include/hardware/bt_gatt_client.h
@@ -23,6 +23,8 @@
 #include "bt_gatt_types.h"
 #include "bt_common_types.h"
 
+#include <bluetooth/uuid.h>
+
 __BEGIN_DECLS
 
 /**
@@ -69,7 +71,7 @@
 typedef struct
 {
     RawAddress        *bda1;
-    bt_uuid_t          *uuid1;
+    bluetooth::Uuid   *uuid1;
     uint16_t            u1;
     uint16_t            u2;
     uint16_t            u3;
@@ -99,7 +101,7 @@
 /** BT-GATT Client callback structure. */
 
 /** Callback invoked in response to register_client */
-typedef void (*register_client_callback)(int status, int client_if, const bt_uuid_t& app_uuid);
+typedef void (*register_client_callback)(int status, int client_if, const bluetooth::Uuid& app_uuid);
 
 /** GATT open callback invoked in response to open */
 typedef void (*connect_callback)(int conn_id, int status, int client_if, const RawAddress& bda);
@@ -200,7 +202,7 @@
 
 typedef struct {
     /** Registers a GATT client application with the stack */
-    bt_status_t (*register_client)(const bt_uuid_t& uuid);
+    bt_status_t (*register_client)(const bluetooth::Uuid& uuid);
 
     /** Unregister a client application from the stack */
     bt_status_t (*unregister_client)(int client_if);
@@ -221,12 +223,12 @@
      * Enumerate all GATT services on a connected device.
      * Optionally, the results can be filtered for a given UUID.
      */
-    bt_status_t (*search_service)(int conn_id, const bt_uuid_t *filter_uuid);
+    bt_status_t (*search_service)(int conn_id, const bluetooth::Uuid *filter_uuid);
 
     /**
      * Sead "Find service by UUID" request. Used only for PTS tests.
      */
-    void (*btif_gattc_discover_service_by_uuid)(int conn_id, const bt_uuid_t& uuid);
+    void (*btif_gattc_discover_service_by_uuid)(int conn_id, const bluetooth::Uuid& uuid);
 
     /** Read a characteristic on a remote device */
     bt_status_t (*read_characteristic)(int conn_id, uint16_t handle,
@@ -234,7 +236,7 @@
 
     /** Read a characteristic on a remote device */
     bt_status_t (*read_using_characteristic_uuid)(
-        int conn_id, const bt_uuid_t& uuid, uint16_t s_handle,
+        int conn_id, const bluetooth::Uuid& uuid, uint16_t s_handle,
         uint16_t e_handle, int auth_req);
 
     /** Write a remote characteristic */
diff --git a/include/hardware/bt_gatt_server.h b/include/hardware/bt_gatt_server.h
index 93ecc02..0a9cb9f 100644
--- a/include/hardware/bt_gatt_server.h
+++ b/include/hardware/bt_gatt_server.h
@@ -46,7 +46,7 @@
 
 /** Callback invoked in response to register_server */
 typedef void (*register_server_callback)(int status, int server_if,
-                const bt_uuid_t& app_uuid);
+                const bluetooth::Uuid& app_uuid);
 
 /** Callback indicating that a remote device has connected or been disconnected */
 typedef void (*connection_callback)(int conn_id, int server_if, int connected,
@@ -135,7 +135,7 @@
 /** Represents the standard BT-GATT server interface. */
 typedef struct {
     /** Registers a GATT server application with the stack */
-    bt_status_t (*register_server)(const bt_uuid_t& uuid);
+    bt_status_t (*register_server)(const bluetooth::Uuid& uuid);
 
     /** Unregister a server application from the stack */
     bt_status_t (*unregister_server)(int server_if );
diff --git a/include/hardware/bt_gatt_types.h b/include/hardware/bt_gatt_types.h
index e037ddc..7130c17 100644
--- a/include/hardware/bt_gatt_types.h
+++ b/include/hardware/bt_gatt_types.h
@@ -21,6 +21,8 @@
 #include <stdint.h>
 #include <stdbool.h>
 
+#include <bluetooth/uuid.h>
+
 __BEGIN_DECLS
 
 /**
@@ -32,7 +34,7 @@
 /** GATT ID adding instance id tracking to the UUID */
 typedef struct
 {
-    bt_uuid_t           uuid;
+    bluetooth::Uuid     uuid;
     uint8_t             inst_id;
 } btgatt_gatt_id_t;
 
diff --git a/include/hardware/bt_sdp.h b/include/hardware/bt_sdp.h
index 76cb579..7db7139 100644
--- a/include/hardware/bt_sdp.h
+++ b/include/hardware/bt_sdp.h
@@ -37,7 +37,7 @@
 
 typedef struct _bluetooth_sdp_hdr {
     bluetooth_sdp_types type;
-    bt_uuid_t   uuid;
+    bluetooth::Uuid uuid;
     uint32_t    service_name_length;
     char       *service_name;
     int32_t     rfcomm_channel_number;
@@ -51,7 +51,7 @@
  */
 typedef struct _bluetooth_sdp_hdr_overlay {
     bluetooth_sdp_types type;
-    bt_uuid_t   uuid;
+    bluetooth::Uuid uuid;
     uint32_t    service_name_length;
     char       *service_name;
     int32_t     rfcomm_channel_number;
@@ -109,7 +109,11 @@
 
 
 /** Callback for SDP search */
-typedef void (*btsdp_search_callback)(bt_status_t status, RawAddress *bd_addr, uint8_t* uuid, int num_records, bluetooth_sdp_record *records);
+typedef void (*btsdp_search_callback)(bt_status_t status,
+                                      const RawAddress &bd_addr,
+                                      const bluetooth::Uuid &uuid,
+                                      int num_records,
+                                      bluetooth_sdp_record *records);
 
 typedef struct {
     /** Set to sizeof(btsdp_callbacks_t) */
@@ -128,7 +132,7 @@
     bt_status_t (*deinit)();
 
     /** Search for SDP records with specific uuid on remote device */
-    bt_status_t (*sdp_search)(RawAddress *bd_addr,  const uint8_t* uuid);
+    bt_status_t (*sdp_search)(RawAddress *bd_addr, const bluetooth::Uuid& uuid);
 
     /**
      * Use listen in the socket interface to create rfcomm and/or l2cap PSM channels,
diff --git a/include/hardware/bt_sock.h b/include/hardware/bt_sock.h
index 4c098f1..70161a3 100644
--- a/include/hardware/bt_sock.h
+++ b/include/hardware/bt_sock.h
@@ -60,7 +60,7 @@
      * used for traffic accounting purposes.
      */
     bt_status_t (*listen)(btsock_type_t type, const char* service_name,
-            const uint8_t* service_uuid, int channel, int* sock_fd, int flags, int callingUid);
+            const bluetooth::Uuid* service_uuid, int channel, int* sock_fd, int flags, int callingUid);
 
     /**
      * Connect to a RFCOMM UUID channel of remote device, It returns the socket fd from which
@@ -68,7 +68,7 @@
      * The callingUid is the UID of the application which is requesting the socket. This is
      * used for traffic accounting purposes.
      */
-    bt_status_t (*connect)(const RawAddress *bd_addr, btsock_type_t type, const uint8_t* uuid,
+    bt_status_t (*connect)(const RawAddress *bd_addr, btsock_type_t type, const bluetooth::Uuid* uuid,
             int channel, int* sock_fd, int flags, int callingUid);
 } btsock_interface_t;