consolidate subsystem sleep state atoms
Test: cts test
Change-Id: Ib9ff746eaa17b6c2c8f9fe5860dd0b480ec85186
diff --git a/cmds/statsd/Android.mk b/cmds/statsd/Android.mk
index 2c35d41..9bddbcb 100644
--- a/cmds/statsd/Android.mk
+++ b/cmds/statsd/Android.mk
@@ -36,7 +36,7 @@
src/config/ConfigManager.cpp \
src/external/StatsPuller.cpp \
src/external/StatsCompanionServicePuller.cpp \
- src/external/ResourcePowerManagerPuller.cpp \
+ src/external/SubsystemSleepStatePuller.cpp \
src/external/CpuTimePerUidPuller.cpp \
src/external/CpuTimePerUidFreqPuller.cpp \
src/external/StatsPullerManagerImpl.cpp \
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index 4a7f0c4..7d513cd 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -94,9 +94,8 @@
MobileBytesTransfer mobile_bytes_transfer = 10002;
MobileBytesTransferByFgBg mobile_bytes_transfer_by_fg_bg = 10003;
KernelWakelock kernel_wakelock = 10004;
- PlatformSleepState platform_sleep_state = 10005;
- SleepStateVoter sleep_state_voter = 10006;
- SubsystemSleepState subsystem_sleep_state = 10007;
+ SubsystemSleepState subsystem_sleep_state = 10005;
+ // 10006 and 10007 are free to use.
CpuTimePerFreq cpu_time_per_freq = 10008;
CpuTimePerUid cpu_time_per_uid = 10009;
CpuTimePerUidFreq cpu_time_per_uid_freq = 10010;
@@ -1027,44 +1026,21 @@
}
/**
- * Pulls PowerStatePlatformSleepState.
- *
- * Definition here:
+ * Pulls low power state information. This includes platform and subsystem sleep state information,
+ * PowerStatePlatformSleepState, PowerStateVoter or PowerStateSubsystemSleepState as defined in
* hardware/interfaces/power/1.0/types.hal
- */
-message PlatformSleepState {
- optional string name = 1;
- optional uint64 residency_in_msec_since_boot = 2;
- optional uint64 total_transitions = 3;
- optional bool supported_only_in_suspend = 4;
-}
-
-/**
- * Pulls PowerStateVoter.
- *
- * Definition here:
- * hardware/interfaces/power/1.0/types.hal
- */
-message SleepStateVoter {
- optional string platform_sleep_state_name = 1;
- optional string voter_name = 2;
- optional uint64 total_time_in_msec_voted_for_since_boot = 3;
- optional uint64 total_number_of_times_voted_since_boot = 4;
-}
-
-/**
- * Pulls PowerStateSubsystemSleepState.
- *
- * Definition here:
* hardware/interfaces/power/1.1/types.hal
*/
message SubsystemSleepState {
- optional string subsystem_name = 1;
- optional string subsystem_sleep_state_name = 2;
- optional uint64 residency_in_msec_since_boot = 3;
- optional uint64 total_transitions = 4;
- optional uint64 last_entry_timestamp_ms = 5;
- optional bool supported_only_in_suspend = 6;
+ // Name should be in the format of XXX.YYY where XXX is subsystem name,
+ // YYY is corresponding voter name.
+ // If there are no voters, the format should just be XXX (with no dot).
+ // XXX and YYY should not contain a "." in it.
+ optional string name = 1;
+ // The number of times it entered, or voted for entering the sleep state
+ optional uint64 count = 2;
+ // The length of time spent in, or spent voting for, the sleep state
+ optional uint64 timeMs = 3;
}
/**
diff --git a/cmds/statsd/src/external/StatsPullerManagerImpl.cpp b/cmds/statsd/src/external/StatsPullerManagerImpl.cpp
index 58c7b12..bb2e8c0 100644
--- a/cmds/statsd/src/external/StatsPullerManagerImpl.cpp
+++ b/cmds/statsd/src/external/StatsPullerManagerImpl.cpp
@@ -23,7 +23,7 @@
#include <climits>
#include "CpuTimePerUidFreqPuller.h"
#include "CpuTimePerUidPuller.h"
-#include "ResourcePowerManagerPuller.h"
+#include "SubsystemSleepStatePuller.h"
#include "StatsCompanionServicePuller.h"
#include "StatsPullerManagerImpl.h"
#include "StatsService.h"
@@ -58,13 +58,9 @@
mPullers.insert({android::util::MOBILE_BYTES_TRANSFER_BY_FG_BG,
make_shared<StatsCompanionServicePuller>(
android::util::MOBILE_BYTES_TRANSFER_BY_FG_BG)});
- mPullers.insert({android::util::PLATFORM_SLEEP_STATE,
- make_shared<ResourcePowerManagerPuller>(android::util::PLATFORM_SLEEP_STATE)});
- mPullers.insert({android::util::SLEEP_STATE_VOTER,
- make_shared<ResourcePowerManagerPuller>(android::util::SLEEP_STATE_VOTER)});
mPullers.insert(
{android::util::SUBSYSTEM_SLEEP_STATE,
- make_shared<ResourcePowerManagerPuller>(android::util::SUBSYSTEM_SLEEP_STATE)});
+ make_shared<SubsystemSleepStatePuller>()});
mPullers.insert({android::util::CPU_TIME_PER_FREQ, make_shared<StatsCompanionServicePuller>(android::util::CPU_TIME_PER_FREQ)});
mPullers.insert({android::util::CPU_TIME_PER_UID, make_shared<CpuTimePerUidPuller>()});
mPullers.insert({android::util::CPU_TIME_PER_UID_FREQ, make_shared<CpuTimePerUidFreqPuller>()});
diff --git a/cmds/statsd/src/external/ResourcePowerManagerPuller.cpp b/cmds/statsd/src/external/SubsystemSleepStatePuller.cpp
similarity index 85%
rename from cmds/statsd/src/external/ResourcePowerManagerPuller.cpp
rename to cmds/statsd/src/external/SubsystemSleepStatePuller.cpp
index 2e29fb0..6d12e25 100644
--- a/cmds/statsd/src/external/ResourcePowerManagerPuller.cpp
+++ b/cmds/statsd/src/external/SubsystemSleepStatePuller.cpp
@@ -30,10 +30,10 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include "external/ResourcePowerManagerPuller.h"
+#include "external/SubsystemSleepStatePuller.h"
#include "external/StatsPuller.h"
-#include "ResourcePowerManagerPuller.h"
+#include "SubsystemSleepStatePuller.h"
#include "logd/LogEvent.h"
#include "statslog.h"
@@ -73,10 +73,10 @@
return gPowerHalV1_0 != nullptr;
}
-ResourcePowerManagerPuller::ResourcePowerManagerPuller(int tagId) : StatsPuller(tagId) {
+SubsystemSleepStatePuller::SubsystemSleepStatePuller() : StatsPuller(android::util::SUBSYSTEM_SLEEP_STATE) {
}
-bool ResourcePowerManagerPuller::PullInternal(vector<shared_ptr<LogEvent>>* data) {
+bool SubsystemSleepStatePuller::PullInternal(vector<shared_ptr<LogEvent>>* data) {
std::lock_guard<std::mutex> lock(gPowerHalMutex);
if (!getPowerHal()) {
@@ -89,8 +89,6 @@
data->clear();
Return<void> ret;
- if (mTagId == android::util::PLATFORM_SLEEP_STATE ||
- mTagId == android::util::SLEEP_STATE_VOTER) {
ret = gPowerHalV1_0->getPlatformLowPowerStats(
[&data, timestamp](hidl_vec<PowerStatePlatformSleepState> states, Status status) {
if (status != Status::SUCCESS) return;
@@ -98,12 +96,11 @@
for (size_t i = 0; i < states.size(); i++) {
const PowerStatePlatformSleepState& state = states[i];
- auto statePtr = make_shared<LogEvent>(android::util::PLATFORM_SLEEP_STATE,
+ auto statePtr = make_shared<LogEvent>(android::util::SUBSYSTEM_SLEEP_STATE,
timestamp);
statePtr->write(state.name);
- statePtr->write(state.residencyInMsecSinceBoot);
statePtr->write(state.totalTransitions);
- statePtr->write(state.supportedOnlyInSuspend);
+ statePtr->write(state.residencyInMsecSinceBoot);
statePtr->init();
data->push_back(statePtr);
VLOG("powerstate: %s, %lld, %lld, %d", state.name.c_str(),
@@ -111,12 +108,11 @@
(long long)state.totalTransitions,
state.supportedOnlyInSuspend ? 1 : 0);
for (auto voter : state.voters) {
- auto voterPtr = make_shared<LogEvent>(android::util::SLEEP_STATE_VOTER,
+ auto voterPtr = make_shared<LogEvent>(android::util::SUBSYSTEM_SLEEP_STATE,
timestamp);
- voterPtr->write(state.name);
- voterPtr->write(voter.name);
- voterPtr->write(voter.totalTimeInMsecVotedForSinceBoot);
+ voterPtr->write((std::string)state.name + "." + (std::string)voter.name);
voterPtr->write(voter.totalNumberOfTimesVotedSinceBoot);
+ voterPtr->write(voter.totalTimeInMsecVotedForSinceBoot);
voterPtr->init();
data->push_back(voterPtr);
VLOG("powerstatevoter: %s, %s, %lld, %lld", state.name.c_str(),
@@ -131,9 +127,7 @@
gPowerHalV1_0 = nullptr;
return false;
}
- }
- if (mTagId == android::util::SUBSYSTEM_SLEEP_STATE) {
// Trying to cast to IPower 1.1, this will succeed only for devices supporting 1.1
sp<android::hardware::power::V1_1::IPower> gPowerHal_1_1 =
android::hardware::power::V1_1::IPower::castFrom(gPowerHalV1_0);
@@ -149,13 +143,10 @@
const PowerStateSubsystemSleepState& state =
subsystem.states[j];
auto subsystemStatePtr = make_shared<LogEvent>(
- android::util::SUBSYSTEM_SLEEP_STATE, timestamp);
- subsystemStatePtr->write(subsystem.name);
- subsystemStatePtr->write(state.name);
- subsystemStatePtr->write(state.residencyInMsecSinceBoot);
+ android::util::SUBSYSTEM_SLEEP_STATE, timestamp);
+ subsystemStatePtr->write((std::string)subsystem.name + "." + (std::string)state.name);
subsystemStatePtr->write(state.totalTransitions);
- subsystemStatePtr->write(state.lastEntryTimestampMs);
- subsystemStatePtr->write(state.supportedOnlyInSuspend);
+ subsystemStatePtr->write(state.residencyInMsecSinceBoot);
subsystemStatePtr->init();
data->push_back(subsystemStatePtr);
VLOG("subsystemstate: %s, %s, %lld, %lld, %lld",
@@ -168,7 +159,6 @@
}
});
}
- }
return true;
}
diff --git a/cmds/statsd/src/external/ResourcePowerManagerPuller.h b/cmds/statsd/src/external/SubsystemSleepStatePuller.h
similarity index 90%
rename from cmds/statsd/src/external/ResourcePowerManagerPuller.h
rename to cmds/statsd/src/external/SubsystemSleepStatePuller.h
index 3399408..17ce5b4cb 100644
--- a/cmds/statsd/src/external/ResourcePowerManagerPuller.h
+++ b/cmds/statsd/src/external/SubsystemSleepStatePuller.h
@@ -26,9 +26,9 @@
/**
* Reads hal for sleep states
*/
-class ResourcePowerManagerPuller : public StatsPuller {
+class SubsystemSleepStatePuller : public StatsPuller {
public:
- ResourcePowerManagerPuller(int tagId);
+ SubsystemSleepStatePuller();
bool PullInternal(vector<std::shared_ptr<LogEvent>>* data) override;
};
diff --git a/cmds/statsd/src/guardrail/StatsdStats.cpp b/cmds/statsd/src/guardrail/StatsdStats.cpp
index 36dd616..4bd4f19 100644
--- a/cmds/statsd/src/guardrail/StatsdStats.cpp
+++ b/cmds/statsd/src/guardrail/StatsdStats.cpp
@@ -66,8 +66,6 @@
{android::util::MOBILE_BYTES_TRANSFER, 1},
{android::util::WIFI_BYTES_TRANSFER_BY_FG_BG, 1},
{android::util::MOBILE_BYTES_TRANSFER_BY_FG_BG, 1},
- {android::util::PLATFORM_SLEEP_STATE, 1},
- {android::util::SLEEP_STATE_VOTER, 1},
{android::util::SUBSYSTEM_SLEEP_STATE, 1},
{android::util::CPU_TIME_PER_FREQ, 1},
{android::util::CPU_TIME_PER_UID, 1},