Add reason to focus change event log
We want to start changing focus in ID for multiple
reasons and this change pulls out the focus change
logic from setInputWindows. In addition, it adds a
reason to the focus event logs for better tracking.
Test: adb logcat -b events and check focus change reasons
Test: atest FlickerTests, inputflinger_tests
Bug: 151179149
Change-Id: I12cb2f02dfbdd7376fe3699a32c4e8d4d03ba57d
diff --git a/services/inputflinger/dispatcher/Entry.cpp b/services/inputflinger/dispatcher/Entry.cpp
index 26a1644..ded74ba 100644
--- a/services/inputflinger/dispatcher/Entry.cpp
+++ b/services/inputflinger/dispatcher/Entry.cpp
@@ -117,10 +117,12 @@
// --- FocusEntry ---
// Focus notifications always go to apps, so set the flag POLICY_FLAG_PASS_TO_USER for all entries
-FocusEntry::FocusEntry(int32_t id, nsecs_t eventTime, sp<IBinder> connectionToken, bool hasFocus)
+FocusEntry::FocusEntry(int32_t id, nsecs_t eventTime, sp<IBinder> connectionToken, bool hasFocus,
+ std::string_view reason)
: EventEntry(id, Type::FOCUS, eventTime, POLICY_FLAG_PASS_TO_USER),
connectionToken(connectionToken),
- hasFocus(hasFocus) {}
+ hasFocus(hasFocus),
+ reason(reason) {}
FocusEntry::~FocusEntry() {}