Make InputApplicationInfo as a part of InputApplicationHandle (1/2)
InputWindowHandle::updateInfo would also call
InputApplicationHandle::updateInfo that may access the null pointer if the
focus application changed in same time.
- To replace allocated mInfo in updateInfo(), make it as an object
member variable of InputApplicationHandle.
Bug: 128930899
Test: atest inputflinger_tests
Change-Id: Id19d2d8cd1be181ea994d0efa7afbb2567c4d734
diff --git a/services/inputflinger/InputDispatcher.cpp b/services/inputflinger/InputDispatcher.cpp
index bcb1ec5..2f2d690 100644
--- a/services/inputflinger/InputDispatcher.cpp
+++ b/services/inputflinger/InputDispatcher.cpp
@@ -3243,13 +3243,11 @@
if (oldFocusedApplicationHandle != inputApplicationHandle) {
if (oldFocusedApplicationHandle != nullptr) {
resetANRTimeoutsLocked();
- oldFocusedApplicationHandle->releaseInfo();
}
mFocusedApplicationHandlesByDisplay[displayId] = inputApplicationHandle;
}
} else if (oldFocusedApplicationHandle != nullptr) {
resetANRTimeoutsLocked();
- oldFocusedApplicationHandle->releaseInfo();
oldFocusedApplicationHandle.clear();
mFocusedApplicationHandlesByDisplay.erase(displayId);
}
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index 3b6fe52..088ad9c 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -340,10 +340,7 @@
virtual ~FakeApplicationHandle() {}
virtual bool updateInfo() {
- if (!mInfo) {
- mInfo = new InputApplicationInfo();
- }
- mInfo->dispatchingTimeout = DISPATCHING_TIMEOUT;
+ mInfo.dispatchingTimeout = DISPATCHING_TIMEOUT;
return true;
}
};