Loading services/stats/Android.bp +31 −1 Original line number Diff line number Diff line Loading @@ -29,10 +29,15 @@ cc_library_shared { "libexpresslog", "libhidlbase", "liblog", "libstatslog", "libstatssocket", "libutils", ], generated_sources: [ "statslog_hidl.cpp", ], generated_headers: [ "statslog_hidl.h", ], export_include_dirs: [ "include/", ], Loading @@ -47,3 +52,28 @@ cc_library_shared { "android.frameworks.stats-service.xml", ], } genrule { name: "statslog_hidl.h", tools: ["stats-log-api-gen"], cmd: "$(location stats-log-api-gen)" + " --header $(genDir)/statslog_hidl.h" + " --module statshidl" + " --namespace android,util,statshidl", out: [ "statslog_hidl.h", ], } genrule { name: "statslog_hidl.cpp", tools: ["stats-log-api-gen"], cmd: "$(location stats-log-api-gen)" + " --cpp $(genDir)/statslog_hidl.cpp" + " --module statshidl" + " --namespace android,util,statshidl" + " --importHeader statslog_hidl.h", out: [ "statslog_hidl.cpp", ], } services/stats/StatsAidl.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -26,9 +26,8 @@ #include <log/log.h> #include <stats_annotations.h> #include <stats_event.h> #include <statslog.h> #include <unordered_map> #include <map> namespace { static const char* g_AtomErrorMetricName = Loading Loading @@ -118,8 +117,8 @@ ndk::ScopedAStatus StatsHal::reportVendorAtom(const VendorAtom& vendorAtom) { } } // populate map for quickier access for VendorAtomValue associated annotations by value index std::unordered_map<int, int> fieldIndexToAnnotationSetMap; // populate map for quicker access for VendorAtomValue associated annotations by value index std::map<int, int> fieldIndexToAnnotationSetMap; if (vendorAtom.valuesAnnotations) { const std::vector<std::optional<AnnotationSet>>& valuesAnnotations = *vendorAtom.valuesAnnotations; Loading services/stats/StatsHal.cpp +28 −23 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ #include "StatsHal.h" #include <log/log.h> #include <statslog.h> #include <statslog_hidl.h> namespace android { namespace frameworks { Loading @@ -32,14 +32,16 @@ StatsHal::StatsHal() { } hardware::Return<void> StatsHal::reportSpeakerImpedance(const SpeakerImpedance& speakerImpedance) { android::util::stats_write(android::util::SPEAKER_IMPEDANCE_REPORTED, speakerImpedance.speakerLocation, speakerImpedance.milliOhms); android::util::statshidl::stats_write(android::util::statshidl::SPEAKER_IMPEDANCE_REPORTED, speakerImpedance.speakerLocation, speakerImpedance.milliOhms); return hardware::Void(); } hardware::Return<void> StatsHal::reportHardwareFailed(const HardwareFailed& hardwareFailed) { android::util::stats_write(android::util::HARDWARE_FAILED, int32_t(hardwareFailed.hardwareType), android::util::statshidl::stats_write( android::util::statshidl::HARDWARE_FAILED, int32_t(hardwareFailed.hardwareType), hardwareFailed.hardwareLocation, int32_t(hardwareFailed.errorCode)); return hardware::Void(); Loading @@ -47,9 +49,10 @@ hardware::Return<void> StatsHal::reportHardwareFailed(const HardwareFailed& hard hardware::Return<void> StatsHal::reportPhysicalDropDetected( const PhysicalDropDetected& physicalDropDetected) { android::util::stats_write( android::util::PHYSICAL_DROP_DETECTED, int32_t(physicalDropDetected.confidencePctg), physicalDropDetected.accelPeak, physicalDropDetected.freefallDuration); android::util::statshidl::stats_write(android::util::statshidl::PHYSICAL_DROP_DETECTED, int32_t(physicalDropDetected.confidencePctg), physicalDropDetected.accelPeak, physicalDropDetected.freefallDuration); return hardware::Void(); } Loading @@ -60,19 +63,19 @@ hardware::Return<void> StatsHal::reportChargeCycles(const ChargeCycles& chargeCy for (int i = 0; i < 10 - initialSize; i++) { buckets.push_back(0); // Push 0 for buckets that do not exist. } android::util::stats_write(android::util::CHARGE_CYCLES_REPORTED, buckets[0], buckets[1], buckets[2], buckets[3], buckets[4], buckets[5], buckets[6], buckets[7], buckets[8], buckets[9]); android::util::statshidl::stats_write( android::util::statshidl::CHARGE_CYCLES_REPORTED, buckets[0], buckets[1], buckets[2], buckets[3], buckets[4], buckets[5], buckets[6], buckets[7], buckets[8], buckets[9]); return hardware::Void(); } hardware::Return<void> StatsHal::reportBatteryHealthSnapshot( const BatteryHealthSnapshotArgs& batteryHealthSnapshotArgs) { android::util::stats_write( android::util::BATTERY_HEALTH_SNAPSHOT, int32_t(batteryHealthSnapshotArgs.type), batteryHealthSnapshotArgs.temperatureDeciC, batteryHealthSnapshotArgs.voltageMicroV, batteryHealthSnapshotArgs.currentMicroA, android::util::statshidl::stats_write( android::util::statshidl::BATTERY_HEALTH_SNAPSHOT, int32_t(batteryHealthSnapshotArgs.type), batteryHealthSnapshotArgs.temperatureDeciC, batteryHealthSnapshotArgs.voltageMicroV, batteryHealthSnapshotArgs.currentMicroA, batteryHealthSnapshotArgs.openCircuitVoltageMicroV, batteryHealthSnapshotArgs.resistanceMicroOhm, batteryHealthSnapshotArgs.levelPercent); Loading @@ -80,14 +83,15 @@ hardware::Return<void> StatsHal::reportBatteryHealthSnapshot( } hardware::Return<void> StatsHal::reportSlowIo(const SlowIo& slowIo) { android::util::stats_write(android::util::SLOW_IO, int32_t(slowIo.operation), slowIo.count); android::util::statshidl::stats_write(android::util::statshidl::SLOW_IO, int32_t(slowIo.operation), slowIo.count); return hardware::Void(); } hardware::Return<void> StatsHal::reportBatteryCausedShutdown( const BatteryCausedShutdown& batteryCausedShutdown) { android::util::stats_write(android::util::BATTERY_CAUSED_SHUTDOWN, android::util::statshidl::stats_write(android::util::statshidl::BATTERY_CAUSED_SHUTDOWN, batteryCausedShutdown.voltageMicroV); return hardware::Void(); Loading @@ -95,8 +99,8 @@ hardware::Return<void> StatsHal::reportBatteryCausedShutdown( hardware::Return<void> StatsHal::reportUsbPortOverheatEvent( const UsbPortOverheatEvent& usbPortOverheatEvent) { android::util::stats_write( android::util::USB_PORT_OVERHEAT_EVENT_REPORTED, android::util::statshidl::stats_write( android::util::statshidl::USB_PORT_OVERHEAT_EVENT_REPORTED, usbPortOverheatEvent.plugTemperatureDeciC, usbPortOverheatEvent.maxTemperatureDeciC, usbPortOverheatEvent.timeToOverheat, usbPortOverheatEvent.timeToHysteresis, usbPortOverheatEvent.timeToInactive); Loading @@ -105,9 +109,10 @@ hardware::Return<void> StatsHal::reportUsbPortOverheatEvent( } hardware::Return<void> StatsHal::reportSpeechDspStat(const SpeechDspStat& speechDspStat) { android::util::stats_write(android::util::SPEECH_DSP_STAT_REPORTED, speechDspStat.totalUptimeMillis, speechDspStat.totalDowntimeMillis, speechDspStat.totalCrashCount, speechDspStat.totalRecoverCount); android::util::statshidl::stats_write( android::util::statshidl::SPEECH_DSP_STAT_REPORTED, speechDspStat.totalUptimeMillis, speechDspStat.totalDowntimeMillis, speechDspStat.totalCrashCount, speechDspStat.totalRecoverCount); return hardware::Void(); } Loading Loading
services/stats/Android.bp +31 −1 Original line number Diff line number Diff line Loading @@ -29,10 +29,15 @@ cc_library_shared { "libexpresslog", "libhidlbase", "liblog", "libstatslog", "libstatssocket", "libutils", ], generated_sources: [ "statslog_hidl.cpp", ], generated_headers: [ "statslog_hidl.h", ], export_include_dirs: [ "include/", ], Loading @@ -47,3 +52,28 @@ cc_library_shared { "android.frameworks.stats-service.xml", ], } genrule { name: "statslog_hidl.h", tools: ["stats-log-api-gen"], cmd: "$(location stats-log-api-gen)" + " --header $(genDir)/statslog_hidl.h" + " --module statshidl" + " --namespace android,util,statshidl", out: [ "statslog_hidl.h", ], } genrule { name: "statslog_hidl.cpp", tools: ["stats-log-api-gen"], cmd: "$(location stats-log-api-gen)" + " --cpp $(genDir)/statslog_hidl.cpp" + " --module statshidl" + " --namespace android,util,statshidl" + " --importHeader statslog_hidl.h", out: [ "statslog_hidl.cpp", ], }
services/stats/StatsAidl.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -26,9 +26,8 @@ #include <log/log.h> #include <stats_annotations.h> #include <stats_event.h> #include <statslog.h> #include <unordered_map> #include <map> namespace { static const char* g_AtomErrorMetricName = Loading Loading @@ -118,8 +117,8 @@ ndk::ScopedAStatus StatsHal::reportVendorAtom(const VendorAtom& vendorAtom) { } } // populate map for quickier access for VendorAtomValue associated annotations by value index std::unordered_map<int, int> fieldIndexToAnnotationSetMap; // populate map for quicker access for VendorAtomValue associated annotations by value index std::map<int, int> fieldIndexToAnnotationSetMap; if (vendorAtom.valuesAnnotations) { const std::vector<std::optional<AnnotationSet>>& valuesAnnotations = *vendorAtom.valuesAnnotations; Loading
services/stats/StatsHal.cpp +28 −23 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ #include "StatsHal.h" #include <log/log.h> #include <statslog.h> #include <statslog_hidl.h> namespace android { namespace frameworks { Loading @@ -32,14 +32,16 @@ StatsHal::StatsHal() { } hardware::Return<void> StatsHal::reportSpeakerImpedance(const SpeakerImpedance& speakerImpedance) { android::util::stats_write(android::util::SPEAKER_IMPEDANCE_REPORTED, speakerImpedance.speakerLocation, speakerImpedance.milliOhms); android::util::statshidl::stats_write(android::util::statshidl::SPEAKER_IMPEDANCE_REPORTED, speakerImpedance.speakerLocation, speakerImpedance.milliOhms); return hardware::Void(); } hardware::Return<void> StatsHal::reportHardwareFailed(const HardwareFailed& hardwareFailed) { android::util::stats_write(android::util::HARDWARE_FAILED, int32_t(hardwareFailed.hardwareType), android::util::statshidl::stats_write( android::util::statshidl::HARDWARE_FAILED, int32_t(hardwareFailed.hardwareType), hardwareFailed.hardwareLocation, int32_t(hardwareFailed.errorCode)); return hardware::Void(); Loading @@ -47,9 +49,10 @@ hardware::Return<void> StatsHal::reportHardwareFailed(const HardwareFailed& hard hardware::Return<void> StatsHal::reportPhysicalDropDetected( const PhysicalDropDetected& physicalDropDetected) { android::util::stats_write( android::util::PHYSICAL_DROP_DETECTED, int32_t(physicalDropDetected.confidencePctg), physicalDropDetected.accelPeak, physicalDropDetected.freefallDuration); android::util::statshidl::stats_write(android::util::statshidl::PHYSICAL_DROP_DETECTED, int32_t(physicalDropDetected.confidencePctg), physicalDropDetected.accelPeak, physicalDropDetected.freefallDuration); return hardware::Void(); } Loading @@ -60,19 +63,19 @@ hardware::Return<void> StatsHal::reportChargeCycles(const ChargeCycles& chargeCy for (int i = 0; i < 10 - initialSize; i++) { buckets.push_back(0); // Push 0 for buckets that do not exist. } android::util::stats_write(android::util::CHARGE_CYCLES_REPORTED, buckets[0], buckets[1], buckets[2], buckets[3], buckets[4], buckets[5], buckets[6], buckets[7], buckets[8], buckets[9]); android::util::statshidl::stats_write( android::util::statshidl::CHARGE_CYCLES_REPORTED, buckets[0], buckets[1], buckets[2], buckets[3], buckets[4], buckets[5], buckets[6], buckets[7], buckets[8], buckets[9]); return hardware::Void(); } hardware::Return<void> StatsHal::reportBatteryHealthSnapshot( const BatteryHealthSnapshotArgs& batteryHealthSnapshotArgs) { android::util::stats_write( android::util::BATTERY_HEALTH_SNAPSHOT, int32_t(batteryHealthSnapshotArgs.type), batteryHealthSnapshotArgs.temperatureDeciC, batteryHealthSnapshotArgs.voltageMicroV, batteryHealthSnapshotArgs.currentMicroA, android::util::statshidl::stats_write( android::util::statshidl::BATTERY_HEALTH_SNAPSHOT, int32_t(batteryHealthSnapshotArgs.type), batteryHealthSnapshotArgs.temperatureDeciC, batteryHealthSnapshotArgs.voltageMicroV, batteryHealthSnapshotArgs.currentMicroA, batteryHealthSnapshotArgs.openCircuitVoltageMicroV, batteryHealthSnapshotArgs.resistanceMicroOhm, batteryHealthSnapshotArgs.levelPercent); Loading @@ -80,14 +83,15 @@ hardware::Return<void> StatsHal::reportBatteryHealthSnapshot( } hardware::Return<void> StatsHal::reportSlowIo(const SlowIo& slowIo) { android::util::stats_write(android::util::SLOW_IO, int32_t(slowIo.operation), slowIo.count); android::util::statshidl::stats_write(android::util::statshidl::SLOW_IO, int32_t(slowIo.operation), slowIo.count); return hardware::Void(); } hardware::Return<void> StatsHal::reportBatteryCausedShutdown( const BatteryCausedShutdown& batteryCausedShutdown) { android::util::stats_write(android::util::BATTERY_CAUSED_SHUTDOWN, android::util::statshidl::stats_write(android::util::statshidl::BATTERY_CAUSED_SHUTDOWN, batteryCausedShutdown.voltageMicroV); return hardware::Void(); Loading @@ -95,8 +99,8 @@ hardware::Return<void> StatsHal::reportBatteryCausedShutdown( hardware::Return<void> StatsHal::reportUsbPortOverheatEvent( const UsbPortOverheatEvent& usbPortOverheatEvent) { android::util::stats_write( android::util::USB_PORT_OVERHEAT_EVENT_REPORTED, android::util::statshidl::stats_write( android::util::statshidl::USB_PORT_OVERHEAT_EVENT_REPORTED, usbPortOverheatEvent.plugTemperatureDeciC, usbPortOverheatEvent.maxTemperatureDeciC, usbPortOverheatEvent.timeToOverheat, usbPortOverheatEvent.timeToHysteresis, usbPortOverheatEvent.timeToInactive); Loading @@ -105,9 +109,10 @@ hardware::Return<void> StatsHal::reportUsbPortOverheatEvent( } hardware::Return<void> StatsHal::reportSpeechDspStat(const SpeechDspStat& speechDspStat) { android::util::stats_write(android::util::SPEECH_DSP_STAT_REPORTED, speechDspStat.totalUptimeMillis, speechDspStat.totalDowntimeMillis, speechDspStat.totalCrashCount, speechDspStat.totalRecoverCount); android::util::statshidl::stats_write( android::util::statshidl::SPEECH_DSP_STAT_REPORTED, speechDspStat.totalUptimeMillis, speechDspStat.totalDowntimeMillis, speechDspStat.totalCrashCount, speechDspStat.totalRecoverCount); return hardware::Void(); } Loading