• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 HARDWARE_GOOGLE_PIXEL_PIXELSTATS_BATTERYFWUPDATEREPORTER_H
18  #define HARDWARE_GOOGLE_PIXEL_PIXELSTATS_BATTERYFWUPDATEREPORTER_H
19 
20 #include <cstdint>
21 #include <string>
22 
23 #include <aidl/android/frameworks/stats/IStats.h>
24 #include <pixelstats/StatsHelper.h>
25 
26 namespace android {
27 namespace hardware {
28 namespace google {
29 namespace pixel {
30 
31 using aidl::android::frameworks::stats::IStats;
32 using aidl::android::frameworks::stats::VendorAtomValue;
33 
34 class BatteryFwUpdateReporter {
35   public:
36     BatteryFwUpdateReporter();
37 
38     void checkAndReportFwUpdate(const std::shared_ptr<IStats> &stats_client,
39                                 const std::vector<std::string> &paths,
40                                 const ReportEventType &event_type);
41 
42   private:
43 
44     struct BatteryFwUpdatePipeline {
45       int32_t msg_type;
46       int32_t msg_category;
47       int32_t major_version_from;
48       int32_t minor_version_from;
49       int32_t major_version_to;
50       int32_t minor_version_to;
51       int32_t update_status;
52       int32_t attempts;
53       int32_t unix_time_sec;
54       int32_t fw_data0;
55       int32_t fw_data1;
56       int32_t fw_data2;
57       int32_t fw_data3;
58     };
59 
60     static constexpr unsigned int kNumMaxFwUpdatePaths = 2;
61     unsigned int last_check_[kNumMaxFwUpdatePaths] = {0};
62     void reportEvent(const std::shared_ptr<IStats> &stats_client,
63                      struct BatteryFwUpdatePipeline &data);
64 
65     const int kNumFwUpdatePipelineFields = sizeof(BatteryFwUpdatePipeline) / sizeof(int32_t);
66 };
67 
68 }  // namespace pixel
69 }  // namespace google
70 }  // namespace hardware
71 }  // namespace android
72 
73  #endif  // HARDWARE_GOOGLE_PIXEL_PIXELSTATS_BATTERYFWUPDATEREPORTER_H
74