From 8f9bf978e108464579527595ebb455f5b175b8e7 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Fri, 31 Mar 2023 10:11:06 -0700 Subject: [PATCH] Ignore OverlayHandlerView as active child Summary: On foldable devices, there's an issue whereas the topmost root view is of type `OverlayHandlerView`. This doesn't seem to be related in any way to the running app's UI. Or at least is not something of interest when debugging the running app's UI (for example, ig4a). This change effectively ignores the `OverlayHandlerView` instance as active child and instead returns the next to last root view. Reviewed By: LukeDefeo Differential Revision: D44579223 fbshipit-source-id: cea52289c5ba1e6a96817232ac54725b8d2f48d9 --- .../uidebugger/descriptors/ApplicationRefDescriptor.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/descriptors/ApplicationRefDescriptor.kt b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/descriptors/ApplicationRefDescriptor.kt index 4a3beadc7..eea5a20a4 100644 --- a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/descriptors/ApplicationRefDescriptor.kt +++ b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/descriptors/ApplicationRefDescriptor.kt @@ -18,7 +18,15 @@ object ApplicationRefDescriptor : ChainedDescriptor() { override fun onGetActiveChild(node: ApplicationRef): Any? { val children = onGetChildren(node) - return if (children.isNotEmpty()) children.last() else null + if (children.isNotEmpty()) { + val last = children.last() + if (last.javaClass.simpleName.contains("OverlayHandlerView")) { + return children.getOrNull(children.size - 2) + } + return last + } + + return null } override fun onGetBounds(node: ApplicationRef): Bounds = DisplayMetrics.getDisplayBounds()