1 /* 2 * Copyright (C) 2021 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_STATSHELPER_H 18 #define HARDWARE_GOOGLE_PIXEL_PIXELSTATS_STATSHELPER_H 19 20 #include <aidl/android/frameworks/stats/IStats.h> 21 #include <hardware/google/pixel/pixelstats/pixelatoms.pb.h> 22 23 namespace android { 24 namespace hardware { 25 namespace google { 26 namespace pixel { 27 28 using aidl::android::frameworks::stats::IStats; 29 using aidl::android::frameworks::stats::VendorAtom; 30 using aidl::android::frameworks::stats::VendorAtomValue; 31 32 bool fileExists(const std::string &path); 33 std::shared_ptr<IStats> getStatsService(); 34 35 enum ReportEventType { 36 EvtFGAbnormalEvent = 0x4142, /* AB */ 37 EvtFwUpdate = 0x4655, /* FU */ 38 EvtHistoryValidation = 0x4856, /* HV */ 39 EvtFGLearningHistory = 0x4C48, /* LH */ 40 EvtModelLoading = 0x4D4C, /* ML */ 41 EvtFGRegularMonitor = 0x524D, /* RM */ 42 EvtGMSR = 0xFFFF, /* GMSR */ 43 EvtWlcFwUpdate = 0x574C, /* WL */ 44 }; 45 46 enum ReportEventFormat { 47 FormatAddrWithVal, 48 FormatIgnoreAddr, 49 FormatOnlyVal, 50 }; 51 52 void reportVendorAtom(const std::shared_ptr<IStats> &stats_client, VendorAtom event); 53 54 void reportSpeakerImpedance(const std::shared_ptr<IStats> &stats_client, 55 const PixelAtoms::VendorSpeakerImpedance &speakerImpedance); 56 57 void reportSlowIo(const std::shared_ptr<IStats> &stats_client, 58 const PixelAtoms::VendorSlowIo &slowIo); 59 60 void reportChargeCycles(const std::shared_ptr<IStats> &stats_client, 61 const std::vector<int32_t> &chargeCycles); 62 63 void reportHardwareFailed(const std::shared_ptr<IStats> &stats_client, 64 const PixelAtoms::VendorHardwareFailed &failure); 65 66 void reportSpeechDspStat(const std::shared_ptr<IStats> &stats_client, 67 const PixelAtoms::VendorSpeechDspStat &dsp_stats); 68 69 void reportUsbPortOverheat(const std::shared_ptr<IStats> &stats_client, 70 const PixelAtoms::VendorUsbPortOverheat &overheat_info); 71 72 void reportSpeakerHealthStat(const std::shared_ptr<IStats> &stats_client, 73 const PixelAtoms::VendorSpeakerStatsReported &speakerHealthStat); 74 75 void reportUsbDataSessionEvent(const std::shared_ptr<IStats> &stats_client, 76 const PixelAtoms::VendorUsbDataSessionEvent &usb_session); 77 78 void readLogbuffer(const std::string &buf_path, int num_fields, uint16_t code, 79 enum ReportEventFormat format, unsigned int last_check_time, 80 std::vector<std::vector<uint32_t>> &events); 81 82 void setAtomFieldValue(std::vector<VendorAtomValue> *values, int offset, int content); 83 84 } // namespace pixel 85 } // namespace google 86 } // namespace hardware 87 } // namespace android 88 89 #endif // HARDWARE_GOOGLE_PIXEL_PIXELSTATS_STATSHELPER_H 90