Do not use RefBase in EventHub
Switch to std::unique_ptr instead.
Unfortunately, have to also switch to shared_ptr because FakeEventHub
implements EventHub but is also used to inject events when testing
InputReader.
Bug: 117684064
Test: atest inputflinger_tests
Change-Id: I789ba0ca255b6a1f179711c61fc9da98a3c6a800
diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h
index 0c08e7d..11ef934 100644
--- a/services/inputflinger/InputReader.h
+++ b/services/inputflinger/InputReader.h
@@ -114,9 +114,9 @@
*/
class InputReader : public InputReaderInterface {
public:
- InputReader(const sp<EventHubInterface>& eventHub,
- const sp<InputReaderPolicyInterface>& policy,
- const sp<InputListenerInterface>& listener);
+ InputReader(std::shared_ptr<EventHubInterface> eventHub,
+ const sp<InputReaderPolicyInterface>& policy,
+ const sp<InputListenerInterface>& listener);
virtual ~InputReader();
virtual void dump(std::string& dump);
@@ -181,7 +181,10 @@
Condition mReaderIsAliveCondition;
- sp<EventHubInterface> mEventHub;
+ // This could be unique_ptr, but due to the way InputReader tests are written,
+ // it is made shared_ptr here. In the tests, an EventHub reference is retained by the test
+ // in parallel to passing it to the InputReader.
+ std::shared_ptr<EventHubInterface> mEventHub;
sp<InputReaderPolicyInterface> mPolicy;
sp<QueuedInputListener> mQueuedListener;