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

Commit 2429cb01 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov Committed by Android (Google) Code Review
Browse files

Merge "[Central Surfaces][Disable] Remove `old` from the disable logger." into udc-qpr-dev

parents ceceefa5 ebddcea8
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ class QSFragmentDisableFlagsLogger @Inject constructor(
            },
            {
                disableFlagsLogger.getDisableFlagsString(
                    old = null,
                    new = DisableFlagsLogger.DisableState(int1, int2),
                    newAfterLocalModification =
                        DisableFlagsLogger.DisableState(long1.toInt(), long2.toInt())
+7 −28
Original line number Diff line number Diff line
@@ -71,15 +71,14 @@ class DisableFlagsLogger constructor(
    }

    /**
     * Returns a string representing the, old, new, and new-after-modification disable flag states,
     * as well as the differences between each of the states.
     * Returns a string representing the new and new-after-modification disable flag states,
     * as well as the differences between them (if there are any).
     *
     * Example if [old], [new], and [newAfterLocalModification] are all different:
     *   Old: EnaiHbcRso.qINgr | New: EnaihBcRso.qiNGR (changed: hB.iGR) | New after local
     *   modification: EnaihBcRso.qInGR (changed: .n)
     * Example if [new] and [newAfterLocalModification] are different:
     *   New: EnaihBcRso.qiNGR | New after local modification: EnaihBCRso.qInGR (changed: C.In)
     *
     * Example if [old] and [new] are the same:
     *   EnaihBcRso.qiNGR (unchanged)
     * Example if [new] and [newAfterLocalModification] are the same:
     *   New: EnaihBcRso.qiNGR
     *
     * A capital character signifies the flag is set and a lowercase character signifies that the
     * flag isn't set. The flag states will be logged in the same order as the passed-in lists.
@@ -88,37 +87,17 @@ class DisableFlagsLogger constructor(
     * is no difference. the new-after-modification state also won't be included if there's no
     * difference from the new state.
     *
     * @param old the disable state that had been previously sent. Null if we don't need to log the
     *   previously sent state.
     * @param new the new disable state that has just been sent.
     * @param newAfterLocalModification the new disable states after a class has locally modified
     *   them. Null if the class does not locally modify.
     */
    fun getDisableFlagsString(
        old: DisableState? = null,
        new: DisableState,
        newAfterLocalModification: DisableState? = null
    ): String {
        val builder = StringBuilder("Received new disable state: ")

        // This if/else has slightly repetitive code but is easier to read.
        if (old != null && old != new) {
            builder.append("Old: ")
            builder.append(getFlagsString(old))
            builder.append(" | ")
            builder.append("New: ")
        builder.append(getFlagsString(new))
            builder.append(" ")
            builder.append(getDiffString(old, new))
        } else if (old != null && old == new) {
            // If old and new are the same, we only need to print one of them.
            builder.append(getFlagsString(new))
            builder.append(" ")
            builder.append(getDiffString(old, new))
        } else { // old == null
            builder.append(getFlagsString(new))
            // Don't get a diff string because we have no [old] to compare with.
        }

        if (newAfterLocalModification != null && new != newAfterLocalModification) {
            builder.append(" | New after local modification: ")
+0 −2
Original line number Diff line number Diff line
@@ -255,8 +255,6 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba
        state2 = mRemoteInputQuickSettingsDisabler.adjustDisableFlags(state2);
        Log.d(CentralSurfaces.TAG,
                mDisableFlagsLogger.getDisableFlagsString(
                        /* old= */ new DisableFlagsLogger.DisableState(
                                mCentralSurfaces.getDisabled1(), mCentralSurfaces.getDisabled2()),
                        /* new= */ new DisableFlagsLogger.DisableState(
                                state1, state2BeforeAdjustment),
                        /* newStateAfterLocalModification= */ new DisableFlagsLogger.DisableState(
+1 −3
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ class CollapsedStatusBarFragmentLogger @Inject constructor(
     * modifications that were made to the flags locally.
     *
     * @param new see [DisableFlagsLogger.getDisableFlagsString]
     * @param newAfterLocalModification see [DisableFlagsLogger.getDisableFlagsString]
     */
    fun logDisableFlagChange(
        new: DisableFlagsLogger.DisableState,
@@ -47,8 +46,7 @@ class CollapsedStatusBarFragmentLogger @Inject constructor(
                },
                {
                    disableFlagsLogger.getDisableFlagsString(
                        old = null,
                        new = DisableFlagsLogger.DisableState(int1, int2),
                        DisableFlagsLogger.DisableState(int1, int2),
                    )
                }
        )
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ class QSFragmentDisableFlagsLoggerTest : SysuiTestCase() {
        buffer.dump(PrintWriter(stringWriter), tailLength = 0)
        val actualString = stringWriter.toString()
        val expectedLogString = disableFlagsLogger.getDisableFlagsString(
            old = null, new = state, newAfterLocalModification = state
            new = state, newAfterLocalModification = state
        )

        assertThat(actualString).contains(expectedLogString)
Loading