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) { metrics::LogMetricsAdapterStateChanged(state); }
30
bond_create_attempt(RawAddress addr,uint32_t device_type)31 void bond_create_attempt(RawAddress addr, uint32_t device_type) {
32 metrics::LogMetricsBondCreateAttempt(&addr, device_type);
33 }
34
bond_state_changed(RawAddress addr,uint32_t device_type,uint32_t status,uint32_t bond_state,int32_t fail_reason)35 void bond_state_changed(RawAddress addr, uint32_t device_type, uint32_t status, uint32_t bond_state,
36 int32_t fail_reason) {
37 metrics::LogMetricsBondStateChanged(&addr, device_type, status, bond_state, fail_reason);
38 }
39
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)40 void device_info_report(RawAddress addr, uint32_t device_type, uint32_t class_of_device,
41 uint32_t appearance, uint32_t vendor_id, uint32_t vendor_id_src,
42 uint32_t product_id, uint32_t version) {
43 metrics::LogMetricsDeviceInfoReport(&addr, device_type, class_of_device, appearance, vendor_id,
44 vendor_id_src, product_id, version);
45 }
46
profile_connection_state_changed(RawAddress addr,uint32_t profile,uint32_t status,uint32_t state)47 void profile_connection_state_changed(RawAddress addr, uint32_t profile, uint32_t status,
48 uint32_t state) {
49 metrics::LogMetricsProfileConnectionStateChanged(&addr, profile, status, state);
50 }
51
acl_connect_attempt(RawAddress addr,uint32_t acl_state)52 void acl_connect_attempt(RawAddress addr, uint32_t acl_state) {
53 metrics::LogMetricsAclConnectAttempt(&addr, acl_state);
54 }
55
acl_connection_state_changed(RawAddress addr,uint32_t transport,uint32_t status,uint32_t acl_state,uint32_t direction,uint32_t hci_reason)56 void acl_connection_state_changed(RawAddress addr, uint32_t transport, uint32_t status,
57 uint32_t acl_state, uint32_t direction, uint32_t hci_reason) {
58 metrics::LogMetricsAclConnectionStateChanged(&addr, transport, status, acl_state, direction,
59 hci_reason);
60 }
61
suspend_complete_state(uint32_t state)62 void suspend_complete_state(uint32_t state) { metrics::LogMetricsSuspendIdState(state); }
63
64 } // namespace rust
65 } // namespace topshim
66 } // namespace bluetooth
67