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.cpp b/services/inputflinger/InputManager.cpp
index 7b3658d..221e193 100644
--- a/services/inputflinger/InputManager.cpp
+++ b/services/inputflinger/InputManager.cpp
@@ -58,8 +58,8 @@
const sp<InputReaderPolicyInterface>& readerPolicy,
const sp<InputDispatcherPolicyInterface>& dispatcherPolicy) {
mDispatcher = createInputDispatcher(dispatcherPolicy);
- mClassifier = new InputClassifier(mDispatcher);
- mReader = createInputReader(readerPolicy, mClassifier);
+ mClassifier = std::make_unique<InputClassifier>(*mDispatcher);
+ mReader = createInputReader(readerPolicy, *mClassifier);
}
InputManager::~InputManager() {
@@ -102,16 +102,16 @@
return status;
}
-sp<InputReaderInterface> InputManager::getReader() {
- return mReader;
+InputReaderInterface& InputManager::getReader() {
+ return *mReader;
}
-sp<InputClassifierInterface> InputManager::getClassifier() {
- return mClassifier;
+InputClassifierInterface& InputManager::getClassifier() {
+ return *mClassifier;
}
-sp<InputDispatcherInterface> InputManager::getDispatcher() {
- return mDispatcher;
+InputDispatcherInterface& InputManager::getDispatcher() {
+ return *mDispatcher;
}
// Used by tests only.