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

Commit 796fbbbc authored by Chris Ye's avatar Chris Ye
Browse files

Generate ACTION_CANCEL event when screen turned off by proximity sensor.

When using PROXIMITY_SCREEN_OFF_WAKE_LOCK and screen was turned off by proximity sensor,
input service should generate ACTION_CANCEL, same as display turned off by pressing power button.

Bug: 154074380
Test: atest libgui_test
Change-Id: I72a10c98adad4a236dbd445cefe5f37c4ec3fd81
Merged-In: I72a10c98adad4a236dbd445cefe5f37c4ec3fd81
parent c30ebd01
Loading
Loading
Loading
Loading
+37 −34
Original line number Diff line number Diff line
@@ -74,36 +74,40 @@ struct DisplayViewport {
    int32_t physicalBottom;
    int32_t deviceWidth;
    int32_t deviceHeight;
    bool isActive;
    std::string uniqueId;
    // The actual (hardware) port that the associated display is connected to.
    // Not all viewports will have this specified.
    std::optional<uint8_t> physicalPort;
    ViewportType type;

    DisplayViewport() :
            displayId(ADISPLAY_ID_NONE), orientation(DISPLAY_ORIENTATION_0),
            logicalLeft(0), logicalTop(0), logicalRight(0), logicalBottom(0),
            physicalLeft(0), physicalTop(0), physicalRight(0), physicalBottom(0),
            deviceWidth(0), deviceHeight(0), uniqueId(), physicalPort(std::nullopt),
            type(ViewportType::VIEWPORT_INTERNAL) {
    }
    DisplayViewport()
          : displayId(ADISPLAY_ID_NONE),
            orientation(DISPLAY_ORIENTATION_0),
            logicalLeft(0),
            logicalTop(0),
            logicalRight(0),
            logicalBottom(0),
            physicalLeft(0),
            physicalTop(0),
            physicalRight(0),
            physicalBottom(0),
            deviceWidth(0),
            deviceHeight(0),
            isActive(false),
            uniqueId(),
            physicalPort(std::nullopt),
            type(ViewportType::VIEWPORT_INTERNAL) {}

    bool operator==(const DisplayViewport& other) const {
        return displayId == other.displayId
                && orientation == other.orientation
                && logicalLeft == other.logicalLeft
                && logicalTop == other.logicalTop
                && logicalRight == other.logicalRight
                && logicalBottom == other.logicalBottom
                && physicalLeft == other.physicalLeft
                && physicalTop == other.physicalTop
                && physicalRight == other.physicalRight
                && physicalBottom == other.physicalBottom
                && deviceWidth == other.deviceWidth
                && deviceHeight == other.deviceHeight
                && uniqueId == other.uniqueId
                && physicalPort == other.physicalPort
                && type == other.type;
        return displayId == other.displayId && orientation == other.orientation &&
                logicalLeft == other.logicalLeft && logicalTop == other.logicalTop &&
                logicalRight == other.logicalRight && logicalBottom == other.logicalBottom &&
                physicalLeft == other.physicalLeft && physicalTop == other.physicalTop &&
                physicalRight == other.physicalRight && physicalBottom == other.physicalBottom &&
                deviceWidth == other.deviceWidth && deviceHeight == other.deviceHeight &&
                isActive == other.isActive && uniqueId == other.uniqueId &&
                physicalPort == other.physicalPort && type == other.type;
    }

    bool operator!=(const DisplayViewport& other) const {
@@ -127,6 +131,7 @@ struct DisplayViewport {
        physicalBottom = height;
        deviceWidth = width;
        deviceHeight = height;
        isActive = false;
        uniqueId.clear();
        physicalPort = std::nullopt;
        type = ViewportType::VIEWPORT_INTERNAL;
@@ -136,16 +141,14 @@ struct DisplayViewport {
        return StringPrintf("Viewport %s: displayId=%d, uniqueId=%s, port=%s, orientation=%d, "
                            "logicalFrame=[%d, %d, %d, %d], "
                            "physicalFrame=[%d, %d, %d, %d], "
            "deviceSize=[%d, %d]",
            viewportTypeToString(type), displayId,
            uniqueId.c_str(),
            physicalPort ? StringPrintf("%" PRIu8, *physicalPort).c_str() : "<none>",
            orientation,
            logicalLeft, logicalTop,
            logicalRight, logicalBottom,
            physicalLeft, physicalTop,
            physicalRight, physicalBottom,
            deviceWidth, deviceHeight);
                            "deviceSize=[%d, %d], "
                            "isActive=[%d]",
                            viewportTypeToString(type), displayId, uniqueId.c_str(),
                            physicalPort ? StringPrintf("%" PRIu8, *physicalPort).c_str()
                                         : "<none>",
                            orientation, logicalLeft, logicalTop, logicalRight, logicalBottom,
                            physicalLeft, physicalTop, physicalRight, physicalBottom, deviceWidth,
                            deviceHeight, isActive);
    }
};