Make InputWindowInfo as a part of InputWindowHandle (1/2)
All over InputDispatcher, we are accessing InputWindowInfo
from InputWindowHandle through the api getInfo().
It's dangerous without checking the result is null.
- To replace allocated mInfo in updateInfo(), make it as an object
member variable of InputWindowHandle.
- Change releaseInfo to releaseChannel to release input channel immediately.
- Add displayId information for logs so we can find out the problems
should belong to which display.
Bug: 112616659
Test: atest inputflinger_tests
Test: Manually enable debug logs
Change-Id: I5770f296e3feab4919fe775bab20ef6346f05295
diff --git a/libs/input/InputWindow.cpp b/libs/input/InputWindow.cpp
index f94faba..6968661 100644
--- a/libs/input/InputWindow.cpp
+++ b/libs/input/InputWindow.cpp
@@ -138,22 +138,18 @@
// --- InputWindowHandle ---
InputWindowHandle::InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle) :
- inputApplicationHandle(inputApplicationHandle), mInfo(nullptr) {
+ inputApplicationHandle(inputApplicationHandle) {
}
InputWindowHandle::~InputWindowHandle() {
- delete mInfo;
}
-void InputWindowHandle::releaseInfo() {
- if (mInfo) {
- delete mInfo;
- mInfo = nullptr;
- }
+void InputWindowHandle::releaseChannel() {
+ mInfo.inputChannel.clear();
}
sp<InputChannel> InputWindowHandle::getInputChannel() const {
- return mInfo ? mInfo->inputChannel : nullptr;
+ return mInfo.inputChannel;
}
} // namespace android