1 /*
2  * Copyright 2023 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 #pragma once
18 
19 #include <cstdint>
20 #include <memory>
21 
22 #include "types/raw_address.h"
23 
24 namespace power_telemetry {
25 
26 struct PowerTelemetryImpl;
27 
28 class PowerTelemetry {
29 public:
30   PowerTelemetry();
31 
32   void RecordLogDataContainer();
33   void LogScanStarted();
34 
35   void LogHciCmdDetail();
36   void LogHciEvtDetail();
37 
38   void LogLinkDetails(uint16_t handle, const RawAddress& bdaddr, bool isConnected,
39                       bool is_acl_link);
40   void LogRxAclPktData(uint16_t len);
41   void LogTxAclPktData(uint16_t len);
42 
43   void LogChannelConnected(uint16_t psm, int32_t src_id, int32_t dst_id, const RawAddress& bd_addr);
44   void LogChannelDisconnected(uint16_t psm, int32_t src_id, int32_t dst_id,
45                               const RawAddress& bd_addr);
46   void LogRxBytes(uint16_t psm, int32_t src_id, int32_t dst_id, const RawAddress& bd_addr,
47                   int32_t num_bytes);
48   void LogTxBytes(uint16_t psm, int32_t src_id, int32_t dst_id, const RawAddress& bd_addr,
49                   int32_t num_bytes);
50 
51   void LogSniffStarted(uint16_t handle, const RawAddress& bdaddr);
52   void LogSniffStopped(uint16_t handle, const RawAddress& bdaddr);
53   void LogAclTxPowerLevel(uint16_t handle, uint8_t txPower);
54   void LogInqScanStarted();
55   void LogInqScanStopped();
56   void LogBleScan(uint16_t num_resps);
57   void LogBleAdvStarted();
58   void LogBleAdvStopped();
59 
60   void LogTxPower(void* res);
61   void LogTrafficData();
62 
63   void Dumpsys(int32_t fd);
64 
65   std::unique_ptr<PowerTelemetryImpl> pimpl_;
66 };
67 
68 PowerTelemetry& GetInstance();
69 
70 }  // namespace power_telemetry
71