Merge "Removing LogBuffer wrapping functions, instead calling buffer directly" into tm-qpr-dev

This commit is contained in:
Michał Brzeziński
2023-01-11 18:02:58 +00:00
committed by Android (Google) Code Review
3 changed files with 302 additions and 212 deletions

View File

@@ -49,109 +49,135 @@ class QSLogger @Inject constructor(@QSLog private val buffer: LogBuffer) :
} }
fun logTileAdded(tileSpec: String) { fun logTileAdded(tileSpec: String) {
log(DEBUG, { buffer.log(TAG, DEBUG, { str1 = tileSpec }, { "[$str1] Tile added" })
str1 = tileSpec
}, {
"[$str1] Tile added"
})
} }
fun logTileDestroyed(tileSpec: String, reason: String) { fun logTileDestroyed(tileSpec: String, reason: String) {
log(DEBUG, { buffer.log(
str1 = tileSpec TAG,
str2 = reason DEBUG,
}, { {
"[$str1] Tile destroyed. Reason: $str2" str1 = tileSpec
}) str2 = reason
},
{ "[$str1] Tile destroyed. Reason: $str2" }
)
} }
fun logTileChangeListening(tileSpec: String, listening: Boolean) { fun logTileChangeListening(tileSpec: String, listening: Boolean) {
log(VERBOSE, { buffer.log(
bool1 = listening TAG,
str1 = tileSpec VERBOSE,
}, { {
"[$str1] Tile listening=$bool1" bool1 = listening
}) str1 = tileSpec
},
{ "[$str1] Tile listening=$bool1" }
)
} }
fun logAllTilesChangeListening(listening: Boolean, containerName: String, allSpecs: String) { fun logAllTilesChangeListening(listening: Boolean, containerName: String, allSpecs: String) {
log(DEBUG, { buffer.log(
bool1 = listening TAG,
str1 = containerName DEBUG,
str2 = allSpecs {
}, { bool1 = listening
"Tiles listening=$bool1 in $str1. $str2" str1 = containerName
}) str2 = allSpecs
},
{ "Tiles listening=$bool1 in $str1. $str2" }
)
} }
fun logTileClick(tileSpec: String, statusBarState: Int, state: Int, eventId: Int) { fun logTileClick(tileSpec: String, statusBarState: Int, state: Int, eventId: Int) {
log(DEBUG, { buffer.log(
str1 = tileSpec TAG,
int1 = eventId DEBUG,
str2 = StatusBarState.toString(statusBarState) {
str3 = toStateString(state) str1 = tileSpec
}, { int1 = eventId
"[$str1][$int1] Tile clicked. StatusBarState=$str2. TileState=$str3" str2 = StatusBarState.toString(statusBarState)
}) str3 = toStateString(state)
},
{ "[$str1][$int1] Tile clicked. StatusBarState=$str2. TileState=$str3" }
)
} }
fun logHandleClick(tileSpec: String, eventId: Int) { fun logHandleClick(tileSpec: String, eventId: Int) {
log(DEBUG, { buffer.log(
str1 = tileSpec TAG,
int1 = eventId DEBUG,
}, { {
"[$str1][$int1] Tile handling click." str1 = tileSpec
}) int1 = eventId
},
{ "[$str1][$int1] Tile handling click." }
)
} }
fun logTileSecondaryClick(tileSpec: String, statusBarState: Int, state: Int, eventId: Int) { fun logTileSecondaryClick(tileSpec: String, statusBarState: Int, state: Int, eventId: Int) {
log(DEBUG, { buffer.log(
str1 = tileSpec TAG,
int1 = eventId DEBUG,
str2 = StatusBarState.toString(statusBarState) {
str3 = toStateString(state) str1 = tileSpec
}, { int1 = eventId
"[$str1][$int1] Tile secondary clicked. StatusBarState=$str2. TileState=$str3" str2 = StatusBarState.toString(statusBarState)
}) str3 = toStateString(state)
},
{ "[$str1][$int1] Tile secondary clicked. StatusBarState=$str2. TileState=$str3" }
)
} }
fun logHandleSecondaryClick(tileSpec: String, eventId: Int) { fun logHandleSecondaryClick(tileSpec: String, eventId: Int) {
log(DEBUG, { buffer.log(
str1 = tileSpec TAG,
int1 = eventId DEBUG,
}, { {
"[$str1][$int1] Tile handling secondary click." str1 = tileSpec
}) int1 = eventId
},
{ "[$str1][$int1] Tile handling secondary click." }
)
} }
fun logTileLongClick(tileSpec: String, statusBarState: Int, state: Int, eventId: Int) { fun logTileLongClick(tileSpec: String, statusBarState: Int, state: Int, eventId: Int) {
log(DEBUG, { buffer.log(
str1 = tileSpec TAG,
int1 = eventId DEBUG,
str2 = StatusBarState.toString(statusBarState) {
str3 = toStateString(state) str1 = tileSpec
}, { int1 = eventId
"[$str1][$int1] Tile long clicked. StatusBarState=$str2. TileState=$str3" str2 = StatusBarState.toString(statusBarState)
}) str3 = toStateString(state)
},
{ "[$str1][$int1] Tile long clicked. StatusBarState=$str2. TileState=$str3" }
)
} }
fun logHandleLongClick(tileSpec: String, eventId: Int) { fun logHandleLongClick(tileSpec: String, eventId: Int) {
log(DEBUG, { buffer.log(
str1 = tileSpec TAG,
int1 = eventId DEBUG,
}, { {
"[$str1][$int1] Tile handling long click." str1 = tileSpec
}) int1 = eventId
},
{ "[$str1][$int1] Tile handling long click." }
)
} }
fun logInternetTileUpdate(tileSpec: String, lastType: Int, callback: String) { fun logInternetTileUpdate(tileSpec: String, lastType: Int, callback: String) {
log(VERBOSE, { buffer.log(
str1 = tileSpec TAG,
int1 = lastType VERBOSE,
str2 = callback {
}, { str1 = tileSpec
"[$str1] mLastTileState=$int1, Callback=$str2." int1 = lastType
}) str2 = callback
},
{ "[$str1] mLastTileState=$int1, Callback=$str2." }
)
} }
// TODO(b/250618218): Remove this method once we know the root cause of b/250618218. // TODO(b/250618218): Remove this method once we know the root cause of b/250618218.
@@ -167,58 +193,75 @@ class QSLogger @Inject constructor(@QSLog private val buffer: LogBuffer) :
if (tileSpec != "internet") { if (tileSpec != "internet") {
return return
} }
log(VERBOSE, { buffer.log(
str1 = tileSpec TAG,
int1 = state VERBOSE,
bool1 = disabledByPolicy {
int2 = color str1 = tileSpec
}, { int1 = state
"[$str1] state=$int1, disabledByPolicy=$bool1, color=$int2." bool1 = disabledByPolicy
}) int2 = color
},
{ "[$str1] state=$int1, disabledByPolicy=$bool1, color=$int2." }
)
} }
fun logTileUpdated(tileSpec: String, state: QSTile.State) { fun logTileUpdated(tileSpec: String, state: QSTile.State) {
log(VERBOSE, { buffer.log(
str1 = tileSpec TAG,
str2 = state.label?.toString() VERBOSE,
str3 = state.icon?.toString() {
int1 = state.state str1 = tileSpec
if (state is QSTile.SignalState) { str2 = state.label?.toString()
bool1 = true str3 = state.icon?.toString()
bool2 = state.activityIn int1 = state.state
bool3 = state.activityOut if (state is QSTile.SignalState) {
bool1 = true
bool2 = state.activityIn
bool3 = state.activityOut
}
},
{
"[$str1] Tile updated. Label=$str2. State=$int1. Icon=$str3." +
if (bool1) " Activity in/out=$bool2/$bool3" else ""
} }
}, { )
"[$str1] Tile updated. Label=$str2. State=$int1. Icon=$str3." +
if (bool1) " Activity in/out=$bool2/$bool3" else ""
})
} }
fun logPanelExpanded(expanded: Boolean, containerName: String) { fun logPanelExpanded(expanded: Boolean, containerName: String) {
log(DEBUG, { buffer.log(
str1 = containerName TAG,
bool1 = expanded DEBUG,
}, { {
"$str1 expanded=$bool1" str1 = containerName
}) bool1 = expanded
},
{ "$str1 expanded=$bool1" }
)
} }
fun logOnViewAttached(orientation: Int, containerName: String) { fun logOnViewAttached(orientation: Int, containerName: String) {
log(DEBUG, { buffer.log(
str1 = containerName TAG,
int1 = orientation DEBUG,
}, { {
"onViewAttached: $str1 orientation $int1" str1 = containerName
}) int1 = orientation
},
{ "onViewAttached: $str1 orientation $int1" }
)
} }
fun logOnViewDetached(orientation: Int, containerName: String) { fun logOnViewDetached(orientation: Int, containerName: String) {
log(DEBUG, { buffer.log(
str1 = containerName TAG,
int1 = orientation DEBUG,
}, { {
"onViewDetached: $str1 orientation $int1" str1 = containerName
}) int1 = orientation
},
{ "onViewDetached: $str1 orientation $int1" }
)
} }
fun logOnConfigurationChanged( fun logOnConfigurationChanged(
@@ -226,13 +269,16 @@ class QSLogger @Inject constructor(@QSLog private val buffer: LogBuffer) :
newOrientation: Int, newOrientation: Int,
containerName: String containerName: String
) { ) {
log(DEBUG, { buffer.log(
str1 = containerName TAG,
int1 = lastOrientation DEBUG,
int2 = newOrientation {
}, { str1 = containerName
"configuration change: $str1 orientation was $int1, now $int2" int1 = lastOrientation
}) int2 = newOrientation
},
{ "configuration change: $str1 orientation was $int1, now $int2" }
)
} }
fun logSwitchTileLayout( fun logSwitchTileLayout(
@@ -241,32 +287,41 @@ class QSLogger @Inject constructor(@QSLog private val buffer: LogBuffer) :
force: Boolean, force: Boolean,
containerName: String containerName: String
) { ) {
log(DEBUG, { buffer.log(
str1 = containerName TAG,
bool1 = after DEBUG,
bool2 = before {
bool3 = force str1 = containerName
}, { bool1 = after
"change tile layout: $str1 horizontal=$bool1 (was $bool2), force? $bool3" bool2 = before
}) bool3 = force
},
{ "change tile layout: $str1 horizontal=$bool1 (was $bool2), force? $bool3" }
)
} }
fun logTileDistributionInProgress(tilesPerPageCount: Int, totalTilesCount: Int) { fun logTileDistributionInProgress(tilesPerPageCount: Int, totalTilesCount: Int) {
log(DEBUG, { buffer.log(
int1 = tilesPerPageCount TAG,
int2 = totalTilesCount DEBUG,
}, { {
"Distributing tiles: [tilesPerPageCount=$int1] [totalTilesCount=$int2]" int1 = tilesPerPageCount
}) int2 = totalTilesCount
},
{ "Distributing tiles: [tilesPerPageCount=$int1] [totalTilesCount=$int2]" }
)
} }
fun logTileDistributed(tileName: String, pageIndex: Int) { fun logTileDistributed(tileName: String, pageIndex: Int) {
log(DEBUG, { buffer.log(
str1 = tileName TAG,
int1 = pageIndex DEBUG,
}, { {
"Adding $str1 to page number $int1" str1 = tileName
}) int1 = pageIndex
},
{ "Adding $str1 to page number $int1" }
)
} }
private fun toStateString(state: Int): String { private fun toStateString(state: Int): String {
@@ -277,12 +332,4 @@ class QSLogger @Inject constructor(@QSLog private val buffer: LogBuffer) :
else -> "wrong state" else -> "wrong state"
} }
} }
private inline fun log(
logLevel: LogLevel,
initializer: LogMessage.() -> Unit,
noinline printer: LogMessage.() -> String
) {
buffer.log(TAG, logLevel, initializer, printer)
}
} }

