Loading services/core/jni/com_android_server_input_InputManagerService.cpp +21 −6 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ #include <batteryservice/include/batteryservice/BatteryServiceConstants.h> #include <binder/IServiceManager.h> #include <com_android_input_flags.h> #include <dispatcher/Entry.h> #include <include/gestures.h> #include <input/Input.h> #include <input/PointerController.h> Loading @@ -66,6 +67,7 @@ #include <atomic> #include <cinttypes> #include <map> #include <variant> #include <vector> #include "android_hardware_display_DisplayTopology.h" Loading Loading @@ -416,7 +418,8 @@ public: void interceptMotionBeforeQueueing(ui::LogicalDisplayId displayId, uint32_t source, int32_t action, nsecs_t when, uint32_t& policyFlags) override; nsecs_t interceptKeyBeforeDispatching(const sp<IBinder>& token, const KeyEvent& keyEvent, std::variant<nsecs_t, inputdispatcher::KeyEntry::InterceptKeyResult> interceptKeyBeforeDispatching(const sp<IBinder>& token, const KeyEvent& keyEvent, uint32_t policyFlags) override; std::optional<KeyEvent> dispatchUnhandledKey(const sp<IBinder>& token, const KeyEvent& keyEvent, uint32_t policyFlags) override; Loading Loading @@ -1905,9 +1908,9 @@ bool NativeInputManager::isDisplayInteractive(ui::LogicalDisplayId displayId) { return true; } nsecs_t NativeInputManager::interceptKeyBeforeDispatching(const sp<IBinder>& token, const KeyEvent& keyEvent, uint32_t policyFlags) { std::variant<nsecs_t, inputdispatcher::KeyEntry::InterceptKeyResult> NativeInputManager::interceptKeyBeforeDispatching(const sp<IBinder>& token, const KeyEvent& keyEvent, uint32_t policyFlags) { ATRACE_CALL(); // Policy: // - Ignore untrusted events and pass them along. Loading Loading @@ -1935,7 +1938,19 @@ nsecs_t NativeInputManager::interceptKeyBeforeDispatching(const sp<IBinder>& tok if (checkAndClearExceptionFromCallback(env, "interceptKeyBeforeDispatching")) { return 0; } return delayMillis < 0 ? -1 : milliseconds_to_nanoseconds(delayMillis); // Negative delay represent states from intercepting the key. // 0 : Continue event. if (delayMillis == 0) { return inputdispatcher::KeyEntry::InterceptKeyResult::CONTINUE; } // -1 : Drop and skip the key event. if (delayMillis == -1) { return inputdispatcher::KeyEntry::InterceptKeyResult::SKIP; } return milliseconds_to_nanoseconds(delayMillis); } std::optional<KeyEvent> NativeInputManager::dispatchUnhandledKey(const sp<IBinder>& token, Loading Loading
services/core/jni/com_android_server_input_InputManagerService.cpp +21 −6 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ #include <batteryservice/include/batteryservice/BatteryServiceConstants.h> #include <binder/IServiceManager.h> #include <com_android_input_flags.h> #include <dispatcher/Entry.h> #include <include/gestures.h> #include <input/Input.h> #include <input/PointerController.h> Loading @@ -66,6 +67,7 @@ #include <atomic> #include <cinttypes> #include <map> #include <variant> #include <vector> #include "android_hardware_display_DisplayTopology.h" Loading Loading @@ -416,7 +418,8 @@ public: void interceptMotionBeforeQueueing(ui::LogicalDisplayId displayId, uint32_t source, int32_t action, nsecs_t when, uint32_t& policyFlags) override; nsecs_t interceptKeyBeforeDispatching(const sp<IBinder>& token, const KeyEvent& keyEvent, std::variant<nsecs_t, inputdispatcher::KeyEntry::InterceptKeyResult> interceptKeyBeforeDispatching(const sp<IBinder>& token, const KeyEvent& keyEvent, uint32_t policyFlags) override; std::optional<KeyEvent> dispatchUnhandledKey(const sp<IBinder>& token, const KeyEvent& keyEvent, uint32_t policyFlags) override; Loading Loading @@ -1905,9 +1908,9 @@ bool NativeInputManager::isDisplayInteractive(ui::LogicalDisplayId displayId) { return true; } nsecs_t NativeInputManager::interceptKeyBeforeDispatching(const sp<IBinder>& token, const KeyEvent& keyEvent, uint32_t policyFlags) { std::variant<nsecs_t, inputdispatcher::KeyEntry::InterceptKeyResult> NativeInputManager::interceptKeyBeforeDispatching(const sp<IBinder>& token, const KeyEvent& keyEvent, uint32_t policyFlags) { ATRACE_CALL(); // Policy: // - Ignore untrusted events and pass them along. Loading Loading @@ -1935,7 +1938,19 @@ nsecs_t NativeInputManager::interceptKeyBeforeDispatching(const sp<IBinder>& tok if (checkAndClearExceptionFromCallback(env, "interceptKeyBeforeDispatching")) { return 0; } return delayMillis < 0 ? -1 : milliseconds_to_nanoseconds(delayMillis); // Negative delay represent states from intercepting the key. // 0 : Continue event. if (delayMillis == 0) { return inputdispatcher::KeyEntry::InterceptKeyResult::CONTINUE; } // -1 : Drop and skip the key event. if (delayMillis == -1) { return inputdispatcher::KeyEntry::InterceptKeyResult::SKIP; } return milliseconds_to_nanoseconds(delayMillis); } std::optional<KeyEvent> NativeInputManager::dispatchUnhandledKey(const sp<IBinder>& token, Loading