[Chipbar] Add logs at the exact time WindowManager calls are made.

Bug: 271411294
Test: Verified logs occurred at the correct times when the chipbar
appeared and disappered

Change-Id: I3c1f0ebb72407ff4b2a073ea927f5a0ab0e71250
This commit is contained in:
Caitlin Shkuratov
2023-03-08 21:07:06 +00:00
parent 8b3f856cdc
commit 6595af0308
2 changed files with 50 additions and 0 deletions

View File

@@ -274,6 +274,7 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora
it.title = newInfo.windowTitle
}
newView.keepScreenOn = true
logger.logViewAddedToWindowManager(displayInfo.info, newView)
windowManager.addView(newView, paramsWithTitle)
animateViewIn(newView)
}
@@ -286,6 +287,11 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora
val view = checkNotNull(currentDisplayInfo.view) {
"First item in activeViews list must have a valid view"
}
logger.logViewRemovedFromWindowManager(
currentDisplayInfo.info,
view,
isReinflation = true,
)
windowManager.removeView(view)
inflateAndUpdateView(currentDisplayInfo)
}
@@ -382,6 +388,7 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora
}
displayInfo.view = null // Need other places??
animateViewOut(view, removalReason) {
logger.logViewRemovedFromWindowManager(displayInfo.info, view)
windowManager.removeView(view)
displayInfo.wakeLock?.release(displayInfo.info.wakeReason)
}

View File

@@ -16,6 +16,7 @@
package com.android.systemui.temporarydisplay
import android.view.View
import com.android.systemui.plugins.log.LogBuffer
import com.android.systemui.plugins.log.LogLevel
@@ -141,4 +142,46 @@ open class TemporaryViewLogger<T : TemporaryViewInfo>(
{ "Removal of view with id=$str2 is ignored because $str1" }
)
}
fun logViewAddedToWindowManager(info: T, view: View) {
buffer.log(
tag,
LogLevel.DEBUG,
{
str1 = info.id
str2 = info.windowTitle
str3 = view.javaClass.name
int1 = view.getIdForLogging()
},
{
"Adding view to window manager. " +
"id=$str1 window=$str2 view=$str3(id=${Integer.toHexString(int1)})"
}
)
}
fun logViewRemovedFromWindowManager(info: T, view: View, isReinflation: Boolean = false) {
buffer.log(
tag,
LogLevel.DEBUG,
{
str1 = info.id
str2 = info.windowTitle
str3 = view.javaClass.name
int1 = view.getIdForLogging()
bool1 = isReinflation
},
{
"Removing view from window manager${if (bool1) " due to reinflation" else ""}. " +
"id=$str1 window=$str2 view=$str3(id=${Integer.toHexString(int1)})"
}
)
}
companion object {
private fun View.getIdForLogging(): Int {
// The identityHashCode is guaranteed to be constant for the lifetime of the object.
return System.identityHashCode(this)
}
}
}