1 /*
2 * Copyright (C) 2022 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 #include "rust/topshim/metrics/metrics_shim.h"
18
19 #include "metrics/metrics.h"
20 #include "src/metrics.rs.h"
21 #include "types/raw_address.h"
22
23 namespace rusty = ::bluetooth::topshim::rust;
24
25 namespace bluetooth {
26 namespace topshim {
27 namespace rust {
28
adapter_state_changed(uint32_t state)29 void adapter_state_changed(uint32_t state) {
30 metrics::LogMetricsAdapterStateChanged(state);
31 }
32
bond_create_attempt(RawAddress addr,uint32_t device_type)33 void bond_create_attempt(RawAddress addr, uint32_t device_type) {
34 metrics::LogMetricsBondCreateAttempt(&addr, device_type);
35 }
36
bond_state_changed(RawAddress addr,uint32_t device_type,uint32_t status,uint32_t bond_state,int32_t fail_reason)37 void bond_state_changed(
38 RawAddress addr, uint32_t device_type, uint32_t status, uint32_t bond_state, int32_t fail_reason) {
39 metrics::LogMetricsBondStateChanged(&addr, device_type, status, bond_state, fail_reason);
40 }
41
device_info_report(RawAddress addr,uint32_t device_type,uint32_t class_of_device,uint32_t appearance,uint32_t vendor_id,uint32_t vendor_id_src,uint32_t product_id,uint32_t version)42 void device_info_report(
43 RawAddress addr,
44 uint32_t device_type,
45 uint32_t class_of_device,
46 uint32_t appearance,
47 uint32_t vendor_id,
48 uint32_t vendor_id_src,
49 uint32_t product_id,
50 uint32_t version) {
51 metrics::LogMetricsDeviceInfoReport(
52 &addr, device_type, class_of_device, appearance, vendor_id, vendor_id_src, product_id, version);
53 }
54
profile_connection_state_changed(RawAddress addr,uint32_t profile,uint32_t status,uint32_t state)55 void profile_connection_state_changed(RawAddress addr, uint32_t profile, uint32_t status, uint32_t state) {
56 metrics::LogMetricsProfileConnectionStateChanged(&addr, profile, status, state);
57 }
58
acl_connect_attempt(RawAddress addr,uint32_t acl_state)59 void acl_connect_attempt(RawAddress addr, uint32_t acl_state) {
60 metrics::LogMetricsAclConnectAttempt(&addr, acl_state);
61 }
62
acl_connection_state_changed(RawAddress addr,uint32_t transport,uint32_t status,uint32_t acl_state,uint32_t direction,uint32_t hci_reason)63 void acl_connection_state_changed(
64 RawAddress addr, uint32_t transport, uint32_t status, uint32_t acl_state, uint32_t direction, uint32_t hci_reason) {
65 metrics::LogMetricsAclConnectionStateChanged(&addr, transport, status, acl_state, direction, hci_reason);
66 }
67
suspend_complete_state(uint32_t state)68 void suspend_complete_state(uint32_t state) {
69 metrics::LogMetricsSuspendIdState(state);
70 }
71
72 } // namespace rust
73 } // namespace topshim
74 } // namespace bluetooth
75