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 30 bool fileExists(const std::string &path); 31 std::shared_ptr<IStats> getStatsService(); 32 33 enum ReportEventType { 34 EvtFGAbnormalEvent = 0x4142, /* AB */ 35 EvtFGLearningHistory = 0x4C48, /* LH */ 36 EvtGMSR = 0xFFFF, /* GMSR */ 37 EvtModelLoading = 0x4D4C, /* ML */ 38 EvtHistoryValidation = 0x4856, /* HV */ 39 EvtFGRegularMonitor = 0x524D, /* RM */ 40 }; 41 42 enum ReportEventFormat { 43 FormatAddrWithVal, 44 FormatIgnoreAddr, 45 FormatNoAddr, 46 }; 47 48 void reportSpeakerImpedance(const std::shared_ptr<IStats> &stats_client, 49 const PixelAtoms::VendorSpeakerImpedance &speakerImpedance); 50 51 void reportSlowIo(const std::shared_ptr<IStats> &stats_client, 52 const PixelAtoms::VendorSlowIo &slowIo); 53 54 void reportChargeCycles(const std::shared_ptr<IStats> &stats_client, 55 const std::vector<int32_t> &chargeCycles); 56 57 void reportHardwareFailed(const std::shared_ptr<IStats> &stats_client, 58 const PixelAtoms::VendorHardwareFailed &failure); 59 60 void reportSpeechDspStat(const std::shared_ptr<IStats> &stats_client, 61 const PixelAtoms::VendorSpeechDspStat &dsp_stats); 62 63 void reportUsbPortOverheat(const std::shared_ptr<IStats> &stats_client, 64 const PixelAtoms::VendorUsbPortOverheat &overheat_info); 65 66 void reportSpeakerHealthStat(const std::shared_ptr<IStats> &stats_client, 67 const PixelAtoms::VendorSpeakerStatsReported &speakerHealthStat); 68 69 void reportUsbDataSessionEvent(const std::shared_ptr<IStats> &stats_client, 70 const PixelAtoms::VendorUsbDataSessionEvent &usb_session); 71 void readLogbuffer(const std::string &buf_path, int num_fields, uint16_t code, 72 enum ReportEventFormat format, unsigned int last_check_time, 73 std::vector<std::vector<uint16_t>> &events); 74 75 void readLogbuffer(const std::string &buf_path, int num_fields, const char *code, 76 enum ReportEventFormat format, unsigned int last_check_time, 77 std::vector<std::vector<uint16_t>> &events); 78 } // namespace pixel 79 } // namespace google 80 } // namespace hardware 81 } // namespace android 82 83 #endif // HARDWARE_GOOGLE_PIXEL_PIXELSTATS_STATSHELPER_H 84