From 6595af030870f3215ea7ed07700bd0c204188a02 Mon Sep 17 00:00:00 2001 From: Caitlin Shkuratov Date: Wed, 8 Mar 2023 21:07:06 +0000 Subject: [PATCH] [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 --- .../TemporaryViewDisplayController.kt | 7 +++ .../temporarydisplay/TemporaryViewLogger.kt | 43 +++++++++++++++++++ 2 files changed, 50 insertions(+) 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) + } + } }