Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d5b3c800 authored by Beverly's avatar Beverly
Browse files

Add status bar state logs

Log the upcoming status bar state

Test: manually check logs (sysui dumpsys)
Bug: 205587594
Change-Id: I3316faac4bea5a79863092d79fed33216308dc21
parent 91af339b
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -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,28 +506,33 @@ 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(")");
                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=")