Merge "Add status bar state logs" into sc-v2-dev

This commit is contained in:
TreeHugger Robot
2021-11-11 14:29:21 +00:00
committed by Android (Google) Code Review

View File

@@ -173,7 +173,7 @@ public class StatusBarStateControllerImpl implements
}
// Record the to-be mState and mLastState
recordHistoricalState(state, mState);
recordHistoricalState(state /* newState */, mState /* lastState */, false);
// b/139259891
if (mState == StatusBarState.SHADE && state == StatusBarState.SHADE_LOCKED) {
@@ -206,6 +206,7 @@ public class StatusBarStateControllerImpl implements
@Override
public void setUpcomingState(int nextState) {
mUpcomingState = nextState;
recordHistoricalState(mUpcomingState /* newState */, mState /* lastState */, true);
}
@Override
@@ -505,31 +506,36 @@ public class StatusBarStateControllerImpl implements
}
}
private void recordHistoricalState(int currentState, int lastState) {
private void recordHistoricalState(int newState, int lastState, boolean upcoming) {
mHistoryIndex = (mHistoryIndex + 1) % HISTORY_SIZE;
HistoricalState state = mHistoricalRecords[mHistoryIndex];
state.mState = currentState;
state.mNewState = newState;
state.mLastState = lastState;
state.mTimestamp = System.currentTimeMillis();
state.mUpcoming = upcoming;
}
/**
* For keeping track of our previous state to help with debugging
*/
private static class HistoricalState {
int mState;
int mNewState;
int mLastState;
long mTimestamp;
boolean mUpcoming;
@Override
public String toString() {
if (mTimestamp != 0) {
StringBuilder sb = new StringBuilder();
sb.append("state=").append(mState)
.append(" (").append(describe(mState)).append(")");
sb.append("lastState=").append(mLastState).append(" (").append(describe(mLastState))
if (mUpcoming) {
sb.append("upcoming-");
}
sb.append("newState=").append(mNewState)
.append("(").append(describe(mNewState)).append(")");
sb.append(" lastState=").append(mLastState).append("(").append(describe(mLastState))
.append(")");
sb.append("timestamp=")
sb.append(" timestamp=")
.append(DateFormat.format("MM-dd HH:mm:ss", mTimestamp));
return sb.toString();