Loading services/inputflinger/InputReader.cpp +17 −16 Original line number Original line Diff line number Diff line Loading @@ -256,18 +256,17 @@ static void synthesizeButtonKeys(InputReaderContext* context, int32_t action, // --- InputReaderConfiguration --- // --- InputReaderConfiguration --- bool InputReaderConfiguration::getDisplayViewport(ViewportType viewportType, std::optional<DisplayViewport> InputReaderConfiguration::getDisplayViewport( const std::string& uniqueDisplayId, DisplayViewport* outViewport) const { ViewportType viewportType, const std::string& uniqueDisplayId) const { for (const DisplayViewport& currentViewport : mDisplays) { for (const DisplayViewport& currentViewport : mDisplays) { if (currentViewport.type == viewportType) { if (currentViewport.type == viewportType) { if (uniqueDisplayId.empty() || if (uniqueDisplayId.empty() || (!uniqueDisplayId.empty() && uniqueDisplayId == currentViewport.uniqueId)) { (!uniqueDisplayId.empty() && uniqueDisplayId == currentViewport.uniqueId)) { *outViewport = currentViewport; return std::make_optional(currentViewport); return true; } } } } } } return false; return std::nullopt; } } void InputReaderConfiguration::setDisplayViewports(const std::vector<DisplayViewport>& viewports) { void InputReaderConfiguration::setDisplayViewports(const std::vector<DisplayViewport>& viewports) { Loading Loading @@ -2249,7 +2248,6 @@ void KeyboardInputMapper::dump(std::string& dump) { dump += StringPrintf(INDENT3 "DownTime: %" PRId64 "\n", mDownTime); dump += StringPrintf(INDENT3 "DownTime: %" PRId64 "\n", mDownTime); } } void KeyboardInputMapper::configure(nsecs_t when, void KeyboardInputMapper::configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes) { const InputReaderConfiguration* config, uint32_t changes) { InputMapper::configure(when, config, changes); InputMapper::configure(when, config, changes); Loading @@ -2261,9 +2259,7 @@ void KeyboardInputMapper::configure(nsecs_t when, if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { if (mParameters.orientationAware) { if (mParameters.orientationAware) { DisplayViewport dvp; mViewport = config->getDisplayViewport(ViewportType::VIEWPORT_INTERNAL, ""); config->getDisplayViewport(ViewportType::VIEWPORT_INTERNAL, "", &dvp); mViewport = dvp; } } } } } } Loading Loading @@ -2672,9 +2668,10 @@ void CursorInputMapper::configure(nsecs_t when, if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { mOrientation = DISPLAY_ORIENTATION_0; mOrientation = DISPLAY_ORIENTATION_0; if (mParameters.orientationAware && mParameters.hasAssociatedDisplay) { if (mParameters.orientationAware && mParameters.hasAssociatedDisplay) { DisplayViewport v; std::optional<DisplayViewport> internalViewport = if (config->getDisplayViewport(ViewportType::VIEWPORT_INTERNAL, "", &v)) { config->getDisplayViewport(ViewportType::VIEWPORT_INTERNAL, ""); mOrientation = v.orientation; if (internalViewport) { mOrientation = internalViewport->orientation; } } } } bumpGeneration(); bumpGeneration(); Loading Loading @@ -2987,9 +2984,10 @@ void RotaryEncoderInputMapper::configure(nsecs_t when, mRotaryEncoderScrollAccumulator.configure(getDevice()); mRotaryEncoderScrollAccumulator.configure(getDevice()); } } if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { DisplayViewport v; std::optional<DisplayViewport> internalViewport = if (config->getDisplayViewport(ViewportType::VIEWPORT_INTERNAL, "", &v)) { config->getDisplayViewport(ViewportType::VIEWPORT_INTERNAL, ""); mOrientation = v.orientation; if (internalViewport) { mOrientation = internalViewport->orientation; } else { } else { mOrientation = DISPLAY_ORIENTATION_0; mOrientation = DISPLAY_ORIENTATION_0; } } Loading Loading @@ -3502,7 +3500,9 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) { viewportTypeToUse = ViewportType::VIEWPORT_INTERNAL; viewportTypeToUse = ViewportType::VIEWPORT_INTERNAL; } } if (!mConfig.getDisplayViewport(viewportTypeToUse, uniqueDisplayId, &newViewport)) { std::optional<DisplayViewport> viewportToUse = mConfig.getDisplayViewport(viewportTypeToUse, uniqueDisplayId); if (!viewportToUse) { ALOGI(INDENT "Touch device '%s' could not query the properties of its associated " ALOGI(INDENT "Touch device '%s' could not query the properties of its associated " "display. The device will be inoperable until the display size " "display. The device will be inoperable until the display size " "becomes available.", "becomes available.", Loading @@ -3510,6 +3510,7 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) { mDeviceMode = DEVICE_MODE_DISABLED; mDeviceMode = DEVICE_MODE_DISABLED; return; return; } } newViewport = *viewportToUse; } else { } else { newViewport.setNonDisplayViewport(rawWidth, rawHeight); newViewport.setNonDisplayViewport(rawWidth, rawHeight); } } Loading services/inputflinger/InputReader.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -202,8 +202,8 @@ struct InputReaderConfiguration { pointerGestureZoomSpeedRatio(0.3f), pointerGestureZoomSpeedRatio(0.3f), showTouches(false) { } showTouches(false) { } bool getDisplayViewport(ViewportType viewportType, const std::string& uniqueDisplayId, std::optional<DisplayViewport> getDisplayViewport(ViewportType viewportType, DisplayViewport* outViewport) const; const std::string& uniqueDisplayId) const; void setDisplayViewports(const std::vector<DisplayViewport>& viewports); void setDisplayViewports(const std::vector<DisplayViewport>& viewports); Loading services/inputflinger/tests/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -10,6 +10,7 @@ cc_test { cflags: [ cflags: [ "-Wall", "-Wall", "-Werror", "-Werror", "-Wextra", "-Wno-unused-parameter", "-Wno-unused-parameter", ], ], shared_libs: [ shared_libs: [ Loading services/inputflinger/tests/InputReader_test.cpp +209 −54 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
services/inputflinger/InputReader.cpp +17 −16 Original line number Original line Diff line number Diff line Loading @@ -256,18 +256,17 @@ static void synthesizeButtonKeys(InputReaderContext* context, int32_t action, // --- InputReaderConfiguration --- // --- InputReaderConfiguration --- bool InputReaderConfiguration::getDisplayViewport(ViewportType viewportType, std::optional<DisplayViewport> InputReaderConfiguration::getDisplayViewport( const std::string& uniqueDisplayId, DisplayViewport* outViewport) const { ViewportType viewportType, const std::string& uniqueDisplayId) const { for (const DisplayViewport& currentViewport : mDisplays) { for (const DisplayViewport& currentViewport : mDisplays) { if (currentViewport.type == viewportType) { if (currentViewport.type == viewportType) { if (uniqueDisplayId.empty() || if (uniqueDisplayId.empty() || (!uniqueDisplayId.empty() && uniqueDisplayId == currentViewport.uniqueId)) { (!uniqueDisplayId.empty() && uniqueDisplayId == currentViewport.uniqueId)) { *outViewport = currentViewport; return std::make_optional(currentViewport); return true; } } } } } } return false; return std::nullopt; } } void InputReaderConfiguration::setDisplayViewports(const std::vector<DisplayViewport>& viewports) { void InputReaderConfiguration::setDisplayViewports(const std::vector<DisplayViewport>& viewports) { Loading Loading @@ -2249,7 +2248,6 @@ void KeyboardInputMapper::dump(std::string& dump) { dump += StringPrintf(INDENT3 "DownTime: %" PRId64 "\n", mDownTime); dump += StringPrintf(INDENT3 "DownTime: %" PRId64 "\n", mDownTime); } } void KeyboardInputMapper::configure(nsecs_t when, void KeyboardInputMapper::configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes) { const InputReaderConfiguration* config, uint32_t changes) { InputMapper::configure(when, config, changes); InputMapper::configure(when, config, changes); Loading @@ -2261,9 +2259,7 @@ void KeyboardInputMapper::configure(nsecs_t when, if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { if (mParameters.orientationAware) { if (mParameters.orientationAware) { DisplayViewport dvp; mViewport = config->getDisplayViewport(ViewportType::VIEWPORT_INTERNAL, ""); config->getDisplayViewport(ViewportType::VIEWPORT_INTERNAL, "", &dvp); mViewport = dvp; } } } } } } Loading Loading @@ -2672,9 +2668,10 @@ void CursorInputMapper::configure(nsecs_t when, if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { mOrientation = DISPLAY_ORIENTATION_0; mOrientation = DISPLAY_ORIENTATION_0; if (mParameters.orientationAware && mParameters.hasAssociatedDisplay) { if (mParameters.orientationAware && mParameters.hasAssociatedDisplay) { DisplayViewport v; std::optional<DisplayViewport> internalViewport = if (config->getDisplayViewport(ViewportType::VIEWPORT_INTERNAL, "", &v)) { config->getDisplayViewport(ViewportType::VIEWPORT_INTERNAL, ""); mOrientation = v.orientation; if (internalViewport) { mOrientation = internalViewport->orientation; } } } } bumpGeneration(); bumpGeneration(); Loading Loading @@ -2987,9 +2984,10 @@ void RotaryEncoderInputMapper::configure(nsecs_t when, mRotaryEncoderScrollAccumulator.configure(getDevice()); mRotaryEncoderScrollAccumulator.configure(getDevice()); } } if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) { DisplayViewport v; std::optional<DisplayViewport> internalViewport = if (config->getDisplayViewport(ViewportType::VIEWPORT_INTERNAL, "", &v)) { config->getDisplayViewport(ViewportType::VIEWPORT_INTERNAL, ""); mOrientation = v.orientation; if (internalViewport) { mOrientation = internalViewport->orientation; } else { } else { mOrientation = DISPLAY_ORIENTATION_0; mOrientation = DISPLAY_ORIENTATION_0; } } Loading Loading @@ -3502,7 +3500,9 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) { viewportTypeToUse = ViewportType::VIEWPORT_INTERNAL; viewportTypeToUse = ViewportType::VIEWPORT_INTERNAL; } } if (!mConfig.getDisplayViewport(viewportTypeToUse, uniqueDisplayId, &newViewport)) { std::optional<DisplayViewport> viewportToUse = mConfig.getDisplayViewport(viewportTypeToUse, uniqueDisplayId); if (!viewportToUse) { ALOGI(INDENT "Touch device '%s' could not query the properties of its associated " ALOGI(INDENT "Touch device '%s' could not query the properties of its associated " "display. The device will be inoperable until the display size " "display. The device will be inoperable until the display size " "becomes available.", "becomes available.", Loading @@ -3510,6 +3510,7 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) { mDeviceMode = DEVICE_MODE_DISABLED; mDeviceMode = DEVICE_MODE_DISABLED; return; return; } } newViewport = *viewportToUse; } else { } else { newViewport.setNonDisplayViewport(rawWidth, rawHeight); newViewport.setNonDisplayViewport(rawWidth, rawHeight); } } Loading
services/inputflinger/InputReader.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -202,8 +202,8 @@ struct InputReaderConfiguration { pointerGestureZoomSpeedRatio(0.3f), pointerGestureZoomSpeedRatio(0.3f), showTouches(false) { } showTouches(false) { } bool getDisplayViewport(ViewportType viewportType, const std::string& uniqueDisplayId, std::optional<DisplayViewport> getDisplayViewport(ViewportType viewportType, DisplayViewport* outViewport) const; const std::string& uniqueDisplayId) const; void setDisplayViewports(const std::vector<DisplayViewport>& viewports); void setDisplayViewports(const std::vector<DisplayViewport>& viewports); Loading
services/inputflinger/tests/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -10,6 +10,7 @@ cc_test { cflags: [ cflags: [ "-Wall", "-Wall", "-Werror", "-Werror", "-Wextra", "-Wno-unused-parameter", "-Wno-unused-parameter", ], ], shared_libs: [ shared_libs: [ Loading
services/inputflinger/tests/InputReader_test.cpp +209 −54 File changed.Preview size limit exceeded, changes collapsed. Show changes