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
diff --git a/include/input/DisplayViewport.h b/include/input/DisplayViewport.h
index 6100626..2427a07 100644
--- a/include/input/DisplayViewport.h
+++ b/include/input/DisplayViewport.h
@@ -74,36 +74,40 @@
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 @@
physicalBottom = height;
deviceWidth = width;
deviceHeight = height;
+ isActive = false;
uniqueId.clear();
physicalPort = std::nullopt;
type = ViewportType::VIEWPORT_INTERNAL;
@@ -134,18 +139,16 @@
std::string toString() const {
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);
+ "logicalFrame=[%d, %d, %d, %d], "
+ "physicalFrame=[%d, %d, %d, %d], "
+ "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);
}
};