From dde67b898d10daf78a93527e1e866d67bb8c3f63 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Tue, 27 Oct 2020 16:09:22 +0000 Subject: Support multiple internal and external viewports The policy is still effectively the same by selecting the first display, but this lets devices which are configured with a specific unique ID to see the viewport that should be associated with it. Bug: 116824030 Bug: 171549575 Test: atest InputReader_test Change-Id: I3f78a122a3a8dce9c8dac3c88f3d51f29afa367c --- services/inputflinger/InputReaderBase.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'services/inputflinger/InputReaderBase.cpp') diff --git a/services/inputflinger/InputReaderBase.cpp b/services/inputflinger/InputReaderBase.cpp index b2dadf8460..9cc777d450 100644 --- a/services/inputflinger/InputReaderBase.cpp +++ b/services/inputflinger/InputReaderBase.cpp @@ -19,6 +19,9 @@ //#define LOG_NDEBUG 0 #include "InputReaderBase.h" +#include "input/DisplayViewport.h" +#include "input/Input.h" +#include "input/NamedEnum.h" #include #include @@ -99,17 +102,19 @@ std::optional InputReaderConfiguration::getDisplayViewportByTyp size_t count = 0; std::optional result = std::nullopt; for (const DisplayViewport& currentViewport : mDisplays) { - // Return the first match + // Return the first match, or the default display if we're looking for the internal viewport if (currentViewport.type == type) { - if (!result) { + if (!result || + (type == ViewportType::INTERNAL && + currentViewport.displayId == ADISPLAY_ID_DEFAULT)) { result = std::make_optional(currentViewport); } count++; } } if (count > 1) { - ALOGE("Found %zu viewports with type %s, but expected 1 at most", - count, viewportTypeToString(type)); + ALOGW("Found %zu viewports with type %s, but expected 1 at most", count, + NamedEnum::string(type).c_str()); } return result; } -- cgit v1.2.3-59-g8ed1b