From b819e4e7e5bdf9ec867e682dd73f06848bb8eff4 Mon Sep 17 00:00:00 2001
From: wescande <wescande@google.com>
Date: Tue, 27 Jul 2021 11:15:49 +0200
Subject: [PATCH] Add more information for bond and acl state change

Report hci error to java. Report transport type to java.
Add both information to log

Test: Manual
Bug: 193685554
Fix: 193685554
Tag: #feature
Merged-In: I4fa3b45d88243f7fc5179971b75acdc28b8761b2
Change-Id: I4fa3b45d88243f7fc5179971b75acdc28b8761b2
---
 system/bta/dm/bta_dm_act.cc                   |  2 ++
 system/bta/include/bta_api.h                  |  2 ++
 system/btif/include/btif_common.h             |  5 ++--
 system/btif/src/bluetooth.cc                  | 27 ++++++++++---------
 system/btif/src/btif_dm.cc                    | 20 +++++++++-----
 system/btif/test/btif_core_test.cc            |  4 +--
 system/btif/test/btif_stack_test.cc           |  5 ++--
 system/gd/rust/linux/stack/src/bluetooth.rs   | 16 +++++++++--
 system/gd/rust/topshim/src/btif.rs            |  8 +++---
 system/include/hardware/bluetooth.h           |  4 ++-
 system/service/adapter.cc                     |  5 ++--
 system/service/hal/bluetooth_interface.cc     | 17 +++++++-----
 system/service/hal/bluetooth_interface.h      |  4 ++-
 .../service/hal/fake_bluetooth_interface.cc   |  5 ++--
 system/service/hal/fake_bluetooth_interface.h |  1 +
 system/service/test/adapter_unittest.cc       | 19 ++++++-------
 system/test/headless/headless.cc              |  5 ++--
 17 files changed, 93 insertions(+), 56 deletions(-)

