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/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index f094fee..695dd17 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -562,6 +562,9 @@
mLooper = new Looper(false);
mReporter = createInputReporter();
+ mWindowInfoListener = new DispatcherWindowListener(*this);
+ SurfaceComposerClient::getDefault()->addWindowInfosListener(mWindowInfoListener);
+
mKeyRepeatState.lastKeyEntry = nullptr;
policy->getDispatcherConfiguration(&mConfig);
@@ -582,10 +585,6 @@
}
}
-void InputDispatcher::onFirstRef() {
- SurfaceComposerClient::getDefault()->addWindowInfosListener(this);
-}
-
status_t InputDispatcher::start() {
if (mThread) {
return ALREADY_EXISTS;
@@ -6284,4 +6283,10 @@
return false;
}
+void InputDispatcher::DispatcherWindowListener::onWindowInfosChanged(
+ const std::vector<gui::WindowInfo>& windowInfos,
+ const std::vector<DisplayInfo>& displayInfos) {
+ mDispatcher.onWindowInfosChanged(windowInfos, displayInfos);
+}
+
} // namespace android::inputdispatcher