View File

@@ -36,16 +36,9 @@ class ShadeLogger @Inject constructor(@ShadeLog private val buffer: LogBuffer) {
buffer.log(TAG, LogLevel.DEBUG, msg) 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) { fun onQsInterceptMoveQsTrackingEnabled(h: Float) {
log( buffer.log(
TAG,
LogLevel.VERBOSE, LogLevel.VERBOSE,
{ double1 = h.toDouble() }, { double1 = h.toDouble() },
{ "onQsIntercept: move action, QS tracking enabled. h = $double1" } { "onQsIntercept: move action, QS tracking enabled. h = $double1" }
@@ -62,7 +55,8 @@ class ShadeLogger @Inject constructor(@ShadeLog private val buffer: LogBuffer) {
keyguardShowing: Boolean, keyguardShowing: Boolean,
qsExpansionEnabled: Boolean qsExpansionEnabled: Boolean
) { ) {
log( buffer.log(
TAG,
LogLevel.VERBOSE, LogLevel.VERBOSE,
{ {
int1 = initialTouchY.toInt() int1 = initialTouchY.toInt()
@@ -82,7 +76,8 @@ class ShadeLogger @Inject constructor(@ShadeLog private val buffer: LogBuffer) {
} }
fun logMotionEvent(event: MotionEvent, message: String) { fun logMotionEvent(event: MotionEvent, message: String) {
log( buffer.log(
TAG,
LogLevel.VERBOSE, LogLevel.VERBOSE,
{ {
str1 = message str1 = message
@@ -99,7 +94,8 @@ class ShadeLogger @Inject constructor(@ShadeLog private val buffer: LogBuffer) {
} }
fun logMotionEventStatusBarState(event: MotionEvent, statusBarState: Int, message: String) { fun logMotionEventStatusBarState(event: MotionEvent, statusBarState: Int, message: String) {
log( buffer.log(
TAG,
LogLevel.VERBOSE, LogLevel.VERBOSE,
{ {
str1 = message str1 = message
@@ -128,25 +124,33 @@ class ShadeLogger @Inject constructor(@ShadeLog private val buffer: LogBuffer) {
tracking: Boolean, tracking: Boolean,
dragDownPxAmount: Float, dragDownPxAmount: Float,
) { ) {
log(LogLevel.VERBOSE, { buffer.log(
str1 = message TAG,
double1 = fraction.toDouble() LogLevel.VERBOSE,
bool1 = expanded {
bool2 = tracking str1 = message
long1 = dragDownPxAmount.toLong() double1 = fraction.toDouble()
}, { bool1 = expanded
"$str1 fraction=$double1,expanded=$bool1," + bool2 = tracking
long1 = dragDownPxAmount.toLong()
},
{
"$str1 fraction=$double1,expanded=$bool1," +
"tracking=$bool2," + "dragDownPxAmount=$dragDownPxAmount" "tracking=$bool2," + "dragDownPxAmount=$dragDownPxAmount"
}) }
)
} }
fun logHasVibrated(hasVibratedOnOpen: Boolean, fraction: Float) { fun logHasVibrated(hasVibratedOnOpen: Boolean, fraction: Float) {
log(LogLevel.VERBOSE, { buffer.log(
bool1 = hasVibratedOnOpen TAG,
double1 = fraction.toDouble() LogLevel.VERBOSE,
}, { {
"hasVibratedOnOpen=$bool1, expansionFraction=$double1" bool1 = hasVibratedOnOpen
}) double1 = fraction.toDouble()
},
{ "hasVibratedOnOpen=$bool1, expansionFraction=$double1" }
)
} }
fun logQsExpansionChanged( fun logQsExpansionChanged(
@@ -159,42 +163,56 @@ class ShadeLogger @Inject constructor(@ShadeLog private val buffer: LogBuffer) {
qsAnimatorExpand: Boolean, qsAnimatorExpand: Boolean,
animatingQs: Boolean animatingQs: Boolean
) { ) {
log(LogLevel.VERBOSE, { buffer.log(
str1 = message TAG,
bool1 = qsExpanded LogLevel.VERBOSE,
int1 = qsMinExpansionHeight {
int2 = qsMaxExpansionHeight str1 = message
bool2 = stackScrollerOverscrolling bool1 = qsExpanded
bool3 = dozing int1 = qsMinExpansionHeight
bool4 = qsAnimatorExpand int2 = qsMaxExpansionHeight
// 0 = false, 1 = true bool2 = stackScrollerOverscrolling
long1 = animatingQs.compareTo(false).toLong() bool3 = dozing
}, { bool4 = qsAnimatorExpand
"$str1 qsExpanded=$bool1,qsMinExpansionHeight=$int1,qsMaxExpansionHeight=$int2," + // 0 = false, 1 = true
long1 = animatingQs.compareTo(false).toLong()
},
{
"$str1 qsExpanded=$bool1,qsMinExpansionHeight=$int1,qsMaxExpansionHeight=$int2," +
"stackScrollerOverscrolling=$bool2,dozing=$bool3,qsAnimatorExpand=$bool4," + "stackScrollerOverscrolling=$bool2,dozing=$bool3,qsAnimatorExpand=$bool4," +
"animatingQs=$long1" "animatingQs=$long1"
}) }
)
} }
fun logSingleTapUp(isDozing: Boolean, singleTapEnabled: Boolean, isNotDocked: Boolean) { fun logSingleTapUp(isDozing: Boolean, singleTapEnabled: Boolean, isNotDocked: Boolean) {
log(LogLevel.DEBUG, { buffer.log(
bool1 = isDozing TAG,
bool2 = singleTapEnabled LogLevel.DEBUG,
bool3 = isNotDocked {
}, { bool1 = isDozing
"PulsingGestureListener#onSingleTapUp all of this must true for single " + bool2 = singleTapEnabled
"tap to be detected: isDozing: $bool1, singleTapEnabled: $bool2, isNotDocked: $bool3" 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) { fun logSingleTapUpFalsingState(proximityIsNotNear: Boolean, isNotFalseTap: Boolean) {
log(LogLevel.DEBUG, { buffer.log(
bool1 = proximityIsNotNear TAG,
bool2 = isNotFalseTap LogLevel.DEBUG,
}, { {
"PulsingGestureListener#onSingleTapUp all of this must true for single " + bool1 = proximityIsNotNear
bool2 = isNotFalseTap
},
{
"PulsingGestureListener#onSingleTapUp all of this must true for single " +
"tap to be detected: proximityIsNotNear: $bool1, isNotFalseTap: $bool2" "tap to be detected: proximityIsNotNear: $bool1, isNotFalseTap: $bool2"
}) }
)
} }
fun logNotInterceptingTouchInstantExpanding( fun logNotInterceptingTouchInstantExpanding(
@@ -202,13 +220,18 @@ class ShadeLogger @Inject constructor(@ShadeLog private val buffer: LogBuffer) {
notificationsDragEnabled: Boolean, notificationsDragEnabled: Boolean,
touchDisabled: Boolean touchDisabled: Boolean
) { ) {
log(LogLevel.VERBOSE, { buffer.log(
bool1 = instantExpanding TAG,
bool2 = notificationsDragEnabled LogLevel.VERBOSE,
bool3 = touchDisabled {
}, { bool1 = instantExpanding
"NPVC not intercepting touch, instantExpanding: $bool1, " + bool2 = notificationsDragEnabled
bool3 = touchDisabled
},
{
"NPVC not intercepting touch, instantExpanding: $bool1, " +
"!notificationsDragEnabled: $bool2, touchDisabled: $bool3" "!notificationsDragEnabled: $bool2, touchDisabled: $bool3"
}) }
)
} }
} }

View File

@@ -32,11 +32,21 @@ class ShadeWindowLogger @Inject constructor(@ShadeWindowLog private val buffer:
ConstantStringsLogger by ConstantStringsLoggerImpl(buffer, TAG) { ConstantStringsLogger by ConstantStringsLoggerImpl(buffer, TAG) {
fun logApplyingWindowLayoutParams(lp: WindowManager.LayoutParams) { 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) { 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( private inline fun log(
@@ -48,11 +58,16 @@ class ShadeWindowLogger @Inject constructor(@ShadeWindowLog private val buffer:
} }
fun logApplyVisibility(visible: Boolean) { 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) { fun logShadeVisibleAndFocusable(visible: Boolean) {
log( buffer.log(
TAG,
DEBUG, DEBUG,
{ bool1 = visible }, { bool1 = visible },
{ "Updating shade, should be visible and focusable: $bool1" } { "Updating shade, should be visible and focusable: $bool1" }
@@ -60,6 +75,11 @@ class ShadeWindowLogger @Inject constructor(@ShadeWindowLog private val buffer:
} }
fun logShadeFocusable(focusable: Boolean) { 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" }
)
} }
} }