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

Commit 787c2950 authored by Michal Brzezinski's avatar Michal Brzezinski
Browse files

Removing LogBuffer wrapping functions, instead calling buffer directly

As per comment https://googleplex-android-review.git.corp.google.com/c/platform/frameworks/base/+/20789219/comment/a398b83a_2e50c9c1/

Bug: 245441667
Test: code compiles
Change-Id: I251be6f2c054f8d5aae08ada1f8a5e7d99792bf6
parent ac2768ae
Loading
Loading
Loading
Loading
+194 −147
Original line number Diff line number Diff line
@@ -49,109 +49,135 @@ class QSLogger @Inject constructor(@QSLog private val buffer: LogBuffer) :
    }

    fun logTileAdded(tileSpec: String) {
        log(DEBUG, {
            str1 = tileSpec
        }, {
            "[$str1] Tile added"
        })
        buffer.log(TAG, DEBUG, { str1 = tileSpec }, { "[$str1] Tile added" })
    }

    fun logTileDestroyed(tileSpec: String, reason: String) {
        log(DEBUG, {
        buffer.log(
            TAG,
            DEBUG,
            {
                str1 = tileSpec
                str2 = reason
        }, {
            "[$str1] Tile destroyed. Reason: $str2"
        })
            },
            { "[$str1] Tile destroyed. Reason: $str2" }
        )
    }

    fun logTileChangeListening(tileSpec: String, listening: Boolean) {
        log(VERBOSE, {
        buffer.log(
            TAG,
            VERBOSE,
            {
                bool1 = listening
                str1 = tileSpec
        }, {
            "[$str1] Tile listening=$bool1"
        })
            },
            { "[$str1] Tile listening=$bool1" }
        )
    }

    fun logAllTilesChangeListening(listening: Boolean, containerName: String, allSpecs: String) {
        log(DEBUG, {
        buffer.log(
            TAG,
            DEBUG,
            {
                bool1 = listening
                str1 = containerName
                str2 = allSpecs
        }, {
            "Tiles listening=$bool1 in $str1. $str2"
        })
            },
            { "Tiles listening=$bool1 in $str1. $str2" }
        )
    }

    fun logTileClick(tileSpec: String, statusBarState: Int, state: Int, eventId: Int) {
        log(DEBUG, {
        buffer.log(
            TAG,
            DEBUG,
            {
                str1 = tileSpec
                int1 = eventId
                str2 = StatusBarState.toString(statusBarState)
                str3 = toStateString(state)
        }, {
            "[$str1][$int1] Tile clicked. StatusBarState=$str2. TileState=$str3"
        })
            },
            { "[$str1][$int1] Tile clicked. StatusBarState=$str2. TileState=$str3" }
        )
    }

    fun logHandleClick(tileSpec: String, eventId: Int) {
        log(DEBUG, {
        buffer.log(
            TAG,
            DEBUG,
            {
                str1 = tileSpec
                int1 = eventId
        }, {
            "[$str1][$int1] Tile handling click."
        })
            },
            { "[$str1][$int1] Tile handling click." }
        )
    }

    fun logTileSecondaryClick(tileSpec: String, statusBarState: Int, state: Int, eventId: Int) {
        log(DEBUG, {
        buffer.log(
            TAG,
            DEBUG,
            {
                str1 = tileSpec
                int1 = eventId
                str2 = StatusBarState.toString(statusBarState)
                str3 = toStateString(state)
        }, {
            "[$str1][$int1] Tile secondary clicked. StatusBarState=$str2. TileState=$str3"
        })
            },
            { "[$str1][$int1] Tile secondary clicked. StatusBarState=$str2. TileState=$str3" }
        )
    }

    fun logHandleSecondaryClick(tileSpec: String, eventId: Int) {
        log(DEBUG, {
        buffer.log(
            TAG,
            DEBUG,
            {
                str1 = tileSpec
                int1 = eventId
        }, {
            "[$str1][$int1] Tile handling secondary click."
        })
            },
            { "[$str1][$int1] Tile handling secondary click." }
        )
    }

    fun logTileLongClick(tileSpec: String, statusBarState: Int, state: Int, eventId: Int) {
        log(DEBUG, {
        buffer.log(
            TAG,
            DEBUG,
            {
                str1 = tileSpec
                int1 = eventId
                str2 = StatusBarState.toString(statusBarState)
                str3 = toStateString(state)
        }, {
            "[$str1][$int1] Tile long clicked. StatusBarState=$str2. TileState=$str3"
        })
            },
            { "[$str1][$int1] Tile long clicked. StatusBarState=$str2. TileState=$str3" }
        )
    }

    fun logHandleLongClick(tileSpec: String, eventId: Int) {
        log(DEBUG, {
        buffer.log(
            TAG,
            DEBUG,
            {
                str1 = tileSpec
                int1 = eventId
        }, {
            "[$str1][$int1] Tile handling long click."
        })
            },
            { "[$str1][$int1] Tile handling long click." }
        )
    }

    fun logInternetTileUpdate(tileSpec: String, lastType: Int, callback: String) {
        log(VERBOSE, {
        buffer.log(
            TAG,
            VERBOSE,
            {
                str1 = tileSpec
                int1 = lastType
                str2 = callback
        }, {
            "[$str1] mLastTileState=$int1, Callback=$str2."
        })
            },
            { "[$str1] mLastTileState=$int1, Callback=$str2." }
        )
    }

    // TODO(b/250618218): Remove this method once we know the root cause of b/250618218.