diff --git a/system/bta/dm/bta_dm_act.cc b/system/bta/dm/bta_dm_act.cc
index f1e1ed8a2aa..4c5aee329a0 100644
--- a/system/bta/dm/bta_dm_act.cc
+++ b/system/bta/dm/bta_dm_act.cc
@@ -2435,6 +2435,7 @@ void bta_dm_acl_up(const RawAddress& bd_addr, tBT_TRANSPORT transport) {
     tBTA_DM_SEC conn;
     memset(&conn, 0, sizeof(tBTA_DM_SEC));
     conn.link_up.bd_addr = bd_addr;
+    conn.link_up.transport_link_type = transport;
 
     bta_dm_cb.p_sec_cback(BTA_DM_LINK_UP_EVT, &conn);
     LOG_DEBUG("Executed security callback for new connection available");
@@ -2521,6 +2522,7 @@ static void bta_dm_acl_down(const RawAddress& bd_addr,
     tBTA_DM_SEC conn;
     memset(&conn, 0, sizeof(tBTA_DM_SEC));
     conn.link_down.bd_addr = bd_addr;
+    conn.link_down.transport_link_type = transport;
 
     bta_dm_cb.p_sec_cback(BTA_DM_LINK_DOWN_EVT, &conn);
     if (issue_unpair_cb) bta_dm_cb.p_sec_cback(BTA_DM_DEV_UNPAIRED_EVT, &conn);
diff --git a/system/bta/include/bta_api.h b/system/bta/include/bta_api.h
index c390ed64e0b..30e315c68c2 100644
--- a/system/bta/include/bta_api.h
+++ b/system/bta/include/bta_api.h
@@ -303,11 +303,13 @@ typedef struct {
 /* Structure associated with BTA_DM_LINK_UP_EVT */
 typedef struct {
   RawAddress bd_addr; /* BD address peer device. */
+  tBT_TRANSPORT transport_link_type;
 } tBTA_DM_LINK_UP;
 
 /* Structure associated with BTA_DM_LINK_DOWN_EVT */
 typedef struct {
   RawAddress bd_addr; /* BD address peer device. */
+  tBT_TRANSPORT transport_link_type;
 } tBTA_DM_LINK_DOWN;
 
 #define BTA_AUTH_SP_YES                                                       \
diff --git a/system/btif/include/btif_common.h b/system/btif/include/btif_common.h
index 73f3428a797..da87283c8bf 100644
--- a/system/btif/include/btif_common.h
+++ b/system/btif/include/btif_common.h
@@ -214,9 +214,10 @@ void invoke_oob_data_request_cb(tBT_TRANSPORT t, bool valid, Octet16 c,
                                 Octet16 r, RawAddress raw_address,
                                 uint8_t address_type);
 void invoke_bond_state_changed_cb(bt_status_t status, RawAddress bd_addr,
-                                  bt_bond_state_t state);
+                                  bt_bond_state_t state, int fail_reason);
 void invoke_acl_state_changed_cb(bt_status_t status, RawAddress bd_addr,
-                                 bt_acl_state_t state, bt_hci_error_code_t hci_reason);
+                                 bt_acl_state_t state, int transport_link_type,
+                                 bt_hci_error_code_t hci_reason);
 void invoke_thread_evt_cb(bt_cb_thread_evt event);
 void invoke_le_test_mode_cb(bt_status_t status, uint16_t count);
 void invoke_energy_info_cb(bt_activity_energy_info energy_info,
diff --git a/system/btif/src/bluetooth.cc b/system/btif/src/bluetooth.cc
index 1184d7b4fe4..7e6d70de482 100644
--- a/system/btif/src/bluetooth.cc
+++ b/system/btif/src/bluetooth.cc
@@ -784,28 +784,29 @@ void invoke_oob_data_request_cb(tBT_TRANSPORT t, bool valid, Octet16 c,
 }
 
 void invoke_bond_state_changed_cb(bt_status_t status, RawAddress bd_addr,
-                                  bt_bond_state_t state) {
-  do_in_jni_thread(
-      FROM_HERE,
-      base::BindOnce(
-          [](bt_status_t status, RawAddress bd_addr, bt_bond_state_t state) {
-            HAL_CBACK(bt_hal_cbacks, bond_state_changed_cb, status, &bd_addr,
-                      state);
-          },
-          status, bd_addr, state));
+                                  bt_bond_state_t state, int fail_reason) {
+  do_in_jni_thread(FROM_HERE, base::BindOnce(
+                                  [](bt_status_t status, RawAddress bd_addr,
+                                     bt_bond_state_t state, int fail_reason) {
+                                    HAL_CBACK(bt_hal_cbacks,
+                                              bond_state_changed_cb, status,
+                                              &bd_addr, state, fail_reason);
+                                  },
+                                  status, bd_addr, state, fail_reason));
 }
 
 void invoke_acl_state_changed_cb(bt_status_t status, RawAddress bd_addr,
-                                 bt_acl_state_t state, bt_hci_error_code_t hci_reason) {
+                                 bt_acl_state_t state, int transport_link_type,
+                                 bt_hci_error_code_t hci_reason) {
   do_in_jni_thread(
       FROM_HERE,
       base::BindOnce(
           [](bt_status_t status, RawAddress bd_addr, bt_acl_state_t state,
-             bt_hci_error_code_t hci_reason) {
+             int transport_link_type, bt_hci_error_code_t hci_reason) {
             HAL_CBACK(bt_hal_cbacks, acl_state_changed_cb, status, &bd_addr,
-                      state, hci_reason);
+                      state, transport_link_type, hci_reason);
           },
-          status, bd_addr, state, hci_reason));
+          status, bd_addr, state, transport_link_type, hci_reason));
 }
 
 void invoke_thread_evt_cb(bt_cb_thread_evt event) {
diff --git a/system/btif/src/btif_dm.cc b/system/btif/src/btif_dm.cc
index e6607ca5c0d..0730f2d17ba 100644
--- a/system/btif/src/btif_dm.cc
+++ b/system/btif/src/btif_dm.cc
@@ -129,6 +129,7 @@ typedef struct {
   bool is_le_only;
   bool is_le_nc; /* LE Numeric comparison */
   btif_dm_ble_cb_t ble;
+  uint8_t fail_reason;
 } btif_dm_pairing_cb_t;
 
 // TODO(jpawlowski): unify ?
@@ -444,7 +445,8 @@ static void bond_state_changed(bt_status_t status, const RawAddress& bd_addr,
   if ((pairing_cb.state == state) && (state == BT_BOND_STATE_BONDING)) {
     // Cross key pairing so send callback for static address
     if (!pairing_cb.static_bdaddr.IsEmpty()) {
-      invoke_bond_state_changed_cb(status, bd_addr, state);
+      invoke_bond_state_changed_cb(status, bd_addr, state,
+                                   pairing_cb.fail_reason);
     }
     return;
   }
@@ -467,7 +469,7 @@ static void bond_state_changed(bt_status_t status, const RawAddress& bd_addr,
                  << bd_addr;
     }
   }
-  invoke_bond_state_changed_cb(status, bd_addr, state);
+  invoke_bond_state_changed_cb(status, bd_addr, state, pairing_cb.fail_reason);
 
   int dev_type;
   if (!btif_get_device_type(bd_addr, &dev_type)) {
@@ -920,6 +922,8 @@ static void btif_dm_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) {
                    pairing_cb.state, p_auth_cmpl->success,
                    p_auth_cmpl->key_present);
 
+  pairing_cb.fail_reason = p_auth_cmpl->fail_reason;
+
   RawAddress bd_addr = p_auth_cmpl->bd_addr;
   if (!bluetooth::shim::is_gd_security_enabled()) {
     if ((p_auth_cmpl->success) && (p_auth_cmpl->key_present)) {
@@ -1573,8 +1577,9 @@ static void btif_dm_upstreams_evt(uint16_t event, char* p_param) {
 
       btif_update_remote_version_property(&bd_addr);
 
-      invoke_acl_state_changed_cb(BT_STATUS_SUCCESS, bd_addr,
-                                  BT_ACL_STATE_CONNECTED, HCI_SUCCESS);
+      invoke_acl_state_changed_cb(
+          BT_STATUS_SUCCESS, bd_addr, BT_ACL_STATE_CONNECTED,
+          (int)p_data->link_up.transport_link_type, HCI_SUCCESS);
       break;
 
     case BTA_DM_LINK_DOWN_EVT:
@@ -1582,9 +1587,10 @@ static void btif_dm_upstreams_evt(uint16_t event, char* p_param) {
       btm_set_bond_type_dev(p_data->link_down.bd_addr,
                             tBTM_SEC_DEV_REC::BOND_TYPE_UNKNOWN);
       btif_av_acl_disconnected(bd_addr);
-      invoke_acl_state_changed_cb(BT_STATUS_SUCCESS, bd_addr,
-                                  BT_ACL_STATE_DISCONNECTED,
-                                  static_cast<bt_hci_error_code_t>(btm_get_acl_disc_reason_code()));
+      invoke_acl_state_changed_cb(
+          BT_STATUS_SUCCESS, bd_addr, BT_ACL_STATE_DISCONNECTED,
+          (int)p_data->link_down.transport_link_type,
+          static_cast<bt_hci_error_code_t>(btm_get_acl_disc_reason_code()));
       LOG_DEBUG(
           "Sent BT_ACL_STATE_DISCONNECTED upward as ACL link down event "
           "device:%s reason:%s",
diff --git a/system/btif/test/btif_core_test.cc b/system/btif/test/btif_core_test.cc
index cbf62f24a69..0f197f07696 100644
--- a/system/btif/test/btif_core_test.cc
+++ b/system/btif/test/btif_core_test.cc
@@ -53,9 +53,9 @@ void ssp_request_callback(RawAddress* remote_bd_addr, bt_bdname_t* bd_name,
                           uint32_t cod, bt_ssp_variant_t pairing_variant,
                           uint32_t pass_key) {}
 void bond_state_changed_callback(bt_status_t status, RawAddress* remote_bd_addr,
-                                 bt_bond_state_t state) {}
+                                 bt_bond_state_t state, int fail_reason) {}
 void acl_state_changed_callback(bt_status_t status, RawAddress* remote_bd_addr,
-                                bt_acl_state_t state,
+                                bt_acl_state_t state, int transport_link_type,
                                 bt_hci_error_code_t hci_reason) {}
 void link_quality_report_callback(uint64_t timestamp, int report_id, int rssi,
                                   int snr, int retransmission_count,
diff --git a/system/btif/test/btif_stack_test.cc b/system/btif/test/btif_stack_test.cc
index 4829375bc73..52f861fd418 100644
--- a/system/btif/test/btif_stack_test.cc
+++ b/system/btif/test/btif_stack_test.cc
@@ -72,13 +72,14 @@ void ssp_request(RawAddress* remote_bd_addr, bt_bdname_t* bd_name, uint32_t cod,
 /** Bluetooth Bond state changed callback */
 /* Invoked in response to create_bond, cancel_bond or remove_bond */
 void bond_state_changed(bt_status_t status, RawAddress* remote_bd_addr,
-                        bt_bond_state_t state) {
+                        bt_bond_state_t state, int fail_reason) {
   LOG_INFO("Callback rx");
 }
 
 /** Bluetooth ACL connection state changed callback */
 void acl_state_changed(bt_status_t status, RawAddress* remote_bd_addr,
-                       bt_acl_state_t state, bt_hci_error_code_t hci_reason) {
+                       bt_acl_state_t state, int transport_link_type,
+                       bt_hci_error_code_t hci_reason) {
   LOG_INFO("status:%s device:%s state:%s", bt_status_text(status).c_str(),
            remote_bd_addr->ToString().c_str(),
            (state) ? "disconnected" : "connected");
diff --git a/system/gd/rust/linux/stack/src/bluetooth.rs b/system/gd/rust/linux/stack/src/bluetooth.rs
index 6c538c649cd..d91d04421d3 100644
--- a/system/gd/rust/linux/stack/src/bluetooth.rs
+++ b/system/gd/rust/linux/stack/src/bluetooth.rs
@@ -195,7 +195,13 @@ pub(crate) trait BtifBluetoothCallbacks {
     );
 
     #[btif_callback(BondState)]
-    fn bond_state(&mut self, status: BtStatus, addr: RawAddress, bond_state: BtBondState);
+    fn bond_state(
+        &mut self,
+        status: BtStatus,
+        addr: RawAddress,
+        bond_state: BtBondState,
+        fail_reason: i32,
+    );
 }
 
 pub fn get_bt_dispatcher(tx: Sender<Message>) -> BaseCallbacksDispatcher {
@@ -274,7 +280,13 @@ impl BtifBluetoothCallbacks for Bluetooth {
         self.intf.lock().unwrap().ssp_reply(&remote_addr, variant, 1, passkey);
     }
 
-    fn bond_state(&mut self, _status: BtStatus, mut addr: RawAddress, bond_state: BtBondState) {
+    fn bond_state(
+        &mut self,
+        _status: BtStatus,
+        mut addr: RawAddress,
+        bond_state: BtBondState,
+        fail_reason: i32,
+    ) {
         if bond_state == BtBondState::Bonded {
             // We are assuming that peer is a HID device and automatically connect to that profile.
             // TODO: Only connect to enabled profiles on that device.
diff --git a/system/gd/rust/topshim/src/btif.rs b/system/gd/rust/topshim/src/btif.rs
index 45f5a6c7445..5d6c2252ee7 100644
--- a/system/gd/rust/topshim/src/btif.rs
+++ b/system/gd/rust/topshim/src/btif.rs
@@ -364,8 +364,8 @@ pub enum BaseCallbacks {
     DiscoveryState(BtDiscoveryState),
     PinRequest(RawAddress, String, u32, bool),
     SspRequest(RawAddress, String, u32, BtSspVariant, u32),
-    BondState(BtStatus, RawAddress, BtBondState),
-    AclState(BtStatus, RawAddress, BtAclState, BtHciErrorCode),
+    BondState(BtStatus, RawAddress, BtBondState, i32),
+    AclState(BtStatus, RawAddress, BtAclState, i32, BtHciErrorCode),
     // Unimplemented so far:
     // thread_evt_cb
     // dut_mode_recv_cb
@@ -408,11 +408,11 @@ cb_variant!(BaseCb, ssp_request_cb -> BaseCallbacks::SspRequest,
     let _1 = String::from(unsafe{*_1});
 });
 cb_variant!(BaseCb, bond_state_cb -> BaseCallbacks::BondState,
-u32 -> BtStatus, *mut FfiAddress, bindings::bt_bond_state_t -> BtBondState, {
+u32 -> BtStatus, *mut FfiAddress, bindings::bt_bond_state_t -> BtBondState, i32, {
     let _1 = unsafe { *(_1 as *const RawAddress) };
 });
 cb_variant!(BaseCb, acl_state_cb -> BaseCallbacks::AclState,
-u32 -> BtStatus, *mut FfiAddress, bindings::bt_acl_state_t -> BtAclState, bindings::bt_hci_error_code_t -> BtHciErrorCode, {
+u32 -> BtStatus, *mut FfiAddress, bindings::bt_acl_state_t -> BtAclState, i32, bindings::bt_hci_error_code_t -> BtHciErrorCode, {
     let _1 = unsafe { *(_1 as *const RawAddress) };
 });
 
diff --git a/system/include/hardware/bluetooth.h b/system/include/hardware/bluetooth.h
index d3103e3a0ae..b015c8eee1e 100644
--- a/system/include/hardware/bluetooth.h
+++ b/system/include/hardware/bluetooth.h
@@ -434,12 +434,14 @@ typedef void (*ssp_request_callback)(RawAddress* remote_bd_addr,
 /* Invoked in response to create_bond, cancel_bond or remove_bond */
 typedef void (*bond_state_changed_callback)(bt_status_t status,
                                             RawAddress* remote_bd_addr,
-                                            bt_bond_state_t state);
+                                            bt_bond_state_t state,
+                                            int fail_reason);
 
 /** Bluetooth ACL connection state changed callback */
 typedef void (*acl_state_changed_callback)(bt_status_t status,
                                            RawAddress* remote_bd_addr,
                                            bt_acl_state_t state,
+                                           int transport_link_type,
                                            bt_hci_error_code_t hci_reason);
 
 /** Bluetooth link quality report callback */
diff --git a/system/service/adapter.cc b/system/service/adapter.cc
index 4f324a5f9c1..40ed9dc77e5 100644
--- a/system/service/adapter.cc
+++ b/system/service/adapter.cc
@@ -675,7 +675,8 @@ class AdapterImpl : public Adapter, public hal::BluetoothInterface::Observer {
   }
 
   void BondStateChangedCallback(bt_status_t status, RawAddress* remote_bdaddr,
-                                bt_bond_state_t state) override {
+                                bt_bond_state_t state,
+                                int fail_reason) override {
     std::string device_address = BtAddrString(remote_bdaddr);
 
     lock_guard<mutex> lock(observers_lock_);
@@ -686,7 +687,7 @@ class AdapterImpl : public Adapter, public hal::BluetoothInterface::Observer {
 
   void AclStateChangedCallback(bt_status_t status,
                                const RawAddress& remote_bdaddr,
-                               bt_acl_state_t state,
+                               bt_acl_state_t state, int transport_link_type,
                                bt_hci_error_code_t hci_reason) override {
     std::string device_address = BtAddrString(&remote_bdaddr);
     bool connected = (state == BT_ACL_STATE_CONNECTED);
diff --git a/system/service/hal/bluetooth_interface.cc b/system/service/hal/bluetooth_interface.cc
index 84a17859ee3..f504ee10ddb 100644
--- a/system/service/hal/bluetooth_interface.cc
+++ b/system/service/hal/bluetooth_interface.cc
@@ -137,17 +137,18 @@ void SSPRequestCallback(RawAddress* remote_bd_addr, bt_bdname_t* bd_name,
 }
 
 void BondStateChangedCallback(bt_status_t status, RawAddress* remote_bd_addr,
-                              bt_bond_state_t state) {
+                              bt_bond_state_t state, int fail_reason) {
   shared_lock<shared_mutex_impl> lock(g_instance_lock);
   VERIFY_INTERFACE_OR_RETURN();
   VLOG(2) << __func__ << " - remote_bd_addr: " << BtAddrString(remote_bd_addr)
           << " - status: " << status << " - state: " << state;
   FOR_EACH_BLUETOOTH_OBSERVER(
-      BondStateChangedCallback(status, remote_bd_addr, state));
+      BondStateChangedCallback(status, remote_bd_addr, state, fail_reason));
 }
 
 void AclStateChangedCallback(bt_status_t status, RawAddress* remote_bd_addr,
-                             bt_acl_state_t state, bt_hci_error_code_t hci_reason) {
+                             bt_acl_state_t state, int transport_link_type,
+                             bt_hci_error_code_t hci_reason) {
   shared_lock<shared_mutex_impl> lock(g_instance_lock);
   VERIFY_INTERFACE_OR_RETURN();
   CHECK(remote_bd_addr);
@@ -156,8 +157,8 @@ void AclStateChangedCallback(bt_status_t status, RawAddress* remote_bd_addr,
           << " - BD_ADDR: " << BtAddrString(remote_bd_addr) << " - state: "
           << ((state == BT_ACL_STATE_CONNECTED) ? "CONNECTED" : "DISCONNECTED")
           << " - HCI_REASON: " << std::to_string(hci_reason);
-  FOR_EACH_BLUETOOTH_OBSERVER(
-      AclStateChangedCallback(status, *remote_bd_addr, state, hci_reason));
+  FOR_EACH_BLUETOOTH_OBSERVER(AclStateChangedCallback(
+      status, *remote_bd_addr, state, transport_link_type, hci_reason));
 }
 
 void ThreadEventCallback(bt_cb_thread_evt evt) {
@@ -360,13 +361,15 @@ void BluetoothInterface::Observer::SSPRequestCallback(
 }
 
 void BluetoothInterface::Observer::BondStateChangedCallback(
-    bt_status_t status, RawAddress* remote_bd_addr, bt_bond_state_t state) {
+    bt_status_t status, RawAddress* remote_bd_addr, bt_bond_state_t state,
+    int fail_reason) {
   // Do nothing.
 }
 
 void BluetoothInterface::Observer::AclStateChangedCallback(
     bt_status_t /* status */, const RawAddress& /* remote_bdaddr */,
-    bt_acl_state_t /* state */, bt_hci_error_code_t /* hci_reason */) {
+    bt_acl_state_t /* state */, int /* transport_link_type */,
+    bt_hci_error_code_t /* hci_reason */) {
   // Do nothing.
 }
 
diff --git a/system/service/hal/bluetooth_interface.h b/system/service/hal/bluetooth_interface.h
index aa4125cc909..65d3e45c084 100644
--- a/system/service/hal/bluetooth_interface.h
+++ b/system/service/hal/bluetooth_interface.h
@@ -69,10 +69,12 @@ class BluetoothInterface {
                                     uint32_t pass_key);
     virtual void BondStateChangedCallback(bt_status_t status,
                                           RawAddress* remote_bd_addr,
-                                          bt_bond_state_t state);
+                                          bt_bond_state_t state,
+                                          int fail_reason);
     virtual void AclStateChangedCallback(bt_status_t status,
                                          const RawAddress& remote_bdaddr,
                                          bt_acl_state_t state,
+                                         int transport_link_type,
                                          bt_hci_error_code_t hci_reason);
     virtual void LinkQualityReportCallback(
         uint64_t timestamp, int report_id, int rssi, int snr,
diff --git a/system/service/hal/fake_bluetooth_interface.cc b/system/service/hal/fake_bluetooth_interface.cc
index 5e7d5e8e8e5..8a905bed28d 100644
--- a/system/service/hal/fake_bluetooth_interface.cc
+++ b/system/service/hal/fake_bluetooth_interface.cc
@@ -143,9 +143,10 @@ void FakeBluetoothInterface::NotifyAdapterLocalLeFeaturesPropertyChanged(
 
 void FakeBluetoothInterface::NotifyAclStateChangedCallback(
     bt_status_t status, const RawAddress& remote_bdaddr, bt_acl_state_t state,
-    bt_hci_error_code_t hci_reason) {
+    int transport_link_type, bt_hci_error_code_t hci_reason) {
   for (auto& observer : observers_) {
-    observer.AclStateChangedCallback(status, remote_bdaddr, state, hci_reason);
+    observer.AclStateChangedCallback(status, remote_bdaddr, state,
+                                     transport_link_type, hci_reason);
   }
 }
 
diff --git a/system/service/hal/fake_bluetooth_interface.h b/system/service/hal/fake_bluetooth_interface.h
index 0fc0aa1976d..7ff8e15e968 100644
--- a/system/service/hal/fake_bluetooth_interface.h
+++ b/system/service/hal/fake_bluetooth_interface.h
@@ -58,6 +58,7 @@ class FakeBluetoothInterface : public BluetoothInterface {
   void NotifyAclStateChangedCallback(bt_status_t status,
                                      const RawAddress& remote_bdaddr,
                                      bt_acl_state_t state,
+                                     int transport_link_type,
                                      bt_hci_error_code_t hci_reason);
 
   // hal::BluetoothInterface overrides:
diff --git a/system/service/test/adapter_unittest.cc b/system/service/test/adapter_unittest.cc
index 5abd08eee5c..23d46a026db 100644
--- a/system/service/test/adapter_unittest.cc
+++ b/system/service/test/adapter_unittest.cc
@@ -20,6 +20,7 @@
 #include "service/adapter.h"
 #include "service/hal/fake_bluetooth_gatt_interface.h"
 #include "service/hal/fake_bluetooth_interface.h"
+#include "types/bt_transport.h"
 
 namespace bluetooth {
 namespace {
@@ -258,25 +259,25 @@ TEST_F(AdapterTest, IsDeviceConnected) {
   ASSERT_TRUE(RawAddress::FromString(kDeviceAddr, hal_addr));
 
   // status != BT_STATUS_SUCCESS should be ignored
-  fake_hal_iface_->NotifyAclStateChangedCallback(BT_STATUS_FAIL, hal_addr,
-                                                 BT_ACL_STATE_CONNECTED,
-                                                 0xff); // HCI_ERR_UNDEFINED
+  fake_hal_iface_->NotifyAclStateChangedCallback(
+      BT_STATUS_FAIL, hal_addr, BT_ACL_STATE_CONNECTED, BT_TRANSPORT_LE,
+      0xff);  // HCI_ERR_UNDEFINED
   EXPECT_FALSE(adapter_->IsDeviceConnected(kDeviceAddr));
   EXPECT_TRUE(observer.last_connection_state_address().empty());
   EXPECT_FALSE(observer.last_device_connected_state());
 
   // Connected
-  fake_hal_iface_->NotifyAclStateChangedCallback(BT_STATUS_SUCCESS, hal_addr,
-                                                 BT_ACL_STATE_CONNECTED,
-                                                 0x00); // HCI_SUCCESS
+  fake_hal_iface_->NotifyAclStateChangedCallback(
+      BT_STATUS_SUCCESS, hal_addr, BT_ACL_STATE_CONNECTED, BT_TRANSPORT_LE,
+      0x00);  // HCI_SUCCESS
   EXPECT_TRUE(adapter_->IsDeviceConnected(kDeviceAddr));
   EXPECT_EQ(kDeviceAddr, observer.last_connection_state_address());
   EXPECT_TRUE(observer.last_device_connected_state());
 
   // Disconnected
-  fake_hal_iface_->NotifyAclStateChangedCallback(BT_STATUS_SUCCESS, hal_addr,
-                                                 BT_ACL_STATE_DISCONNECTED,
-                                                 0x16); // HCI_ERR_CONN_CAUSE_LOCAL_HOST
+  fake_hal_iface_->NotifyAclStateChangedCallback(
+      BT_STATUS_SUCCESS, hal_addr, BT_ACL_STATE_DISCONNECTED, BT_TRANSPORT_LE,
+      0x16);  // HCI_ERR_CONN_CAUSE_LOCAL_HOST
   EXPECT_FALSE(adapter_->IsDeviceConnected(kDeviceAddr));
   EXPECT_EQ(kDeviceAddr, observer.last_connection_state_address());
   EXPECT_FALSE(observer.last_device_connected_state());
diff --git a/system/test/headless/headless.cc b/system/test/headless/headless.cc
index a3b54410a80..b4c7753765b 100644
--- a/system/test/headless/headless.cc
+++ b/system/test/headless/headless.cc
@@ -97,13 +97,14 @@ void ssp_request(RawAddress* remote_bd_addr, bt_bdname_t* bd_name, uint32_t cod,
 /** Bluetooth Bond state changed callback */
 /* Invoked in response to create_bond, cancel_bond or remove_bond */
 void bond_state_changed(bt_status_t status, RawAddress* remote_bd_addr,
-                        bt_bond_state_t state) {
+                        bt_bond_state_t state, int fail_reason) {
   LOG_INFO("%s", __func__);
 }
 
 /** Bluetooth ACL connection state changed callback */
 void acl_state_changed(bt_status_t status, RawAddress* remote_bd_addr,
-                       bt_acl_state_t state, bt_hci_error_code_t hci_reason) {
+                       bt_acl_state_t state, int transport_link_type,
+                       bt_hci_error_code_t hci_reason) {
   auto callback_list = interface_api_callback_map_.at(__func__);
   for (auto callback : callback_list) {
     interface_data_t params{
-- 
GitLab