Fix format of subsystem power stats

The Subsystem power stats string in batteryStats dumpsys has an extra
newline that is causing PowerBug to skip the line when parsing the
history information.
Also, the string for subsystem power stats is missing a heading title
and has some redundant text

This commit fixes these format errors so powerbug can read and parse that
line successfully

Bug: 63447034
Test: Manual testing + Read the bugreport by historian and verify output

Change-Id: Idf971823dd5f769e653b4788b00fc025593d0d3d
Signed-off-by: Ahmed ElArabawy <arabawy@google.com>
This commit is contained in:
Ahmed ElArabawy
2017-07-07 17:48:13 -07:00
parent dc7b2bc5e3
commit 307edcd9c2
2 changed files with 35 additions and 27 deletions

View File

@@ -5606,8 +5606,10 @@ public abstract class BatteryStats implements Parcelable {
pw.print(',');
if (rec.stepDetails.statPlatformIdleState != null) {
pw.print(rec.stepDetails.statPlatformIdleState);
if (rec.stepDetails.statSubsystemPowerState != null) {
pw.print(',');
}
}
pw.println();
if (rec.stepDetails.statSubsystemPowerState != null) {
pw.print(rec.stepDetails.statSubsystemPowerState);

View File

@@ -301,30 +301,17 @@ static jint getSubsystemLowPowerStats(JNIEnv* env, jobject /* clazz */, jobject
if (status != Status::SUCCESS)
return;
for (size_t i = 0; i < subsystems.size(); i++) {
int added;
const PowerStateSubsystem &subsystem = subsystems[i];
added = snprintf(offset, remaining,
"subsystem_%zu name=%s ", i + 1, subsystem.name.c_str());
if (added < 0) {
break;
}
if (added > remaining) {
added = remaining;
}
if (subsystems.size() > 0) {
int added = snprintf(offset, remaining, "SubsystemPowerState ");
offset += added;
remaining -= added;
total_added += added;
for (size_t j = 0; j < subsystem.states.size(); j++) {
const PowerStateSubsystemSleepState& state = subsystem.states[j];
for (size_t i = 0; i < subsystems.size(); i++) {
const PowerStateSubsystem &subsystem = subsystems[i];
added = snprintf(offset, remaining,
"state_%zu name=%s time=%" PRIu64 " count=%" PRIu64 " last entry TS(ms)=%" PRIu64 " ",
j + 1, state.name.c_str(), state.residencyInMsecSinceBoot,
state.totalTransitions, state.lastEntryTimestampMs);
"subsystem_%zu name=%s ", i + 1, subsystem.name.c_str());
if (added < 0) {
break;
}
@@ -336,14 +323,33 @@ static jint getSubsystemLowPowerStats(JNIEnv* env, jobject /* clazz */, jobject
offset += added;
remaining -= added;
total_added += added;
}
if (remaining <= 0) {
/* rewrite NULL character*/
offset--;
total_added--;
ALOGE("PowerHal: buffer not enough");
break;
for (size_t j = 0; j < subsystem.states.size(); j++) {
const PowerStateSubsystemSleepState& state = subsystem.states[j];
added = snprintf(offset, remaining,
"state_%zu name=%s time=%" PRIu64 " count=%" PRIu64 " last entry=%" PRIu64 " ",
j + 1, state.name.c_str(), state.residencyInMsecSinceBoot,
state.totalTransitions, state.lastEntryTimestampMs);
if (added < 0) {
break;
}
if (added > remaining) {
added = remaining;
}
offset += added;
remaining -= added;
total_added += added;
}
if (remaining <= 0) {
/* rewrite NULL character*/
offset--;
total_added--;
ALOGE("PowerHal: buffer not enough");
break;
}
}
}
}