@@ -167,18 +193,24 @@ class QSLogger @Inject constructor(@QSLog private val buffer: LogBuffer) :
        if (tileSpec != "internet") {
            return
        }
        log(VERBOSE, {
        buffer.log(
            TAG,
            VERBOSE,
            {
                str1 = tileSpec
                int1 = state
                bool1 = disabledByPolicy
                int2 = color
        }, {
            "[$str1] state=$int1, disabledByPolicy=$bool1, color=$int2."
        })
            },
            { "[$str1] state=$int1, disabledByPolicy=$bool1, color=$int2." }
        )
    }

    fun logTileUpdated(tileSpec: String, state: QSTile.State) {
        log(VERBOSE, {
        buffer.log(
            TAG,
            VERBOSE,
            {
                str1 = tileSpec
                str2 = state.label?.toString()
                str3 = state.icon?.toString()
@@ -188,37 +220,48 @@ class QSLogger @Inject constructor(@QSLog private val buffer: LogBuffer) :
                    bool2 = state.activityIn
                    bool3 = state.activityOut
                }
        }, {
            },
            {
                "[$str1] Tile updated. Label=$str2. State=$int1. Icon=$str3." +
                    if (bool1) " Activity in/out=$bool2/$bool3" else ""
        })
            }
        )
    }

    fun logPanelExpanded(expanded: Boolean, containerName: String) {
        log(DEBUG, {
        buffer.log(
            TAG,
            DEBUG,
            {
                str1 = containerName
                bool1 = expanded
        }, {
            "$str1 expanded=$bool1"
        })
            },
            { "$str1 expanded=$bool1" }
        )
    }

    fun logOnViewAttached(orientation: Int, containerName: String) {
        log(DEBUG, {
        buffer.log(
            TAG,
            DEBUG,
            {
                str1 = containerName
                int1 = orientation
        }, {
            "onViewAttached: $str1 orientation $int1"
        })
            },
            { "onViewAttached: $str1 orientation $int1" }
        )
    }

    fun logOnViewDetached(orientation: Int, containerName: String) {
        log(DEBUG, {
        buffer.log(
            TAG,
            DEBUG,
            {
                str1 = containerName
                int1 = orientation
        }, {
            "onViewDetached: $str1 orientation $int1"
        })
            },
            { "onViewDetached: $str1 orientation $int1" }
        )
    }

    fun logOnConfigurationChanged(
@@ -226,13 +269,16 @@ class QSLogger @Inject constructor(@QSLog private val buffer: LogBuffer) :
        newOrientation: Int,
        containerName: String
    ) {
        log(DEBUG, {
        buffer.log(
            TAG,
            DEBUG,
            {
                str1 = containerName
                int1 = lastOrientation
                int2 = newOrientation
        }, {
            "configuration change: $str1 orientation was $int1, now $int2"
        })
            },
            { "configuration change: $str1 orientation was $int1, now $int2" }
        )
    }

    fun logSwitchTileLayout(
@@ -241,32 +287,41 @@ class QSLogger @Inject constructor(@QSLog private val buffer: LogBuffer) :
        force: Boolean,
        containerName: String
    ) {
        log(DEBUG, {
        buffer.log(
            TAG,
            DEBUG,
            {
                str1 = containerName
                bool1 = after
                bool2 = before
                bool3 = force
        }, {
            "change tile layout: $str1 horizontal=$bool1 (was $bool2), force? $bool3"
        })
            },
            { "change tile layout: $str1 horizontal=$bool1 (was $bool2), force? $bool3" }
        )
    }

    fun logTileDistributionInProgress(tilesPerPageCount: Int, totalTilesCount: Int) {
        log(DEBUG, {
        buffer.log(
            TAG,
            DEBUG,
            {
                int1 = tilesPerPageCount
                int2 = totalTilesCount
        }, {
            "Distributing tiles: [tilesPerPageCount=$int1] [totalTilesCount=$int2]"
        })
            },
            { "Distributing tiles: [tilesPerPageCount=$int1] [totalTilesCount=$int2]" }
        )
    }

    fun logTileDistributed(tileName: String, pageIndex: Int) {
        log(DEBUG, {
        buffer.log(
            TAG,
            DEBUG,
            {
                str1 = tileName
                int1 = pageIndex
        }, {
            "Adding $str1 to page number $int1"
        })
            },
            { "Adding $str1 to page number $int1" }
        )
    }

    private fun toStateString(state: Int): String {
@@ -277,12 +332,4 @@ class QSLogger @Inject constructor(@QSLog private val buffer: LogBuffer) :
            else -> "wrong state"
        }
    }

    private inline fun log(
        logLevel: LogLevel,
        initializer: LogMessage.() -> Unit,
        noinline printer: LogMessage.() -> String
    ) {
        buffer.log(TAG, logLevel, initializer, printer)
    }
}
+83 −60
Original line number Diff line number Diff line
@@ -36,16 +36,9 @@ class ShadeLogger @Inject constructor(@ShadeLog private val buffer: LogBuffer) {
        buffer.log(TAG, LogLevel.DEBUG, msg)
    }

    private inline fun log(
        logLevel: LogLevel,
        initializer: LogMessage.() -> Unit,
        noinline printer: LogMessage.() -> String
    ) {
        buffer.log(TAG, logLevel, initializer, printer)
    }

    fun onQsInterceptMoveQsTrackingEnabled(h: Float) {
        log(
        buffer.log(
            TAG,
            LogLevel.VERBOSE,
            { double1 = h.toDouble() },
            { "onQsIntercept: move action, QS tracking enabled. h = $double1" }
@@ -62,7 +55,8 @@ class ShadeLogger @Inject constructor(@ShadeLog private val buffer: LogBuffer) {
        keyguardShowing: Boolean,
        qsExpansionEnabled: Boolean
    ) {
        log(
        buffer.log(
            TAG,
            LogLevel.VERBOSE,
            {
                int1 = initialTouchY.toInt()
@@ -82,7 +76,8 @@ class ShadeLogger @Inject constructor(@ShadeLog private val buffer: LogBuffer) {
    }

    fun logMotionEvent(event: MotionEvent, message: String) {
        log(
        buffer.log(
            TAG,
            LogLevel.VERBOSE,
            {
                str1 = message
@@ -99,7 +94,8 @@ class ShadeLogger @Inject constructor(@ShadeLog private val buffer: LogBuffer) {
    }

    fun logMotionEventStatusBarState(event: MotionEvent, statusBarState: Int, message: String) {
        log(
        buffer.log(
                TAG,
                LogLevel.VERBOSE,
                {
                    str1 = message
@@ -128,25 +124,33 @@ class ShadeLogger @Inject constructor(@ShadeLog private val buffer: LogBuffer) {
            tracking: Boolean,
            dragDownPxAmount: Float,
    ) {
        log(LogLevel.VERBOSE, {
        buffer.log(
            TAG,
            LogLevel.VERBOSE,
            {
                str1 = message
                double1 = fraction.toDouble()
                bool1 = expanded
                bool2 = tracking
                long1 = dragDownPxAmount.toLong()
        }, {
            },
            {
                "$str1 fraction=$double1,expanded=$bool1," +
                    "tracking=$bool2," + "dragDownPxAmount=$dragDownPxAmount"
        })
            }
        )
    }

    fun logHasVibrated(hasVibratedOnOpen: Boolean, fraction: Float) {
        log(LogLevel.VERBOSE, {
        buffer.log(
            TAG,
            LogLevel.VERBOSE,
            {
                bool1 = hasVibratedOnOpen
                double1 = fraction.toDouble()
        }, {
            "hasVibratedOnOpen=$bool1, expansionFraction=$double1"
        })
            },
            { "hasVibratedOnOpen=$bool1, expansionFraction=$double1" }
        )
    }

    fun logQsExpansionChanged(
@@ -159,7 +163,10 @@ class ShadeLogger @Inject constructor(@ShadeLog private val buffer: LogBuffer) {
            qsAnimatorExpand: Boolean,
            animatingQs: Boolean
    ) {
        log(LogLevel.VERBOSE, {
        buffer.log(
            TAG,
            LogLevel.VERBOSE,
            {
                str1 = message
                bool1 = qsExpanded
                int1 = qsMinExpansionHeight
@@ -169,32 +176,43 @@ class ShadeLogger @Inject constructor(@ShadeLog private val buffer: LogBuffer) {
                bool4 = qsAnimatorExpand
                // 0 = false, 1 = true
                long1 = animatingQs.compareTo(false).toLong()
        }, {
            },
            {
                "$str1 qsExpanded=$bool1,qsMinExpansionHeight=$int1,qsMaxExpansionHeight=$int2," +
                    "stackScrollerOverscrolling=$bool2,dozing=$bool3,qsAnimatorExpand=$bool4," +
                    "animatingQs=$long1"
        })
            }
        )
    }

    fun logSingleTapUp(isDozing: Boolean, singleTapEnabled: Boolean, isNotDocked: Boolean) {
        log(LogLevel.DEBUG, {
        buffer.log(
            TAG,
            LogLevel.DEBUG,
            {
                bool1 = isDozing
                bool2 = singleTapEnabled
                bool3 = isNotDocked
        }, {
            },
            {
                "PulsingGestureListener#onSingleTapUp all of this must true for single " +
               "tap to be detected: isDozing: $bool1, singleTapEnabled: $bool2, isNotDocked: $bool3"
        })
    }

    fun logSingleTapUpFalsingState(proximityIsNotNear: Boolean, isNotFalseTap: Boolean) {
        log(LogLevel.DEBUG, {
        buffer.log(
            TAG,
            LogLevel.DEBUG,
            {
                bool1 = proximityIsNotNear
                bool2 = isNotFalseTap
        }, {
            },
            {
                "PulsingGestureListener#onSingleTapUp all of this must true for single " +
                    "tap to be detected: proximityIsNotNear: $bool1, isNotFalseTap: $bool2"
        })
            }
        )
    }

    fun logNotInterceptingTouchInstantExpanding(
@@ -202,13 +220,18 @@ class ShadeLogger @Inject constructor(@ShadeLog private val buffer: LogBuffer) {
            notificationsDragEnabled: Boolean,
            touchDisabled: Boolean
    ) {
        log(LogLevel.VERBOSE, {
        buffer.log(
            TAG,
            LogLevel.VERBOSE,
            {
                bool1 = instantExpanding
                bool2 = notificationsDragEnabled
                bool3 = touchDisabled
        }, {
            },
            {
                "NPVC not intercepting touch, instantExpanding: $bool1, " +
                    "!notificationsDragEnabled: $bool2, touchDisabled: $bool3"
        })
            }
        )
    }
}
+25 −5
Original line number Diff line number Diff line
@@ -32,11 +32,21 @@ class ShadeWindowLogger @Inject constructor(@ShadeWindowLog private val buffer:
    ConstantStringsLogger by ConstantStringsLoggerImpl(buffer, TAG) {

    fun logApplyingWindowLayoutParams(lp: WindowManager.LayoutParams) {
        log(DEBUG, { str1 = lp.toString() }, { "Applying new window layout params: $str1" })
        buffer.log(
            TAG,
            DEBUG,
            { str1 = lp.toString() },
            { "Applying new window layout params: $str1" }
        )
    }

    fun logNewState(state: Any) {
        log(DEBUG, { str1 = state.toString() }, { "Applying new state: $str1" })
        buffer.log(
            TAG,
            DEBUG,
            { str1 = state.toString() },
            { "Applying new state: $str1" }
        )
    }

    private inline fun log(
@@ -48,11 +58,16 @@ class ShadeWindowLogger @Inject constructor(@ShadeWindowLog private val buffer:
    }

    fun logApplyVisibility(visible: Boolean) {
        log(DEBUG, { bool1 = visible }, { "Updating visibility, should be visible : $bool1" })
        buffer.log(
            TAG,
            DEBUG,
            { bool1 = visible },
            { "Updating visibility, should be visible : $bool1" })
    }

    fun logShadeVisibleAndFocusable(visible: Boolean) {
        log(
        buffer.log(
            TAG,
            DEBUG,
            { bool1 = visible },
            { "Updating shade, should be visible and focusable: $bool1" }
@@ -60,6 +75,11 @@ class ShadeWindowLogger @Inject constructor(@ShadeWindowLog private val buffer:
    }

    fun logShadeFocusable(focusable: Boolean) {
        log(DEBUG, { bool1 = focusable }, { "Updating shade, should be focusable : $bool1" })
        buffer.log(
            TAG,
            DEBUG,
            { bool1 = focusable },
            { "Updating shade, should be focusable : $bool1" }
        )
    }
}