Use unique_ptr for CommandEntry

Currently, there is some unusual behaviour happening for CommandEntries.
The entry is created and pushed onto a queue, but a pointer to the entry
is returned in order to modify the entry after it has been created.

Instead, fully construct the entry before enqueueing it. Also, switch to
using unique_ptr in order to simplify memory management of queue
entries.

Bug: 70668286
Test: SANITIZE_TARGET=hwaddress atest libinput_tests inputflinger_tests
Change-Id: Ie8ee9b732cdcd8f9a391f8315346fe4720d68e58
diff --git a/services/inputflinger/InputDispatcher.h b/services/inputflinger/InputDispatcher.h
index b6c0797..92e1e5f 100644
--- a/services/inputflinger/InputDispatcher.h
+++ b/services/inputflinger/InputDispatcher.h
@@ -853,7 +853,7 @@
     EventEntry* mPendingEvent GUARDED_BY(mLock);
     std::deque<EventEntry*> mInboundQueue GUARDED_BY(mLock);
     std::deque<EventEntry*> mRecentQueue GUARDED_BY(mLock);
-    std::deque<CommandEntry*> mCommandQueue GUARDED_BY(mLock);
+    std::deque<std::unique_ptr<CommandEntry>> mCommandQueue GUARDED_BY(mLock);
 
     DropReason mLastDropReason GUARDED_BY(mLock);
 
@@ -953,7 +953,7 @@
     // Deferred command processing.
     bool haveCommandsLocked() const REQUIRES(mLock);
     bool runCommandsLockedInterruptible() REQUIRES(mLock);
-    CommandEntry* postCommandLocked(Command command) REQUIRES(mLock);
+    void postCommandLocked(std::unique_ptr<CommandEntry> commandEntry) REQUIRES(mLock);
 
     // Input filter processing.
     bool shouldSendKeyToInputFilterLocked(const NotifyKeyArgs* args) REQUIRES(mLock);