From 366fb5bfcb2fd14504da9702759b431840bd0caf Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Wed, 6 Dec 2023 11:23:41 -0800 Subject: InputDispatcher: dump window in a separate function This makes it more convenient to dump windows from other places during debugging. For example, this could also be called from setInputWindows to inspect all of the window flags that might be changing. Bug: 312714754 Test: adb shell dumpsys input Change-Id: I2ace23bec1231f3a318e1b6a19f146b588e077b6 --- libs/gui/WindowInfo.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'libs/gui/WindowInfo.cpp') diff --git a/libs/gui/WindowInfo.cpp b/libs/gui/WindowInfo.cpp index 6a4460b650..ba1d196e9c 100644 --- a/libs/gui/WindowInfo.cpp +++ b/libs/gui/WindowInfo.cpp @@ -26,6 +26,41 @@ namespace android::gui { +namespace { + +std::ostream& operator<<(std::ostream& out, const sp& binder) { + if (binder == nullptr) { + out << ""; + } else { + out << binder.get(); + } + return out; +} + +std::ostream& operator<<(std::ostream& out, const Region& region) { + if (region.isEmpty()) { + out << ""; + return out; + } + + bool first = true; + Region::const_iterator cur = region.begin(); + Region::const_iterator const tail = region.end(); + while (cur != tail) { + if (first) { + first = false; + } else { + out << "|"; + } + out << "[" << cur->left << "," << cur->top << "][" << cur->right << "," << cur->bottom + << "]"; + cur++; + } + return out; +} + +} // namespace + void WindowInfo::setInputConfig(ftl::Flags config, bool value) { if (value) { inputConfig |= config; @@ -222,4 +257,24 @@ sp WindowInfoHandle::getToken() const { void WindowInfoHandle::updateFrom(sp handle) { mInfo = handle->mInfo; } + +std::ostream& operator<<(std::ostream& out, const WindowInfoHandle& window) { + const WindowInfo& info = *window.getInfo(); + std::string transform; + info.transform.dump(transform, "transform", " "); + out << "name=" << info.name << ", id=" << info.id << ", displayId=" << info.displayId + << ", inputConfig=" << info.inputConfig.string() << ", alpha=" << info.alpha << ", frame=[" + << info.frame.left << "," << info.frame.top << "][" << info.frame.right << "," + << info.frame.bottom << "], globalScale=" << info.globalScaleFactor + << ", applicationInfo.name=" << info.applicationInfo.name + << ", applicationInfo.token=" << info.applicationInfo.token + << ", touchableRegion=" << info.touchableRegion << ", ownerPid=" << info.ownerPid.toString() + << ", ownerUid=" << info.ownerUid.toString() << ", dispatchingTimeout=" + << std::chrono::duration_cast(info.dispatchingTimeout).count() + << "ms, token=" << info.token.get() + << ", touchOcclusionMode=" << ftl::enum_string(info.touchOcclusionMode) << "\n" + << transform; + return out; +} + } // namespace android::gui -- cgit v1.2.3-59-g8ed1b