PointerChoreographer: Do not call the policy with the lock held
Since there is already precedent for InputReader to interact with the
policy with its lock held, we must not do the same from other
components, since it can result in deadlocks.
In this CL, we ensure that the PointerChoreographer does not interact
with the policy while holding its lock. The exception is the use of the
factory method for PointerController, which is only part of the policy
to work around dependency issues with graphics libraries.
Bug: 327717240
Test: atest inputflinger_tests
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:5a51a2280743605a51e2f9d632077e9297276520)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:ea5ddd132cfe5818f4e05d70a0f8e006fd6e2da6)
Merged-In: Ib81d72898a212275d95f9d84d89a16e7172e108e
Change-Id: Ib81d72898a212275d95f9d84d89a16e7172e108e
diff --git a/services/inputflinger/include/PointerChoreographerPolicyInterface.h b/services/inputflinger/include/PointerChoreographerPolicyInterface.h
index 8b47b55..462aedc 100644
--- a/services/inputflinger/include/PointerChoreographerPolicyInterface.h
+++ b/services/inputflinger/include/PointerChoreographerPolicyInterface.h
@@ -25,6 +25,9 @@
*
* This is the interface that PointerChoreographer uses to talk to Window Manager and other
* system components.
+ *
+ * NOTE: In general, the PointerChoreographer must not interact with the policy while
+ * holding any locks.
*/
class PointerChoreographerPolicyInterface {
public:
@@ -37,6 +40,9 @@
* for and runnable on the host, the PointerController implementation must be in a separate
* library, libinputservice, that has the additional dependencies. The PointerController
* will be mocked when testing PointerChoreographer.
+ *
+ * Since this is a factory method used to work around dependencies, it will not interact with
+ * other input components and may be called with the PointerChoreographer lock held.
*/
virtual std::shared_ptr<PointerControllerInterface> createPointerController(
PointerControllerInterface::ControllerType type) = 0;