From 1868aa3a92434f3d296cac72eca914a19f00ff43 Mon Sep 17 00:00:00 2001
From: Corinna Vinschen <xda@vinschen.de>
Date: Sat, 12 Aug 2017 21:22:57 +0200
Subject: [PATCH] InputDispatcher: On keypress, deliver keycode to
 pokeUserActivity
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Change-Id: I8f64a6fa9b4b2e4520e25731f55e89f5087c70da
Signed-off-by: Corinna Vinschen <xda@vinschen.de>
Signed-off-by: Simão Gomes Viana <devel@superboring.dev>
---
 services/inputflinger/dispatcher/InputDispatcher.cpp        | 6 ++++--
 .../dispatcher/include/InputDispatcherPolicyInterface.h     | 3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 9d1adad7ec..91cc837bc7 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -2851,6 +2851,7 @@ void InputDispatcher::pokeUserActivityLocked(const EventEntry& eventEntry) {
     }
 
     int32_t eventType = USER_ACTIVITY_EVENT_OTHER;
+    int32_t keyCode = AKEYCODE_UNKNOWN;
     switch (eventEntry.type) {
         case EventEntry::Type::MOTION: {
             const MotionEntry& motionEntry = static_cast<const MotionEntry&>(eventEntry);
@@ -2869,6 +2870,7 @@ void InputDispatcher::pokeUserActivityLocked(const EventEntry& eventEntry) {
                 return;
             }
             eventType = USER_ACTIVITY_EVENT_BUTTON;
+            keyCode = keyEntry.keyCode;
             break;
         }
         default: {
@@ -2878,10 +2880,10 @@ void InputDispatcher::pokeUserActivityLocked(const EventEntry& eventEntry) {
         }
     }
 
-    auto command = [this, eventTime = eventEntry.eventTime, eventType, displayId]()
+    auto command = [this, eventTime = eventEntry.eventTime, eventType, displayId, keyCode]()
                            REQUIRES(mLock) {
                                scoped_unlock unlock(mLock);
-                               mPolicy->pokeUserActivity(eventTime, eventType, displayId);
+                               mPolicy->pokeUserActivity(eventTime, eventType, displayId, keyCode);
                            };
     postCommandLocked(std::move(command));
 }
diff --git a/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h b/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h
index 575b3d7059..89977c99a8 100644
--- a/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h
+++ b/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h
@@ -123,7 +123,8 @@ public:
                               uint32_t policyFlags) = 0;
 
     /* Poke user activity for an event dispatched to a window. */
-    virtual void pokeUserActivity(nsecs_t eventTime, int32_t eventType, int32_t displayId) = 0;
+    virtual void pokeUserActivity(nsecs_t eventTime, int32_t eventType, int32_t displayId,
+                                  int32_t keyCode) = 0;
 
     /* Notifies the policy that a pointer down event has occurred outside the current focused
      * window.
-- 
GitLab