Add DisplayViewport native tests
The strategy for finding DisplayViewport has changed in ag/4723479.
Add native tests for the new lookup logic here.
The matching is done by uniqueId if it is specified, and by type only if it is not.
Some additional refactors:
- Return std::optional from getDisplayViewport
- Make internal viewport optional. Expect normal operation if internal
viewport is not present at all.
Bug: 111108021
Test: atest -a inputflinger_tests
Change-Id: I7d7d698438d0d691f5f07fef2da80e792a504978
diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h
index 74668b7..3410bc9 100644
--- a/services/inputflinger/InputReader.h
+++ b/services/inputflinger/InputReader.h
@@ -202,8 +202,8 @@
pointerGestureZoomSpeedRatio(0.3f),
showTouches(false) { }
- bool getDisplayViewport(ViewportType viewportType, const std::string& uniqueDisplayId,
- DisplayViewport* outViewport) const;
+ std::optional<DisplayViewport> getDisplayViewport(ViewportType viewportType,
+ const std::string& uniqueDisplayId) const;
void setDisplayViewports(const std::vector<DisplayViewport>& viewports);