Remove RefBase from InputListener interface
We don't need refbase for inputlisteners. Remove it, and switch to
references, which cannot be null. This way, we can avoid dereferencing
the pointers without checking for nullness.
Bug: 198472780
Test: atest inputflinger_tests
Change-Id: I2f469fd268472c7e78d36812353cff5c52a90163
diff --git a/services/inputflinger/InputManager.h b/services/inputflinger/InputManager.h
index f053568..a6baf2f 100644
--- a/services/inputflinger/InputManager.h
+++ b/services/inputflinger/InputManager.h
@@ -75,13 +75,13 @@
virtual status_t stop() = 0;
/* Gets the input reader. */
- virtual sp<InputReaderInterface> getReader() = 0;
+ virtual InputReaderInterface& getReader() = 0;
/* Gets the input classifier */
- virtual sp<InputClassifierInterface> getClassifier() = 0;
+ virtual InputClassifierInterface& getClassifier() = 0;
/* Gets the input dispatcher. */
- virtual sp<InputDispatcherInterface> getDispatcher() = 0;
+ virtual InputDispatcherInterface& getDispatcher() = 0;
};
class InputManager : public InputManagerInterface, public BnInputFlinger {
@@ -96,9 +96,9 @@
status_t start() override;
status_t stop() override;
- sp<InputReaderInterface> getReader() override;
- sp<InputClassifierInterface> getClassifier() override;
- sp<InputDispatcherInterface> getDispatcher() override;
+ InputReaderInterface& getReader() override;
+ InputClassifierInterface& getClassifier() override;
+ InputDispatcherInterface& getDispatcher() override;
status_t dump(int fd, const Vector<String16>& args) override;
binder::Status createInputChannel(const std::string& name, InputChannel* outChannel) override;
@@ -106,11 +106,11 @@
binder::Status setFocusedWindow(const gui::FocusRequest&) override;
private:
- sp<InputReaderInterface> mReader;
+ std::unique_ptr<InputReaderInterface> mReader;
- sp<InputClassifierInterface> mClassifier;
+ std::unique_ptr<InputClassifierInterface> mClassifier;
- sp<InputDispatcherInterface> mDispatcher;
+ std::unique_ptr<InputDispatcherInterface> mDispatcher;
};
} // namespace android