Wait for dispatcher idle before asserting policy callbacks

Before this CL, the policy state was asserted too early. The dispatcher
might not have finished processing the commands yet.

To fix this, force the tests to wait until dispatcher is idle by
providing a dispatcher reference to the assertion function.

Bug: 282837934
Test: atest inputflinger_tests
Change-Id: Ie427071f774d2bfb4b9ebfef94c7971656a69509
diff --git a/services/inputflinger/dispatcher/InputDispatcher.h b/services/inputflinger/dispatcher/InputDispatcher.h
index 6635df7..96151ed 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.h
+++ b/services/inputflinger/dispatcher/InputDispatcher.h
@@ -89,7 +89,7 @@
 
     void dump(std::string& dump) override;
     void monitor() override;
-    bool waitForIdle() override;
+    bool waitForIdle() const override;
     status_t start() override;
     status_t stop() override;
 
@@ -169,10 +169,10 @@
     InputDispatcherPolicyInterface& mPolicy;
     android::InputDispatcherConfiguration mConfig GUARDED_BY(mLock);
 
-    std::mutex mLock;
+    mutable std::mutex mLock;
 
     std::condition_variable mDispatcherIsAlive;
-    std::condition_variable mDispatcherEnteredIdle;
+    mutable std::condition_variable mDispatcherEnteredIdle;
 
     sp<Looper> mLooper;