diff --git a/packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayController.kt b/packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayController.kt index c6cb79a6a8802..59122aff7f216 100644 --- a/packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayController.kt +++ b/packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayController.kt @@ -274,6 +274,7 @@ abstract class TemporaryViewDisplayController( { "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) + } + } }