Optimization: Restrict signing to ACTION_UP and ACTION_DOWN while doing a motion gesture such as scrolling apps

Savings. ~2.5% of total system_server time while scrolling on apps drawer screen.

Baseline:
https://pprof.corp.google.com/?id=732307aa60aa82bf478b0c3f0e6de6be&ignore=sendMessage
https://screenshot.googleplex.com/JpWt25tXRJO

Optimized:
https://pprof.corp.google.com/?id=5040d255411f407662a7f2da0109ca48&ignore=sendMessage
https://screenshot.googleplex.com/x81k7vUUKdd

Test: atest inputflinger_tests
Bug: 154278518
Merged-In: I52dd33f8203fe62bfcbde7be5a1ac45c46064585
Change-Id: I52dd33f8203fe62bfcbde7be5a1ac45c46064585
(cherry picked from commit c6ae4bbc44183811ad84abf5abc56a96843545bc)
diff --git a/services/inputflinger/dispatcher/InputDispatcher.h b/services/inputflinger/dispatcher/InputDispatcher.h
index cbba7e1..2b9cbce 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.h
+++ b/services/inputflinger/dispatcher/InputDispatcher.h
@@ -62,7 +62,7 @@
     std::array<uint8_t, 32> sign(const VerifiedInputEvent& event) const;
 
 private:
-    std::array<uint8_t, 32> sign(const std::vector<uint8_t>& data) const;
+    std::array<uint8_t, 32> sign(const uint8_t* data, size_t size) const;
     const std::array<uint8_t, 128> mHmacKey;
 };
 
@@ -219,7 +219,11 @@
     // the pointer stream in order to claim it for a system gesture.
     std::unordered_map<int32_t, std::vector<Monitor>> mGestureMonitorsByDisplay GUARDED_BY(mLock);
 
-    HmacKeyManager mHmacKeyManager;
+    const HmacKeyManager mHmacKeyManager;
+    const std::array<uint8_t, 32> getSignature(const MotionEntry& motionEntry,
+                                               const DispatchEntry& dispatchEntry) const;
+    const std::array<uint8_t, 32> getSignature(const KeyEntry& keyEntry,
+                                               const DispatchEntry& dispatchEntry) const;
 
     // Event injection and synchronization.
     std::condition_variable mInjectionResultAvailable;