Loading services/stats/.clang-format 0 → 100644 +17 −0 Original line number Original line Diff line number Diff line BasedOnStyle: Google AllowShortIfStatementsOnASingleLine: true AllowShortFunctionsOnASingleLine: false AllowShortLoopsOnASingleLine: true BinPackArguments: true BinPackParameters: true ColumnLimit: 100 CommentPragmas: NOLINT:.* ContinuationIndentWidth: 8 DerivePointerAlignment: false IndentWidth: 4 PointerAlignment: Left TabWidth: 4 AccessModifierOffset: -4 IncludeCategories: - Regex: '^"Log\.h"' Priority: -1 services/stats/StatsAidl.cpp +19 −22 Original line number Original line Diff line number Diff line Loading @@ -17,17 +17,18 @@ #define DEBUG false // STOPSHIP if true #define DEBUG false // STOPSHIP if true #define LOG_TAG "StatsAidl" #define LOG_TAG "StatsAidl" #include "StatsAidl.h" #include <log/log.h> #include <log/log.h> #include <statslog.h> #include <statslog.h> #include "StatsAidl.h" namespace aidl { namespace aidl { namespace android { namespace android { namespace frameworks { namespace frameworks { namespace stats { namespace stats { StatsHal::StatsHal() {} StatsHal::StatsHal() { } ndk::ScopedAStatus StatsHal::reportVendorAtom(const VendorAtom& vendorAtom) { ndk::ScopedAStatus StatsHal::reportVendorAtom(const VendorAtom& vendorAtom) { if (vendorAtom.atomId < 100000 || vendorAtom.atomId >= 200000) { if (vendorAtom.atomId < 100000 || vendorAtom.atomId >= 200000) { Loading @@ -47,24 +48,20 @@ ndk::ScopedAStatus StatsHal::reportVendorAtom(const VendorAtom& vendorAtom) { for (const auto& atomValue : vendorAtom.values) { for (const auto& atomValue : vendorAtom.values) { switch (atomValue.getTag()) { switch (atomValue.getTag()) { case VendorAtomValue::intValue: case VendorAtomValue::intValue: AStatsEvent_writeInt32(event, AStatsEvent_writeInt32(event, atomValue.get<VendorAtomValue::intValue>()); atomValue.get<VendorAtomValue::intValue>()); break; break; case VendorAtomValue::longValue: case VendorAtomValue::longValue: AStatsEvent_writeInt64(event, AStatsEvent_writeInt64(event, atomValue.get<VendorAtomValue::longValue>()); atomValue.get<VendorAtomValue::longValue>()); break; break; case VendorAtomValue::floatValue: case VendorAtomValue::floatValue: AStatsEvent_writeFloat(event, AStatsEvent_writeFloat(event, atomValue.get<VendorAtomValue::floatValue>()); atomValue.get<VendorAtomValue::floatValue>()); break; break; case VendorAtomValue::stringValue: case VendorAtomValue::stringValue: AStatsEvent_writeString(event, AStatsEvent_writeString(event, atomValue.get<VendorAtomValue::stringValue>().c_str()); atomValue.get<VendorAtomValue::stringValue>().c_str()); break; break; case VendorAtomValue::boolValue: case VendorAtomValue::boolValue: AStatsEvent_writeBool(event, AStatsEvent_writeBool(event, atomValue.get<VendorAtomValue::boolValue>()); atomValue.get<VendorAtomValue::boolValue>()); break; break; case VendorAtomValue::repeatedIntValue: { case VendorAtomValue::repeatedIntValue: { const std::optional<std::vector<int>>& repeatedIntValue = const std::optional<std::vector<int>>& repeatedIntValue = Loading Loading @@ -152,9 +149,9 @@ ndk::ScopedAStatus StatsHal::reportVendorAtom(const VendorAtom& vendorAtom) { const int ret = AStatsEvent_write(event); const int ret = AStatsEvent_write(event); AStatsEvent_release(event); AStatsEvent_release(event); return ret <= 0 ? return ret <= 0 ? ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(ret, ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(ret, "report atom failed") : "report atom failed") ndk::ScopedAStatus::ok(); : ndk::ScopedAStatus::ok(); } } } // namespace stats } // namespace stats Loading services/stats/StatsHal.cpp +25 −24 Original line number Original line Diff line number Diff line Loading @@ -17,21 +17,21 @@ #define DEBUG false // STOPSHIP if true #define DEBUG false // STOPSHIP if true #define LOG_TAG "StatsHal" #define LOG_TAG "StatsHal" #include "StatsHal.h" #include <log/log.h> #include <log/log.h> #include <statslog.h> #include <statslog.h> #include "StatsHal.h" namespace android { namespace android { namespace frameworks { namespace frameworks { namespace stats { namespace stats { namespace V1_0 { namespace V1_0 { namespace implementation { namespace implementation { StatsHal::StatsHal() {} StatsHal::StatsHal() { } hardware::Return<void> StatsHal::reportSpeakerImpedance( hardware::Return<void> StatsHal::reportSpeakerImpedance(const SpeakerImpedance& speakerImpedance) { const SpeakerImpedance& speakerImpedance) { android::util::stats_write(android::util::SPEAKER_IMPEDANCE_REPORTED, android::util::stats_write(android::util::SPEAKER_IMPEDANCE_REPORTED, speakerImpedance.speakerLocation, speakerImpedance.milliOhms); speakerImpedance.speakerLocation, speakerImpedance.milliOhms); Loading @@ -47,9 +47,9 @@ hardware::Return<void> StatsHal::reportHardwareFailed(const HardwareFailed& hard hardware::Return<void> StatsHal::reportPhysicalDropDetected( hardware::Return<void> StatsHal::reportPhysicalDropDetected( const PhysicalDropDetected& physicalDropDetected) { const PhysicalDropDetected& physicalDropDetected) { android::util::stats_write(android::util::PHYSICAL_DROP_DETECTED, android::util::stats_write( int32_t(physicalDropDetected.confidencePctg), physicalDropDetected.accelPeak, android::util::PHYSICAL_DROP_DETECTED, int32_t(physicalDropDetected.confidencePctg), physicalDropDetected.freefallDuration); physicalDropDetected.accelPeak, physicalDropDetected.freefallDuration); return hardware::Void(); return hardware::Void(); } } Loading @@ -61,17 +61,18 @@ hardware::Return<void> StatsHal::reportChargeCycles(const ChargeCycles& chargeCy buckets.push_back(0); // Push 0 for buckets that do not exist. 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], 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[2], buckets[3], buckets[4], buckets[5], buckets[6], buckets[9]); buckets[7], buckets[8], buckets[9]); return hardware::Void(); return hardware::Void(); } } hardware::Return<void> StatsHal::reportBatteryHealthSnapshot( hardware::Return<void> StatsHal::reportBatteryHealthSnapshot( const BatteryHealthSnapshotArgs& batteryHealthSnapshotArgs) { const BatteryHealthSnapshotArgs& batteryHealthSnapshotArgs) { android::util::stats_write(android::util::BATTERY_HEALTH_SNAPSHOT, android::util::stats_write( int32_t(batteryHealthSnapshotArgs.type), batteryHealthSnapshotArgs.temperatureDeciC, android::util::BATTERY_HEALTH_SNAPSHOT, int32_t(batteryHealthSnapshotArgs.type), batteryHealthSnapshotArgs.voltageMicroV, batteryHealthSnapshotArgs.currentMicroA, batteryHealthSnapshotArgs.temperatureDeciC, batteryHealthSnapshotArgs.voltageMicroV, batteryHealthSnapshotArgs.currentMicroA, batteryHealthSnapshotArgs.openCircuitVoltageMicroV, batteryHealthSnapshotArgs.openCircuitVoltageMicroV, batteryHealthSnapshotArgs.resistanceMicroOhm, batteryHealthSnapshotArgs.levelPercent); batteryHealthSnapshotArgs.resistanceMicroOhm, batteryHealthSnapshotArgs.levelPercent); Loading @@ -94,7 +95,8 @@ hardware::Return<void> StatsHal::reportBatteryCausedShutdown( hardware::Return<void> StatsHal::reportUsbPortOverheatEvent( hardware::Return<void> StatsHal::reportUsbPortOverheatEvent( const UsbPortOverheatEvent& usbPortOverheatEvent) { const UsbPortOverheatEvent& usbPortOverheatEvent) { android::util::stats_write(android::util::USB_PORT_OVERHEAT_EVENT_REPORTED, android::util::stats_write( android::util::USB_PORT_OVERHEAT_EVENT_REPORTED, usbPortOverheatEvent.plugTemperatureDeciC, usbPortOverheatEvent.maxTemperatureDeciC, usbPortOverheatEvent.plugTemperatureDeciC, usbPortOverheatEvent.maxTemperatureDeciC, usbPortOverheatEvent.timeToOverheat, usbPortOverheatEvent.timeToHysteresis, usbPortOverheatEvent.timeToOverheat, usbPortOverheatEvent.timeToHysteresis, usbPortOverheatEvent.timeToInactive); usbPortOverheatEvent.timeToInactive); Loading @@ -102,8 +104,7 @@ hardware::Return<void> StatsHal::reportUsbPortOverheatEvent( return hardware::Void(); return hardware::Void(); } } hardware::Return<void> StatsHal::reportSpeechDspStat( hardware::Return<void> StatsHal::reportSpeechDspStat(const SpeechDspStat& speechDspStat) { const SpeechDspStat& speechDspStat) { android::util::stats_write(android::util::SPEECH_DSP_STAT_REPORTED, android::util::stats_write(android::util::SPEECH_DSP_STAT_REPORTED, speechDspStat.totalUptimeMillis, speechDspStat.totalDowntimeMillis, speechDspStat.totalUptimeMillis, speechDspStat.totalDowntimeMillis, speechDspStat.totalCrashCount, speechDspStat.totalRecoverCount); speechDspStat.totalCrashCount, speechDspStat.totalRecoverCount); Loading services/stats/include/stats/StatsAidl.h +1 −2 Original line number Original line Diff line number Diff line Loading @@ -28,8 +28,7 @@ public: /** /** * Binder call to get vendor atom. * Binder call to get vendor atom. */ */ virtual ndk::ScopedAStatus reportVendorAtom( virtual ndk::ScopedAStatus reportVendorAtom(const VendorAtom& in_vendorAtom) override; const VendorAtom& in_vendorAtom) override; }; }; } // namespace stats } // namespace stats Loading services/stats/include/stats/StatsHal.h +5 −7 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,6 @@ #include <android/frameworks/stats/1.0/IStats.h> #include <android/frameworks/stats/1.0/IStats.h> #include <android/frameworks/stats/1.0/types.h> #include <android/frameworks/stats/1.0/types.h> #include <stats_event.h> #include <stats_event.h> using namespace android::frameworks::stats::V1_0; using namespace android::frameworks::stats::V1_0; Loading Loading @@ -83,8 +82,7 @@ public: /** /** * Binder call to get Speech DSP state atom. * Binder call to get Speech DSP state atom. */ */ virtual Return<void> reportSpeechDspStat( virtual Return<void> reportSpeechDspStat(const SpeechDspStat& speechDspStat) override; const SpeechDspStat& speechDspStat) override; /** /** * Binder call to get vendor atom. * Binder call to get vendor atom. Loading Loading
services/stats/.clang-format 0 → 100644 +17 −0 Original line number Original line Diff line number Diff line BasedOnStyle: Google AllowShortIfStatementsOnASingleLine: true AllowShortFunctionsOnASingleLine: false AllowShortLoopsOnASingleLine: true BinPackArguments: true BinPackParameters: true ColumnLimit: 100 CommentPragmas: NOLINT:.* ContinuationIndentWidth: 8 DerivePointerAlignment: false IndentWidth: 4 PointerAlignment: Left TabWidth: 4 AccessModifierOffset: -4 IncludeCategories: - Regex: '^"Log\.h"' Priority: -1
services/stats/StatsAidl.cpp +19 −22 Original line number Original line Diff line number Diff line Loading @@ -17,17 +17,18 @@ #define DEBUG false // STOPSHIP if true #define DEBUG false // STOPSHIP if true #define LOG_TAG "StatsAidl" #define LOG_TAG "StatsAidl" #include "StatsAidl.h" #include <log/log.h> #include <log/log.h> #include <statslog.h> #include <statslog.h> #include "StatsAidl.h" namespace aidl { namespace aidl { namespace android { namespace android { namespace frameworks { namespace frameworks { namespace stats { namespace stats { StatsHal::StatsHal() {} StatsHal::StatsHal() { } ndk::ScopedAStatus StatsHal::reportVendorAtom(const VendorAtom& vendorAtom) { ndk::ScopedAStatus StatsHal::reportVendorAtom(const VendorAtom& vendorAtom) { if (vendorAtom.atomId < 100000 || vendorAtom.atomId >= 200000) { if (vendorAtom.atomId < 100000 || vendorAtom.atomId >= 200000) { Loading @@ -47,24 +48,20 @@ ndk::ScopedAStatus StatsHal::reportVendorAtom(const VendorAtom& vendorAtom) { for (const auto& atomValue : vendorAtom.values) { for (const auto& atomValue : vendorAtom.values) { switch (atomValue.getTag()) { switch (atomValue.getTag()) { case VendorAtomValue::intValue: case VendorAtomValue::intValue: AStatsEvent_writeInt32(event, AStatsEvent_writeInt32(event, atomValue.get<VendorAtomValue::intValue>()); atomValue.get<VendorAtomValue::intValue>()); break; break; case VendorAtomValue::longValue: case VendorAtomValue::longValue: AStatsEvent_writeInt64(event, AStatsEvent_writeInt64(event, atomValue.get<VendorAtomValue::longValue>()); atomValue.get<VendorAtomValue::longValue>()); break; break; case VendorAtomValue::floatValue: case VendorAtomValue::floatValue: AStatsEvent_writeFloat(event, AStatsEvent_writeFloat(event, atomValue.get<VendorAtomValue::floatValue>()); atomValue.get<VendorAtomValue::floatValue>()); break; break; case VendorAtomValue::stringValue: case VendorAtomValue::stringValue: AStatsEvent_writeString(event, AStatsEvent_writeString(event, atomValue.get<VendorAtomValue::stringValue>().c_str()); atomValue.get<VendorAtomValue::stringValue>().c_str()); break; break; case VendorAtomValue::boolValue: case VendorAtomValue::boolValue: AStatsEvent_writeBool(event, AStatsEvent_writeBool(event, atomValue.get<VendorAtomValue::boolValue>()); atomValue.get<VendorAtomValue::boolValue>()); break; break; case VendorAtomValue::repeatedIntValue: { case VendorAtomValue::repeatedIntValue: { const std::optional<std::vector<int>>& repeatedIntValue = const std::optional<std::vector<int>>& repeatedIntValue = Loading Loading @@ -152,9 +149,9 @@ ndk::ScopedAStatus StatsHal::reportVendorAtom(const VendorAtom& vendorAtom) { const int ret = AStatsEvent_write(event); const int ret = AStatsEvent_write(event); AStatsEvent_release(event); AStatsEvent_release(event); return ret <= 0 ? return ret <= 0 ? ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(ret, ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(ret, "report atom failed") : "report atom failed") ndk::ScopedAStatus::ok(); : ndk::ScopedAStatus::ok(); } } } // namespace stats } // namespace stats Loading
services/stats/StatsHal.cpp +25 −24 Original line number Original line Diff line number Diff line Loading @@ -17,21 +17,21 @@ #define DEBUG false // STOPSHIP if true #define DEBUG false // STOPSHIP if true #define LOG_TAG "StatsHal" #define LOG_TAG "StatsHal" #include "StatsHal.h" #include <log/log.h> #include <log/log.h> #include <statslog.h> #include <statslog.h> #include "StatsHal.h" namespace android { namespace android { namespace frameworks { namespace frameworks { namespace stats { namespace stats { namespace V1_0 { namespace V1_0 { namespace implementation { namespace implementation { StatsHal::StatsHal() {} StatsHal::StatsHal() { } hardware::Return<void> StatsHal::reportSpeakerImpedance( hardware::Return<void> StatsHal::reportSpeakerImpedance(const SpeakerImpedance& speakerImpedance) { const SpeakerImpedance& speakerImpedance) { android::util::stats_write(android::util::SPEAKER_IMPEDANCE_REPORTED, android::util::stats_write(android::util::SPEAKER_IMPEDANCE_REPORTED, speakerImpedance.speakerLocation, speakerImpedance.milliOhms); speakerImpedance.speakerLocation, speakerImpedance.milliOhms); Loading @@ -47,9 +47,9 @@ hardware::Return<void> StatsHal::reportHardwareFailed(const HardwareFailed& hard hardware::Return<void> StatsHal::reportPhysicalDropDetected( hardware::Return<void> StatsHal::reportPhysicalDropDetected( const PhysicalDropDetected& physicalDropDetected) { const PhysicalDropDetected& physicalDropDetected) { android::util::stats_write(android::util::PHYSICAL_DROP_DETECTED, android::util::stats_write( int32_t(physicalDropDetected.confidencePctg), physicalDropDetected.accelPeak, android::util::PHYSICAL_DROP_DETECTED, int32_t(physicalDropDetected.confidencePctg), physicalDropDetected.freefallDuration); physicalDropDetected.accelPeak, physicalDropDetected.freefallDuration); return hardware::Void(); return hardware::Void(); } } Loading @@ -61,17 +61,18 @@ hardware::Return<void> StatsHal::reportChargeCycles(const ChargeCycles& chargeCy buckets.push_back(0); // Push 0 for buckets that do not exist. 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], 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[2], buckets[3], buckets[4], buckets[5], buckets[6], buckets[9]); buckets[7], buckets[8], buckets[9]); return hardware::Void(); return hardware::Void(); } } hardware::Return<void> StatsHal::reportBatteryHealthSnapshot( hardware::Return<void> StatsHal::reportBatteryHealthSnapshot( const BatteryHealthSnapshotArgs& batteryHealthSnapshotArgs) { const BatteryHealthSnapshotArgs& batteryHealthSnapshotArgs) { android::util::stats_write(android::util::BATTERY_HEALTH_SNAPSHOT, android::util::stats_write( int32_t(batteryHealthSnapshotArgs.type), batteryHealthSnapshotArgs.temperatureDeciC, android::util::BATTERY_HEALTH_SNAPSHOT, int32_t(batteryHealthSnapshotArgs.type), batteryHealthSnapshotArgs.voltageMicroV, batteryHealthSnapshotArgs.currentMicroA, batteryHealthSnapshotArgs.temperatureDeciC, batteryHealthSnapshotArgs.voltageMicroV, batteryHealthSnapshotArgs.currentMicroA, batteryHealthSnapshotArgs.openCircuitVoltageMicroV, batteryHealthSnapshotArgs.openCircuitVoltageMicroV, batteryHealthSnapshotArgs.resistanceMicroOhm, batteryHealthSnapshotArgs.levelPercent); batteryHealthSnapshotArgs.resistanceMicroOhm, batteryHealthSnapshotArgs.levelPercent); Loading @@ -94,7 +95,8 @@ hardware::Return<void> StatsHal::reportBatteryCausedShutdown( hardware::Return<void> StatsHal::reportUsbPortOverheatEvent( hardware::Return<void> StatsHal::reportUsbPortOverheatEvent( const UsbPortOverheatEvent& usbPortOverheatEvent) { const UsbPortOverheatEvent& usbPortOverheatEvent) { android::util::stats_write(android::util::USB_PORT_OVERHEAT_EVENT_REPORTED, android::util::stats_write( android::util::USB_PORT_OVERHEAT_EVENT_REPORTED, usbPortOverheatEvent.plugTemperatureDeciC, usbPortOverheatEvent.maxTemperatureDeciC, usbPortOverheatEvent.plugTemperatureDeciC, usbPortOverheatEvent.maxTemperatureDeciC, usbPortOverheatEvent.timeToOverheat, usbPortOverheatEvent.timeToHysteresis, usbPortOverheatEvent.timeToOverheat, usbPortOverheatEvent.timeToHysteresis, usbPortOverheatEvent.timeToInactive); usbPortOverheatEvent.timeToInactive); Loading @@ -102,8 +104,7 @@ hardware::Return<void> StatsHal::reportUsbPortOverheatEvent( return hardware::Void(); return hardware::Void(); } } hardware::Return<void> StatsHal::reportSpeechDspStat( hardware::Return<void> StatsHal::reportSpeechDspStat(const SpeechDspStat& speechDspStat) { const SpeechDspStat& speechDspStat) { android::util::stats_write(android::util::SPEECH_DSP_STAT_REPORTED, android::util::stats_write(android::util::SPEECH_DSP_STAT_REPORTED, speechDspStat.totalUptimeMillis, speechDspStat.totalDowntimeMillis, speechDspStat.totalUptimeMillis, speechDspStat.totalDowntimeMillis, speechDspStat.totalCrashCount, speechDspStat.totalRecoverCount); speechDspStat.totalCrashCount, speechDspStat.totalRecoverCount); Loading
services/stats/include/stats/StatsAidl.h +1 −2 Original line number Original line Diff line number Diff line Loading @@ -28,8 +28,7 @@ public: /** /** * Binder call to get vendor atom. * Binder call to get vendor atom. */ */ virtual ndk::ScopedAStatus reportVendorAtom( virtual ndk::ScopedAStatus reportVendorAtom(const VendorAtom& in_vendorAtom) override; const VendorAtom& in_vendorAtom) override; }; }; } // namespace stats } // namespace stats Loading
services/stats/include/stats/StatsHal.h +5 −7 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,6 @@ #include <android/frameworks/stats/1.0/IStats.h> #include <android/frameworks/stats/1.0/IStats.h> #include <android/frameworks/stats/1.0/types.h> #include <android/frameworks/stats/1.0/types.h> #include <stats_event.h> #include <stats_event.h> using namespace android::frameworks::stats::V1_0; using namespace android::frameworks::stats::V1_0; Loading Loading @@ -83,8 +82,7 @@ public: /** /** * Binder call to get Speech DSP state atom. * Binder call to get Speech DSP state atom. */ */ virtual Return<void> reportSpeechDspStat( virtual Return<void> reportSpeechDspStat(const SpeechDspStat& speechDspStat) override; const SpeechDspStat& speechDspStat) override; /** /** * Binder call to get vendor atom. * Binder call to get vendor atom. Loading