Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aa93961a authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Create viewports in a separate function" into main

parents 83302fce 117b7579
Loading
Loading
Loading
Loading
+24 −27
Original line number Diff line number Diff line
@@ -31,6 +31,30 @@ static const int HW_TIMEOUT_MULTIPLIER = base::GetIntProperty("ro.hw_timeout_mul

} // namespace

DisplayViewport createViewport(ui::LogicalDisplayId displayId, int32_t width, int32_t height,
                               ui::Rotation orientation, bool isActive, const std::string& uniqueId,
                               std::optional<uint8_t> physicalPort, ViewportType type) {
    const bool isRotated = orientation == ui::ROTATION_90 || orientation == ui::ROTATION_270;
    DisplayViewport v;
    v.displayId = displayId;
    v.orientation = orientation;
    v.logicalLeft = 0;
    v.logicalTop = 0;
    v.logicalRight = isRotated ? height : width;
    v.logicalBottom = isRotated ? width : height;
    v.physicalLeft = 0;
    v.physicalTop = 0;
    v.physicalRight = isRotated ? height : width;
    v.physicalBottom = isRotated ? width : height;
    v.deviceWidth = isRotated ? height : width;
    v.deviceHeight = isRotated ? width : height;
    v.isActive = isActive;
    v.uniqueId = uniqueId;
    v.physicalPort = physicalPort;
    v.type = type;
    return v;
};

void FakeInputReaderPolicy::assertInputDevicesChanged() {
    waitForInputDevices(
            [](bool devicesChanged) {
@@ -115,33 +139,6 @@ void FakeInputReaderPolicy::addDisplayViewport(DisplayViewport viewport) {
    mConfig.setDisplayViewports(mViewports);
}

void FakeInputReaderPolicy::addDisplayViewport(ui::LogicalDisplayId displayId, int32_t width,
                                               int32_t height, ui::Rotation orientation,
                                               bool isActive, const std::string& uniqueId,
                                               std::optional<uint8_t> physicalPort,
                                               ViewportType type) {
    const bool isRotated = orientation == ui::ROTATION_90 || orientation == ui::ROTATION_270;
    DisplayViewport v;
    v.displayId = displayId;
    v.orientation = orientation;
    v.logicalLeft = 0;
    v.logicalTop = 0;
    v.logicalRight = isRotated ? height : width;
    v.logicalBottom = isRotated ? width : height;
    v.physicalLeft = 0;
    v.physicalTop = 0;
    v.physicalRight = isRotated ? height : width;
    v.physicalBottom = isRotated ? width : height;
    v.deviceWidth = isRotated ? height : width;
    v.deviceHeight = isRotated ? width : height;
    v.isActive = isActive;
    v.uniqueId = uniqueId;
    v.physicalPort = physicalPort;
    v.type = type;

    addDisplayViewport(v);
}

bool FakeInputReaderPolicy::updateViewport(const DisplayViewport& viewport) {
    size_t count = mViewports.size();
    for (size_t i = 0; i < count; i++) {
+4 −3
Original line number Diff line number Diff line
@@ -31,6 +31,10 @@

namespace android {

DisplayViewport createViewport(ui::LogicalDisplayId displayId, int32_t width, int32_t height,
                               ui::Rotation orientation, bool isActive, const std::string& uniqueId,
                               std::optional<uint8_t> physicalPort, ViewportType type);

class FakeInputReaderPolicy : public InputReaderPolicyInterface {
protected:
    virtual ~FakeInputReaderPolicy() {}
@@ -50,9 +54,6 @@ public:
    std::optional<DisplayViewport> getDisplayViewportByType(ViewportType type) const;
    std::optional<DisplayViewport> getDisplayViewportByPort(uint8_t displayPort) const;
    void addDisplayViewport(DisplayViewport viewport);
    void addDisplayViewport(ui::LogicalDisplayId displayId, int32_t width, int32_t height,
                            ui::Rotation orientation, bool isActive, const std::string& uniqueId,
                            std::optional<uint8_t> physicalPort, ViewportType type);
    bool updateViewport(const DisplayViewport& viewport);
    void addExcludedDeviceName(const std::string& deviceName);
    void addInputPortAssociation(const std::string& inputPort, uint8_t displayPort);
+4 −2
Original line number Diff line number Diff line
@@ -186,8 +186,10 @@ void InputMapperTest::setDisplayInfoAndReconfigure(ui::LogicalDisplayId displayI
                                                   const std::string& uniqueId,
                                                   std::optional<uint8_t> physicalPort,
                                                   ViewportType viewportType) {
    mFakePolicy->addDisplayViewport(displayId, width, height, orientation, /* isActive= */ true,
                                    uniqueId, physicalPort, viewportType);
    DisplayViewport viewport =
            createViewport(displayId, width, height, orientation, /* isActive= */ true, uniqueId,
                           physicalPort, viewportType);
    mFakePolicy->addDisplayViewport(viewport);
    configureDevice(InputReaderConfiguration::Change::DISPLAY_INFO);
}

+137 −126

File changed.

Preview size limit exceeded, changes collapsed.

+4 −3
Original line number Diff line number Diff line
@@ -109,9 +109,10 @@ protected:
        mockSlotValues({});

        mFakePolicy->setDefaultPointerDisplayId(DISPLAY_ID);
        mFakePolicy->addDisplayViewport(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, ui::ROTATION_0,
                                        /*isActive=*/true, "local:0", NO_PORT,
                                        ViewportType::INTERNAL);
        DisplayViewport internalViewport =
                createViewport(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, ui::ROTATION_0,
                               /*isActive=*/true, "local:0", NO_PORT, ViewportType::INTERNAL);
        mFakePolicy->addDisplayViewport(internalViewport);
        mMapper = createInputMapper<MultiTouchInputMapper>(*mDeviceContext,
                                                           mFakePolicy->getReaderConfiguration());
    }
Loading