diff options
Diffstat (limited to 'cmds/statsd/src/StatsService.h')
-rw-r--r-- | cmds/statsd/src/StatsService.h | 97 |
1 files changed, 76 insertions, 21 deletions
diff --git a/cmds/statsd/src/StatsService.h b/cmds/statsd/src/StatsService.h index d8aab88ce9f9..4a5f05fef034 100644 --- a/cmds/statsd/src/StatsService.h +++ b/cmds/statsd/src/StatsService.h @@ -22,9 +22,13 @@ #include "anomaly/AlarmMonitor.h" #include "config/ConfigManager.h" #include "external/StatsPullerManager.h" +#include "logd/LogListener.h" #include "packages/UidMap.h" +#include "shell/ShellSubscriber.h" #include "statscompanion_util.h" +#include <android/frameworks/stats/1.0/IStats.h> +#include <android/frameworks/stats/1.0/types.h> #include <android/os/BnStatsManager.h> #include <android/os/IStatsCompanionService.h> #include <binder/IResultReceiver.h> @@ -36,6 +40,7 @@ using namespace android; using namespace android::base; using namespace android::binder; +using namespace android::frameworks::stats::V1_0; using namespace android::os; using namespace std; @@ -43,18 +48,23 @@ namespace android { namespace os { namespace statsd { -class StatsService : public BnStatsManager, public LogListener, public IBinder::DeathRecipient { +using android::hardware::Return; + +class StatsService : public BnStatsManager, + public LogListener, + public IStats, + public IBinder::DeathRecipient { public: StatsService(const sp<Looper>& handlerLooper); virtual ~StatsService(); /** The anomaly alarm registered with AlarmManager won't be updated by less than this. */ - // TODO: Consider making this configurable. And choose a good number. const uint32_t MIN_DIFF_TO_UPDATE_REGISTERED_ALARM_SECS = 5; virtual status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags); virtual status_t dump(int fd, const Vector<String16>& args); - virtual status_t command(FILE* in, FILE* out, FILE* err, Vector<String8>& args); + virtual status_t command(int inFd, int outFd, int err, Vector<String8>& args, + sp<IResultReceiver> resultReceiver); virtual Status systemRunning(); virtual Status statsCompanionReady(); @@ -81,7 +91,7 @@ public: /** * Called by LogReader when there's a log event to process. */ - virtual void OnLogEvent(LogEvent* event, bool reconnectionStarts); + virtual void OnLogEvent(LogEvent* event); /** * Binder call for clients to request data for this configuration key. @@ -149,6 +159,44 @@ public: */ virtual Status sendAppBreadcrumbAtom(int32_t label, int32_t state) override; + /** + * Binder call to get SpeakerImpedance atom. + */ + virtual Return<void> reportSpeakerImpedance(const SpeakerImpedance& speakerImpedance) override; + + /** + * Binder call to get HardwareFailed atom. + */ + virtual Return<void> reportHardwareFailed(const HardwareFailed& hardwareFailed) override; + + /** + * Binder call to get PhysicalDropDetected atom. + */ + virtual Return<void> reportPhysicalDropDetected( + const PhysicalDropDetected& physicalDropDetected) override; + + /** + * Binder call to get ChargeCyclesReported atom. + */ + virtual Return<void> reportChargeCycles(const ChargeCycles& chargeCycles) override; + + /** + * Binder call to get BatteryHealthSnapshot atom. + */ + virtual Return<void> reportBatteryHealthSnapshot( + const BatteryHealthSnapshotArgs& batteryHealthSnapshotArgs) override; + + /** + * Binder call to get SlowIo atom. + */ + virtual Return<void> reportSlowIo(const SlowIo& slowIo) override; + + /** + * Binder call to get BatteryCausedShutdown atom. + */ + virtual Return<void> reportBatteryCausedShutdown( + const BatteryCausedShutdown& batteryCausedShutdown) override; + /** IBinder::DeathRecipient */ virtual void binderDied(const wp<IBinder>& who) override; @@ -165,75 +213,80 @@ private: uint32_t serial); /** - * Text or proto output of dumpsys. + * Proto output of statsd report data dumpsys, wrapped in a StatsDataDumpProto. + */ + void dumpIncidentSection(int outFd); + + /** + * Text or proto output of statsdStats dumpsys. */ - void dump_impl(FILE* out, bool verbose, bool proto); + void dumpStatsdStats(int outFd, bool verbose, bool proto); /** * Print usage information for the commands */ - void print_cmd_help(FILE* out); + void print_cmd_help(int out); /** * Trigger a broadcast. */ - status_t cmd_trigger_broadcast(FILE* out, Vector<String8>& args); + status_t cmd_trigger_broadcast(int outFd, Vector<String8>& args); /** * Handle the config sub-command. */ - status_t cmd_config(FILE* in, FILE* out, FILE* err, Vector<String8>& args); + status_t cmd_config(int inFd, int outFd, int err, Vector<String8>& args); /** * Prints some basic stats to std out. */ - status_t cmd_print_stats(FILE* out, const Vector<String8>& args); + status_t cmd_print_stats(int outFd, const Vector<String8>& args); /** * Print the event log. */ - status_t cmd_dump_report(FILE* out, FILE* err, const Vector<String8>& args); + status_t cmd_dump_report(int outFd, const Vector<String8>& args); /** * Print the mapping of uids to package names. */ - status_t cmd_print_uid_map(FILE* out, const Vector<String8>& args); + status_t cmd_print_uid_map(int outFd, const Vector<String8>& args); /** * Flush the data to disk. */ - status_t cmd_write_data_to_disk(FILE* out); + status_t cmd_write_data_to_disk(int outFd); /** * Write an AppBreadcrumbReported event to the StatsLog buffer, as if calling * StatsLog.write(APP_BREADCRUMB_REPORTED). */ - status_t cmd_log_app_breadcrumb(FILE* out, const Vector<String8>& args); + status_t cmd_log_app_breadcrumb(int outFd, const Vector<String8>& args); /** * Print contents of a pulled metrics source. */ - status_t cmd_print_pulled_metrics(FILE* out, const Vector<String8>& args); + status_t cmd_print_pulled_metrics(int outFd, const Vector<String8>& args); /** * Removes all configs stored on disk and on memory. */ - status_t cmd_remove_all_configs(FILE* out); + status_t cmd_remove_all_configs(int outFd); /* * Dump memory usage by statsd. */ - status_t cmd_dump_memory_info(FILE* out); + status_t cmd_dump_memory_info(int outFd); /* * Clear all puller cached data */ - status_t cmd_clear_puller_cache(FILE* out); + status_t cmd_clear_puller_cache(int outFd); /** * Print all stats logs received to logcat. */ - status_t cmd_print_logs(FILE* out, const Vector<String8>& args); + status_t cmd_print_logs(int outFd, const Vector<String8>& args); /** * Adds a configuration after checking permissions and obtaining UID from binder call. @@ -251,9 +304,9 @@ private: sp<UidMap> mUidMap; /** - * Fetches external metrics. + * Fetches external metrics */ - StatsPullerManager mStatsPullerManager; + sp<StatsPullerManager> mPullerManager; /** * Tracks the configurations that have been passed to statsd. @@ -280,6 +333,8 @@ private: */ bool mEngBuild; + sp<ShellSubscriber> mShellSubscriber; + FRIEND_TEST(StatsServiceTest, TestAddConfig_simple); FRIEND_TEST(StatsServiceTest, TestAddConfig_empty); FRIEND_TEST(StatsServiceTest, TestAddConfig_invalid); |