xref: /aosp_15_r20/system/chre/core/include/chre/core/telemetry_manager.h (revision 84e339476a462649f82315436d70fd732297a399)
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 #ifndef CHRE_CORE_TELEMETRY_MANAGER_H_
18 #define CHRE_CORE_TELEMETRY_MANAGER_H_
19 
20 #ifdef CHRE_TELEMETRY_SUPPORT_ENABLED
21 
22 #include <cinttypes>
23 
24 #include "chre/util/non_copyable.h"
25 
26 namespace chre {
27 
28 /**
29  * Container class that handles reporting system telemetry metrics to the host.
30  */
31 class TelemetryManager : public NonCopyable {
32  public:
33   /**
34    * Enum type to describe a CHRE PAL.
35    */
36   enum PalType : uint8_t {
37     UNKNOWN = 0,
38     SENSOR,
39     WIFI,
40     GNSS,
41     WWAN,
42     AUDIO,
43     BLE,
44   };
45 
46   TelemetryManager();
47 
48   /**
49    * Sends telemetry data related to a PAL open failure.
50    *
51    * @param type The type of PAL that failed to open.
52    */
53   void onPalOpenFailure(PalType type);
54 
55   /**
56    * Collects system-level metrics to send to the host for logging.
57    */
58   void collectSystemMetrics();
59 
60  private:
61   /**
62    * Schedules a periodic timer to collect system metrics.
63    */
64   void scheduleMetricTimer();
65 };
66 
67 }  // namespace chre
68 
69 #endif  // CHRE_TELEMETRY_SUPPORT_ENABLED
70 
71 #endif  // CHRE_CORE_TELEMETRY_MANAGER_H_
72