@@ -1896,14 +1896,14 @@ bool InputDispatcher::dispatchKeyLocked(nsecs_t currentTime, std::shared_ptr<con
18961896 entry->interceptKeyWakeupTime = 0 ;
18971897 }
18981898
1899+ const ui::LogicalDisplayId displayId = getTargetDisplayId (*entry);
18991900 // Give the policy a chance to intercept the key.
19001901 if (entry->interceptKeyResult == KeyEntry::InterceptKeyResult::UNKNOWN) {
19011902 if (entry->policyFlags & POLICY_FLAG_PASS_TO_USER) {
1902- sp<IBinder> focusedWindowToken =
1903- mFocusResolver .getFocusedWindowToken (getTargetDisplayId (*entry));
1903+ sp<IBinder> focusedWindowToken = mFocusResolver .getFocusedWindowToken (displayId);
19041904
1905- auto command = [this , focusedWindowToken, entry]() REQUIRES (mLock ) {
1906- doInterceptKeyBeforeDispatchingCommand (focusedWindowToken, *entry);
1905+ auto command = [this , focusedWindowToken, displayId, entry]() REQUIRES (mLock ) {
1906+ doInterceptKeyBeforeDispatchingCommand (focusedWindowToken, displayId, *entry);
19071907 };
19081908 postCommandLocked (std::move (command));
19091909 return false ; // wait for the command to run
@@ -1952,7 +1952,7 @@ bool InputDispatcher::dispatchKeyLocked(nsecs_t currentTime, std::shared_ptr<con
19521952 InputTarget::Flags::FOREGROUND, getDownTime (*entry), inputTargets);
19531953
19541954 // Add monitor channels from event's or focused display.
1955- addGlobalMonitoringTargetsLocked (inputTargets, getTargetDisplayId (*entry) );
1955+ addGlobalMonitoringTargetsLocked (inputTargets, displayId );
19561956
19571957 if (mTracer ) {
19581958 ensureEventTraced (*entry);
@@ -6632,8 +6632,10 @@ void InputDispatcher::updateLastAnrStateLocked(const std::string& windowLabel,
66326632}
66336633
66346634void InputDispatcher::doInterceptKeyBeforeDispatchingCommand (const sp<IBinder>& focusedWindowToken,
6635+ const ui::LogicalDisplayId displayId,
66356636 const KeyEntry& entry) {
6636- const KeyEvent event = createKeyEvent (entry);
6637+ KeyEvent event = createKeyEvent (entry);
6638+ event.setDisplayId (displayId);
66376639 std::variant<nsecs_t , KeyEntry::InterceptKeyResult> interceptResult;
66386640 nsecs_t delay = 0 ;
66396641 { // release lock
0 commit comments