From 426886af6120d822838cac5c96b5b206f673d6b9 Mon Sep 17 00:00:00 2001 From: Martin Brabham Date: Tue, 8 Sep 2020 13:09:21 -0700 Subject: [PATCH] Add in metrics calls Bug: 162984360 Tag: #gd-refactor Test: cert/run --host SecurityTest Test: atest --host bluetooth_test_gd Test: Manual testing with hybrid stack Change-Id: I454fd60e8ff669a73407d65e601519b8bf0331e0 --- main/shim/btm_api.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main/shim/btm_api.cc b/main/shim/btm_api.cc index 8e478ef39..46004319a 100644 --- a/main/shim/btm_api.cc +++ b/main/shim/btm_api.cc @@ -20,6 +20,7 @@ #include +#include "common/metric_id_allocator.h" #include "common/time_util.h" #include "device/include/controller.h" #include "gd/common/callback.h" @@ -36,6 +37,8 @@ #include "stack/btm/btm_int_types.h" #include "types/raw_address.h" +using bluetooth::common::MetricIdAllocator; + #define BTIF_DM_DEFAULT_INQ_MAX_RESULTS 0 #define BTIF_DM_DEFAULT_INQ_MAX_DURATION 10 @@ -429,12 +432,21 @@ class ShimBondListener : public bluetooth::security::ISecurityManagerListener { bluetooth::ToRawAddress(device.GetAddress()), 0, name, BTM_SUCCESS); } } + MetricIdAllocator::GetInstance().AllocateId( + bluetooth::ToRawAddress(device.GetAddress())); + if (!MetricIdAllocator::GetInstance().SaveDevice( + bluetooth::ToRawAddress(device.GetAddress()))) { + LOG(FATAL) << __func__ << ": Fail to save metric id for device " + << bluetooth::ToRawAddress(device.GetAddress()); + } } void OnDeviceUnbonded(bluetooth::hci::AddressWithType device) override { if (bta_callbacks_->p_bond_cancel_cmpl_callback) { (*bta_callbacks_->p_bond_cancel_cmpl_callback)(BTM_SUCCESS); } + MetricIdAllocator::GetInstance().ForgetDevice( + bluetooth::ToRawAddress(device.GetAddress())); } void OnDeviceBondFailed(bluetooth::hci::AddressWithType device) override { -- 2.11.0