1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_INCLUDE_BLUETOOTH_H
18 #define ANDROID_INCLUDE_BLUETOOTH_H
19 
20 #include <stdbool.h>
21 #include <stdint.h>
22 #include <sys/cdefs.h>
23 #include <sys/types.h>
24 
25 #include "avrcp/avrcp.h"
26 #include "bluetooth/uuid.h"
27 #include "raw_address.h"
28 
29 /**
30  * The Bluetooth Hardware Module ID
31  */
32 
33 #define BT_HARDWARE_MODULE_ID "bluetooth"
34 #define BT_STACK_MODULE_ID "bluetooth"
35 
36 /** Bluetooth profile interface IDs */
37 #define BT_PROFILE_HANDSFREE_ID "handsfree"
38 #define BT_PROFILE_HANDSFREE_CLIENT_ID "handsfree_client"
39 #define BT_PROFILE_ADVANCED_AUDIO_ID "a2dp"
40 #define BT_PROFILE_ADVANCED_AUDIO_SINK_ID "a2dp_sink"
41 #define BT_PROFILE_SOCKETS_ID "socket"
42 #define BT_PROFILE_HIDHOST_ID "hidhost"
43 #define BT_PROFILE_HIDDEV_ID "hiddev"
44 #define BT_PROFILE_PAN_ID "pan"
45 #define BT_PROFILE_MAP_CLIENT_ID "map_client"
46 #define BT_PROFILE_SDP_CLIENT_ID "sdp"
47 #define BT_PROFILE_GATT_ID "gatt"
48 #define BT_PROFILE_AV_RC_ID "avrcp"
49 #define BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl"
50 #define BT_PROFILE_HEARING_AID_ID "hearing_aid"
51 #define BT_KEYSTORE_ID "bluetooth_keystore"
52 
53 /** Bluetooth Device Name */
54 typedef struct { uint8_t name[249]; } __attribute__((packed)) bt_bdname_t;
55 
56 /** Bluetooth Adapter Visibility Modes*/
57 typedef enum {
58   BT_SCAN_MODE_NONE,
59   BT_SCAN_MODE_CONNECTABLE,
60   BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE
61 } bt_scan_mode_t;
62 
63 /** Bluetooth Adapter State */
64 typedef enum { BT_STATE_OFF, BT_STATE_ON } bt_state_t;
65 
66 /** Bluetooth Adapter Input Output Capabilities which determine Pairing/Security
67  */
68 typedef enum {
69   BT_IO_CAP_OUT,    /* DisplayOnly */
70   BT_IO_CAP_IO,     /* DisplayYesNo */
71   BT_IO_CAP_IN,     /* KeyboardOnly */
72   BT_IO_CAP_NONE,   /* NoInputNoOutput */
73   BT_IO_CAP_KBDISP, /* Keyboard display */
74   BT_IO_CAP_MAX,
75   BT_IO_CAP_UNKNOWN = 0xFF /* Unknown value */
76 } bt_io_cap_t;
77 
78 /** Bluetooth Error Status */
79 /** We need to build on this */
80 
81 typedef enum {
82   BT_STATUS_SUCCESS,
83   BT_STATUS_FAIL,
84   BT_STATUS_NOT_READY,
85   BT_STATUS_NOMEM,
86   BT_STATUS_BUSY,
87   BT_STATUS_DONE, /* request already completed */
88   BT_STATUS_UNSUPPORTED,
89   BT_STATUS_PARM_INVALID,
90   BT_STATUS_UNHANDLED,
91   BT_STATUS_AUTH_FAILURE,
92   BT_STATUS_RMT_DEV_DOWN,
93   BT_STATUS_AUTH_REJECTED,
94   BT_STATUS_JNI_ENVIRONMENT_ERROR,
95   BT_STATUS_JNI_THREAD_ATTACH_ERROR,
96   BT_STATUS_WAKELOCK_ERROR
97 } bt_status_t;
98 
99 /** Bluetooth PinKey Code */
100 typedef struct { uint8_t pin[16]; } __attribute__((packed)) bt_pin_code_t;
101 
102 typedef struct {
103   uint8_t status;
104   uint8_t ctrl_state;   /* stack reported state */
105   uint64_t tx_time;     /* in ms */
106   uint64_t rx_time;     /* in ms */
107   uint64_t idle_time;   /* in ms */
108   uint64_t energy_used; /* a product of mA, V and ms */
109 } __attribute__((packed)) bt_activity_energy_info;
110 
111 typedef struct {
112   int32_t app_uid;
113   uint64_t tx_bytes;
114   uint64_t rx_bytes;
115 } __attribute__((packed)) bt_uid_traffic_t;
116 
117 /** Bluetooth Adapter Discovery state */
118 typedef enum {
119   BT_DISCOVERY_STOPPED,
120   BT_DISCOVERY_STARTED
121 } bt_discovery_state_t;
122 
123 /** Bluetooth ACL connection state */
124 typedef enum {
125   BT_ACL_STATE_CONNECTED,
126   BT_ACL_STATE_DISCONNECTED
127 } bt_acl_state_t;
128 
129 /** Bluetooth SDP service record */
130 typedef struct {
131   bluetooth::Uuid uuid;
132   uint16_t channel;
133   char name[256];  // what's the maximum length
134 } bt_service_record_t;
135 
136 /** Bluetooth Remote Version info */
137 typedef struct {
138   int version;
139   int sub_ver;
140   int manufacturer;
141 } bt_remote_version_t;
142 
143 typedef struct {
144   uint16_t version_supported;
145   uint8_t local_privacy_enabled;
146   uint8_t max_adv_instance;
147   uint8_t rpa_offload_supported;
148   uint8_t max_irk_list_size;
149   uint8_t max_adv_filter_supported;
150   uint8_t activity_energy_info_supported;
151   uint16_t scan_result_storage_size;
152   uint16_t total_trackable_advertisers;
153   bool extended_scan_support;
154   bool debug_logging_supported;
155   bool le_2m_phy_supported;
156   bool le_coded_phy_supported;
157   bool le_extended_advertising_supported;
158   bool le_periodic_advertising_supported;
159   uint16_t le_maximum_advertising_data_length;
160 } bt_local_le_features_t;
161 
162 /* Bluetooth Adapter and Remote Device property types */
163 typedef enum {
164   /* Properties common to both adapter and remote device */
165   /**
166    * Description - Bluetooth Device Name
167    * Access mode - Adapter name can be GET/SET. Remote device can be GET
168    * Data type   - bt_bdname_t
169    */
170   BT_PROPERTY_BDNAME = 0x1,
171   /**
172    * Description - Bluetooth Device Address
173    * Access mode - Only GET.
174    * Data type   - RawAddress
175    */
176   BT_PROPERTY_BDADDR,
177   /**
178    * Description - Bluetooth Service 128-bit UUIDs
179    * Access mode - Only GET.
180    * Data type   - Array of bluetooth::Uuid (Array size inferred from property
181    *               length).
182    */
183   BT_PROPERTY_UUIDS,
184   /**
185    * Description - Bluetooth Class of Device as found in Assigned Numbers
186    * Access mode - Only GET.
187    * Data type   - uint32_t.
188    */
189   BT_PROPERTY_CLASS_OF_DEVICE,
190   /**
191    * Description - Device Type - BREDR, BLE or DUAL Mode
192    * Access mode - Only GET.
193    * Data type   - bt_device_type_t
194    */
195   BT_PROPERTY_TYPE_OF_DEVICE,
196   /**
197    * Description - Bluetooth Service Record
198    * Access mode - Only GET.
199    * Data type   - bt_service_record_t
200    */
201   BT_PROPERTY_SERVICE_RECORD,
202 
203   /* Properties unique to adapter */
204   /**
205    * Description - Bluetooth Adapter scan mode
206    * Access mode - GET and SET
207    * Data type   - bt_scan_mode_t.
208    */
209   BT_PROPERTY_ADAPTER_SCAN_MODE,
210   /**
211    * Description - List of bonded devices
212    * Access mode - Only GET.
213    * Data type   - Array of RawAddress of the bonded remote devices
214    *               (Array size inferred from property length).
215    */
216   BT_PROPERTY_ADAPTER_BONDED_DEVICES,
217   /**
218    * Description - Bluetooth Adapter Discovery timeout (in seconds)
219    * Access mode - GET and SET
220    * Data type   - uint32_t
221    */
222   BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
223 
224   /* Properties unique to remote device */
225   /**
226    * Description - User defined friendly name of the remote device
227    * Access mode - GET and SET
228    * Data type   - bt_bdname_t.
229    */
230   BT_PROPERTY_REMOTE_FRIENDLY_NAME,
231   /**
232    * Description - RSSI value of the inquired remote device
233    * Access mode - Only GET.
234    * Data type   - int8_t.
235    */
236   BT_PROPERTY_REMOTE_RSSI,
237   /**
238    * Description - Remote version info
239    * Access mode - SET/GET.
240    * Data type   - bt_remote_version_t.
241    */
242 
243   BT_PROPERTY_REMOTE_VERSION_INFO,
244 
245   /**
246    * Description - Local LE features
247    * Access mode - GET.
248    * Data type   - bt_local_le_features_t.
249    */
250   BT_PROPERTY_LOCAL_LE_FEATURES,
251 
252   /**
253    * Description - Local Input/Output Capabilities for classic Bluetooth
254    * Access mode - GET and SET
255    * Data Type - bt_io_cap_t.
256    */
257   BT_PROPERTY_LOCAL_IO_CAPS,
258 
259   /**
260    * Description - Local Input/Output Capabilities for BLE
261    * Access mode - GET and SET
262    * Data Type - bt_io_cap_t.
263    */
264   BT_PROPERTY_LOCAL_IO_CAPS_BLE,
265 
266   BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF,
267 } bt_property_type_t;
268 
269 /** Bluetooth Adapter Property data structure */
270 typedef struct {
271   bt_property_type_t type;
272   int len;
273   void* val;
274 } bt_property_t;
275 
276 /** Bluetooth Out Of Band data for bonding */
277 typedef struct {
278   uint8_t le_bt_dev_addr[7]; /* LE Bluetooth Device Address */
279   uint8_t c192[16];          /* Simple Pairing Hash C-192 */
280   uint8_t r192[16];          /* Simple Pairing Randomizer R-192 */
281   uint8_t c256[16];          /* Simple Pairing Hash C-256 */
282   uint8_t r256[16];          /* Simple Pairing Randomizer R-256 */
283   uint8_t sm_tk[16];         /* Security Manager TK Value */
284   uint8_t le_sc_c[16];       /* LE Secure Connections Confirmation Value */
285   uint8_t le_sc_r[16];       /* LE Secure Connections Random Value */
286 } bt_out_of_band_data_t;
287 
288 /** Bluetooth Device Type */
289 typedef enum {
290   BT_DEVICE_DEVTYPE_BREDR = 0x1,
291   BT_DEVICE_DEVTYPE_BLE,
292   BT_DEVICE_DEVTYPE_DUAL
293 } bt_device_type_t;
294 /** Bluetooth Bond state */
295 typedef enum {
296   BT_BOND_STATE_NONE,
297   BT_BOND_STATE_BONDING,
298   BT_BOND_STATE_BONDED
299 } bt_bond_state_t;
300 
301 /** Bluetooth SSP Bonding Variant */
302 typedef enum {
303   BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
304   BT_SSP_VARIANT_PASSKEY_ENTRY,
305   BT_SSP_VARIANT_CONSENT,
306   BT_SSP_VARIANT_PASSKEY_NOTIFICATION
307 } bt_ssp_variant_t;
308 
309 #define BT_MAX_NUM_UUIDS 32
310 
311 /** Bluetooth Interface callbacks */
312 
313 /** Bluetooth Enable/Disable Callback. */
314 typedef void (*adapter_state_changed_callback)(bt_state_t state);
315 
316 /** GET/SET Adapter Properties callback */
317 /* TODO: For the GET/SET property APIs/callbacks, we may need a session
318  * identifier to associate the call with the callback. This would be needed
319  * whenever more than one simultaneous instance of the same adapter_type
320  * is get/set.
321  *
322  * If this is going to be handled in the Java framework, then we do not need
323  * to manage sessions here.
324  */
325 typedef void (*adapter_properties_callback)(bt_status_t status,
326                                             int num_properties,
327                                             bt_property_t* properties);
328 
329 /** GET/SET Remote Device Properties callback */
330 /** TODO: For remote device properties, do not see a need to get/set
331  * multiple properties - num_properties shall be 1
332  */
333 typedef void (*remote_device_properties_callback)(bt_status_t status,
334                                                   RawAddress* bd_addr,
335                                                   int num_properties,
336                                                   bt_property_t* properties);
337 
338 /** New device discovered callback */
339 /** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1
340  * respectively */
341 typedef void (*device_found_callback)(int num_properties,
342                                       bt_property_t* properties);
343 
344 /** Discovery state changed callback */
345 typedef void (*discovery_state_changed_callback)(bt_discovery_state_t state);
346 
347 /** Bluetooth Legacy PinKey Request callback */
348 typedef void (*pin_request_callback)(RawAddress* remote_bd_addr,
349                                      bt_bdname_t* bd_name, uint32_t cod,
350                                      bool min_16_digit);
351 
352 /** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/
353 /** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT &
354  *  BT_SSP_PAIRING_PASSKEY_ENTRY */
355 /* TODO: Passkey request callback shall not be needed for devices with display
356  * capability. We still need support this in the stack for completeness */
357 typedef void (*ssp_request_callback)(RawAddress* remote_bd_addr,
358                                      bt_bdname_t* bd_name, uint32_t cod,
359                                      bt_ssp_variant_t pairing_variant,
360                                      uint32_t pass_key);
361 
362 /** Bluetooth Bond state changed callback */
363 /* Invoked in response to create_bond, cancel_bond or remove_bond */
364 typedef void (*bond_state_changed_callback)(bt_status_t status,
365                                             RawAddress* remote_bd_addr,
366                                             bt_bond_state_t state);
367 
368 /** Bluetooth ACL connection state changed callback */
369 typedef void (*acl_state_changed_callback)(bt_status_t status,
370                                            RawAddress* remote_bd_addr,
371                                            bt_acl_state_t state);
372 
373 typedef enum { ASSOCIATE_JVM, DISASSOCIATE_JVM } bt_cb_thread_evt;
374 
375 /** Thread Associate/Disassociate JVM Callback */
376 /* Callback that is invoked by the callback thread to allow upper layer to
377  * attach/detach to/from the JVM */
378 typedef void (*callback_thread_event)(bt_cb_thread_evt evt);
379 
380 /** Bluetooth Test Mode Callback */
381 /* Receive any HCI event from controller. Must be in DUT Mode for this callback
382  * to be received */
383 typedef void (*dut_mode_recv_callback)(uint16_t opcode, uint8_t* buf,
384                                        uint8_t len);
385 
386 /* LE Test mode callbacks
387  * This callback shall be invoked whenever the le_tx_test, le_rx_test or
388  * le_test_end is invoked The num_packets is valid only for le_test_end command
389  */
390 typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets);
391 
392 /** Callback invoked when energy details are obtained */
393 /* Ctrl_state-Current controller state-Active-1,scan-2,or idle-3 state as
394  * defined by HCI spec. If the ctrl_state value is 0, it means the API call
395  * failed Time values-In milliseconds as returned by the controller Energy
396  * used-Value as returned by the controller Status-Provides the status of the
397  * read_energy_info API call uid_data provides an array of bt_uid_traffic_t,
398  * where the array is terminated by an element with app_uid set to -1.
399  */
400 typedef void (*energy_info_callback)(bt_activity_energy_info* energy_info,
401                                      bt_uid_traffic_t* uid_data);
402 
403 /** TODO: Add callbacks for Link Up/Down and other generic
404  *  notifications/callbacks */
405 
406 /** Bluetooth DM callback structure. */
407 typedef struct {
408   /** set to sizeof(bt_callbacks_t) */
409   size_t size;
410   adapter_state_changed_callback adapter_state_changed_cb;
411   adapter_properties_callback adapter_properties_cb;
412   remote_device_properties_callback remote_device_properties_cb;
413   device_found_callback device_found_cb;
414   discovery_state_changed_callback discovery_state_changed_cb;
415   pin_request_callback pin_request_cb;
416   ssp_request_callback ssp_request_cb;
417   bond_state_changed_callback bond_state_changed_cb;
418   acl_state_changed_callback acl_state_changed_cb;
419   callback_thread_event thread_evt_cb;
420   dut_mode_recv_callback dut_mode_recv_cb;
421   le_test_mode_callback le_test_mode_cb;
422   energy_info_callback energy_info_cb;
423 } bt_callbacks_t;
424 
425 typedef void (*alarm_cb)(void* data);
426 typedef bool (*set_wake_alarm_callout)(uint64_t delay_millis, bool should_wake,
427                                        alarm_cb cb, void* data);
428 typedef int (*acquire_wake_lock_callout)(const char* lock_name);
429 typedef int (*release_wake_lock_callout)(const char* lock_name);
430 
431 /** The set of functions required by bluedroid to set wake alarms and
432  * grab wake locks. This struct is passed into the stack through the
433  * |set_os_callouts| function on |bt_interface_t|.
434  */
435 typedef struct {
436   /* set to sizeof(bt_os_callouts_t) */
437   size_t size;
438 
439   set_wake_alarm_callout set_wake_alarm;
440   acquire_wake_lock_callout acquire_wake_lock;
441   release_wake_lock_callout release_wake_lock;
442 } bt_os_callouts_t;
443 
444 /** NOTE: By default, no profiles are initialized at the time of init/enable.
445  *  Whenever the application invokes the 'init' API of a profile, then one of
446  *  the following shall occur:
447  *
448  *    1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the
449  *        profile as enabled. Subsequently, when the application invokes the
450  *        Bluetooth 'enable', as part of the enable sequence the profile that
451  * were marked shall be enabled by calling appropriate stack APIs. The
452  *        'adapter_properties_cb' shall return the list of UUIDs of the
453  *        enabled profiles.
454  *
455  *    2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the
456  * stack profile API to initialize the profile and trigger a
457  *        'adapter_properties_cb' with the current list of UUIDs including the
458  *        newly added profile's UUID.
459  *
460  *   The reverse shall occur whenever the profile 'cleanup' APIs are invoked
461  */
462 
463 /** Represents the standard Bluetooth DM interface. */
464 typedef struct {
465   /** set to sizeof(bt_interface_t) */
466   size_t size;
467   /**
468    * Opens the interface and provides the callback routines
469    * to the implemenation of this interface.
470    * The |start_restricted| flag inits the adapter in restricted mode. In
471    * restricted mode, bonds that are created are marked as restricted in the
472    * config file. These devices are deleted upon leaving restricted mode.
473    * The |is_niap_mode| flag inits the adapter in NIAP mode.
474    * The |config_compare_result| flag show the config checksum check result if
475    * is in NIAP mode.
476    * The |init_flags| are config flags that cannot change during run.
477    */
478   int (*init)(bt_callbacks_t* callbacks, bool guest_mode, bool is_niap_mode,
479               int config_compare_result, const char** init_flags);
480 
481   /** Enable Bluetooth. */
482   int (*enable)();
483 
484   /** Disable Bluetooth. */
485   int (*disable)(void);
486 
487   /** Closes the interface. */
488   void (*cleanup)(void);
489 
490   /** Get all Bluetooth Adapter properties at init */
491   int (*get_adapter_properties)(void);
492 
493   /** Get Bluetooth Adapter property of 'type' */
494   int (*get_adapter_property)(bt_property_type_t type);
495 
496   /** Set Bluetooth Adapter property of 'type' */
497   /* Based on the type, val shall be one of
498    * RawAddress or bt_bdname_t or bt_scanmode_t etc
499    */
500   int (*set_adapter_property)(const bt_property_t* property);
501 
502   /** Get all Remote Device properties */
503   int (*get_remote_device_properties)(RawAddress* remote_addr);
504 
505   /** Get Remote Device property of 'type' */
506   int (*get_remote_device_property)(RawAddress* remote_addr,
507                                     bt_property_type_t type);
508 
509   /** Set Remote Device property of 'type' */
510   int (*set_remote_device_property)(RawAddress* remote_addr,
511                                     const bt_property_t* property);
512 
513   /** Get Remote Device's service record  for the given UUID */
514   int (*get_remote_service_record)(const RawAddress& remote_addr,
515                                    const bluetooth::Uuid& uuid);
516 
517   /** Start SDP to get remote services */
518   int (*get_remote_services)(RawAddress* remote_addr);
519 
520   /** Start Discovery */
521   int (*start_discovery)(void);
522 
523   /** Cancel Discovery */
524   int (*cancel_discovery)(void);
525 
526   /** Create Bluetooth Bonding */
527   int (*create_bond)(const RawAddress* bd_addr, int transport);
528 
529   /** Create Bluetooth Bond using out of band data */
530   int (*create_bond_out_of_band)(const RawAddress* bd_addr, int transport,
531                                  const bt_out_of_band_data_t* oob_data);
532 
533   /** Remove Bond */
534   int (*remove_bond)(const RawAddress* bd_addr);
535 
536   /** Cancel Bond */
537   int (*cancel_bond)(const RawAddress* bd_addr);
538 
539   /**
540    * Get the connection status for a given remote device.
541    * return value of 0 means the device is not connected,
542    * non-zero return status indicates an active connection.
543    */
544   int (*get_connection_state)(const RawAddress* bd_addr);
545 
546   /** BT Legacy PinKey Reply */
547   /** If accept==FALSE, then pin_len and pin_code shall be 0x0 */
548   int (*pin_reply)(const RawAddress* bd_addr, uint8_t accept, uint8_t pin_len,
549                    bt_pin_code_t* pin_code);
550 
551   /** BT SSP Reply - Just Works, Numeric Comparison and Passkey
552    * passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON &
553    * BT_SSP_VARIANT_CONSENT
554    * For BT_SSP_VARIANT_PASSKEY_ENTRY, if accept==FALSE, then passkey
555    * shall be zero */
556   int (*ssp_reply)(const RawAddress* bd_addr, bt_ssp_variant_t variant,
557                    uint8_t accept, uint32_t passkey);
558 
559   /** Get Bluetooth profile interface */
560   const void* (*get_profile_interface)(const char* profile_id);
561 
562   /** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */
563   /* Configure DUT Mode - Use this mode to enter/exit DUT mode */
564   int (*dut_mode_configure)(uint8_t enable);
565 
566   /* Send any test HCI (vendor-specific) command to the controller. Must be in
567    * DUT Mode */
568   int (*dut_mode_send)(uint16_t opcode, uint8_t* buf, uint8_t len);
569   /** BLE Test Mode APIs */
570   /* opcode MUST be one of: LE_Receiver_Test, LE_Transmitter_Test, LE_Test_End
571    */
572   int (*le_test_mode)(uint16_t opcode, uint8_t* buf, uint8_t len);
573 
574   /** Sets the OS call-out functions that bluedroid needs for alarms and wake
575    * locks. This should be called immediately after a successful |init|.
576    */
577   int (*set_os_callouts)(bt_os_callouts_t* callouts);
578 
579   /** Read Energy info details - return value indicates BT_STATUS_SUCCESS or
580    * BT_STATUS_NOT_READY Success indicates that the VSC command was sent to
581    * controller
582    */
583   int (*read_energy_info)();
584 
585   /**
586    * Native support for dumpsys function
587    * Function is synchronous and |fd| is owned by caller.
588    * |arguments| are arguments which may affect the output, encoded as
589    * UTF-8 strings.
590    */
591   void (*dump)(int fd, const char** arguments);
592 
593   /**
594    * Native support for metrics protobuf dumping. The dumping format will be
595    * raw byte array
596    *
597    * @param output an externally allocated string to dump serialized protobuf
598    */
599   void (*dumpMetrics)(std::string* output);
600 
601   /**
602    * Clear /data/misc/bt_config.conf and erase all stored connections
603    */
604   int (*config_clear)(void);
605 
606   /**
607    * Clear (reset) the dynamic portion of the device interoperability database.
608    */
609   void (*interop_database_clear)(void);
610 
611   /**
612    * Add a new device interoperability workaround for a remote device whose
613    * first |len| bytes of the its device address match |addr|.
614    * NOTE: |feature| has to match an item defined in interop_feature_t
615    * (interop.h).
616    */
617   void (*interop_database_add)(uint16_t feature, const RawAddress* addr,
618                                size_t len);
619 
620   /**
621    * Get the AvrcpTarget Service interface to interact with the Avrcp Service
622    */
623   bluetooth::avrcp::ServiceInterface* (*get_avrcp_service)(void);
624 
625   /**
626    * Obfuscate Bluetooth MAC address into a PII free ID string
627    *
628    * @param address Bluetooth MAC address to be obfuscated
629    * @return a string of uint8_t that is unique to this MAC address
630    */
631   std::string (*obfuscate_address)(const RawAddress& address);
632 
633   /**
634    * Get an incremental id for as primary key for Bluetooth metric and log
635    *
636    * @param address Bluetooth MAC address of Bluetooth device
637    * @return int incremental Bluetooth id
638    */
639   int (*get_metric_id)(const RawAddress& address);
640 } bt_interface_t;
641 
642 #define BLUETOOTH_INTERFACE_STRING "bluetoothInterface"
643 
644 #endif /* ANDROID_INCLUDE_BLUETOOTH_H */
645