InputDispatcher: Blame the window from the focus request for ANR
If there are no focusable windows, then try to blame the window that
was requested to become focused. This will avoid blaming the wrong
process when WM requests focus on a window that is placed on top
of the focused app and the window fails to become focusable.
Test: atest inputflinger_tests
Fixes: b/239907039
Change-Id: Ie2bc3dc66516b51784159a875c7cf865b4cb5b35
diff --git a/services/inputflinger/dispatcher/FocusResolver.h b/services/inputflinger/dispatcher/FocusResolver.h
index 6d11a77..8a6dfa4 100644
--- a/services/inputflinger/dispatcher/FocusResolver.h
+++ b/services/inputflinger/dispatcher/FocusResolver.h
@@ -62,6 +62,7 @@
std::optional<FocusResolver::FocusChanges> setFocusedWindow(
const android::gui::FocusRequest& request,
const std::vector<sp<android::gui::WindowInfoHandle>>& windows);
+ std::optional<android::gui::FocusRequest> getFocusRequest(int32_t displayId) const;
// Display has been removed from the system, clean up old references.
void displayRemoved(int32_t displayId);
@@ -112,7 +113,6 @@
std::optional<FocusResolver::FocusChanges> updateFocusedWindow(
int32_t displayId, const std::string& reason, const sp<IBinder>& token,
const std::string& tokenName = "");
- std::optional<android::gui::FocusRequest> getFocusRequest(int32_t displayId);
};
} // namespace android::inputdispatcher