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/include/input/InputWindow.h b/include/input/InputWindow.h
index 7c284dd..918b9e1 100644
--- a/include/input/InputWindow.h
+++ b/include/input/InputWindow.h
@@ -168,17 +168,17 @@
const sp<InputApplicationHandle> inputApplicationHandle;
inline const InputWindowInfo* getInfo() const {
- return mInfo;
+ return &mInfo;
}
sp<InputChannel> getInputChannel() const;
inline std::string getName() const {
- return mInfo ? mInfo->name : "<invalid>";
+ return mInfo.inputChannel ? mInfo.name : "<invalid>";
}
inline nsecs_t getDispatchingTimeout(nsecs_t defaultValue) const {
- return mInfo ? mInfo->dispatchingTimeout : defaultValue;
+ return mInfo.inputChannel? mInfo.dispatchingTimeout : defaultValue;
}
/**
@@ -193,16 +193,16 @@
virtual bool updateInfo() = 0;
/**
- * Releases the storage used by the associated information when it is
+ * Releases the channel used by the associated information when it is
* no longer needed.
*/
- void releaseInfo();
+ void releaseChannel();
protected:
explicit InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle);
virtual ~InputWindowHandle();
- InputWindowInfo* mInfo;
+ InputWindowInfo mInfo;
};
} // namespace android