summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Siarhei Vishniakou <svv@google.com> 2019-10-29 12:53:08 -0700
committer Siarhei Vishniakou <svv@google.com> 2019-10-31 18:27:56 +0000
commit9757f78ee892e2bb08c9db7f407704a6700e71cc (patch)
tree2f8b8ef0c00b15ec4ef27262e11afc75e8bd3328
parent97d754f78d3797ec0b11de1ddb431d8399780ab2 (diff)
Return KeyEvent instead of initializing
Minor refactor to make ownership of KeyEvent explicit. You will now pass a KeyEntry and receive a KeyEvent in return. Bug: none Test: none Change-Id: I02aaf5f6a2472215b851c9eaadc578aee02ba1cd
-rw-r--r--services/inputflinger/dispatcher/InputDispatcher.cpp19
-rw-r--r--services/inputflinger/dispatcher/InputDispatcher.h2
2 files changed, 10 insertions, 11 deletions
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 58404a2510..9e5f5f7fb7 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -4188,8 +4188,7 @@ void InputDispatcher::doInterceptKeyBeforeDispatchingLockedInterruptible(
CommandEntry* commandEntry) {
KeyEntry* entry = commandEntry->keyEntry;
- KeyEvent event;
- initializeKeyEvent(&event, entry);
+ KeyEvent event = createKeyEvent(*entry);
mLock.unlock();
@@ -4309,8 +4308,7 @@ bool InputDispatcher::afterKeyEventLockedInterruptible(const sp<Connection>& con
keyEntry->keyCode, keyEntry->action, keyEntry->repeatCount,
keyEntry->policyFlags);
#endif
- KeyEvent event;
- initializeKeyEvent(&event, keyEntry);
+ KeyEvent event = createKeyEvent(*keyEntry);
event.setFlags(event.getFlags() | AKEY_EVENT_FLAG_CANCELED);
mLock.unlock();
@@ -4352,8 +4350,7 @@ bool InputDispatcher::afterKeyEventLockedInterruptible(const sp<Connection>& con
"keyCode=%d, action=%d, repeatCount=%d, policyFlags=0x%08x",
keyEntry->keyCode, keyEntry->action, keyEntry->repeatCount, keyEntry->policyFlags);
#endif
- KeyEvent event;
- initializeKeyEvent(&event, keyEntry);
+ KeyEvent event = createKeyEvent(*keyEntry);
mLock.unlock();
@@ -4470,10 +4467,12 @@ void InputDispatcher::doPokeUserActivityLockedInterruptible(CommandEntry* comman
mLock.lock();
}
-void InputDispatcher::initializeKeyEvent(KeyEvent* event, const KeyEntry* entry) {
- event->initialize(entry->deviceId, entry->source, entry->displayId, entry->action, entry->flags,
- entry->keyCode, entry->scanCode, entry->metaState, entry->repeatCount,
- entry->downTime, entry->eventTime);
+KeyEvent InputDispatcher::createKeyEvent(const KeyEntry& entry) {
+ KeyEvent event;
+ event.initialize(entry.deviceId, entry.source, entry.displayId, entry.action, entry.flags,
+ entry.keyCode, entry.scanCode, entry.metaState, entry.repeatCount,
+ entry.downTime, entry.eventTime);
+ return event;
}
void InputDispatcher::updateDispatchStatistics(nsecs_t currentTime, const EventEntry& entry,
diff --git a/services/inputflinger/dispatcher/InputDispatcher.h b/services/inputflinger/dispatcher/InputDispatcher.h
index d7d7e17cd7..923d0e9ef6 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.h
+++ b/services/inputflinger/dispatcher/InputDispatcher.h
@@ -450,7 +450,7 @@ private:
DispatchEntry* dispatchEntry, MotionEntry* motionEntry,
bool handled) REQUIRES(mLock);
void doPokeUserActivityLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock);
- void initializeKeyEvent(KeyEvent* event, const KeyEntry* entry);
+ KeyEvent createKeyEvent(const KeyEntry& entry);
void doOnPointerDownOutsideFocusLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock);
// Statistics gathering.