diff options
56 files changed, 1763 insertions, 1477 deletions
diff --git a/include/input/DisplayViewport.h b/include/input/DisplayViewport.h index 97c2ab8451..56294dd91a 100644 --- a/include/input/DisplayViewport.h +++ b/include/input/DisplayViewport.h @@ -46,7 +46,7 @@ enum class ViewportType : int32_t { * See com.android.server.display.DisplayViewport. */ struct DisplayViewport { - ui::LogicalDisplayId displayId; // ADISPLAY_ID_NONE if invalid + ui::LogicalDisplayId displayId; ui::Rotation orientation; int32_t logicalLeft; int32_t logicalTop; @@ -66,7 +66,7 @@ struct DisplayViewport { ViewportType type; DisplayViewport() - : displayId(ui::ADISPLAY_ID_NONE), + : displayId(ui::LogicalDisplayId::INVALID), orientation(ui::ROTATION_0), logicalLeft(0), logicalTop(0), @@ -101,7 +101,7 @@ struct DisplayViewport { inline bool isValid() const { return displayId.isValid(); } void setNonDisplayViewport(int32_t width, int32_t height) { - displayId = ui::ADISPLAY_ID_NONE; + displayId = ui::LogicalDisplayId::INVALID; orientation = ui::ROTATION_0; logicalLeft = 0; logicalTop = 0; diff --git a/include/input/Input.h b/include/input/Input.h index e939145bbf..3ca9c19876 100644 --- a/include/input/Input.h +++ b/include/input/Input.h @@ -553,7 +553,7 @@ protected: int32_t mId; DeviceId mDeviceId; uint32_t mSource; - ui::LogicalDisplayId mDisplayId{ui::ADISPLAY_ID_NONE}; + ui::LogicalDisplayId mDisplayId{ui::LogicalDisplayId::INVALID}; std::array<uint8_t, 32> mHmac; }; diff --git a/include/input/InputDevice.h b/include/input/InputDevice.h index 8783d9c192..7d8c19e702 100644 --- a/include/input/InputDevice.h +++ b/include/input/InputDevice.h @@ -366,7 +366,7 @@ private: int32_t mKeyboardType; std::shared_ptr<KeyCharacterMap> mKeyCharacterMap; std::optional<InputDeviceUsiVersion> mUsiVersion; - ui::LogicalDisplayId mAssociatedDisplayId{ui::ADISPLAY_ID_NONE}; + ui::LogicalDisplayId mAssociatedDisplayId{ui::LogicalDisplayId::INVALID}; bool mEnabled; bool mHasVibrator; diff --git a/include/input/InputEventBuilders.h b/include/input/InputEventBuilders.h index 837e70e114..25d35e9fe7 100644 --- a/include/input/InputEventBuilders.h +++ b/include/input/InputEventBuilders.h @@ -158,7 +158,7 @@ private: int32_t mSource; nsecs_t mDownTime; nsecs_t mEventTime; - ui::LogicalDisplayId mDisplayId{ui::ADISPLAY_ID_DEFAULT}; + ui::LogicalDisplayId mDisplayId{ui::LogicalDisplayId::DEFAULT}; int32_t mActionButton{0}; int32_t mButtonState{0}; int32_t mFlags{0}; @@ -247,7 +247,7 @@ private: uint32_t mSource; nsecs_t mDownTime; nsecs_t mEventTime; - ui::LogicalDisplayId mDisplayId{ui::ADISPLAY_ID_DEFAULT}; + ui::LogicalDisplayId mDisplayId{ui::LogicalDisplayId::DEFAULT}; uint32_t mPolicyFlags = DEFAULT_POLICY_FLAGS; int32_t mFlags{0}; int32_t mKeyCode{AKEYCODE_UNKNOWN}; diff --git a/libs/gui/include/gui/DisplayInfo.h b/libs/gui/include/gui/DisplayInfo.h index 7282b807a4..7094658379 100644 --- a/libs/gui/include/gui/DisplayInfo.h +++ b/libs/gui/include/gui/DisplayInfo.h @@ -29,7 +29,7 @@ namespace android::gui { * This should only be used by InputFlinger to support raw coordinates in logical display space. */ struct DisplayInfo : public Parcelable { - ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE; + ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID; // Logical display dimensions. int32_t logicalWidth = 0; diff --git a/libs/gui/include/gui/WindowInfo.h b/libs/gui/include/gui/WindowInfo.h index 3ea3f67bd8..eb3be5588a 100644 --- a/libs/gui/include/gui/WindowInfo.h +++ b/libs/gui/include/gui/WindowInfo.h @@ -234,7 +234,7 @@ struct WindowInfo : public Parcelable { Uid ownerUid = Uid::INVALID; std::string packageName; ftl::Flags<InputConfig> inputConfig; - ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE; + ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID; InputApplicationInfo applicationInfo; bool replaceTouchableRegionWithCrop = false; wp<IBinder> touchableRegionCropHandle; diff --git a/libs/gui/tests/EndToEndNativeInputTest.cpp b/libs/gui/tests/EndToEndNativeInputTest.cpp index c0e79655f8..45e33902c7 100644 --- a/libs/gui/tests/EndToEndNativeInputTest.cpp +++ b/libs/gui/tests/EndToEndNativeInputTest.cpp @@ -59,8 +59,6 @@ using android::gui::FocusRequest; using android::gui::InputApplicationInfo; using android::gui::TouchOcclusionMode; using android::gui::WindowInfo; -using android::ui::ADISPLAY_ID_DEFAULT; -using android::ui::ADISPLAY_ID_NONE; namespace android { namespace { @@ -313,7 +311,7 @@ public: reportedListener->wait(); } - void requestFocus(ui::LogicalDisplayId displayId = ADISPLAY_ID_DEFAULT) { + void requestFocus(ui::LogicalDisplayId displayId = ui::LogicalDisplayId::DEFAULT) { SurfaceComposerClient::Transaction t; FocusRequest request; request.token = mInputInfo.token; @@ -438,7 +436,7 @@ void injectTapOnDisplay(int x, int y, ui::LogicalDisplayId displayId) { } void injectTap(int x, int y) { - injectTapOnDisplay(x, y, ADISPLAY_ID_DEFAULT); + injectTapOnDisplay(x, y, ui::LogicalDisplayId::DEFAULT); } void injectKeyOnDisplay(uint32_t keycode, ui::LogicalDisplayId displayId) { @@ -451,7 +449,7 @@ void injectKeyOnDisplay(uint32_t keycode, ui::LogicalDisplayId displayId) { } void injectKey(uint32_t keycode) { - injectKeyOnDisplay(keycode, ADISPLAY_ID_NONE); + injectKeyOnDisplay(keycode, ui::LogicalDisplayId::INVALID); } TEST_F(InputSurfacesTest, can_receive_input) { diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp index 1178d02510..ee121d53fe 100644 --- a/libs/input/Input.cpp +++ b/libs/input/Input.cpp @@ -1198,7 +1198,7 @@ std::ostream& operator<<(std::ostream& out, const MotionEvent& event) { void FocusEvent::initialize(int32_t id, bool hasFocus) { InputEvent::initialize(id, ReservedInputDeviceId::VIRTUAL_KEYBOARD_ID, AINPUT_SOURCE_UNKNOWN, - ui::ADISPLAY_ID_NONE, INVALID_HMAC); + ui::LogicalDisplayId::INVALID, INVALID_HMAC); mHasFocus = hasFocus; } @@ -1211,7 +1211,7 @@ void FocusEvent::initialize(const FocusEvent& from) { void CaptureEvent::initialize(int32_t id, bool pointerCaptureEnabled) { InputEvent::initialize(id, ReservedInputDeviceId::VIRTUAL_KEYBOARD_ID, AINPUT_SOURCE_UNKNOWN, - ui::ADISPLAY_ID_NONE, INVALID_HMAC); + ui::LogicalDisplayId::INVALID, INVALID_HMAC); mPointerCaptureEnabled = pointerCaptureEnabled; } @@ -1224,7 +1224,7 @@ void CaptureEvent::initialize(const CaptureEvent& from) { void DragEvent::initialize(int32_t id, float x, float y, bool isExiting) { InputEvent::initialize(id, ReservedInputDeviceId::VIRTUAL_KEYBOARD_ID, AINPUT_SOURCE_UNKNOWN, - ui::ADISPLAY_ID_NONE, INVALID_HMAC); + ui::LogicalDisplayId::INVALID, INVALID_HMAC); mIsExiting = isExiting; mX = x; mY = y; @@ -1241,7 +1241,7 @@ void DragEvent::initialize(const DragEvent& from) { void TouchModeEvent::initialize(int32_t id, bool isInTouchMode) { InputEvent::initialize(id, ReservedInputDeviceId::VIRTUAL_KEYBOARD_ID, AINPUT_SOURCE_UNKNOWN, - ui::ADISPLAY_ID_NONE, INVALID_HMAC); + ui::LogicalDisplayId::INVALID, INVALID_HMAC); mIsInTouchMode = isInTouchMode; } diff --git a/libs/input/InputDevice.cpp b/libs/input/InputDevice.cpp index 50239a1f9f..bc678103c2 100644 --- a/libs/input/InputDevice.cpp +++ b/libs/input/InputDevice.cpp @@ -169,7 +169,7 @@ std::string InputDeviceIdentifier::getCanonicalName() const { // --- InputDeviceInfo --- InputDeviceInfo::InputDeviceInfo() { - initialize(-1, 0, -1, InputDeviceIdentifier(), "", false, false, ui::ADISPLAY_ID_NONE); + initialize(-1, 0, -1, InputDeviceIdentifier(), "", false, false, ui::LogicalDisplayId::INVALID); } InputDeviceInfo::InputDeviceInfo(const InputDeviceInfo& other) diff --git a/libs/input/KeyCharacterMap.cpp b/libs/input/KeyCharacterMap.cpp index f75bf410f2..1cf5612d45 100644 --- a/libs/input/KeyCharacterMap.cpp +++ b/libs/input/KeyCharacterMap.cpp @@ -497,9 +497,10 @@ void KeyCharacterMap::addKey(Vector<KeyEvent>& outEvents, int32_t deviceId, int3 int32_t metaState, bool down, nsecs_t time) { outEvents.push(); KeyEvent& event = outEvents.editTop(); - event.initialize(InputEvent::nextId(), deviceId, AINPUT_SOURCE_KEYBOARD, ui::ADISPLAY_ID_NONE, - INVALID_HMAC, down ? AKEY_EVENT_ACTION_DOWN : AKEY_EVENT_ACTION_UP, 0, keyCode, - 0, metaState, 0, time, time); + event.initialize(InputEvent::nextId(), deviceId, AINPUT_SOURCE_KEYBOARD, + ui::LogicalDisplayId::INVALID, INVALID_HMAC, + down ? AKEY_EVENT_ACTION_DOWN : AKEY_EVENT_ACTION_UP, 0, keyCode, 0, metaState, + 0, time, time); } void KeyCharacterMap::addMetaKeys(Vector<KeyEvent>& outEvents, diff --git a/libs/input/tests/InputEvent_test.cpp b/libs/input/tests/InputEvent_test.cpp index cc2574de9a..704ea46fe9 100644 --- a/libs/input/tests/InputEvent_test.cpp +++ b/libs/input/tests/InputEvent_test.cpp @@ -27,7 +27,7 @@ namespace android { // Default display id. -static constexpr ui::LogicalDisplayId DISPLAY_ID = ui::ADISPLAY_ID_DEFAULT; +static constexpr ui::LogicalDisplayId DISPLAY_ID = ui::LogicalDisplayId::DEFAULT; static constexpr float EPSILON = MotionEvent::ROUNDING_PRECISION; @@ -858,8 +858,8 @@ MotionEvent createMotionEvent(int32_t source, uint32_t action, float x, float y, pointerCoords.back().setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, dy); nsecs_t eventTime = systemTime(SYSTEM_TIME_MONOTONIC); MotionEvent event; - event.initialize(InputEvent::nextId(), /* deviceId */ 1, source, - /* displayId */ ui::ADISPLAY_ID_DEFAULT, INVALID_HMAC, action, + event.initialize(InputEvent::nextId(), /* deviceId */ 1, source, ui::LogicalDisplayId::DEFAULT, + INVALID_HMAC, action, /* actionButton */ 0, /* flags */ 0, /* edgeFlags */ 0, AMETA_NONE, /* buttonState */ 0, MotionClassification::NONE, transform, /* xPrecision */ 0, /* yPrecision */ 0, AMOTION_EVENT_INVALID_CURSOR_POSITION, diff --git a/libs/input/tests/InputPublisherAndConsumerNoResampling_test.cpp b/libs/input/tests/InputPublisherAndConsumerNoResampling_test.cpp index 7ae1cd8444..70529bbd39 100644 --- a/libs/input/tests/InputPublisherAndConsumerNoResampling_test.cpp +++ b/libs/input/tests/InputPublisherAndConsumerNoResampling_test.cpp @@ -55,7 +55,7 @@ struct PublishMotionArgs { const int32_t eventId; const int32_t deviceId = 1; const uint32_t source = AINPUT_SOURCE_TOUCHSCREEN; - const ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_DEFAULT; + const ui::LogicalDisplayId displayId = ui::LogicalDisplayId::DEFAULT; const int32_t actionButton = 0; const int32_t edgeFlags = AMOTION_EVENT_EDGE_FLAG_TOP; const int32_t metaState = AMETA_ALT_LEFT_ON | AMETA_ALT_ON; @@ -445,7 +445,7 @@ void InputPublisherAndConsumerNoResamplingTest::publishAndConsumeKeyEvent() { int32_t eventId = InputEvent::nextId(); constexpr int32_t deviceId = 1; constexpr uint32_t source = AINPUT_SOURCE_KEYBOARD; - constexpr ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_DEFAULT; + constexpr ui::LogicalDisplayId displayId = ui::LogicalDisplayId::DEFAULT; constexpr std::array<uint8_t, 32> hmac = {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; @@ -737,10 +737,10 @@ TEST_F(InputPublisherAndConsumerNoResamplingTest, ui::Transform identityTransform; status = - mPublisher->publishMotionEvent(0, InputEvent::nextId(), 0, 0, ui::ADISPLAY_ID_DEFAULT, - INVALID_HMAC, 0, 0, 0, 0, 0, 0, - MotionClassification::NONE, identityTransform, 0, 0, - AMOTION_EVENT_INVALID_CURSOR_POSITION, + mPublisher->publishMotionEvent(0, InputEvent::nextId(), 0, 0, + ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, 0, 0, 0, 0, + 0, 0, MotionClassification::NONE, identityTransform, 0, + 0, AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform, 0, 0, pointerCount, pointerProperties, pointerCoords); ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE"; @@ -755,10 +755,10 @@ TEST_F(InputPublisherAndConsumerNoResamplingTest, ui::Transform identityTransform; status = - mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0, ui::ADISPLAY_ID_DEFAULT, - INVALID_HMAC, 0, 0, 0, 0, 0, 0, - MotionClassification::NONE, identityTransform, 0, 0, - AMOTION_EVENT_INVALID_CURSOR_POSITION, + mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0, + ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, 0, 0, 0, 0, + 0, 0, MotionClassification::NONE, identityTransform, 0, + 0, AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform, 0, 0, pointerCount, pointerProperties, pointerCoords); ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE"; @@ -777,10 +777,10 @@ TEST_F(InputPublisherAndConsumerNoResamplingTest, ui::Transform identityTransform; status = - mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0, ui::ADISPLAY_ID_DEFAULT, - INVALID_HMAC, 0, 0, 0, 0, 0, 0, - MotionClassification::NONE, identityTransform, 0, 0, - AMOTION_EVENT_INVALID_CURSOR_POSITION, + mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0, + ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, 0, 0, 0, 0, + 0, 0, MotionClassification::NONE, identityTransform, 0, + 0, AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform, 0, 0, pointerCount, pointerProperties, pointerCoords); ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE"; diff --git a/libs/input/tests/InputPublisherAndConsumer_test.cpp b/libs/input/tests/InputPublisherAndConsumer_test.cpp index d0dbe2ad31..48512f7c6e 100644 --- a/libs/input/tests/InputPublisherAndConsumer_test.cpp +++ b/libs/input/tests/InputPublisherAndConsumer_test.cpp @@ -48,7 +48,7 @@ struct PublishMotionArgs { const int32_t eventId; const int32_t deviceId = 1; const uint32_t source = AINPUT_SOURCE_TOUCHSCREEN; - const ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_DEFAULT; + const ui::LogicalDisplayId displayId = ui::LogicalDisplayId::DEFAULT; const int32_t actionButton = 0; const int32_t edgeFlags = AMOTION_EVENT_EDGE_FLAG_TOP; const int32_t metaState = AMETA_ALT_LEFT_ON | AMETA_ALT_ON; @@ -262,7 +262,7 @@ void InputPublisherAndConsumerTest::publishAndConsumeKeyEvent() { int32_t eventId = InputEvent::nextId(); constexpr int32_t deviceId = 1; constexpr uint32_t source = AINPUT_SOURCE_KEYBOARD; - constexpr ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_DEFAULT; + constexpr ui::LogicalDisplayId displayId = ui::LogicalDisplayId::DEFAULT; constexpr std::array<uint8_t, 32> hmac = {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; @@ -622,10 +622,10 @@ TEST_F(InputPublisherAndConsumerTest, PublishMotionEvent_WhenSequenceNumberIsZer ui::Transform identityTransform; status = - mPublisher->publishMotionEvent(0, InputEvent::nextId(), 0, 0, ui::ADISPLAY_ID_DEFAULT, - INVALID_HMAC, 0, 0, 0, 0, 0, 0, - MotionClassification::NONE, identityTransform, 0, 0, - AMOTION_EVENT_INVALID_CURSOR_POSITION, + mPublisher->publishMotionEvent(0, InputEvent::nextId(), 0, 0, + ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, 0, 0, 0, 0, + 0, 0, MotionClassification::NONE, identityTransform, 0, + 0, AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform, 0, 0, pointerCount, pointerProperties, pointerCoords); ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE"; @@ -639,10 +639,10 @@ TEST_F(InputPublisherAndConsumerTest, PublishMotionEvent_WhenPointerCountLessTha ui::Transform identityTransform; status = - mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0, ui::ADISPLAY_ID_DEFAULT, - INVALID_HMAC, 0, 0, 0, 0, 0, 0, - MotionClassification::NONE, identityTransform, 0, 0, - AMOTION_EVENT_INVALID_CURSOR_POSITION, + mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0, + ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, 0, 0, 0, 0, + 0, 0, MotionClassification::NONE, identityTransform, 0, + 0, AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform, 0, 0, pointerCount, pointerProperties, pointerCoords); ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE"; @@ -661,10 +661,10 @@ TEST_F(InputPublisherAndConsumerTest, ui::Transform identityTransform; status = - mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0, ui::ADISPLAY_ID_DEFAULT, - INVALID_HMAC, 0, 0, 0, 0, 0, 0, - MotionClassification::NONE, identityTransform, 0, 0, - AMOTION_EVENT_INVALID_CURSOR_POSITION, + mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0, + ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, 0, 0, 0, 0, + 0, 0, MotionClassification::NONE, identityTransform, 0, + 0, AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform, 0, 0, pointerCount, pointerProperties, pointerCoords); ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE"; diff --git a/libs/input/tests/MotionPredictor_test.cpp b/libs/input/tests/MotionPredictor_test.cpp index 1c9f0c7399..d077760757 100644 --- a/libs/input/tests/MotionPredictor_test.cpp +++ b/libs/input/tests/MotionPredictor_test.cpp @@ -58,9 +58,10 @@ static MotionEvent getMotionEvent(int32_t action, float x, float y, } ui::Transform identityTransform; - event.initialize(InputEvent::nextId(), deviceId, AINPUT_SOURCE_STYLUS, ui::ADISPLAY_ID_DEFAULT, - {0}, action, /*actionButton=*/0, /*flags=*/0, AMOTION_EVENT_EDGE_FLAG_NONE, - AMETA_NONE, /*buttonState=*/0, MotionClassification::NONE, identityTransform, + event.initialize(InputEvent::nextId(), deviceId, AINPUT_SOURCE_STYLUS, + ui::LogicalDisplayId::DEFAULT, {0}, action, /*actionButton=*/0, /*flags=*/0, + AMOTION_EVENT_EDGE_FLAG_NONE, AMETA_NONE, /*buttonState=*/0, + MotionClassification::NONE, identityTransform, /*xPrecision=*/0.1, /*yPrecision=*/0.2, /*xCursorPosition=*/280, /*yCursorPosition=*/540, identityTransform, /*downTime=*/100, eventTime.count(), pointerCount, diff --git a/libs/input/tests/TouchResampling_test.cpp b/libs/input/tests/TouchResampling_test.cpp index 1694cadfbe..2dc9fdb7f1 100644 --- a/libs/input/tests/TouchResampling_test.cpp +++ b/libs/input/tests/TouchResampling_test.cpp @@ -84,11 +84,11 @@ status_t TouchResamplingTest::publishSimpleMotionEventWithCoords( ADD_FAILURE() << "Downtime should be equal to 0 (hardcoded for convenience)"; } return mPublisher->publishMotionEvent(mSeq++, InputEvent::nextId(), /*deviceId=*/1, - AINPUT_SOURCE_TOUCHSCREEN, - /*displayId=*/ui::ADISPLAY_ID_DEFAULT, INVALID_HMAC, - action, /*actionButton=*/0, /*flags=*/0, /*edgeFlags=*/0, - AMETA_NONE, /*buttonState=*/0, MotionClassification::NONE, - identityTransform, /*xPrecision=*/0, /*yPrecision=*/0, + AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, + INVALID_HMAC, action, /*actionButton=*/0, /*flags=*/0, + /*edgeFlags=*/0, AMETA_NONE, /*buttonState=*/0, + MotionClassification::NONE, identityTransform, + /*xPrecision=*/0, /*yPrecision=*/0, AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform, downTime, eventTime, properties.size(), properties.data(), diff --git a/libs/input/tests/VelocityTracker_test.cpp b/libs/input/tests/VelocityTracker_test.cpp index b4c4e1286d..f50a3cdb99 100644 --- a/libs/input/tests/VelocityTracker_test.cpp +++ b/libs/input/tests/VelocityTracker_test.cpp @@ -33,7 +33,7 @@ using android::base::StringPrintf; namespace android { -constexpr ui::LogicalDisplayId DISPLAY_ID = ui::ADISPLAY_ID_DEFAULT; // default display id +constexpr ui::LogicalDisplayId DISPLAY_ID = ui::LogicalDisplayId::DEFAULT; // default display id constexpr int32_t DEFAULT_POINTER_ID = 0; // pointer ID used for manually defined tests @@ -155,7 +155,7 @@ static std::vector<MotionEvent> createAxisScrollMotionEventStream( MotionEvent event; ui::Transform identityTransform; event.initialize(InputEvent::nextId(), /*deviceId=*/5, AINPUT_SOURCE_ROTARY_ENCODER, - ui::ADISPLAY_ID_NONE, INVALID_HMAC, AMOTION_EVENT_ACTION_SCROLL, + ui::LogicalDisplayId::INVALID, INVALID_HMAC, AMOTION_EVENT_ACTION_SCROLL, /*actionButton=*/0, /*flags=*/0, AMOTION_EVENT_EDGE_FLAG_NONE, AMETA_NONE, /*buttonState=*/0, MotionClassification::NONE, identityTransform, /*xPrecision=*/0, /*yPrecision=*/0, AMOTION_EVENT_INVALID_CURSOR_POSITION, diff --git a/libs/input/tests/VerifiedInputEvent_test.cpp b/libs/input/tests/VerifiedInputEvent_test.cpp index 40cfaaeb05..df5fe9d2d0 100644 --- a/libs/input/tests/VerifiedInputEvent_test.cpp +++ b/libs/input/tests/VerifiedInputEvent_test.cpp @@ -23,7 +23,7 @@ namespace android { static KeyEvent getKeyEventWithFlags(int32_t flags) { KeyEvent event; event.initialize(InputEvent::nextId(), /*deviceId=*/2, AINPUT_SOURCE_GAMEPAD, - ui::ADISPLAY_ID_DEFAULT, INVALID_HMAC, AKEY_EVENT_ACTION_DOWN, flags, + ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, AKEY_EVENT_ACTION_DOWN, flags, AKEYCODE_BUTTON_X, /*scanCode=*/121, AMETA_ALT_ON, /*repeatCount=*/1, /*downTime=*/1000, /*eventTime=*/2000); return event; @@ -44,7 +44,7 @@ static MotionEvent getMotionEventWithFlags(int32_t flags) { transform.set({2, 0, 4, 0, 3, 5, 0, 0, 1}); ui::Transform identity; event.initialize(InputEvent::nextId(), /*deviceId=*/0, AINPUT_SOURCE_MOUSE, - ui::ADISPLAY_ID_DEFAULT, INVALID_HMAC, AMOTION_EVENT_ACTION_DOWN, + ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, AMOTION_EVENT_ACTION_DOWN, /*actionButton=*/0, flags, AMOTION_EVENT_EDGE_FLAG_NONE, AMETA_NONE, /*buttonState=*/0, MotionClassification::NONE, transform, /*xPrecision=*/0.1, /*yPrecision=*/0.2, diff --git a/libs/ui/include/ui/LogicalDisplayId.h b/libs/ui/include/ui/LogicalDisplayId.h index 3e504e7101..d745758f0c 100644 --- a/libs/ui/include/ui/LogicalDisplayId.h +++ b/libs/ui/include/ui/LogicalDisplayId.h @@ -35,10 +35,20 @@ struct LogicalDisplayId : ftl::Constructible<LogicalDisplayId, int32_t>, constexpr bool isValid() const { return val() >= 0; } std::string toString() const { return std::to_string(val()); } + + static const LogicalDisplayId INVALID; + static const LogicalDisplayId DEFAULT; }; -constexpr LogicalDisplayId ADISPLAY_ID_NONE{-1}; -constexpr LogicalDisplayId ADISPLAY_ID_DEFAULT{0}; +constexpr inline LogicalDisplayId LogicalDisplayId::INVALID{-1}; +constexpr inline LogicalDisplayId LogicalDisplayId::DEFAULT{0}; + +/** + * Deprecated! Use LogicalDisplayId::INVALID / LogicalDisplayId::DEFAULT instead. + * TODO(b/339106983): remove these. + */ +[[deprecated]] constexpr LogicalDisplayId ADISPLAY_ID_NONE{-1}; +[[deprecated]] constexpr LogicalDisplayId ADISPLAY_ID_DEFAULT{0}; inline std::ostream& operator<<(std::ostream& stream, LogicalDisplayId displayId) { return stream << displayId.val(); diff --git a/services/inputflinger/InputReaderBase.cpp b/services/inputflinger/InputReaderBase.cpp index 29b487f1d2..6b2627ce96 100644 --- a/services/inputflinger/InputReaderBase.cpp +++ b/services/inputflinger/InputReaderBase.cpp @@ -68,7 +68,7 @@ std::optional<DisplayViewport> InputReaderConfiguration::getDisplayViewportByTyp if (currentViewport.type == type) { if (!result || (type == ViewportType::INTERNAL && - currentViewport.displayId == ui::ADISPLAY_ID_DEFAULT)) { + currentViewport.displayId == ui::LogicalDisplayId::DEFAULT)) { result = std::make_optional(currentViewport); } count++; diff --git a/services/inputflinger/PointerChoreographer.cpp b/services/inputflinger/PointerChoreographer.cpp index d6c6f938d4..8a1eed603f 100644 --- a/services/inputflinger/PointerChoreographer.cpp +++ b/services/inputflinger/PointerChoreographer.cpp @@ -101,8 +101,8 @@ PointerChoreographer::PointerChoreographer(InputListenerInterface& listener, }), mNextListener(listener), mPolicy(policy), - mDefaultMouseDisplayId(ui::ADISPLAY_ID_DEFAULT), - mNotifiedPointerDisplayId(ui::ADISPLAY_ID_NONE), + mDefaultMouseDisplayId(ui::LogicalDisplayId::DEFAULT), + mNotifiedPointerDisplayId(ui::LogicalDisplayId::INVALID), mShowTouchesEnabled(false), mStylusPointerIconEnabled(false) {} @@ -236,7 +236,7 @@ NotifyMotionArgs PointerChoreographer::processTouchpadEventLocked(const NotifyMo } void PointerChoreographer::processDrawingTabletEventLocked(const android::NotifyMotionArgs& args) { - if (args.displayId == ui::ADISPLAY_ID_NONE) { + if (args.displayId == ui::LogicalDisplayId::INVALID) { return; } @@ -557,7 +557,7 @@ PointerChoreographer::PointerDisplayChange PointerChoreographer::updatePointerCo PointerChoreographer::PointerDisplayChange PointerChoreographer::calculatePointerDisplayChangeToNotify() { - ui::LogicalDisplayId displayIdToNotify = ui::ADISPLAY_ID_NONE; + ui::LogicalDisplayId displayIdToNotify = ui::LogicalDisplayId::INVALID; FloatPoint cursorPosition = {0, 0}; if (const auto it = mMousePointersByDisplay.find(mDefaultMouseDisplayId); it != mMousePointersByDisplay.end()) { diff --git a/services/inputflinger/PointerChoreographer.h b/services/inputflinger/PointerChoreographer.h index fda5f5231e..12316c0427 100644 --- a/services/inputflinger/PointerChoreographer.h +++ b/services/inputflinger/PointerChoreographer.h @@ -57,7 +57,7 @@ public: virtual void setDefaultMouseDisplayId(ui::LogicalDisplayId displayId) = 0; virtual void setDisplayViewports(const std::vector<DisplayViewport>& viewports) = 0; virtual std::optional<DisplayViewport> getViewportForPointerDevice( - ui::LogicalDisplayId associatedDisplayId = ui::ADISPLAY_ID_NONE) = 0; + ui::LogicalDisplayId associatedDisplayId = ui::LogicalDisplayId::INVALID) = 0; virtual FloatPoint getMouseCursorPosition(ui::LogicalDisplayId displayId) = 0; virtual void setShowTouchesEnabled(bool enabled) = 0; virtual void setStylusPointerIconEnabled(bool enabled) = 0; diff --git a/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp b/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp index 66e4a297dd..96c8640e2f 100644 --- a/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp +++ b/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp @@ -37,7 +37,7 @@ namespace { constexpr DeviceId DEVICE_ID = 1; // An arbitrary display id -constexpr ui::LogicalDisplayId DISPLAY_ID = ui::ADISPLAY_ID_DEFAULT; +constexpr ui::LogicalDisplayId DISPLAY_ID = ui::LogicalDisplayId::DEFAULT; static constexpr std::chrono::duration INJECT_EVENT_TIMEOUT = 5s; @@ -62,7 +62,7 @@ static MotionEvent generateMotionEvent() { ui::Transform identityTransform; MotionEvent event; event.initialize(IInputConstants::INVALID_INPUT_EVENT_ID, DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, - ui::ADISPLAY_ID_DEFAULT, INVALID_HMAC, AMOTION_EVENT_ACTION_DOWN, + ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, AMOTION_EVENT_ACTION_DOWN, /* actionButton */ 0, /* flags */ 0, /* edgeFlags */ 0, AMETA_NONE, /* buttonState */ 0, MotionClassification::NONE, identityTransform, /* xPrecision */ 0, @@ -88,7 +88,7 @@ static NotifyMotionArgs generateMotionArgs() { const nsecs_t currentTime = now(); // Define a valid motion event. NotifyMotionArgs args(IInputConstants::INVALID_INPUT_EVENT_ID, currentTime, currentTime, - DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, ui::ADISPLAY_ID_DEFAULT, + DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, POLICY_FLAG_PASS_TO_USER, AMOTION_EVENT_ACTION_DOWN, /* actionButton */ 0, /* flags */ 0, AMETA_NONE, /* buttonState */ 0, MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE, 1, diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp index 8e0da1470e..dae2b6119c 100644 --- a/services/inputflinger/dispatcher/InputDispatcher.cpp +++ b/services/inputflinger/dispatcher/InputDispatcher.cpp @@ -918,9 +918,9 @@ InputDispatcher::InputDispatcher(InputDispatcherPolicyInterface& policy, mDispatchFrozen(false), mInputFilterEnabled(false), mMaximumObscuringOpacityForTouch(1.0f), - mFocusedDisplayId(ui::ADISPLAY_ID_DEFAULT), + mFocusedDisplayId(ui::LogicalDisplayId::DEFAULT), mWindowTokenWithPointerCapture(nullptr), - mAwaitedApplicationDisplayId(ui::ADISPLAY_ID_NONE), + mAwaitedApplicationDisplayId(ui::LogicalDisplayId::INVALID), mLatencyAggregator(), mLatencyTracker(&mLatencyAggregator) { mLooper = sp<Looper>::make(false); @@ -2201,7 +2201,7 @@ void InputDispatcher::resetNoFocusedWindowTimeoutLocked() { * Focused display is the display that the user most recently interacted with. */ ui::LogicalDisplayId InputDispatcher::getTargetDisplayId(const EventEntry& entry) { - ui::LogicalDisplayId displayId{ui::ADISPLAY_ID_NONE}; + ui::LogicalDisplayId displayId{ui::LogicalDisplayId::INVALID}; switch (entry.type) { case EventEntry::Type::KEY: { const KeyEntry& keyEntry = static_cast<const KeyEntry&>(entry); @@ -2221,10 +2221,10 @@ ui::LogicalDisplayId InputDispatcher::getTargetDisplayId(const EventEntry& entry case EventEntry::Type::SENSOR: case EventEntry::Type::DRAG: { ALOGE("%s events do not have a target display", ftl::enum_string(entry.type).c_str()); - return ui::ADISPLAY_ID_NONE; + return ui::LogicalDisplayId::INVALID; } } - return displayId == ui::ADISPLAY_ID_NONE ? mFocusedDisplayId : displayId; + return displayId == ui::LogicalDisplayId::INVALID ? mFocusedDisplayId : displayId; } bool InputDispatcher::shouldWaitToSendKeyLocked(nsecs_t currentTime, @@ -2829,7 +2829,7 @@ std::vector<InputTarget> InputDispatcher::findTouchedWindowTargetsLocked( // Save changes unless the action was scroll in which case the temporary touch // state was only valid for this one action. if (maskedAction != AMOTION_EVENT_ACTION_SCROLL) { - if (displayId >= ui::ADISPLAY_ID_DEFAULT) { + if (displayId >= ui::LogicalDisplayId::DEFAULT) { tempTouchState.clearWindowsWithoutPointers(); mTouchStatesByDisplay[displayId] = tempTouchState; } else { @@ -4862,8 +4862,8 @@ InputEventInjectionResult InputDispatcher::injectInputEvent(const InputEvent* ev isFromSource(event->getSource(), AINPUT_SOURCE_CLASS_POINTER); // If a pointer event has no displayId specified, inject it to the default display. const ui::LogicalDisplayId displayId = - isPointerEvent && (event->getDisplayId() == ui::ADISPLAY_ID_NONE) - ? ui::ADISPLAY_ID_DEFAULT + isPointerEvent && (event->getDisplayId() == ui::LogicalDisplayId::INVALID) + ? ui::LogicalDisplayId::DEFAULT : event->getDisplayId(); int32_t flags = motionEvent.getFlags(); @@ -4890,9 +4890,9 @@ InputEventInjectionResult InputDispatcher::injectInputEvent(const InputEvent* ev // events for consistency and print an error. An inconsistent event sent from // InputFilter could cause a crash in the later stages of dispatching pipeline. auto [it, _] = - mInputFilterVerifiersByDisplay - .try_emplace(displayId, - StringPrintf("Injection on %" PRId32, displayId)); + mInputFilterVerifiersByDisplay.try_emplace(displayId, + std::string("Injection on ") + + displayId.toString()); InputVerifier& verifier = it->second; Result<void> result = @@ -5523,7 +5523,7 @@ void InputDispatcher::setFocusedDisplay(ui::LogicalDisplayId displayId) { options(CancelationOptions::Mode::CANCEL_NON_POINTER_EVENTS, "The display which contains this window no longer has focus.", traceContext.getTracker()); - options.displayId = ui::ADISPLAY_ID_NONE; + options.displayId = ui::LogicalDisplayId::INVALID; synthesizeCancelationEventsForWindowLocked(windowHandle, options); } mFocusedDisplayId = displayId; @@ -5675,7 +5675,7 @@ InputDispatcher::findTouchStateWindowAndDisplayLocked(const sp<IBinder>& token) } } } - return std::make_tuple(nullptr, nullptr, ui::ADISPLAY_ID_DEFAULT); + return std::make_tuple(nullptr, nullptr, ui::LogicalDisplayId::DEFAULT); } bool InputDispatcher::transferTouchGesture(const sp<IBinder>& fromToken, const sp<IBinder>& toToken, @@ -6125,7 +6125,7 @@ Result<std::unique_ptr<InputChannel>> InputDispatcher::createInputMonitor( { // acquire lock std::scoped_lock _l(mLock); - if (displayId < ui::ADISPLAY_ID_DEFAULT) { + if (displayId < ui::LogicalDisplayId::DEFAULT) { return base::Error(BAD_VALUE) << "Attempted to create input monitor with name " << name << " without a specified display."; } diff --git a/services/inputflinger/dispatcher/InputState.h b/services/inputflinger/dispatcher/InputState.h index ab83ef911d..2808ba71bd 100644 --- a/services/inputflinger/dispatcher/InputState.h +++ b/services/inputflinger/dispatcher/InputState.h @@ -90,7 +90,7 @@ private: struct KeyMemento { DeviceId deviceId; uint32_t source; - ui::LogicalDisplayId displayId{ui::ADISPLAY_ID_NONE}; + ui::LogicalDisplayId displayId{ui::LogicalDisplayId::INVALID}; int32_t keyCode; int32_t scanCode; int32_t metaState; @@ -102,7 +102,7 @@ private: struct MotionMemento { DeviceId deviceId; uint32_t source; - ui::LogicalDisplayId displayId{ui::ADISPLAY_ID_NONE}; + ui::LogicalDisplayId displayId{ui::LogicalDisplayId::INVALID}; int32_t flags; float xPrecision; float yPrecision; diff --git a/services/inputflinger/include/InputReaderBase.h b/services/inputflinger/include/InputReaderBase.h index e5c3aa08d1..c62fc7d98e 100644 --- a/services/inputflinger/include/InputReaderBase.h +++ b/services/inputflinger/include/InputReaderBase.h @@ -243,7 +243,7 @@ struct InputReaderConfiguration { InputReaderConfiguration() : virtualKeyQuietTime(0), - defaultPointerDisplayId(ui::ADISPLAY_ID_DEFAULT), + defaultPointerDisplayId(ui::LogicalDisplayId::DEFAULT), mousePointerSpeed(0), displaysWithMousePointerAccelerationDisabled(), pointerVelocityControlParameters(1.0f, 500.0f, 3000.0f, @@ -472,7 +472,7 @@ public: * be used as the range of possible values for pointing devices, like mice and touchpads. */ virtual std::optional<DisplayViewport> getPointerViewportForAssociatedDisplay( - ui::LogicalDisplayId associatedDisplayId = ui::ADISPLAY_ID_NONE) = 0; + ui::LogicalDisplayId associatedDisplayId = ui::LogicalDisplayId::INVALID) = 0; }; } // namespace android diff --git a/services/inputflinger/include/NotifyArgs.h b/services/inputflinger/include/NotifyArgs.h index 865f3d0302..db417cf830 100644 --- a/services/inputflinger/include/NotifyArgs.h +++ b/services/inputflinger/include/NotifyArgs.h @@ -61,7 +61,7 @@ struct NotifyKeyArgs { int32_t deviceId; uint32_t source; - ui::LogicalDisplayId displayId{ui::ADISPLAY_ID_NONE}; + ui::LogicalDisplayId displayId{ui::LogicalDisplayId::INVALID}; uint32_t policyFlags; int32_t action; int32_t flags; @@ -91,7 +91,7 @@ struct NotifyMotionArgs { int32_t deviceId; uint32_t source; - ui::LogicalDisplayId displayId{ui::ADISPLAY_ID_NONE}; + ui::LogicalDisplayId displayId{ui::LogicalDisplayId::INVALID}; uint32_t policyFlags; int32_t action; int32_t actionButton; diff --git a/services/inputflinger/include/NotifyArgsBuilders.h b/services/inputflinger/include/NotifyArgsBuilders.h index 1ba0cfd20a..cae638f7bf 100644 --- a/services/inputflinger/include/NotifyArgsBuilders.h +++ b/services/inputflinger/include/NotifyArgsBuilders.h @@ -150,7 +150,7 @@ private: uint32_t mSource; nsecs_t mDownTime; nsecs_t mEventTime; - ui::LogicalDisplayId mDisplayId{ui::ADISPLAY_ID_DEFAULT}; + ui::LogicalDisplayId mDisplayId{ui::LogicalDisplayId::DEFAULT}; uint32_t mPolicyFlags = DEFAULT_POLICY_FLAGS; int32_t mActionButton{0}; int32_t mButtonState{0}; @@ -229,7 +229,7 @@ private: uint32_t mSource; nsecs_t mDownTime; nsecs_t mEventTime; - ui::LogicalDisplayId mDisplayId{ui::ADISPLAY_ID_DEFAULT}; + ui::LogicalDisplayId mDisplayId{ui::LogicalDisplayId::DEFAULT}; uint32_t mPolicyFlags = DEFAULT_POLICY_FLAGS; int32_t mFlags{0}; int32_t mKeyCode{AKEYCODE_UNKNOWN}; diff --git a/services/inputflinger/reader/InputDevice.cpp b/services/inputflinger/reader/InputDevice.cpp index 15586e2c4b..956484c931 100644 --- a/services/inputflinger/reader/InputDevice.cpp +++ b/services/inputflinger/reader/InputDevice.cpp @@ -442,7 +442,8 @@ std::list<NotifyArgs> InputDevice::updateExternalStylusState(const StylusState& InputDeviceInfo InputDevice::getDeviceInfo() { InputDeviceInfo outDeviceInfo; outDeviceInfo.initialize(mId, mGeneration, mControllerNumber, mIdentifier, mAlias, mIsExternal, - mHasMic, getAssociatedDisplayId().value_or(ui::ADISPLAY_ID_NONE), + mHasMic, + getAssociatedDisplayId().value_or(ui::LogicalDisplayId::INVALID), {mShouldSmoothScroll}, isEnabled()); for_each_mapper( diff --git a/services/inputflinger/reader/mapper/CapturedTouchpadEventConverter.cpp b/services/inputflinger/reader/mapper/CapturedTouchpadEventConverter.cpp index 21dec6ffa6..09a5f08a23 100644 --- a/services/inputflinger/reader/mapper/CapturedTouchpadEventConverter.cpp +++ b/services/inputflinger/reader/mapper/CapturedTouchpadEventConverter.cpp @@ -278,7 +278,7 @@ NotifyMotionArgs CapturedTouchpadEventConverter::makeMotionArgs( LOG_ALWAYS_FATAL_IF(coords.size() != properties.size(), "Mismatched coords and properties arrays."); return NotifyMotionArgs(mReaderContext.getNextId(), when, readTime, mDeviceId, SOURCE, - ui::ADISPLAY_ID_NONE, /*policyFlags=*/POLICY_FLAG_WAKE, action, + ui::LogicalDisplayId::INVALID, /*policyFlags=*/POLICY_FLAG_WAKE, action, /*actionButton=*/actionButton, flags, mReaderContext.getGlobalMetaState(), mButtonState, MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE, coords.size(), diff --git a/services/inputflinger/reader/mapper/CursorInputMapper.cpp b/services/inputflinger/reader/mapper/CursorInputMapper.cpp index d5fe0400b2..c67314dbcf 100644 --- a/services/inputflinger/reader/mapper/CursorInputMapper.cpp +++ b/services/inputflinger/reader/mapper/CursorInputMapper.cpp @@ -488,13 +488,13 @@ void CursorInputMapper::configureOnChangePointerSpeed(const InputReaderConfigura if (mEnableNewMousePointerBallistics) { mNewPointerVelocityControl.setAccelerationEnabled( config.displaysWithMousePointerAccelerationDisabled.count( - mDisplayId.value_or(ui::ADISPLAY_ID_NONE)) == 0); + mDisplayId.value_or(ui::LogicalDisplayId::INVALID)) == 0); mNewPointerVelocityControl.setCurve( createAccelerationCurveForPointerSensitivity(config.mousePointerSpeed)); } else { mOldPointerVelocityControl.setParameters( (config.displaysWithMousePointerAccelerationDisabled.count( - mDisplayId.value_or(ui::ADISPLAY_ID_NONE)) == 0) + mDisplayId.value_or(ui::LogicalDisplayId::INVALID)) == 0) ? config.pointerVelocityControlParameters : FLAT_VELOCITY_CONTROL_PARAMS); } @@ -506,7 +506,7 @@ void CursorInputMapper::configureOnChangePointerSpeed(const InputReaderConfigura void CursorInputMapper::configureOnChangeDisplayInfo(const InputReaderConfiguration& config) { const bool isPointer = mParameters.mode == Parameters::Mode::POINTER; - mDisplayId = ui::ADISPLAY_ID_NONE; + mDisplayId = ui::LogicalDisplayId::INVALID; std::optional<DisplayViewport> resolvedViewport; if (auto assocViewport = mDeviceContext.getAssociatedViewport(); assocViewport) { // This InputDevice is associated with a viewport. @@ -518,7 +518,8 @@ void CursorInputMapper::configureOnChangeDisplayInfo(const InputReaderConfigurat // Always use DISPLAY_ID_NONE for mouse events. // PointerChoreographer will make it target the correct the displayId later. resolvedViewport = getContext()->getPolicy()->getPointerViewportForAssociatedDisplay(); - mDisplayId = resolvedViewport ? std::make_optional(ui::ADISPLAY_ID_NONE) : std::nullopt; + mDisplayId = + resolvedViewport ? std::make_optional(ui::LogicalDisplayId::INVALID) : std::nullopt; } mOrientation = (mParameters.orientationAware && mParameters.hasAssociatedDisplay) || diff --git a/services/inputflinger/reader/mapper/CursorInputMapper.h b/services/inputflinger/reader/mapper/CursorInputMapper.h index e45105ad3a..75ca9c00a8 100644 --- a/services/inputflinger/reader/mapper/CursorInputMapper.h +++ b/services/inputflinger/reader/mapper/CursorInputMapper.h @@ -113,7 +113,7 @@ private: SimpleVelocityControl mWheelYVelocityControl; // The display that events generated by this mapper should target. This can be set to - // ADISPLAY_ID_NONE to target the focused display. If there is no display target (i.e. + // LogicalDisplayId::INVALID to target the focused display. If there is no display target (i.e. // std::nullopt), all events will be ignored. std::optional<ui::LogicalDisplayId> mDisplayId; ui::Rotation mOrientation{ui::ROTATION_0}; diff --git a/services/inputflinger/reader/mapper/JoystickInputMapper.cpp b/services/inputflinger/reader/mapper/JoystickInputMapper.cpp index 7fcff951b0..5ce4d30bb3 100644 --- a/services/inputflinger/reader/mapper/JoystickInputMapper.cpp +++ b/services/inputflinger/reader/mapper/JoystickInputMapper.cpp @@ -341,7 +341,7 @@ std::list<NotifyArgs> JoystickInputMapper::sync(nsecs_t when, nsecs_t readTime, // button will likely wake the device. // TODO: Use the input device configuration to control this behavior more finely. uint32_t policyFlags = 0; - ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE; + ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID; if (getDeviceContext().getAssociatedViewport()) { displayId = getDeviceContext().getAssociatedViewport()->displayId; } diff --git a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp index be8d183215..21245555a2 100644 --- a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp +++ b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp @@ -114,7 +114,7 @@ ui::LogicalDisplayId KeyboardInputMapper::getDisplayId() { if (mViewport) { return mViewport->displayId; } - return ui::ADISPLAY_ID_NONE; + return ui::LogicalDisplayId::INVALID; } std::optional<KeyboardLayoutInfo> KeyboardInputMapper::getKeyboardLayoutInfo() const { diff --git a/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp b/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp index a3206c2844..0ddbc06890 100644 --- a/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp +++ b/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp @@ -125,7 +125,7 @@ std::list<NotifyArgs> RotaryEncoderInputMapper::sync(nsecs_t when, nsecs_t readT if (scrolled) { int32_t metaState = getContext()->getGlobalMetaState(); // This is not a pointer, so it's not associated with a display. - ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE; + ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID; if (mOrientation == ui::ROTATION_180) { scroll = -scroll; diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp index 489bea8959..8b4b691a45 100644 --- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp +++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp @@ -2646,7 +2646,7 @@ std::list<NotifyArgs> TouchInputMapper::dispatchPointerGestures(nsecs_t when, ns PointerCoords pointerCoords; pointerCoords.clear(); out.push_back(NotifyMotionArgs(getContext()->getNextId(), when, readTime, getDeviceId(), - mSource, ui::ADISPLAY_ID_NONE, policyFlags, + mSource, ui::LogicalDisplayId::INVALID, policyFlags, AMOTION_EVENT_ACTION_HOVER_MOVE, 0, flags, metaState, buttonState, MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE, 1, &pointerProperties, @@ -3477,7 +3477,8 @@ std::list<NotifyArgs> TouchInputMapper::dispatchPointerMouse(nsecs_t when, nsecs hovering = false; } - return dispatchPointerSimple(when, readTime, policyFlags, down, hovering, ui::ADISPLAY_ID_NONE); + return dispatchPointerSimple(when, readTime, policyFlags, down, hovering, + ui::LogicalDisplayId::INVALID); } std::list<NotifyArgs> TouchInputMapper::abortPointerMouse(nsecs_t when, nsecs_t readTime, @@ -3684,7 +3685,8 @@ NotifyMotionArgs TouchInputMapper::dispatchMotion( source |= AINPUT_SOURCE_BLUETOOTH_STYLUS; } - const ui::LogicalDisplayId displayId = getAssociatedDisplayId().value_or(ui::ADISPLAY_ID_NONE); + const ui::LogicalDisplayId displayId = + getAssociatedDisplayId().value_or(ui::LogicalDisplayId::INVALID); float xCursorPosition = AMOTION_EVENT_INVALID_CURSOR_POSITION; float yCursorPosition = AMOTION_EVENT_INVALID_CURSOR_POSITION; @@ -3961,7 +3963,7 @@ bool TouchInputMapper::markSupportedKeyCodes(uint32_t sourceMask, std::optional<ui::LogicalDisplayId> TouchInputMapper::getAssociatedDisplayId() { if (mParameters.hasAssociatedDisplay) { if (mDeviceMode == DeviceMode::POINTER) { - return ui::ADISPLAY_ID_NONE; + return ui::LogicalDisplayId::INVALID; } else { return std::make_optional(mViewport.displayId); } diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.h b/services/inputflinger/reader/mapper/TouchInputMapper.h index 0c9ffa24d0..b24f2ff8da 100644 --- a/services/inputflinger/reader/mapper/TouchInputMapper.h +++ b/services/inputflinger/reader/mapper/TouchInputMapper.h @@ -705,7 +705,7 @@ private: // Values reported for the last pointer event. uint32_t source; - ui::LogicalDisplayId displayId{ui::ADISPLAY_ID_NONE}; + ui::LogicalDisplayId displayId{ui::LogicalDisplayId::INVALID}; float lastCursorX; float lastCursorY; @@ -718,7 +718,7 @@ private: hovering = false; downTime = 0; source = 0; - displayId = ui::ADISPLAY_ID_NONE; + displayId = ui::LogicalDisplayId::INVALID; lastCursorX = 0.f; lastCursorY = 0.f; } diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp index e157862f85..2a580c9e4f 100644 --- a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp +++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp @@ -322,7 +322,7 @@ std::list<NotifyArgs> TouchpadInputMapper::reconfigure(nsecs_t when, } if (!changes.any() || changes.test(InputReaderConfiguration::Change::DISPLAY_INFO)) { - mDisplayId = ui::ADISPLAY_ID_NONE; + mDisplayId = ui::LogicalDisplayId::INVALID; std::optional<DisplayViewport> resolvedViewport; std::optional<FloatRect> boundsInLogicalDisplay; if (auto assocViewport = mDeviceContext.getAssociatedViewport(); assocViewport) { @@ -335,7 +335,8 @@ std::list<NotifyArgs> TouchpadInputMapper::reconfigure(nsecs_t when, // Always use DISPLAY_ID_NONE for touchpad events. // PointerChoreographer will make it target the correct the displayId later. resolvedViewport = getContext()->getPolicy()->getPointerViewportForAssociatedDisplay(); - mDisplayId = resolvedViewport ? std::make_optional(ui::ADISPLAY_ID_NONE) : std::nullopt; + mDisplayId = resolvedViewport ? std::make_optional(ui::LogicalDisplayId::INVALID) + : std::nullopt; } mGestureConverter.setDisplayId(mDisplayId); diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.h b/services/inputflinger/reader/mapper/TouchpadInputMapper.h index f27895fd9c..546fa5bb9c 100644 --- a/services/inputflinger/reader/mapper/TouchpadInputMapper.h +++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.h @@ -107,7 +107,7 @@ private: std::set<int32_t> mPalmTrackingIds; // The display that events generated by this mapper should target. This can be set to - // ADISPLAY_ID_NONE to target the focused display. If there is no display target (i.e. + // LogicalDisplayId::INVALID to target the focused display. If there is no display target (i.e. // std::nullopt), all events will be ignored. std::optional<ui::LogicalDisplayId> mDisplayId; diff --git a/services/inputflinger/tests/CursorInputMapper_test.cpp b/services/inputflinger/tests/CursorInputMapper_test.cpp index 72b5573047..83074ff899 100644 --- a/services/inputflinger/tests/CursorInputMapper_test.cpp +++ b/services/inputflinger/tests/CursorInputMapper_test.cpp @@ -50,7 +50,7 @@ constexpr auto BUTTON_PRESS = AMOTION_EVENT_ACTION_BUTTON_PRESS; constexpr auto BUTTON_RELEASE = AMOTION_EVENT_ACTION_BUTTON_RELEASE; constexpr auto HOVER_MOVE = AMOTION_EVENT_ACTION_HOVER_MOVE; constexpr auto INVALID_CURSOR_POSITION = AMOTION_EVENT_INVALID_CURSOR_POSITION; -constexpr ui::LogicalDisplayId DISPLAY_ID = ui::ADISPLAY_ID_DEFAULT; +constexpr ui::LogicalDisplayId DISPLAY_ID = ui::LogicalDisplayId::DEFAULT; constexpr ui::LogicalDisplayId SECONDARY_DISPLAY_ID = ui::LogicalDisplayId{DISPLAY_ID.val() + 1}; constexpr int32_t DISPLAY_WIDTH = 480; constexpr int32_t DISPLAY_HEIGHT = 800; @@ -909,7 +909,8 @@ TEST_F(CursorInputMapperUnitTest, ConfigureDisplayIdNoAssociatedViewport) { EXPECT_THAT(args, ElementsAre(VariantWith<NotifyMotionArgs>( AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE), - WithSource(AINPUT_SOURCE_MOUSE), WithDisplayId(ui::ADISPLAY_ID_NONE), + WithSource(AINPUT_SOURCE_MOUSE), + WithDisplayId(ui::LogicalDisplayId::INVALID), WithCoords(0.0f, 0.0f))))); } diff --git a/services/inputflinger/tests/FakePointerController.cpp b/services/inputflinger/tests/FakePointerController.cpp index 731a28668f..2bb57b3e81 100644 --- a/services/inputflinger/tests/FakePointerController.cpp +++ b/services/inputflinger/tests/FakePointerController.cpp @@ -53,7 +53,7 @@ FloatPoint FakePointerController::getPosition() const { ui::LogicalDisplayId FakePointerController::getDisplayId() const { if (!mEnabled || !mDisplayId) { - return ui::ADISPLAY_ID_NONE; + return ui::LogicalDisplayId::INVALID; } return *mDisplayId; } diff --git a/services/inputflinger/tests/FakeWindows.cpp b/services/inputflinger/tests/FakeWindows.cpp index c800d6ad4e..b116521155 100644 --- a/services/inputflinger/tests/FakeWindows.cpp +++ b/services/inputflinger/tests/FakeWindows.cpp @@ -152,7 +152,7 @@ void FakeInputReceiver::consumeFocusEvent(bool hasFocus, bool inTouchMode) { ASSERT_NE(nullptr, event) << mName.c_str() << ": consumer should have returned non-NULL event."; ASSERT_EQ(InputEventType::FOCUS, event->getType()) << "Instead of FocusEvent, got " << *event; - ASSERT_EQ(ui::ADISPLAY_ID_NONE, event->getDisplayId()) + ASSERT_EQ(ui::LogicalDisplayId::INVALID, event->getDisplayId()) << mName.c_str() << ": event displayId should always be NONE."; FocusEvent& focusEvent = static_cast<FocusEvent&>(*event); @@ -165,7 +165,7 @@ void FakeInputReceiver::consumeCaptureEvent(bool hasCapture) { ASSERT_EQ(InputEventType::CAPTURE, event->getType()) << "Instead of CaptureEvent, got " << *event; - ASSERT_EQ(ui::ADISPLAY_ID_NONE, event->getDisplayId()) + ASSERT_EQ(ui::LogicalDisplayId::INVALID, event->getDisplayId()) << mName.c_str() << ": event displayId should always be NONE."; const auto& captureEvent = static_cast<const CaptureEvent&>(*event); @@ -177,7 +177,7 @@ void FakeInputReceiver::consumeDragEvent(bool isExiting, float x, float y) { ASSERT_NE(nullptr, event) << mName.c_str() << ": consumer should have returned non-NULL event."; ASSERT_EQ(InputEventType::DRAG, event->getType()) << "Instead of DragEvent, got " << *event; - EXPECT_EQ(ui::ADISPLAY_ID_NONE, event->getDisplayId()) + EXPECT_EQ(ui::LogicalDisplayId::INVALID, event->getDisplayId()) << mName.c_str() << ": event displayId should always be NONE."; const auto& dragEvent = static_cast<const DragEvent&>(*event); @@ -192,7 +192,7 @@ void FakeInputReceiver::consumeTouchModeEvent(bool inTouchMode) { ASSERT_EQ(InputEventType::TOUCH_MODE, event->getType()) << "Instead of TouchModeEvent, got " << *event; - ASSERT_EQ(ui::ADISPLAY_ID_NONE, event->getDisplayId()) + ASSERT_EQ(ui::LogicalDisplayId::INVALID, event->getDisplayId()) << mName.c_str() << ": event displayId should always be NONE."; const auto& touchModeEvent = static_cast<const TouchModeEvent&>(*event); EXPECT_EQ(inTouchMode, touchModeEvent.isInTouchMode()); diff --git a/services/inputflinger/tests/FakeWindows.h b/services/inputflinger/tests/FakeWindows.h index 8a40337db4..36a8f0066e 100644 --- a/services/inputflinger/tests/FakeWindows.h +++ b/services/inputflinger/tests/FakeWindows.h @@ -261,22 +261,24 @@ public: } inline void consumeMotionCancel( - ui::LogicalDisplayId expectedDisplayId = ui::ADISPLAY_ID_DEFAULT, + ui::LogicalDisplayId expectedDisplayId = ui::LogicalDisplayId::DEFAULT, int32_t expectedFlags = 0) { consumeMotionEvent(testing::AllOf(WithMotionAction(AMOTION_EVENT_ACTION_CANCEL), WithDisplayId(expectedDisplayId), WithFlags(expectedFlags | AMOTION_EVENT_FLAG_CANCELED))); } - inline void consumeMotionMove(ui::LogicalDisplayId expectedDisplayId = ui::ADISPLAY_ID_DEFAULT, - int32_t expectedFlags = 0) { + inline void consumeMotionMove( + ui::LogicalDisplayId expectedDisplayId = ui::LogicalDisplayId::DEFAULT, + int32_t expectedFlags = 0) { consumeMotionEvent(testing::AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), WithDisplayId(expectedDisplayId), WithFlags(expectedFlags))); } - inline void consumeMotionDown(ui::LogicalDisplayId expectedDisplayId = ui::ADISPLAY_ID_DEFAULT, - int32_t expectedFlags = 0) { + inline void consumeMotionDown( + ui::LogicalDisplayId expectedDisplayId = ui::LogicalDisplayId::DEFAULT, + int32_t expectedFlags = 0) { consumeAnyMotionDown(expectedDisplayId, expectedFlags); } @@ -292,7 +294,8 @@ public: } inline void consumeMotionPointerDown( - int32_t pointerIdx, ui::LogicalDisplayId expectedDisplayId = ui::ADISPLAY_ID_DEFAULT, + int32_t pointerIdx, + ui::LogicalDisplayId expectedDisplayId = ui::LogicalDisplayId::DEFAULT, int32_t expectedFlags = 0) { const int32_t action = AMOTION_EVENT_ACTION_POINTER_DOWN | (pointerIdx << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT); @@ -302,7 +305,8 @@ public: } inline void consumeMotionPointerUp( - int32_t pointerIdx, ui::LogicalDisplayId expectedDisplayId = ui::ADISPLAY_ID_DEFAULT, + int32_t pointerIdx, + ui::LogicalDisplayId expectedDisplayId = ui::LogicalDisplayId::DEFAULT, int32_t expectedFlags = 0) { const int32_t action = AMOTION_EVENT_ACTION_POINTER_UP | (pointerIdx << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT); @@ -311,15 +315,16 @@ public: WithFlags(expectedFlags))); } - inline void consumeMotionUp(ui::LogicalDisplayId expectedDisplayId = ui::ADISPLAY_ID_DEFAULT, - int32_t expectedFlags = 0) { + inline void consumeMotionUp( + ui::LogicalDisplayId expectedDisplayId = ui::LogicalDisplayId::DEFAULT, + int32_t expectedFlags = 0) { consumeMotionEvent(testing::AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), WithDisplayId(expectedDisplayId), WithFlags(expectedFlags))); } inline void consumeMotionOutside( - ui::LogicalDisplayId expectedDisplayId = ui::ADISPLAY_ID_DEFAULT, + ui::LogicalDisplayId expectedDisplayId = ui::LogicalDisplayId::DEFAULT, int32_t expectedFlags = 0) { consumeMotionEvent(testing::AllOf(WithMotionAction(AMOTION_EVENT_ACTION_OUTSIDE), WithDisplayId(expectedDisplayId), diff --git a/services/inputflinger/tests/GestureConverter_test.cpp b/services/inputflinger/tests/GestureConverter_test.cpp index 1132e9284c..2f9036f2b4 100644 --- a/services/inputflinger/tests/GestureConverter_test.cpp +++ b/services/inputflinger/tests/GestureConverter_test.cpp @@ -45,7 +45,6 @@ const auto TOUCHPAD_PALM_REJECTION_V2 = } // namespace -using android::ui::ADISPLAY_ID_DEFAULT; using testing::AllOf; using testing::Each; using testing::ElementsAre; @@ -93,7 +92,7 @@ protected: TEST_F(GestureConverterTest, Move) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10); std::list<NotifyArgs> args = @@ -107,9 +106,9 @@ TEST_F(GestureConverterTest, Move) { WithRelativeMotion(-5, 10), WithButtonState(0), WithPressure(0.0f))))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0), - WithToolType(ToolType::FINGER), - WithDisplayId(ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithCoords(0, 0), WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); // The same gesture again should only repeat the HOVER_MOVE, not the HOVER_ENTER. args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture); @@ -118,14 +117,14 @@ TEST_F(GestureConverterTest, Move) { AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE), WithCoords(0, 0), WithRelativeMotion(-5, 10), WithToolType(ToolType::FINGER), WithButtonState(0), WithPressure(0.0f), - WithDisplayId(ADISPLAY_ID_DEFAULT))))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); } TEST_F(GestureConverterTest, Move_Rotated) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); converter.setOrientation(ui::ROTATION_90); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10); std::list<NotifyArgs> args = @@ -139,15 +138,15 @@ TEST_F(GestureConverterTest, Move_Rotated) { WithRelativeMotion(10, 5), WithButtonState(0), WithPressure(0.0f))))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0), - WithToolType(ToolType::FINGER), - WithDisplayId(ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithCoords(0, 0), WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); } TEST_F(GestureConverterTest, ButtonsChange) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); // Press left and right buttons at once Gesture downGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, @@ -170,9 +169,9 @@ TEST_F(GestureConverterTest, ButtonsChange) { WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY | AMOTION_EVENT_BUTTON_SECONDARY))))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0), - WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithCoords(0, 0), WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); // Then release the left button Gesture leftUpGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, @@ -185,7 +184,7 @@ TEST_F(GestureConverterTest, ButtonsChange) { WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY), WithButtonState(AMOTION_EVENT_BUTTON_SECONDARY), WithCoords(0, 0), WithToolType(ToolType::FINGER), - WithDisplayId(ADISPLAY_ID_DEFAULT))))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); // Finally release the right button Gesture rightUpGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, @@ -201,15 +200,15 @@ TEST_F(GestureConverterTest, ButtonsChange) { VariantWith<NotifyMotionArgs>( WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER)))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithButtonState(0), WithCoords(0, 0), - WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithButtonState(0), WithCoords(0, 0), WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); } TEST_F(GestureConverterTest, ButtonDownAfterMoveExitsHover) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10); std::list<NotifyArgs> args = @@ -223,13 +222,13 @@ TEST_F(GestureConverterTest, ButtonDownAfterMoveExitsHover) { VariantWith<NotifyMotionArgs>( AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT), WithButtonState(0), WithCoords(0, 0), WithToolType(ToolType::FINGER), - WithDisplayId(ADISPLAY_ID_DEFAULT)))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT)))); } TEST_F(GestureConverterTest, DragWithButton) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); // Press the button Gesture downGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, @@ -246,9 +245,9 @@ TEST_F(GestureConverterTest, DragWithButton) { WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY), WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY))))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0), - WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithCoords(0, 0), WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); // Move Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10); @@ -258,7 +257,7 @@ TEST_F(GestureConverterTest, DragWithButton) { AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), WithCoords(0, 0), WithRelativeMotion(-5, 10), WithToolType(ToolType::FINGER), WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY), WithPressure(1.0f), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); // Release the button Gesture upGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, @@ -274,16 +273,16 @@ TEST_F(GestureConverterTest, DragWithButton) { VariantWith<NotifyMotionArgs>( WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER)))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithButtonState(0), WithCoords(0, 0), - WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithButtonState(0), WithCoords(0, 0), WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); } TEST_F(GestureConverterTest, Scroll) { const nsecs_t downTime = 12345; InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10); std::list<NotifyArgs> args = @@ -303,7 +302,7 @@ TEST_F(GestureConverterTest, Scroll) { AllOf(WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE), WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5); args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture); @@ -314,7 +313,7 @@ TEST_F(GestureConverterTest, Scroll) { WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), WithToolType(ToolType::FINGER), WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1, GESTURES_FLING_START); @@ -332,8 +331,9 @@ TEST_F(GestureConverterTest, Scroll) { WithCoords(0, 0), WithMotionClassification(MotionClassification::NONE))))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); } TEST_F(GestureConverterTest, Scroll_Rotated) { @@ -341,7 +341,7 @@ TEST_F(GestureConverterTest, Scroll_Rotated) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); converter.setOrientation(ui::ROTATION_90); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10); std::list<NotifyArgs> args = @@ -360,7 +360,7 @@ TEST_F(GestureConverterTest, Scroll_Rotated) { Each(VariantWith<NotifyMotionArgs>( AllOf(WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5); args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture); @@ -370,7 +370,7 @@ TEST_F(GestureConverterTest, Scroll_Rotated) { WithGestureScrollDistance(0, 5, EPSILON), WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), WithToolType(ToolType::FINGER), - WithDisplayId(ADISPLAY_ID_DEFAULT))))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1, GESTURES_FLING_START); @@ -387,14 +387,15 @@ TEST_F(GestureConverterTest, Scroll_Rotated) { WithCoords(0, 0), WithMotionClassification(MotionClassification::NONE))))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); } TEST_F(GestureConverterTest, Scroll_ClearsClassificationAfterGesture) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10); std::list<NotifyArgs> args = @@ -412,13 +413,13 @@ TEST_F(GestureConverterTest, Scroll_ClearsClassificationAfterGesture) { ASSERT_THAT(args, ElementsAre(VariantWith<NotifyMotionArgs>( AllOf(WithMotionClassification(MotionClassification::NONE), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); } TEST_F(GestureConverterTest, Scroll_ClearsScrollDistanceAfterGesture) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10); std::list<NotifyArgs> args = @@ -443,7 +444,7 @@ TEST_F(GestureConverterTest, Scroll_ClearsScrollDistanceAfterGesture) { TEST_F(GestureConverterTest, ThreeFingerSwipe_ClearsClassificationAfterGesture) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dx=*/0, /*dy=*/0); @@ -464,7 +465,7 @@ TEST_F(GestureConverterTest, ThreeFingerSwipe_ClearsClassificationAfterGesture) TEST_F(GestureConverterTest, ThreeFingerSwipe_ClearsGestureAxesAfterGesture) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dx=*/5, /*dy=*/5); @@ -491,7 +492,7 @@ TEST_F(GestureConverterTest, ThreeFingerSwipe_Vertical) { // only checks movement in one dimension. InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dx= */ 0, /* dy= */ 10); @@ -502,7 +503,7 @@ TEST_F(GestureConverterTest, ThreeFingerSwipe_Vertical) { Each(VariantWith<NotifyMotionArgs>( AllOf(WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE), WithGestureSwipeFingerCount(3), WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); // Three fake fingers should be created. We don't actually care where they are, so long as they // move appropriately. @@ -548,7 +549,7 @@ TEST_F(GestureConverterTest, ThreeFingerSwipe_Vertical) { WithGestureOffset(0, -0.005, EPSILON), WithGestureSwipeFingerCount(3), WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE), WithPointerCount(3u), WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))); EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX()); EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX()); EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX()); @@ -589,22 +590,24 @@ TEST_F(GestureConverterTest, ThreeFingerSwipe_Vertical) { WithCoords(0, 0), WithMotionClassification(MotionClassification::NONE))))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); } TEST_F(GestureConverterTest, ThreeFingerSwipe_Rotated) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); converter.setOrientation(ui::ROTATION_90); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dx= */ 0, /* dy= */ 10); std::list<NotifyArgs> args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture); ASSERT_EQ(4u, args.size()); - ASSERT_THAT(args, Each(VariantWith<NotifyMotionArgs>(WithDisplayId(ui::ADISPLAY_ID_DEFAULT)))); + ASSERT_THAT(args, + Each(VariantWith<NotifyMotionArgs>(WithDisplayId(ui::LogicalDisplayId::DEFAULT)))); // Three fake fingers should be created. We don't actually care where they are, so long as they // move appropriately. @@ -648,7 +651,7 @@ TEST_F(GestureConverterTest, ThreeFingerSwipe_Rotated) { ASSERT_THAT(arg, AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), WithGestureOffset(0, -0.005, EPSILON), WithPointerCount(3u), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))); EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX() - 15); EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX() - 15); EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX() - 15); @@ -674,13 +677,14 @@ TEST_F(GestureConverterTest, ThreeFingerSwipe_Rotated) { WithGestureOffset(0, 0, EPSILON), WithPointerCount(1u))), VariantWith<NotifyMotionArgs>( AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER))))); - ASSERT_THAT(args, Each(VariantWith<NotifyMotionArgs>(WithDisplayId(ADISPLAY_ID_DEFAULT)))); + ASSERT_THAT(args, + Each(VariantWith<NotifyMotionArgs>(WithDisplayId(ui::LogicalDisplayId::DEFAULT)))); } TEST_F(GestureConverterTest, FourFingerSwipe_Horizontal) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture startGesture(kGestureFourFingerSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dx= */ 10, /* dy= */ 0); @@ -691,7 +695,7 @@ TEST_F(GestureConverterTest, FourFingerSwipe_Horizontal) { Each(VariantWith<NotifyMotionArgs>( AllOf(WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE), WithGestureSwipeFingerCount(4), WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); // Four fake fingers should be created. We don't actually care where they are, so long as they // move appropriately. @@ -746,7 +750,7 @@ TEST_F(GestureConverterTest, FourFingerSwipe_Horizontal) { WithGestureOffset(0.005, 0, EPSILON), WithGestureSwipeFingerCount(4), WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE), WithPointerCount(4u), WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))); EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX() + 15); EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX() + 15); EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX() + 15); @@ -798,14 +802,15 @@ TEST_F(GestureConverterTest, FourFingerSwipe_Horizontal) { WithCoords(0, 0), WithMotionClassification(MotionClassification::NONE))))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); } TEST_F(GestureConverterTest, Pinch_Inwards) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1, GESTURES_ZOOM_START); @@ -825,7 +830,7 @@ TEST_F(GestureConverterTest, Pinch_Inwards) { AllOf(WithMotionClassification(MotionClassification::PINCH), WithGesturePinchScaleFactor(1.0f, EPSILON), WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); Gesture updateGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 0.8, GESTURES_ZOOM_UPDATE); @@ -837,7 +842,7 @@ TEST_F(GestureConverterTest, Pinch_Inwards) { WithGesturePinchScaleFactor(0.8f, EPSILON), WithPointerCoords(0, -80, 0), WithPointerCoords(1, 80, 0), WithPointerCount(2u), WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); Gesture endGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1, GESTURES_ZOOM_END); @@ -860,14 +865,15 @@ TEST_F(GestureConverterTest, Pinch_Inwards) { WithCoords(0, 0), WithMotionClassification(MotionClassification::NONE))))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER), - WithDisplayId(ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); } TEST_F(GestureConverterTest, Pinch_Outwards) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1, GESTURES_ZOOM_START); @@ -887,7 +893,7 @@ TEST_F(GestureConverterTest, Pinch_Outwards) { AllOf(WithMotionClassification(MotionClassification::PINCH), WithGesturePinchScaleFactor(1.0f, EPSILON), WithToolType(ToolType::FINGER), - WithDisplayId(ADISPLAY_ID_DEFAULT))))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); Gesture updateGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1.1, GESTURES_ZOOM_UPDATE); @@ -899,7 +905,7 @@ TEST_F(GestureConverterTest, Pinch_Outwards) { WithGesturePinchScaleFactor(1.1f, EPSILON), WithPointerCoords(0, -110, 0), WithPointerCoords(1, 110, 0), WithPointerCount(2u), WithToolType(ToolType::FINGER), - WithDisplayId(ADISPLAY_ID_DEFAULT))))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); Gesture endGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1, GESTURES_ZOOM_END); @@ -922,14 +928,15 @@ TEST_F(GestureConverterTest, Pinch_Outwards) { WithCoords(0, 0), WithMotionClassification(MotionClassification::NONE))))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); } TEST_F(GestureConverterTest, Pinch_ClearsClassificationAfterGesture) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1, GESTURES_ZOOM_START); @@ -954,7 +961,7 @@ TEST_F(GestureConverterTest, Pinch_ClearsClassificationAfterGesture) { TEST_F(GestureConverterTest, Pinch_ClearsScaleFactorAfterGesture) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1, GESTURES_ZOOM_START); @@ -981,7 +988,7 @@ TEST_F(GestureConverterTest, Pinch_ClearsScaleFactorAfterGesture) { TEST_F(GestureConverterTest, ResetWithButtonPressed) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture downGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*down=*/GESTURES_BUTTON_LEFT | GESTURES_BUTTON_RIGHT, @@ -1005,15 +1012,15 @@ TEST_F(GestureConverterTest, ResetWithButtonPressed) { AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), WithButtonState(0))))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0), - WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithCoords(0, 0), WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); } TEST_F(GestureConverterTest, ResetDuringScroll) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10); (void)converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture); @@ -1032,14 +1039,15 @@ TEST_F(GestureConverterTest, ResetDuringScroll) { WithCoords(0, 0), WithMotionClassification(MotionClassification::NONE))))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); } TEST_F(GestureConverterTest, ResetDuringThreeFingerSwipe) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dx=*/0, /*dy=*/10); @@ -1073,14 +1081,15 @@ TEST_F(GestureConverterTest, ResetDuringThreeFingerSwipe) { AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), WithMotionClassification(MotionClassification::NONE))))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); } TEST_F(GestureConverterTest, ResetDuringPinch) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1, GESTURES_ZOOM_START); @@ -1105,14 +1114,15 @@ TEST_F(GestureConverterTest, ResetDuringPinch) { WithCoords(0, 0), WithMotionClassification(MotionClassification::NONE))))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); } TEST_F(GestureConverterTest, FlingTapDown) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture tapDownGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*vx=*/0.f, /*vy=*/0.f, GESTURES_FLING_TAP_DOWN); @@ -1122,14 +1132,15 @@ TEST_F(GestureConverterTest, FlingTapDown) { ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()), AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), WithCoords(0, 0), WithRelativeMotion(0.f, 0.f), WithToolType(ToolType::FINGER), - WithButtonState(0), WithPressure(0.0f), WithDisplayId(ADISPLAY_ID_DEFAULT))); + WithButtonState(0), WithPressure(0.0f), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))); } TEST_F(GestureConverterTest, FlingTapDownAfterScrollStopsFling) { InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); input_flags::enable_touchpad_fling_stop(true); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture scrollGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10); std::list<NotifyArgs> args = @@ -1153,7 +1164,7 @@ TEST_F(GestureConverterTest, FlingTapDownAfterScrollStopsFling) { ASSERT_THAT(args, Each(VariantWith<NotifyMotionArgs>( AllOf(WithCoords(0, 0), WithToolType(ToolType::FINGER), - WithDisplayId(ADISPLAY_ID_DEFAULT), + WithDisplayId(ui::LogicalDisplayId::DEFAULT), WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE))))); } @@ -1161,7 +1172,7 @@ TEST_F(GestureConverterTest, Tap) { // Tap should produce button press/release events InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* vx= */ 0, /* vy= */ 0, GESTURES_FLING_TAP_DOWN); @@ -1198,17 +1209,17 @@ TEST_F(GestureConverterTest, Tap) { AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), WithButtonState(0), WithPressure(0.0f))))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0), - WithRelativeMotion(0.f, 0.f), - WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithCoords(0, 0), WithRelativeMotion(0.f, 0.f), + WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); } TEST_F(GestureConverterTest, Click) { // Click should produce button press/release events InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* vx= */ 0, /* vy= */ 0, GESTURES_FLING_TAP_DOWN); @@ -1235,10 +1246,10 @@ TEST_F(GestureConverterTest, Click) { WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY), WithPressure(1.0f))))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0), - WithRelativeMotion(0.f, 0.f), - WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithCoords(0, 0), WithRelativeMotion(0.f, 0.f), + WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); Gesture buttonUpGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* down= */ GESTURES_BUTTON_NONE, @@ -1257,10 +1268,10 @@ TEST_F(GestureConverterTest, Click) { AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), WithPressure(0.0f))))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithButtonState(0), WithCoords(0, 0), - WithRelativeMotion(0.f, 0.f), - WithToolType(ToolType::FINGER), - WithDisplayId(ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithButtonState(0), WithCoords(0, 0), WithRelativeMotion(0.f, 0.f), + WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); } TEST_F_WITH_FLAGS(GestureConverterTest, TapWithTapToClickDisabled, @@ -1273,7 +1284,7 @@ TEST_F_WITH_FLAGS(GestureConverterTest, TapWithTapToClickDisabled, InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture flingGesture(kGestureFling, currentTime, currentTime, /* vx= */ 0, /* vy= */ 0, GESTURES_FLING_TAP_DOWN); @@ -1302,7 +1313,7 @@ TEST_F_WITH_FLAGS(GestureConverterTest, TapWithTapToClickDisabledWithDelay, InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture flingGesture(kGestureFling, currentTime, currentTime, /* vx= */ 0, /* vy= */ 0, GESTURES_FLING_TAP_DOWN); @@ -1384,7 +1395,7 @@ TEST_F_WITH_FLAGS(GestureConverterTest, ClickWithTapToClickDisabled, InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* vx= */ 0, /* vy= */ 0, GESTURES_FLING_TAP_DOWN); @@ -1411,10 +1422,10 @@ TEST_F_WITH_FLAGS(GestureConverterTest, ClickWithTapToClickDisabled, WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY), WithPressure(1.0f))))); ASSERT_THAT(args, - Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0), - WithRelativeMotion(0.f, 0.f), - WithToolType(ToolType::FINGER), - WithDisplayId(ui::ADISPLAY_ID_DEFAULT))))); + Each(VariantWith<NotifyMotionArgs>( + AllOf(WithCoords(0, 0), WithRelativeMotion(0.f, 0.f), + WithToolType(ToolType::FINGER), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); Gesture buttonUpGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* down= */ GESTURES_BUTTON_NONE, @@ -1428,18 +1439,20 @@ TEST_F_WITH_FLAGS(GestureConverterTest, ClickWithTapToClickDisabled, WithButtonState(0), WithCoords(0, 0), WithRelativeMotion(0.f, 0.f), WithToolType(ToolType::FINGER), WithButtonState(0), - WithPressure(1.0f), WithDisplayId(ADISPLAY_ID_DEFAULT))), + WithPressure(1.0f), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))), VariantWith<NotifyMotionArgs>( AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), WithCoords(0, 0), WithRelativeMotion(0.f, 0.f), WithToolType(ToolType::FINGER), WithButtonState(0), - WithPressure(0.0f), WithDisplayId(ADISPLAY_ID_DEFAULT))), + WithPressure(0.0f), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))), VariantWith<NotifyMotionArgs>( AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), WithCoords(0, 0), WithRelativeMotion(0, 0), WithToolType(ToolType::FINGER), WithButtonState(0), WithPressure(0.0f), - WithDisplayId(ADISPLAY_ID_DEFAULT))))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))))); // Future taps should be re-enabled ASSERT_FALSE(mReader->getContext()->isPreventingTouchpadTaps()); @@ -1452,7 +1465,7 @@ TEST_F_WITH_FLAGS(GestureConverterTest, MoveEnablesTapToClick, InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10); std::list<NotifyArgs> args = @@ -1468,7 +1481,7 @@ TEST_F_WITH_FLAGS(GestureConverterTest, KeypressCancelsHoverMove, const nsecs_t gestureStartTime = 1000; InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID); GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID); - converter.setDisplayId(ui::ADISPLAY_ID_DEFAULT); + converter.setDisplayId(ui::LogicalDisplayId::DEFAULT); // Start a move gesture at gestureStartTime Gesture moveGesture(kGestureMove, gestureStartTime, gestureStartTime, -5, 10); diff --git a/services/inputflinger/tests/InputDeviceMetricsCollector_test.cpp b/services/inputflinger/tests/InputDeviceMetricsCollector_test.cpp index 029414b23d..28699b8518 100644 --- a/services/inputflinger/tests/InputDeviceMetricsCollector_test.cpp +++ b/services/inputflinger/tests/InputDeviceMetricsCollector_test.cpp @@ -63,7 +63,7 @@ InputDeviceInfo generateTestDeviceInfo(int32_t id = DEVICE_ID, uint32_t sources = TOUCHSCREEN | STYLUS) { auto info = InputDeviceInfo(); info.initialize(id, /*generation=*/1, /*controllerNumber=*/1, generateTestIdentifier(id), - "alias", /*isExternal=*/false, /*hasMic=*/false, ui::ADISPLAY_ID_NONE); + "alias", /*isExternal=*/false, /*hasMic=*/false, ui::LogicalDisplayId::INVALID); info.addSource(sources); return info; } diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp index 184659df0d..8ad235f3a3 100644 --- a/services/inputflinger/tests/InputDispatcher_test.cpp +++ b/services/inputflinger/tests/InputDispatcher_test.cpp @@ -53,7 +53,6 @@ using android::gui::WindowInfo; using android::gui::WindowInfoHandle; using android::os::InputEventInjectionResult; using android::os::InputEventInjectionSync; -using android::ui::ADISPLAY_ID_DEFAULT; namespace android::inputdispatcher { @@ -73,7 +72,7 @@ static constexpr int32_t DEVICE_ID = DEFAULT_DEVICE_ID; static constexpr int32_t SECOND_DEVICE_ID = 2; // An arbitrary display id. -constexpr ui::LogicalDisplayId DISPLAY_ID = ADISPLAY_ID_DEFAULT; +constexpr ui::LogicalDisplayId DISPLAY_ID = ui::LogicalDisplayId::DEFAULT; constexpr ui::LogicalDisplayId SECOND_DISPLAY_ID = ui::LogicalDisplayId{1}; // Ensure common actions are interchangeable between keys and motions for convenience. @@ -129,9 +128,9 @@ using ReservedInputDeviceId::VIRTUAL_KEYBOARD_ID; static KeyEvent getTestKeyEvent() { KeyEvent event; - event.initialize(InputEvent::nextId(), DEVICE_ID, AINPUT_SOURCE_KEYBOARD, ui::ADISPLAY_ID_NONE, - INVALID_HMAC, AKEY_EVENT_ACTION_DOWN, 0, AKEYCODE_A, KEY_A, AMETA_NONE, 0, - ARBITRARY_TIME, ARBITRARY_TIME); + event.initialize(InputEvent::nextId(), DEVICE_ID, AINPUT_SOURCE_KEYBOARD, + ui::LogicalDisplayId::INVALID, INVALID_HMAC, AKEY_EVENT_ACTION_DOWN, 0, + AKEYCODE_A, KEY_A, AMETA_NONE, 0, ARBITRARY_TIME, ARBITRARY_TIME); return event; } @@ -253,8 +252,8 @@ TEST_F(InputDispatcherTest, InjectInputEvent_ValidatesKeyEvents) { KeyEvent event; // Rejects undefined key actions. - event.initialize(InputEvent::nextId(), DEVICE_ID, AINPUT_SOURCE_KEYBOARD, ui::ADISPLAY_ID_NONE, - INVALID_HMAC, + event.initialize(InputEvent::nextId(), DEVICE_ID, AINPUT_SOURCE_KEYBOARD, + ui::LogicalDisplayId::INVALID, INVALID_HMAC, /*action=*/-1, 0, AKEYCODE_A, KEY_A, AMETA_NONE, 0, ARBITRARY_TIME, ARBITRARY_TIME); ASSERT_EQ(InputEventInjectionResult::FAILED, @@ -263,9 +262,9 @@ TEST_F(InputDispatcherTest, InjectInputEvent_ValidatesKeyEvents) { << "Should reject key events with undefined action."; // Rejects ACTION_MULTIPLE since it is not supported despite being defined in the API. - event.initialize(InputEvent::nextId(), DEVICE_ID, AINPUT_SOURCE_KEYBOARD, ui::ADISPLAY_ID_NONE, - INVALID_HMAC, AKEY_EVENT_ACTION_MULTIPLE, 0, AKEYCODE_A, KEY_A, AMETA_NONE, 0, - ARBITRARY_TIME, ARBITRARY_TIME); + event.initialize(InputEvent::nextId(), DEVICE_ID, AINPUT_SOURCE_KEYBOARD, + ui::LogicalDisplayId::INVALID, INVALID_HMAC, AKEY_EVENT_ACTION_MULTIPLE, 0, + AKEYCODE_A, KEY_A, AMETA_NONE, 0, ARBITRARY_TIME, ARBITRARY_TIME); ASSERT_EQ(InputEventInjectionResult::FAILED, mDispatcher->injectInputEvent(&event, /*targetUid=*/{}, InputEventInjectionSync::NONE, 0ms, 0)) @@ -482,7 +481,7 @@ public: void consumeMotionPointerDown(int32_t pointerIdx) { int32_t action = AMOTION_EVENT_ACTION_POINTER_DOWN | (pointerIdx << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT); - mInputReceiver.consumeEvent(InputEventType::MOTION, action, ADISPLAY_ID_DEFAULT, + mInputReceiver.consumeEvent(InputEventType::MOTION, action, ui::LogicalDisplayId::DEFAULT, /*expectedFlags=*/0); } @@ -500,7 +499,7 @@ private: static InputEventInjectionResult injectKey( InputDispatcher& dispatcher, int32_t action, int32_t repeatCount, - ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE, + ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID, InputEventInjectionSync syncMode = InputEventInjectionSync::WAIT_FOR_RESULT, std::chrono::milliseconds injectionTimeout = INJECT_EVENT_TIMEOUT, bool allowKeyRepeat = true, std::optional<gui::Uid> targetUid = {}, @@ -522,15 +521,17 @@ static InputEventInjectionResult injectKey( static void assertInjectedKeyTimesOut(InputDispatcher& dispatcher) { InputEventInjectionResult result = - injectKey(dispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, ui::ADISPLAY_ID_NONE, - InputEventInjectionSync::WAIT_FOR_RESULT, CONSUME_TIMEOUT_NO_EVENT_EXPECTED); + injectKey(dispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, + ui::LogicalDisplayId::INVALID, InputEventInjectionSync::WAIT_FOR_RESULT, + CONSUME_TIMEOUT_NO_EVENT_EXPECTED); if (result != InputEventInjectionResult::TIMED_OUT) { FAIL() << "Injection should have timed out, but got " << ftl::enum_string(result); } } static InputEventInjectionResult injectKeyDown( - InputDispatcher& dispatcher, ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE) { + InputDispatcher& dispatcher, + ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID) { return injectKey(dispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, displayId); } @@ -538,14 +539,16 @@ static InputEventInjectionResult injectKeyDown( // sending a subsequent key up. When key repeat is enabled, the dispatcher cannot idle because it // has to be woken up to process the repeating key. static InputEventInjectionResult injectKeyDownNoRepeat( - InputDispatcher& dispatcher, ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE) { + InputDispatcher& dispatcher, + ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID) { return injectKey(dispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, displayId, InputEventInjectionSync::WAIT_FOR_RESULT, INJECT_EVENT_TIMEOUT, /*allowKeyRepeat=*/false); } static InputEventInjectionResult injectKeyUp( - InputDispatcher& dispatcher, ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE) { + InputDispatcher& dispatcher, + ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID) { return injectKey(dispatcher, AKEY_EVENT_ACTION_UP, /*repeatCount=*/0, displayId); } @@ -596,8 +599,8 @@ static InputEventInjectionResult injectMotionUp(InputDispatcher& dispatcher, int return injectMotionEvent(dispatcher, AMOTION_EVENT_ACTION_UP, source, displayId, location); } -static NotifyKeyArgs generateKeyArgs(int32_t action, - ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE) { +static NotifyKeyArgs generateKeyArgs( + int32_t action, ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID) { nsecs_t currentTime = systemTime(SYSTEM_TIME_MONOTONIC); // Define a valid key event. NotifyKeyArgs args(InputEvent::nextId(), currentTime, /*readTime=*/0, DEVICE_ID, @@ -608,7 +611,7 @@ static NotifyKeyArgs generateKeyArgs(int32_t action, } static NotifyKeyArgs generateSystemShortcutArgs( - int32_t action, ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE) { + int32_t action, ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID) { nsecs_t currentTime = systemTime(SYSTEM_TIME_MONOTONIC); // Define a valid key event. NotifyKeyArgs args(InputEvent::nextId(), currentTime, /*readTime=*/0, DEVICE_ID, @@ -619,7 +622,7 @@ static NotifyKeyArgs generateSystemShortcutArgs( } static NotifyKeyArgs generateAssistantKeyArgs( - int32_t action, ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE) { + int32_t action, ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID) { nsecs_t currentTime = systemTime(SYSTEM_TIME_MONOTONIC); // Define a valid key event. NotifyKeyArgs args(InputEvent::nextId(), currentTime, /*readTime=*/0, DEVICE_ID, @@ -686,9 +689,9 @@ static NotifyPointerCaptureChangedArgs generatePointerCaptureChangedArgs( */ TEST_F(InputDispatcherTest, WhenInputChannelBreaks_PolicyIsNotified) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, - "Window that breaks its input channel", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, + "Window that breaks its input channel", + ui::LogicalDisplayId::DEFAULT); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -699,16 +702,18 @@ TEST_F(InputDispatcherTest, WhenInputChannelBreaks_PolicyIsNotified) { TEST_F(InputDispatcherTest, SetInputWindow_SingleWindowTouch) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; // Window should receive motion event. - window->consumeMotionDown(ADISPLAY_ID_DEFAULT); + window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); } using InputDispatcherDeathTest = InputDispatcherTest; @@ -722,8 +727,9 @@ TEST_F(InputDispatcherDeathTest, DuplicateWindowInfosAbortDispatcher) { ScopedSilentDeath _silentDeath; std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); ASSERT_DEATH(mDispatcher->onWindowInfosChanged( {{*window->getInfo(), *window->getInfo()}, {}, 0, 0}), "Incorrect WindowInfosUpdate provided"); @@ -731,17 +737,19 @@ TEST_F(InputDispatcherDeathTest, DuplicateWindowInfosAbortDispatcher) { TEST_F(InputDispatcherTest, WhenDisplayNotSpecified_InjectMotionToDefaultDisplay) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); // Inject a MotionEvent to an unknown display. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::ADISPLAY_ID_NONE)) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::INVALID)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; // Window should receive motion event. - window->consumeMotionDown(ADISPLAY_ID_DEFAULT); + window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); } /** @@ -751,18 +759,19 @@ TEST_F(InputDispatcherTest, WhenDisplayNotSpecified_InjectMotionToDefaultDisplay */ TEST_F(InputDispatcherTest, SetInputWindowOnceWithSingleTouchWindow) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 100, 100)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {50, 50})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {50, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; // Window should receive motion event. - window->consumeMotionDown(ADISPLAY_ID_DEFAULT); + window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); } /** @@ -770,37 +779,40 @@ TEST_F(InputDispatcherTest, SetInputWindowOnceWithSingleTouchWindow) { */ TEST_F(InputDispatcherTest, SetInputWindowTwice_SingleWindowTouch) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 100, 100)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {50, 50})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {50, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; // Window should receive motion event. - window->consumeMotionDown(ADISPLAY_ID_DEFAULT); + window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); } // The foreground window should receive the first touch down event. TEST_F(InputDispatcherTest, SetInputWindow_MultiWindowsTouch) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> windowTop = - sp<FakeWindowHandle>::make(application, mDispatcher, "Top", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> windowTop = sp<FakeWindowHandle>::make(application, mDispatcher, "Top", + ui::LogicalDisplayId::DEFAULT); sp<FakeWindowHandle> windowSecond = - sp<FakeWindowHandle>::make(application, mDispatcher, "Second", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Second", + ui::LogicalDisplayId::DEFAULT); mDispatcher->onWindowInfosChanged( {{*windowTop->getInfo(), *windowSecond->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; // Top window should receive the touch down event. Second window should not receive anything. - windowTop->consumeMotionDown(ADISPLAY_ID_DEFAULT); + windowTop->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); windowSecond->assertNoEvents(); } @@ -814,10 +826,12 @@ TEST_F(InputDispatcherTest, SetInputWindow_MultiWindowsTouch) { TEST_F(InputDispatcherTest, WhenForegroundWindowDisappears_WallpaperTouchIsCanceled) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> foregroundWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", + ui::LogicalDisplayId::DEFAULT); foregroundWindow->setDupTouchToWallpaper(true); sp<FakeWindowHandle> wallpaperWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper", + ui::LogicalDisplayId::DEFAULT); wallpaperWindow->setIsWallpaper(true); mDispatcher->onWindowInfosChanged( @@ -831,7 +845,7 @@ TEST_F(InputDispatcherTest, WhenForegroundWindowDisappears_WallpaperTouchIsCance // Both foreground window and its wallpaper should receive the touch down foregroundWindow->consumeMotionDown(); - wallpaperWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS); + wallpaperWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, @@ -841,13 +855,13 @@ TEST_F(InputDispatcherTest, WhenForegroundWindowDisappears_WallpaperTouchIsCance << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; foregroundWindow->consumeMotionEvent(WithMotionAction(ACTION_MOVE)); - wallpaperWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS); + wallpaperWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS); // Now the foreground window goes away, but the wallpaper stays mDispatcher->onWindowInfosChanged({{*wallpaperWindow->getInfo()}, {}, 0, 0}); foregroundWindow->consumeMotionCancel(); // Since the "parent" window of the wallpaper is gone, wallpaper should receive cancel, too. - wallpaperWindow->consumeMotionCancel(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS); + wallpaperWindow->consumeMotionCancel(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS); } /** @@ -857,8 +871,8 @@ TEST_F(InputDispatcherTest, WhenForegroundWindowDisappears_WallpaperTouchIsCance */ TEST_F(InputDispatcherTest, CancelAfterPointer0Up) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); // First touch pointer down on right window @@ -897,30 +911,32 @@ TEST_F(InputDispatcherTest, CancelAfterPointer0Up) { TEST_F(InputDispatcherTest, WhenWallpaperDisappears_NoCrash) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> foregroundWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", + ui::LogicalDisplayId::DEFAULT); foregroundWindow->setDupTouchToWallpaper(true); sp<FakeWindowHandle> wallpaperWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper", + ui::LogicalDisplayId::DEFAULT); wallpaperWindow->setIsWallpaper(true); mDispatcher->onWindowInfosChanged( {{*foregroundWindow->getInfo(), *wallpaperWindow->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {100, 200})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {100, 200})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; // Both foreground window and its wallpaper should receive the touch down foregroundWindow->consumeMotionDown(); - wallpaperWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS); + wallpaperWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {110, 200})) + ui::LogicalDisplayId::DEFAULT, {110, 200})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; foregroundWindow->consumeMotionMove(); - wallpaperWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS); + wallpaperWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS); // Wallpaper closes its channel, but the window remains. wallpaperWindow->destroyReceiver(); @@ -942,23 +958,23 @@ TEST_F(InputDispatcherTest, MultiDeviceDisappearingWindowWithWallpaperWindows) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> leftForegroundWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left foreground window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); leftForegroundWindow->setFrame(Rect(0, 0, 100, 100)); leftForegroundWindow->setDupTouchToWallpaper(true); sp<FakeWindowHandle> leftWallpaperWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left wallpaper window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); leftWallpaperWindow->setFrame(Rect(0, 0, 100, 100)); leftWallpaperWindow->setIsWallpaper(true); sp<FakeWindowHandle> rightForegroundWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right foreground window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); rightForegroundWindow->setFrame(Rect(100, 0, 200, 100)); rightForegroundWindow->setDupTouchToWallpaper(true); sp<FakeWindowHandle> rightWallpaperWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right wallpaper window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); rightWallpaperWindow->setFrame(Rect(100, 0, 200, 100)); rightWallpaperWindow->setIsWallpaper(true); @@ -1026,35 +1042,35 @@ TEST_F(InputDispatcherTest, MultiDeviceSlipperyTouchWithWallpaperWindow) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> leftForegroundWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left foreground window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); leftForegroundWindow->setFrame(Rect(0, 0, 100, 100)); leftForegroundWindow->setDupTouchToWallpaper(true); sp<FakeWindowHandle> leftWallpaperWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left wallpaper window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); leftWallpaperWindow->setFrame(Rect(0, 0, 100, 100)); leftWallpaperWindow->setIsWallpaper(true); sp<FakeWindowHandle> middleForegroundWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Middle foreground window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); middleForegroundWindow->setFrame(Rect(100, 0, 200, 100)); middleForegroundWindow->setDupTouchToWallpaper(true); middleForegroundWindow->setSlippery(true); sp<FakeWindowHandle> middleWallpaperWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Middle wallpaper window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); middleWallpaperWindow->setFrame(Rect(100, 0, 200, 100)); middleWallpaperWindow->setIsWallpaper(true); sp<FakeWindowHandle> rightForegroundWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right foreground window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); rightForegroundWindow->setFrame(Rect(200, 0, 300, 100)); rightForegroundWindow->setDupTouchToWallpaper(true); sp<FakeWindowHandle> rightWallpaperWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right wallpaper window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); rightWallpaperWindow->setFrame(Rect(200, 0, 300, 100)); rightWallpaperWindow->setIsWallpaper(true); @@ -1132,34 +1148,34 @@ TEST_F(InputDispatcherTest, MultiDeviceTouchTransferWithWallpaperWindows) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> leftForegroundWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left foreground window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); leftForegroundWindow->setFrame(Rect(0, 0, 100, 100)); leftForegroundWindow->setDupTouchToWallpaper(true); sp<FakeWindowHandle> leftWallpaperWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left wallpaper window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); leftWallpaperWindow->setFrame(Rect(0, 0, 100, 100)); leftWallpaperWindow->setIsWallpaper(true); sp<FakeWindowHandle> middleForegroundWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Middle foreground window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); middleForegroundWindow->setFrame(Rect(100, 0, 200, 100)); middleForegroundWindow->setDupTouchToWallpaper(true); sp<FakeWindowHandle> middleWallpaperWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Middle wallpaper window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); middleWallpaperWindow->setFrame(Rect(100, 0, 200, 100)); middleWallpaperWindow->setIsWallpaper(true); sp<FakeWindowHandle> rightForegroundWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right foreground window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); rightForegroundWindow->setFrame(Rect(200, 0, 300, 100)); rightForegroundWindow->setDupTouchToWallpaper(true); sp<FakeWindowHandle> rightWallpaperWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right wallpaper window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); rightWallpaperWindow->setFrame(Rect(200, 0, 300, 100)); rightWallpaperWindow->setIsWallpaper(true); @@ -1239,12 +1255,14 @@ INSTANTIATE_TEST_SUITE_P(InputDispatcherTest, ShouldSplitTouchFixture, TEST_P(ShouldSplitTouchFixture, WallpaperWindowReceivesMultiTouch) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> foregroundWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", + ui::LogicalDisplayId::DEFAULT); foregroundWindow->setDupTouchToWallpaper(true); foregroundWindow->setPreventSplitting(GetParam()); sp<FakeWindowHandle> wallpaperWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper", + ui::LogicalDisplayId::DEFAULT); wallpaperWindow->setIsWallpaper(true); mDispatcher->onWindowInfosChanged( @@ -1252,13 +1270,13 @@ TEST_P(ShouldSplitTouchFixture, WallpaperWindowReceivesMultiTouch) { // Touch down on top window ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {100, 100})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {100, 100})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; // Both top window and its wallpaper should receive the touch down foregroundWindow->consumeMotionDown(); - wallpaperWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS); + wallpaperWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS); // Second finger down on the top window const MotionEvent secondFingerDownEvent = @@ -1272,12 +1290,12 @@ TEST_P(ShouldSplitTouchFixture, WallpaperWindowReceivesMultiTouch) { InputEventInjectionSync::WAIT_FOR_RESULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; foregroundWindow->consumeMotionPointerDown(/*pointerIndex=*/1); - wallpaperWindow->consumeMotionPointerDown(/*pointerIndex=*/1, ADISPLAY_ID_DEFAULT, + wallpaperWindow->consumeMotionPointerDown(/*pointerIndex=*/1, ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS); const MotionEvent secondFingerUpEvent = MotionEventBuilder(POINTER_0_UP, AINPUT_SOURCE_TOUCHSCREEN) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .eventTime(systemTime(SYSTEM_TIME_MONOTONIC)) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(100)) .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(150).y(150)) @@ -1287,13 +1305,14 @@ TEST_P(ShouldSplitTouchFixture, WallpaperWindowReceivesMultiTouch) { InputEventInjectionSync::WAIT_FOR_RESULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; foregroundWindow->consumeMotionPointerUp(0); - wallpaperWindow->consumeMotionPointerUp(0, ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS); + wallpaperWindow->consumeMotionPointerUp(0, ui::LogicalDisplayId::DEFAULT, + EXPECTED_WALLPAPER_FLAGS); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, MotionEventBuilder(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .eventTime(systemTime(SYSTEM_TIME_MONOTONIC)) .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER) .x(100) @@ -1301,8 +1320,8 @@ TEST_P(ShouldSplitTouchFixture, WallpaperWindowReceivesMultiTouch) { .build(), INJECT_EVENT_TIMEOUT, InputEventInjectionSync::WAIT_FOR_RESULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - foregroundWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT); - wallpaperWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS); + foregroundWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT); + wallpaperWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS); } /** @@ -1315,18 +1334,19 @@ TEST_P(ShouldSplitTouchFixture, WallpaperWindowReceivesMultiTouch) { */ TEST_F(InputDispatcherTest, TwoWindows_SplitWallpaperTouch) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> leftWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left", + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect(0, 0, 200, 200)); leftWindow->setDupTouchToWallpaper(true); - sp<FakeWindowHandle> rightWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right", + ui::LogicalDisplayId::DEFAULT); rightWindow->setFrame(Rect(200, 0, 400, 200)); rightWindow->setDupTouchToWallpaper(true); sp<FakeWindowHandle> wallpaperWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper", + ui::LogicalDisplayId::DEFAULT); wallpaperWindow->setFrame(Rect(0, 0, 400, 200)); wallpaperWindow->setIsWallpaper(true); @@ -1338,13 +1358,13 @@ TEST_F(InputDispatcherTest, TwoWindows_SplitWallpaperTouch) { // Touch down on left window ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {100, 100})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {100, 100})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; // Both foreground window and its wallpaper should receive the touch down leftWindow->consumeMotionDown(); - wallpaperWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS); + wallpaperWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS); // Second finger down on the right window const MotionEvent secondFingerDownEvent = @@ -1360,8 +1380,8 @@ TEST_F(InputDispatcherTest, TwoWindows_SplitWallpaperTouch) { leftWindow->consumeMotionMove(); // Since the touch is split, right window gets ACTION_DOWN - rightWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT); - wallpaperWindow->consumeMotionPointerDown(/*pointerIndex=*/1, ADISPLAY_ID_DEFAULT, + rightWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); + wallpaperWindow->consumeMotionPointerDown(/*pointerIndex=*/1, ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS); // Now, leftWindow, which received the first finger, disappears. @@ -1369,7 +1389,7 @@ TEST_F(InputDispatcherTest, TwoWindows_SplitWallpaperTouch) { {{*rightWindow->getInfo(), *wallpaperWindow->getInfo()}, {}, 0, 0}); leftWindow->consumeMotionCancel(); // Since a "parent" window of the wallpaper is gone, wallpaper should receive cancel, too. - wallpaperWindow->consumeMotionCancel(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS); + wallpaperWindow->consumeMotionCancel(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS); // The pointer that's still down on the right window moves, and goes to the right window only. // As far as the dispatcher's concerned though, both pointers are still present. @@ -1396,18 +1416,19 @@ TEST_F(InputDispatcherTest, TwoWindows_SplitWallpaperTouch) { */ TEST_F(InputDispatcherTest, WallpaperWindowWhenSlippery) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> leftWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left", + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect(0, 0, 200, 200)); leftWindow->setDupTouchToWallpaper(true); leftWindow->setSlippery(true); - sp<FakeWindowHandle> rightWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right", + ui::LogicalDisplayId::DEFAULT); rightWindow->setFrame(Rect(200, 0, 400, 200)); sp<FakeWindowHandle> wallpaperWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper", + ui::LogicalDisplayId::DEFAULT); wallpaperWindow->setIsWallpaper(true); mDispatcher->onWindowInfosChanged( @@ -1418,23 +1439,23 @@ TEST_F(InputDispatcherTest, WallpaperWindowWhenSlippery) { // Touch down on left window ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {100, 100})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {100, 100})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; // Both foreground window and its wallpaper should receive the touch down leftWindow->consumeMotionDown(); - wallpaperWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS); + wallpaperWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS); // Move to right window, the left window should receive cancel. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {201, 100})) + ui::LogicalDisplayId::DEFAULT, {201, 100})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; leftWindow->consumeMotionCancel(); - rightWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT); - wallpaperWindow->consumeMotionCancel(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS); + rightWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); + wallpaperWindow->consumeMotionCancel(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS); } /** @@ -1455,14 +1476,14 @@ TEST_F(InputDispatcherTest, WallpaperWindowWhenSlippery) { */ TEST_F(InputDispatcherTest, TwoPointerCancelInconsistentPolicy) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> spyWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", + ui::LogicalDisplayId::DEFAULT); spyWindow->setFrame(Rect(0, 0, 200, 200)); spyWindow->setTrustedOverlay(true); spyWindow->setSpy(true); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); mDispatcher->onWindowInfosChanged({{*spyWindow->getInfo(), *window->getInfo()}, {}, 0, 0}); @@ -1533,8 +1554,8 @@ TEST_F(InputDispatcherTest, TwoPointerCancelInconsistentPolicy) { TEST_F(InputDispatcherTest, HoverEventInconsistentPolicy) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 300, 300)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -1595,12 +1616,12 @@ TEST_F(InputDispatcherTest, HoverFromLeftToRightAndTap_legacy) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> leftWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left", + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect(0, 0, 200, 200)); - sp<FakeWindowHandle> rightWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right", + ui::LogicalDisplayId::DEFAULT); rightWindow->setFrame(Rect(200, 0, 400, 200)); mDispatcher->onWindowInfosChanged( @@ -1703,12 +1724,12 @@ TEST_F(InputDispatcherTest, HoverFromLeftToRightAndTap) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> leftWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left", + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect(0, 0, 200, 200)); - sp<FakeWindowHandle> rightWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right", + ui::LogicalDisplayId::DEFAULT); rightWindow->setFrame(Rect(200, 0, 400, 200)); mDispatcher->onWindowInfosChanged( @@ -1792,8 +1813,8 @@ TEST_F(InputDispatcherTest, HoverFromLeftToRightAndTap) { */ TEST_F(InputDispatcherTest, HoverWhileWindowAppears) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); // Only a single window is present at first @@ -1808,7 +1829,7 @@ TEST_F(InputDispatcherTest, HoverWhileWindowAppears) { // Now, an obscuring window appears! sp<FakeWindowHandle> obscuringWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Obscuring window", - ADISPLAY_ID_DEFAULT, + ui::LogicalDisplayId::DEFAULT, /*createInputChannel=*/false); obscuringWindow->setFrame(Rect(0, 0, 200, 200)); obscuringWindow->setTouchOcclusionMode(TouchOcclusionMode::BLOCK_UNTRUSTED); @@ -1841,8 +1862,8 @@ TEST_F(InputDispatcherTest, HoverWhileWindowAppears) { */ TEST_F(InputDispatcherTest, HoverMoveWhileWindowAppears) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); // Only a single window is present at first @@ -1857,7 +1878,7 @@ TEST_F(InputDispatcherTest, HoverMoveWhileWindowAppears) { // Now, an obscuring window appears! sp<FakeWindowHandle> obscuringWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Obscuring window", - ADISPLAY_ID_DEFAULT, + ui::LogicalDisplayId::DEFAULT, /*createInputChannel=*/false); obscuringWindow->setFrame(Rect(0, 0, 200, 200)); obscuringWindow->setTouchOcclusionMode(TouchOcclusionMode::BLOCK_UNTRUSTED); @@ -1899,8 +1920,8 @@ TEST_F(InputDispatcherTest, HoverMoveWhileWindowAppears) { */ TEST_F(InputDispatcherTest, HoverMoveAndScroll) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -1931,8 +1952,8 @@ using InputDispatcherMultiDeviceTest = InputDispatcherTest; TEST_F(InputDispatcherMultiDeviceTest, StylusDownBlocksTouchDown) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -1978,8 +1999,8 @@ TEST_F(InputDispatcherMultiDeviceTest, StylusDownBlocksTouchDown) { TEST_F(InputDispatcherMultiDeviceTest, StylusDownDoesNotBlockTouchDown) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -2027,10 +2048,10 @@ TEST_F(InputDispatcherMultiDeviceTest, StylusDownDoesNotBlockTouchDown) { TEST_F(InputDispatcherMultiDeviceTest, StylusDownWithSpyBlocksTouchDown) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); - sp<FakeWindowHandle> spyWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); + sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", + ui::LogicalDisplayId::DEFAULT); spyWindow->setFrame(Rect(0, 0, 200, 200)); spyWindow->setTrustedOverlay(true); spyWindow->setSpy(true); @@ -2086,10 +2107,10 @@ TEST_F(InputDispatcherMultiDeviceTest, StylusDownWithSpyBlocksTouchDown) { TEST_F(InputDispatcherMultiDeviceTest, StylusDownWithSpyDoesNotBlockTouchDown) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); - sp<FakeWindowHandle> spyWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); + sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", + ui::LogicalDisplayId::DEFAULT); spyWindow->setFrame(Rect(0, 0, 200, 200)); spyWindow->setTrustedOverlay(true); spyWindow->setSpy(true); @@ -2148,8 +2169,8 @@ TEST_F(InputDispatcherMultiDeviceTest, StylusDownWithSpyDoesNotBlockTouchDown) { TEST_F(InputDispatcherMultiDeviceTest, StylusHoverBlocksTouchDown) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -2200,8 +2221,8 @@ TEST_F(InputDispatcherMultiDeviceTest, StylusHoverBlocksTouchDown) { TEST_F(InputDispatcherMultiDeviceTest, StylusHoverDoesNotBlockTouchDown) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -2254,8 +2275,8 @@ TEST_F(InputDispatcherMultiDeviceTest, StylusHoverDoesNotBlockTouchDown) { TEST_F(InputDispatcherMultiDeviceTest, TouchIsCanceledByStylusHover) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -2308,8 +2329,8 @@ TEST_F(InputDispatcherMultiDeviceTest, TouchIsCanceledByStylusHover) { TEST_F(InputDispatcherMultiDeviceTest, TouchIsNotCanceledByStylusHover) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -2363,8 +2384,8 @@ TEST_F(InputDispatcherMultiDeviceTest, TouchIsNotCanceledByStylusHover) { TEST_F(InputDispatcherMultiDeviceTest, LatestStylusWins) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -2415,8 +2436,8 @@ TEST_F(InputDispatcherMultiDeviceTest, LatestStylusWins) { TEST_F(InputDispatcherMultiDeviceTest, TwoStylusDevicesActiveAtTheSameTime) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -2463,8 +2484,8 @@ TEST_F(InputDispatcherMultiDeviceTest, TwoStylusDevicesActiveAtTheSameTime) { TEST_F(InputDispatcherMultiDeviceTest, TouchIsCanceledByStylusDown) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -2508,8 +2529,8 @@ TEST_F(InputDispatcherMultiDeviceTest, TouchIsCanceledByStylusDown) { TEST_F(InputDispatcherMultiDeviceTest, TouchIsNotCanceledByStylusDown) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -2562,12 +2583,12 @@ TEST_F(InputDispatcherMultiDeviceTest, TouchIsNotCanceledByStylusDown) { TEST_F(InputDispatcherMultiDeviceTest, MultiDeviceSplitTouch_legacy) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> leftWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left", + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect(0, 0, 200, 200)); - sp<FakeWindowHandle> rightWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right", + ui::LogicalDisplayId::DEFAULT); rightWindow->setFrame(Rect(200, 0, 400, 200)); mDispatcher->onWindowInfosChanged( @@ -2647,12 +2668,12 @@ TEST_F(InputDispatcherMultiDeviceTest, MultiDeviceSplitTouch_legacy) { TEST_F(InputDispatcherMultiDeviceTest, MultiDeviceSplitTouch) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> leftWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left", + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect(0, 0, 200, 200)); - sp<FakeWindowHandle> rightWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right", + ui::LogicalDisplayId::DEFAULT); rightWindow->setFrame(Rect(200, 0, 400, 200)); mDispatcher->onWindowInfosChanged( @@ -2725,12 +2746,12 @@ TEST_F(InputDispatcherMultiDeviceTest, MultiDeviceSplitTouch) { */ TEST_F(InputDispatcherMultiDeviceTest, MultiDeviceHover) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> leftWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left", + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect(0, 0, 200, 200)); - sp<FakeWindowHandle> rightWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right", + ui::LogicalDisplayId::DEFAULT); rightWindow->setFrame(Rect(200, 0, 400, 200)); mDispatcher->onWindowInfosChanged( @@ -2784,18 +2805,18 @@ TEST_F(InputDispatcherMultiDeviceTest, MultiDeviceWithSpy_legacy) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> spyWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", + ui::LogicalDisplayId::DEFAULT); spyWindow->setFrame(Rect(0, 0, 400, 400)); spyWindow->setTrustedOverlay(true); spyWindow->setSpy(true); - sp<FakeWindowHandle> leftWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left", + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect(0, 0, 200, 200)); - sp<FakeWindowHandle> rightWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right", + ui::LogicalDisplayId::DEFAULT); rightWindow->setFrame(Rect(200, 0, 400, 200)); @@ -2860,18 +2881,18 @@ TEST_F(InputDispatcherMultiDeviceTest, MultiDeviceWithSpy) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> spyWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", + ui::LogicalDisplayId::DEFAULT); spyWindow->setFrame(Rect(0, 0, 400, 400)); spyWindow->setTrustedOverlay(true); spyWindow->setSpy(true); - sp<FakeWindowHandle> leftWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left", + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect(0, 0, 200, 200)); - sp<FakeWindowHandle> rightWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right", + ui::LogicalDisplayId::DEFAULT); rightWindow->setFrame(Rect(200, 0, 400, 200)); @@ -2939,18 +2960,18 @@ TEST_F(InputDispatcherMultiDeviceTest, MultiDeviceHoverBlocksTouchWithSpy) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> spyWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", + ui::LogicalDisplayId::DEFAULT); spyWindow->setFrame(Rect(0, 0, 400, 400)); spyWindow->setTrustedOverlay(true); spyWindow->setSpy(true); - sp<FakeWindowHandle> leftWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left", + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect(0, 0, 200, 200)); - sp<FakeWindowHandle> rightWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right", + ui::LogicalDisplayId::DEFAULT); rightWindow->setFrame(Rect(200, 0, 400, 200)); mDispatcher->onWindowInfosChanged( @@ -3015,18 +3036,18 @@ TEST_F(InputDispatcherMultiDeviceTest, MultiDeviceHoverDoesNotBlockTouchWithSpy) SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> spyWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", + ui::LogicalDisplayId::DEFAULT); spyWindow->setFrame(Rect(0, 0, 400, 400)); spyWindow->setTrustedOverlay(true); spyWindow->setSpy(true); - sp<FakeWindowHandle> leftWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left", + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect(0, 0, 200, 200)); - sp<FakeWindowHandle> rightWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right", + ui::LogicalDisplayId::DEFAULT); rightWindow->setFrame(Rect(200, 0, 400, 200)); mDispatcher->onWindowInfosChanged( @@ -3092,8 +3113,8 @@ TEST_F(InputDispatcherMultiDeviceTest, MultiDeviceHoverDoesNotBlockTouchWithSpy) TEST_F(InputDispatcherMultiDeviceTest, MixedTouchAndMouseWithPointerDown_legacy) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 400, 400)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -3172,8 +3193,8 @@ TEST_F(InputDispatcherMultiDeviceTest, MixedTouchAndMouseWithPointerDown_legacy) TEST_F(InputDispatcherMultiDeviceTest, MixedTouchAndMouseWithPointerDown) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 400, 400)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -3247,8 +3268,8 @@ TEST_F(InputDispatcherMultiDeviceTest, MixedTouchAndMouseWithPointerDown) { TEST_F(InputDispatcherMultiDeviceTest, UnfinishedInjectedEvent_legacy) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 400, 400)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -3284,8 +3305,8 @@ TEST_F(InputDispatcherMultiDeviceTest, UnfinishedInjectedEvent_legacy) { TEST_F(InputDispatcherMultiDeviceTest, UnfinishedInjectedEvent) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 400, 400)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -3328,12 +3349,12 @@ TEST_F(InputDispatcherMultiDeviceTest, UnfinishedInjectedEvent) { TEST_F(InputDispatcherMultiDeviceTest, HoverTapAndSplitTouch_legacy) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> leftWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left", + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect(0, 0, 200, 200)); - sp<FakeWindowHandle> rightWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right", + ui::LogicalDisplayId::DEFAULT); rightWindow->setFrame(Rect(200, 0, 400, 200)); mDispatcher->onWindowInfosChanged( @@ -3414,12 +3435,12 @@ TEST_F(InputDispatcherMultiDeviceTest, HoverTapAndSplitTouch_legacy) { TEST_F(InputDispatcherMultiDeviceTest, HoverTapAndSplitTouch) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> leftWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left", + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect(0, 0, 200, 200)); - sp<FakeWindowHandle> rightWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right", + ui::LogicalDisplayId::DEFAULT); rightWindow->setFrame(Rect(200, 0, 400, 200)); mDispatcher->onWindowInfosChanged( @@ -3481,8 +3502,8 @@ TEST_F(InputDispatcherMultiDeviceTest, HoverTapAndSplitTouch) { TEST_F(InputDispatcherMultiDeviceTest, StylusHoverIgnoresTouchTap) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -3548,8 +3569,8 @@ TEST_F(InputDispatcherMultiDeviceTest, StylusHoverIgnoresTouchTap) { TEST_F(InputDispatcherMultiDeviceTest, StylusHoverWithTouchTap) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -3608,12 +3629,13 @@ TEST_F(InputDispatcherMultiDeviceTest, GlobalStylusDownBlocksTouch) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect(0, 0, 100, 100)); sp<FakeWindowHandle> sbtRightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, - "Stylus blocks touch (right) window", ADISPLAY_ID_DEFAULT); + "Stylus blocks touch (right) window", + ui::LogicalDisplayId::DEFAULT); sbtRightWindow->setFrame(Rect(100, 100, 200, 200)); sbtRightWindow->setGlobalStylusBlocksTouch(true); @@ -3680,12 +3702,13 @@ TEST_F(InputDispatcherMultiDeviceTest, GlobalStylusHoverBlocksTouch) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect(0, 0, 100, 100)); sp<FakeWindowHandle> sbtRightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, - "Stylus blocks touch (right) window", ADISPLAY_ID_DEFAULT); + "Stylus blocks touch (right) window", + ui::LogicalDisplayId::DEFAULT); sbtRightWindow->setFrame(Rect(100, 100, 200, 200)); sbtRightWindow->setGlobalStylusBlocksTouch(true); @@ -3746,13 +3769,13 @@ TEST_F(InputDispatcherMultiDeviceTest, GlobalStylusHoverBlocksTouch) { */ TEST_F(InputDispatcherTest, StylusHoverAndDownNoInputChannel) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> spyWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", + ui::LogicalDisplayId::DEFAULT); spyWindow->setFrame(Rect(0, 0, 200, 200)); spyWindow->setTrustedOverlay(true); spyWindow->setSpy(true); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setNoInputChannel(true); window->setFrame(Rect(0, 0, 200, 200)); @@ -3805,8 +3828,8 @@ TEST_F(InputDispatcherTest, StylusHoverAndDownNoInputChannel) { TEST_F(InputDispatcherTest, StaleStylusHoverGestureIsComplete) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -3844,13 +3867,13 @@ TEST_F(InputDispatcherTest, StaleStylusHoverGestureIsComplete) { TEST_F(InputDispatcherTest, TouchPilferAndMouseMove_legacy) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> spyWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", + ui::LogicalDisplayId::DEFAULT); spyWindow->setFrame(Rect(0, 0, 200, 200)); spyWindow->setTrustedOverlay(true); spyWindow->setSpy(true); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); mDispatcher->onWindowInfosChanged({{*spyWindow->getInfo(), *window->getInfo()}, {}, 0, 0}); @@ -3947,13 +3970,13 @@ TEST_F(InputDispatcherTest, TouchPilferAndMouseMove_legacy) { TEST_F(InputDispatcherTest, TouchPilferAndMouseMove) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> spyWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", + ui::LogicalDisplayId::DEFAULT); spyWindow->setFrame(Rect(0, 0, 200, 200)); spyWindow->setTrustedOverlay(true); spyWindow->setSpy(true); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 200, 200)); mDispatcher->onWindowInfosChanged({{*spyWindow->getInfo(), *window->getInfo()}, {}, 0, 0}); @@ -4171,14 +4194,14 @@ TEST_F(InputDispatcherTest, SplitTouchesSendCorrectActionDownTime) { TEST_F(InputDispatcherTest, HoverMoveEnterMouseClickAndHoverMoveExit) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> windowLeft = - sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> windowLeft = sp<FakeWindowHandle>::make(application, mDispatcher, "Left", + ui::LogicalDisplayId::DEFAULT); windowLeft->setFrame(Rect(0, 0, 600, 800)); - sp<FakeWindowHandle> windowRight = - sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> windowRight = sp<FakeWindowHandle>::make(application, mDispatcher, "Right", + ui::LogicalDisplayId::DEFAULT); windowRight->setFrame(Rect(600, 0, 1200, 800)); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); mDispatcher->onWindowInfosChanged( {{*windowLeft->getInfo(), *windowRight->getInfo()}, {}, 0, 0}); @@ -4238,7 +4261,7 @@ TEST_F(InputDispatcherTest, HoverMoveEnterMouseClickAndHoverMoveExit) { .buttonState(0) .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400)) .build())); - windowLeft->consumeMotionUp(ADISPLAY_ID_DEFAULT); + windowLeft->consumeMotionUp(ui::LogicalDisplayId::DEFAULT); // Move mouse cursor back to right window ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, @@ -4262,8 +4285,8 @@ TEST_F(InputDispatcherTest, HoverMoveEnterMouseClickAndHoverMoveExit) { TEST_F(InputDispatcherTest, TwoPointersDownMouseClick_legacy) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 600, 800)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -4322,8 +4345,8 @@ TEST_F(InputDispatcherTest, TwoPointersDownMouseClick_legacy) { TEST_F(InputDispatcherTest, TwoPointersDownMouseClick) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 600, 800)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -4376,16 +4399,16 @@ TEST_F(InputDispatcherTest, TwoPointersDownMouseClick) { TEST_F(InputDispatcherTest, HoverWithSpyWindows) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> spyWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", + ui::LogicalDisplayId::DEFAULT); spyWindow->setFrame(Rect(0, 0, 600, 800)); spyWindow->setTrustedOverlay(true); spyWindow->setSpy(true); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 600, 800)); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); mDispatcher->onWindowInfosChanged({{*spyWindow->getInfo(), *window->getInfo()}, {}, 0, 0}); // Send mouse cursor to the window @@ -4409,16 +4432,16 @@ TEST_F(InputDispatcherTest, MouseAndTouchWithSpyWindows_legacy) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> spyWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", + ui::LogicalDisplayId::DEFAULT); spyWindow->setFrame(Rect(0, 0, 600, 800)); spyWindow->setTrustedOverlay(true); spyWindow->setSpy(true); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 600, 800)); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); mDispatcher->onWindowInfosChanged({{*spyWindow->getInfo(), *window->getInfo()}, {}, 0, 0}); // Send mouse cursor to the window @@ -4516,16 +4539,16 @@ TEST_F(InputDispatcherTest, MouseAndTouchWithSpyWindows) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> spyWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", + ui::LogicalDisplayId::DEFAULT); spyWindow->setFrame(Rect(0, 0, 600, 800)); spyWindow->setTrustedOverlay(true); spyWindow->setSpy(true); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 600, 800)); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); mDispatcher->onWindowInfosChanged({{*spyWindow->getInfo(), *window->getInfo()}, {}, 0, 0}); // Send mouse cursor to the window @@ -4612,11 +4635,11 @@ TEST_F(InputDispatcherTest, MouseAndTouchWithSpyWindows) { // directly in this test. TEST_F(InputDispatcherTest, HoverEnterMouseClickAndHoverExit) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 1200, 800)); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -4663,7 +4686,7 @@ TEST_F(InputDispatcherTest, HoverEnterMouseClickAndHoverExit) { .buttonState(0) .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400)) .build())); - window->consumeMotionUp(ADISPLAY_ID_DEFAULT); + window->consumeMotionUp(ui::LogicalDisplayId::DEFAULT); // We already canceled the hovering implicitly by injecting the "DOWN" event without lifting the // hover first. Therefore, injection of HOVER_EXIT is inconsistent, and should fail. @@ -4682,11 +4705,11 @@ TEST_F(InputDispatcherTest, HoverEnterMouseClickAndHoverExit) { */ TEST_F(InputDispatcherTest, HoverExitIsSentToRemovedWindow) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 1200, 800)); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -4710,11 +4733,11 @@ TEST_F_WITH_FLAGS(InputDispatcherTest, InvalidA11yHoverStreamDoesNotCrash, REQUIRES_FLAGS_DISABLED(ACONFIG_FLAG(com::android::input::flags, a11y_crash_on_inconsistent_event_stream))) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 1200, 800)); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -4736,8 +4759,8 @@ TEST_F_WITH_FLAGS(InputDispatcherTest, InvalidA11yHoverStreamDoesNotCrash, TEST_F(InputDispatcherTest, TouchDownAfterMouseHover_legacy) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 100, 100)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -4770,8 +4793,8 @@ TEST_F(InputDispatcherTest, TouchDownAfterMouseHover_legacy) { TEST_F(InputDispatcherTest, TouchDownAfterMouseHover) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 100, 100)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -4803,8 +4826,8 @@ TEST_F(InputDispatcherTest, TouchDownAfterMouseHover) { TEST_F(InputDispatcherTest, MouseHoverAndTouchTap_legacy) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 100, 100)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -4843,8 +4866,8 @@ TEST_F(InputDispatcherTest, MouseHoverAndTouchTap_legacy) { TEST_F(InputDispatcherTest, MouseHoverAndTouchTap) { SCOPED_FLAG_OVERRIDE(enable_multi_device_same_window_stream, true); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 100, 100)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -4878,7 +4901,7 @@ TEST_F(InputDispatcherTest, HoverEnterMoveRemoveWindowsInSecondDisplay) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> windowDefaultDisplay = sp<FakeWindowHandle>::make(application, mDispatcher, "DefaultDisplay", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); windowDefaultDisplay->setFrame(Rect(0, 0, 600, 800)); sp<FakeWindowHandle> windowSecondDisplay = sp<FakeWindowHandle>::make(application, mDispatcher, "SecondDisplay", @@ -4894,7 +4917,7 @@ TEST_F(InputDispatcherTest, HoverEnterMoveRemoveWindowsInSecondDisplay) { injectMotionEvent(*mDispatcher, MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE, AINPUT_SOURCE_MOUSE) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(600)) .build())); windowDefaultDisplay->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER)); @@ -4913,7 +4936,7 @@ TEST_F(InputDispatcherTest, HoverEnterMoveRemoveWindowsInSecondDisplay) { injectMotionEvent(*mDispatcher, MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE, AINPUT_SOURCE_MOUSE) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .pointer(PointerBuilder(0, ToolType::MOUSE).x(400).y(700)) .build())); windowDefaultDisplay->consumeMotionEvent( @@ -4925,14 +4948,14 @@ TEST_F(InputDispatcherTest, HoverEnterMoveRemoveWindowsInSecondDisplay) { TEST_F(InputDispatcherTest, DispatchMouseEventsUnderCursor) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> windowLeft = - sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> windowLeft = sp<FakeWindowHandle>::make(application, mDispatcher, "Left", + ui::LogicalDisplayId::DEFAULT); windowLeft->setFrame(Rect(0, 0, 600, 800)); - sp<FakeWindowHandle> windowRight = - sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> windowRight = sp<FakeWindowHandle>::make(application, mDispatcher, "Right", + ui::LogicalDisplayId::DEFAULT); windowRight->setFrame(Rect(600, 0, 1200, 800)); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); mDispatcher->onWindowInfosChanged( {{*windowLeft->getInfo(), *windowRight->getInfo()}, {}, 0, 0}); @@ -4941,15 +4964,16 @@ TEST_F(InputDispatcherTest, DispatchMouseEventsUnderCursor) { // left window. This event should be dispatched to the left window. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_MOUSE, - ADISPLAY_ID_DEFAULT, {610, 400}, {599, 400})); - windowLeft->consumeMotionDown(ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT, {610, 400}, {599, 400})); + windowLeft->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); windowRight->assertNoEvents(); } TEST_F(InputDispatcherTest, NotifyDeviceReset_CancelsKeyStream) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); window->setFocusable(true); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -4957,41 +4981,44 @@ TEST_F(InputDispatcherTest, NotifyDeviceReset_CancelsKeyStream) { window->consumeFocusEvent(true); - mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT)); + mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT)); // Window should receive key down event. - window->consumeKeyDown(ADISPLAY_ID_DEFAULT); + window->consumeKeyDown(ui::LogicalDisplayId::DEFAULT); // When device reset happens, that key stream should be terminated with FLAG_CANCELED // on the app side. mDispatcher->notifyDeviceReset({/*id=*/10, /*eventTime=*/20, DEVICE_ID}); - window->consumeKeyUp(ADISPLAY_ID_DEFAULT, AKEY_EVENT_FLAG_CANCELED); + window->consumeKeyUp(ui::LogicalDisplayId::DEFAULT, AKEY_EVENT_FLAG_CANCELED); } TEST_F(InputDispatcherTest, NotifyDeviceReset_CancelsMotionStream) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)); // Window should receive motion down event. - window->consumeMotionDown(ADISPLAY_ID_DEFAULT); + window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); // When device reset happens, that motion stream should be terminated with ACTION_CANCEL // on the app side. mDispatcher->notifyDeviceReset({/*id=*/10, /*eventTime=*/20, DEVICE_ID}); window->consumeMotionEvent( - AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ADISPLAY_ID_DEFAULT))); + AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ui::LogicalDisplayId::DEFAULT))); } TEST_F(InputDispatcherTest, NotifyDeviceResetCancelsHoveringStream) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -5014,8 +5041,9 @@ TEST_F(InputDispatcherTest, NotifyDeviceResetCancelsHoveringStream) { TEST_F(InputDispatcherTest, InterceptKeyByPolicy) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); window->setFocusable(true); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -5023,13 +5051,14 @@ TEST_F(InputDispatcherTest, InterceptKeyByPolicy) { window->consumeFocusEvent(true); - const NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT); + const NotifyKeyArgs keyArgs = + generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT); const std::chrono::milliseconds interceptKeyTimeout = 50ms; const nsecs_t injectTime = keyArgs.eventTime; mFakePolicy->setInterceptKeyTimeout(interceptKeyTimeout); mDispatcher->notifyKey(keyArgs); // The dispatching time should be always greater than or equal to intercept key timeout. - window->consumeKeyDown(ADISPLAY_ID_DEFAULT); + window->consumeKeyDown(ui::LogicalDisplayId::DEFAULT); ASSERT_TRUE((systemTime(SYSTEM_TIME_MONOTONIC) - injectTime) >= std::chrono::nanoseconds(interceptKeyTimeout).count()); } @@ -5039,8 +5068,9 @@ TEST_F(InputDispatcherTest, InterceptKeyByPolicy) { */ TEST_F(InputDispatcherTest, InterceptKeyIfKeyUp) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); window->setFocusable(true); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -5048,15 +5078,15 @@ TEST_F(InputDispatcherTest, InterceptKeyIfKeyUp) { window->consumeFocusEvent(true); - mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT)); - window->consumeKeyDown(ADISPLAY_ID_DEFAULT); + mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT)); + window->consumeKeyDown(ui::LogicalDisplayId::DEFAULT); // Set a value that's significantly larger than the default consumption timeout. If the // implementation is correct, the actual value doesn't matter; it won't slow down the test. mFakePolicy->setInterceptKeyTimeout(600ms); - mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT)); + mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ui::LogicalDisplayId::DEFAULT)); // Window should receive key event immediately when same key up. - window->consumeKeyUp(ADISPLAY_ID_DEFAULT); + window->consumeKeyUp(ui::LogicalDisplayId::DEFAULT); } /** @@ -5068,13 +5098,13 @@ TEST_F(InputDispatcherTest, InterceptKeyIfKeyUp) { */ TEST_F(InputDispatcherTest, ActionOutsideForOwnedWindowHasValidCoordinates) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect{0, 0, 100, 100}); sp<FakeWindowHandle> outsideWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Outside Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); outsideWindow->setFrame(Rect{100, 100, 200, 200}); outsideWindow->setWatchOutsideTouch(true); // outsideWindow must be above 'window' to receive ACTION_OUTSIDE events when 'window' is tapped @@ -5082,8 +5112,8 @@ TEST_F(InputDispatcherTest, ActionOutsideForOwnedWindowHasValidCoordinates) { // Tap on first window. mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {PointF{50, 50}})); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {PointF{50, 50}})); window->consumeMotionDown(); // The coordinates of the tap in 'outsideWindow' are relative to its top left corner. // Therefore, we should offset them by (100, 100) relative to the screen's top left corner. @@ -5092,7 +5122,7 @@ TEST_F(InputDispatcherTest, ActionOutsideForOwnedWindowHasValidCoordinates) { // Ensure outsideWindow doesn't get any more events for the gesture. mDispatcher->notifyMotion(generateMotionArgs(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {PointF{51, 51}})); + ui::LogicalDisplayId::DEFAULT, {PointF{51, 51}})); window->consumeMotionMove(); outsideWindow->assertNoEvents(); } @@ -5116,13 +5146,13 @@ TEST_F(InputDispatcherTest, ActionOutsideForOwnedWindowHasValidCoordinatesWhenMu std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect{0, 0, 100, 100}); leftWindow->setOwnerInfo(gui::Pid{1}, gui::Uid{101}); sp<FakeWindowHandle> outsideWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Outside Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); outsideWindow->setFrame(Rect{100, 100, 200, 200}); outsideWindow->setOwnerInfo(gui::Pid{1}, gui::Uid{101}); outsideWindow->setWatchOutsideTouch(true); @@ -5131,7 +5161,7 @@ TEST_F(InputDispatcherTest, ActionOutsideForOwnedWindowHasValidCoordinatesWhenMu std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(anotherApplication, mDispatcher, "Right Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); rightWindow->setFrame(Rect{100, 0, 200, 100}); rightWindow->setOwnerInfo(gui::Pid{2}, gui::Uid{202}); @@ -5195,32 +5225,33 @@ TEST_F(InputDispatcherTest, ActionOutsideForOwnedWindowHasValidCoordinatesWhenMu TEST_F(InputDispatcherTest, ActionOutsideSentOnlyWhenAWindowIsTouched) { // There are three windows that do not overlap. `window` wants to WATCH_OUTSIDE_TOUCH. std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "First Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "First Window", + ui::LogicalDisplayId::DEFAULT); window->setWatchOutsideTouch(true); window->setFrame(Rect{0, 0, 100, 100}); sp<FakeWindowHandle> secondWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Second Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); secondWindow->setFrame(Rect{100, 100, 200, 200}); sp<FakeWindowHandle> thirdWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Third Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); thirdWindow->setFrame(Rect{200, 200, 300, 300}); mDispatcher->onWindowInfosChanged( {{*window->getInfo(), *secondWindow->getInfo(), *thirdWindow->getInfo()}, {}, 0, 0}); // First pointer lands outside all windows. `window` does not get ACTION_OUTSIDE. - mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {PointF{-10, -10}})); + mDispatcher->notifyMotion( + generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {PointF{-10, -10}})); window->assertNoEvents(); secondWindow->assertNoEvents(); // The second pointer lands inside `secondWindow`, which should receive a DOWN event. // Now, `window` should get ACTION_OUTSIDE. mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, + ui::LogicalDisplayId::DEFAULT, {PointF{-10, -10}, PointF{105, 105}})); const std::map<int32_t, PointF> expectedPointers{{0, PointF{-10, -10}}, {1, PointF{105, 105}}}; window->consumeMotionEvent( @@ -5231,7 +5262,8 @@ TEST_F(InputDispatcherTest, ActionOutsideSentOnlyWhenAWindowIsTouched) { // The third pointer lands inside `thirdWindow`, which should receive a DOWN event. There is // no ACTION_OUTSIDE sent to `window` because one has already been sent for this gesture. mDispatcher->notifyMotion( - generateMotionArgs(POINTER_2_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, + generateMotionArgs(POINTER_2_DOWN, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {PointF{-10, -10}, PointF{105, 105}, PointF{205, 205}})); window->assertNoEvents(); secondWindow->consumeMotionMove(); @@ -5240,8 +5272,9 @@ TEST_F(InputDispatcherTest, ActionOutsideSentOnlyWhenAWindowIsTouched) { TEST_F(InputDispatcherTest, OnWindowInfosChanged_RemoveAllWindowsOnDisplay) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); window->setFocusable(true); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -5249,13 +5282,15 @@ TEST_F(InputDispatcherTest, OnWindowInfosChanged_RemoveAllWindowsOnDisplay) { window->consumeFocusEvent(true); - const NotifyKeyArgs keyDown = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT); - const NotifyKeyArgs keyUp = generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT); + const NotifyKeyArgs keyDown = + generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT); + const NotifyKeyArgs keyUp = + generateKeyArgs(AKEY_EVENT_ACTION_UP, ui::LogicalDisplayId::DEFAULT); mDispatcher->notifyKey(keyDown); mDispatcher->notifyKey(keyUp); - window->consumeKeyDown(ADISPLAY_ID_DEFAULT); - window->consumeKeyUp(ADISPLAY_ID_DEFAULT); + window->consumeKeyDown(ui::LogicalDisplayId::DEFAULT); + window->consumeKeyUp(ui::LogicalDisplayId::DEFAULT); // All windows are removed from the display. Ensure that we can no longer dispatch to it. mDispatcher->onWindowInfosChanged({{}, {}, 0, 0}); @@ -5269,22 +5304,23 @@ TEST_F(InputDispatcherTest, OnWindowInfosChanged_RemoveAllWindowsOnDisplay) { TEST_F(InputDispatcherTest, NonSplitTouchableWindowReceivesMultiTouch) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); // Ensure window is non-split and have some transform. window->setPreventSplitting(true); window->setWindowOffset(20, 40); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {50, 50})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {50, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - window->consumeMotionDown(ADISPLAY_ID_DEFAULT); + window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); const MotionEvent secondFingerDownEvent = MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .eventTime(systemTime(SYSTEM_TIME_MONOTONIC)) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(50).y(50)) .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(-30).y(-50)) @@ -5315,12 +5351,12 @@ TEST_F(InputDispatcherTest, SplittableAndNonSplittableWindows) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left splittable Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); leftWindow->setPreventSplitting(false); leftWindow->setFrame(Rect(0, 0, 100, 100)); sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right non-splittable Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); rightWindow->setPreventSplitting(true); rightWindow->setFrame(Rect(100, 100, 200, 200)); mDispatcher->onWindowInfosChanged( @@ -5343,12 +5379,12 @@ TEST_F(InputDispatcherTest, SplittableAndNonSplittableWindows) { TEST_F(InputDispatcherTest, TouchpadThreeFingerSwipeOnlySentToTrustedOverlays) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 400, 400)); sp<FakeWindowHandle> trustedOverlay = sp<FakeWindowHandle>::make(application, mDispatcher, "Trusted Overlay", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); trustedOverlay->setSpy(true); trustedOverlay->setTrustedOverlay(true); @@ -5411,8 +5447,8 @@ TEST_F(InputDispatcherTest, TouchpadThreeFingerSwipeOnlySentToTrustedOverlays) { TEST_F(InputDispatcherTest, TouchpadThreeFingerSwipeNotSentToSingleWindow) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 400, 400)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -5468,8 +5504,8 @@ TEST_F(InputDispatcherTest, TouchpadThreeFingerSwipeNotSentToSingleWindow) { */ TEST_F(InputDispatcherTest, MultiplePointersWithRotatingWindow) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 400, 400)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -5534,13 +5570,14 @@ TEST_F(InputDispatcherTest, WhenMultiDisplayWindowSameToken_DispatchCancelToTarg std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> spyWindowDefaultDisplay = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", + ui::LogicalDisplayId::DEFAULT); spyWindowDefaultDisplay->setTrustedOverlay(true); spyWindowDefaultDisplay->setSpy(true); sp<FakeWindowHandle> windowDefaultDisplay = sp<FakeWindowHandle>::make(application, mDispatcher, "DefaultDisplay", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); windowDefaultDisplay->setWindowTransform(1, 0, 0, 1); sp<FakeWindowHandle> windowSecondDisplay = windowDefaultDisplay->clone(SECOND_DISPLAY_ID); @@ -5554,10 +5591,10 @@ TEST_F(InputDispatcherTest, WhenMultiDisplayWindowSameToken_DispatchCancelToTarg 0, 0}); - // Send down to ADISPLAY_ID_DEFAULT + // Send down to ui::LogicalDisplayId::DEFAULT ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {100, 100})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {100, 100})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; spyWindowDefaultDisplay->consumeMotionDown(); @@ -5570,10 +5607,10 @@ TEST_F(InputDispatcherTest, WhenMultiDisplayWindowSameToken_DispatchCancelToTarg ASSERT_NE(nullptr, event); EXPECT_EQ(AMOTION_EVENT_ACTION_CANCEL, event->getAction()); - // The cancel event is sent to windowDefaultDisplay of the ADISPLAY_ID_DEFAULT display, so - // the coordinates of the cancel are converted by windowDefaultDisplay's transform, the x and y - // coordinates are both 100, otherwise if the cancel event is sent to windowSecondDisplay of - // SECOND_DISPLAY_ID, the x and y coordinates are 200 + // The cancel event is sent to windowDefaultDisplay of the ui::LogicalDisplayId::DEFAULT + // display, so the coordinates of the cancel are converted by windowDefaultDisplay's transform, + // the x and y coordinates are both 100, otherwise if the cancel event is sent to + // windowSecondDisplay of SECOND_DISPLAY_ID, the x and y coordinates are 200 EXPECT_EQ(100, event->getX(0)); EXPECT_EQ(100, event->getY(0)); } @@ -5617,7 +5654,7 @@ public: // respectively. ui::Transform displayTransform; displayTransform.set(2, 0, 0, 4); - addDisplayInfo(ADISPLAY_ID_DEFAULT, displayTransform); + addDisplayInfo(ui::LogicalDisplayId::DEFAULT, displayTransform); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); @@ -5625,13 +5662,13 @@ public: // Add two windows to the display. Their frames are represented in the display space. sp<FakeWindowHandle> firstWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "First Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); firstWindow->setFrame(Rect(0, 0, 100, 200), displayTransform); addWindow(firstWindow); sp<FakeWindowHandle> secondWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Second Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); secondWindow->setFrame(Rect(100, 200, 200, 400), displayTransform); addWindow(secondWindow); return {std::move(firstWindow), std::move(secondWindow)}; @@ -5648,8 +5685,8 @@ TEST_F(InputDispatcherDisplayProjectionTest, HitTestCoordinateSpaceConsistency) // selected so that if the hit test was performed with the point and the bounds being in // different coordinate spaces, the event would end up in the incorrect window. mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {PointF{75, 55}})); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {PointF{75, 55}})); firstWindow->consumeMotionDown(); secondWindow->assertNoEvents(); @@ -5662,7 +5699,7 @@ TEST_F(InputDispatcherDisplayProjectionTest, InjectionInLogicalDisplaySpace) { // Send down to the first window. The point is represented in the logical display space. The // point is selected so that if the hit test was done in logical display space, then it would // end up in the incorrect window. - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, PointF{75 * 2, 55 * 4}); firstWindow->consumeMotionDown(); @@ -5681,7 +5718,7 @@ TEST_F(InputDispatcherDisplayProjectionTest, InjectionWithTransformInLogicalDisp const vec2 untransformedPoint = injectedEventTransform.inverse().transform(expectedPoint); MotionEvent event = MotionEventBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .eventTime(systemTime(SYSTEM_TIME_MONOTONIC)) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER) .x(untransformedPoint.x) @@ -5700,9 +5737,9 @@ TEST_F(InputDispatcherDisplayProjectionTest, WindowGetsEventsInCorrectCoordinate auto [firstWindow, secondWindow] = setupScaledDisplayScenario(); // Send down to the second window. - mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {PointF{150, 220}})); + mDispatcher->notifyMotion( + generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {PointF{150, 220}})); firstWindow->assertNoEvents(); std::unique_ptr<MotionEvent> event = secondWindow->consumeMotionEvent(); @@ -5724,17 +5761,17 @@ TEST_F(InputDispatcherDisplayProjectionTest, CancelMotionWithCorrectCoordinates) auto [firstWindow, secondWindow] = setupScaledDisplayScenario(); // The monitor will always receive events in the logical display's coordinate space, because // it does not have a window. - FakeMonitorReceiver monitor{*mDispatcher, "Monitor", ADISPLAY_ID_DEFAULT}; + FakeMonitorReceiver monitor{*mDispatcher, "Monitor", ui::LogicalDisplayId::DEFAULT}; // Send down to the first window. mDispatcher->notifyMotion(generateMotionArgs(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {PointF{50, 100}})); + ui::LogicalDisplayId::DEFAULT, {PointF{50, 100}})); firstWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_DOWN), WithCoords(100, 400))); monitor.consumeMotionEvent(AllOf(WithMotionAction(ACTION_DOWN), WithCoords(100, 400))); // Second pointer goes down on second window. mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, + ui::LogicalDisplayId::DEFAULT, {PointF{50, 100}, PointF{150, 220}})); secondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_DOWN), WithCoords(100, 80))); const std::map<int32_t, PointF> expectedMonitorPointers{{0, PointF{100, 400}}, @@ -5755,7 +5792,7 @@ TEST_F(InputDispatcherDisplayProjectionTest, SynthesizeDownWithCorrectCoordinate // Send down to the first window. mDispatcher->notifyMotion(generateMotionArgs(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {PointF{50, 100}})); + ui::LogicalDisplayId::DEFAULT, {PointF{50, 100}})); firstWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_DOWN), WithCoords(100, 400))); // The pointer is transferred to the second window, and the second window receives it in the @@ -5770,13 +5807,15 @@ TEST_F(InputDispatcherDisplayProjectionTest, SynthesizeHoverEnterExitWithCorrect // Send hover move to the second window, and ensure it shows up as hover enter. mDispatcher->notifyMotion(generateMotionArgs(ACTION_HOVER_MOVE, AINPUT_SOURCE_STYLUS, - ADISPLAY_ID_DEFAULT, {PointF{150, 220}})); + ui::LogicalDisplayId::DEFAULT, + {PointF{150, 220}})); secondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_HOVER_ENTER), WithCoords(100, 80), WithRawCoords(300, 880))); // Touch down at the same location and ensure a hover exit is synthesized. mDispatcher->notifyMotion(generateMotionArgs(ACTION_DOWN, AINPUT_SOURCE_STYLUS, - ADISPLAY_ID_DEFAULT, {PointF{150, 220}})); + ui::LogicalDisplayId::DEFAULT, + {PointF{150, 220}})); secondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_HOVER_EXIT), WithCoords(100, 80), WithRawCoords(300, 880))); secondWindow->consumeMotionEvent( @@ -5801,14 +5840,16 @@ TEST_F(InputDispatcherDisplayProjectionTest, // Send hover move to the second window, and ensure it shows up as hover enter. mDispatcher->notifyMotion(generateMotionArgs(ACTION_HOVER_MOVE, AINPUT_SOURCE_STYLUS, - ADISPLAY_ID_DEFAULT, {PointF{150, 220}})); + ui::LogicalDisplayId::DEFAULT, + {PointF{150, 220}})); secondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_HOVER_ENTER), WithCoords(100, 80), WithRawCoords(300, 880))); // Touch down at the same location and ensure a hover exit is synthesized for the correct // display. mDispatcher->notifyMotion(generateMotionArgs(ACTION_DOWN, AINPUT_SOURCE_STYLUS, - ADISPLAY_ID_DEFAULT, {PointF{150, 220}})); + ui::LogicalDisplayId::DEFAULT, + {PointF{150, 220}})); secondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_HOVER_EXIT), WithCoords(100, 80), WithRawCoords(300, 880))); secondWindow->consumeMotionEvent( @@ -5822,7 +5863,8 @@ TEST_F(InputDispatcherDisplayProjectionTest, SynthesizeHoverCancelationWithCorre // Send hover enter to second window mDispatcher->notifyMotion(generateMotionArgs(ACTION_HOVER_ENTER, AINPUT_SOURCE_STYLUS, - ADISPLAY_ID_DEFAULT, {PointF{150, 220}})); + ui::LogicalDisplayId::DEFAULT, + {PointF{150, 220}})); secondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_HOVER_ENTER), WithCoords(100, 80), WithRawCoords(300, 880))); @@ -5850,17 +5892,18 @@ TEST_F(InputDispatcherDisplayProjectionTest, // Send hover enter to second window mDispatcher->notifyMotion(generateMotionArgs(ACTION_HOVER_ENTER, AINPUT_SOURCE_STYLUS, - ADISPLAY_ID_DEFAULT, {PointF{150, 220}})); + ui::LogicalDisplayId::DEFAULT, + {PointF{150, 220}})); secondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_HOVER_ENTER), WithCoords(100, 80), WithRawCoords(300, 880), - WithDisplayId(ADISPLAY_ID_DEFAULT))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))); mDispatcher->cancelCurrentTouch(); // Ensure the cancelation happens with the correct displayId and the correct coordinates. secondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_HOVER_EXIT), WithCoords(100, 80), WithRawCoords(300, 880), - WithDisplayId(ADISPLAY_ID_DEFAULT))); + WithDisplayId(ui::LogicalDisplayId::DEFAULT))); secondWindow->assertNoEvents(); firstWindow->assertNoEvents(); } @@ -5887,13 +5930,13 @@ TEST_P(InputDispatcherDisplayOrientationFixture, HitTestInDifferentOrientations) const int32_t logicalDisplayHeight = isRotated ? displayWidth : displayHeight; const ui::Transform displayTransform(ui::Transform::toRotationFlags(rotation), logicalDisplayWidth, logicalDisplayHeight); - addDisplayInfo(ADISPLAY_ID_DEFAULT, displayTransform); + addDisplayInfo(ui::LogicalDisplayId::DEFAULT, displayTransform); // Create a window with its bounds determined in the logical display. const Rect frameInLogicalDisplay(100, 100, 200, 300); const Rect frameInDisplay = displayTransform.inverse().transform(frameInLogicalDisplay); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(frameInDisplay, displayTransform); addWindow(window); @@ -5903,14 +5946,14 @@ TEST_P(InputDispatcherDisplayOrientationFixture, HitTestInDifferentOrientations) for (const auto pointInsideWindow : insidePoints) { const vec2 p = displayTransform.inverse().transform(pointInsideWindow); const PointF pointInDisplaySpace{p.x, p.y}; - mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {pointInDisplaySpace})); + mDispatcher->notifyMotion( + generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {pointInDisplaySpace})); window->consumeMotionDown(); - mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {pointInDisplaySpace})); + mDispatcher->notifyMotion( + generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {pointInDisplaySpace})); window->consumeMotionUp(); } @@ -5920,13 +5963,13 @@ TEST_P(InputDispatcherDisplayOrientationFixture, HitTestInDifferentOrientations) for (const auto pointOutsideWindow : outsidePoints) { const vec2 p = displayTransform.inverse().transform(pointOutsideWindow); const PointF pointInDisplaySpace{p.x, p.y}; - mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {pointInDisplaySpace})); + mDispatcher->notifyMotion( + generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {pointInDisplaySpace})); - mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {pointInDisplaySpace})); + mDispatcher->notifyMotion( + generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {pointInDisplaySpace})); } window->assertNoEvents(); } @@ -5950,7 +5993,7 @@ TEST_P(InputDispatcherDisplayOrientationFixture, BlockUntrustClickInDifferentOri const int32_t logicalDisplayHeight = isRotated ? displayWidth : displayHeight; const ui::Transform displayTransform(ui::Transform::toRotationFlags(rotation), logicalDisplayWidth, logicalDisplayHeight); - addDisplayInfo(ADISPLAY_ID_DEFAULT, displayTransform); + addDisplayInfo(ui::LogicalDisplayId::DEFAULT, displayTransform); // Create a window that not trusted. const Rect untrustedWindowFrameInLogicalDisplay(100, 100, 200, 300); @@ -5960,7 +6003,7 @@ TEST_P(InputDispatcherDisplayOrientationFixture, BlockUntrustClickInDifferentOri sp<FakeWindowHandle> untrustedWindow = sp<FakeWindowHandle>::make(untrustedWindowApplication, mDispatcher, "UntrustedWindow", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); untrustedWindow->setFrame(untrustedWindowFrameInDisplay, displayTransform); untrustedWindow->setTrustedOverlay(false); untrustedWindow->setTouchOcclusionMode(TouchOcclusionMode::BLOCK_UNTRUSTED); @@ -5976,7 +6019,7 @@ TEST_P(InputDispatcherDisplayOrientationFixture, BlockUntrustClickInDifferentOri sp<FakeWindowHandle> simpleAppWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "SimpleAppWindow", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); simpleAppWindow->setFrame(simpleAppWindowFrameInDisplay, displayTransform); simpleAppWindow->setOwnerInfo(gui::Pid{2}, gui::Uid{202}); addWindow(simpleAppWindow); @@ -5989,12 +6032,12 @@ TEST_P(InputDispatcherDisplayOrientationFixture, BlockUntrustClickInDifferentOri for (const auto untrustedPoint : untrustedPoints) { const vec2 p = displayTransform.inverse().transform(untrustedPoint); const PointF pointInDisplaySpace{p.x, p.y}; - mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {pointInDisplaySpace})); - mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {pointInDisplaySpace})); + mDispatcher->notifyMotion( + generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {pointInDisplaySpace})); + mDispatcher->notifyMotion( + generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {pointInDisplaySpace})); } untrustedWindow->assertNoEvents(); simpleAppWindow->assertNoEvents(); @@ -6005,15 +6048,15 @@ TEST_P(InputDispatcherDisplayOrientationFixture, BlockUntrustClickInDifferentOri for (const auto trustedPoint : trustedPoints) { const vec2 p = displayTransform.inverse().transform(trustedPoint); const PointF pointInDisplaySpace{p.x, p.y}; - mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {pointInDisplaySpace})); - simpleAppWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, + mDispatcher->notifyMotion( + generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {pointInDisplaySpace})); + simpleAppWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED); - mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {pointInDisplaySpace})); - simpleAppWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, + mDispatcher->notifyMotion( + generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {pointInDisplaySpace})); + simpleAppWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED); } untrustedWindow->assertNoEvents(); @@ -6040,13 +6083,14 @@ TEST_P(TransferTouchFixture, TransferTouch_OnePointer) { // Create a couple of windows sp<FakeWindowHandle> firstWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "First Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); firstWindow->setDupTouchToWallpaper(true); sp<FakeWindowHandle> secondWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Second Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); sp<FakeWindowHandle> wallpaper = - sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper", + ui::LogicalDisplayId::DEFAULT); wallpaper->setIsWallpaper(true); // Add the windows to the dispatcher, and ensure the first window is focused mDispatcher->onWindowInfosChanged( @@ -6056,12 +6100,13 @@ TEST_P(TransferTouchFixture, TransferTouch_OnePointer) { // Send down to the first window mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)); // Only the first window should get the down event firstWindow->consumeMotionDown(); secondWindow->assertNoEvents(); - wallpaper->consumeMotionDown(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS); + wallpaper->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS); // Dispatcher reports pointer down outside focus for the wallpaper mFakePolicy->assertOnPointerDownEquals(wallpaper->getToken()); @@ -6071,17 +6116,19 @@ TEST_P(TransferTouchFixture, TransferTouch_OnePointer) { ASSERT_TRUE(success); // The first window gets cancel and the second gets down firstWindow->consumeMotionCancel(); - secondWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); - wallpaper->consumeMotionCancel(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS); + secondWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + wallpaper->consumeMotionCancel(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS); // There should not be any changes to the focused window when transferring touch ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertOnPointerDownWasNotCalled()); // Send up event to the second window mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT)); + ui::LogicalDisplayId::DEFAULT)); // The first window gets no events and the second gets up firstWindow->assertNoEvents(); - secondWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + secondWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); wallpaper->assertNoEvents(); } @@ -6101,14 +6148,15 @@ TEST_P(TransferTouchFixture, TransferTouch_MultipleWindowsWithSpy) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); // Create a couple of windows + a spy window - sp<FakeWindowHandle> spyWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> spyWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy", + ui::LogicalDisplayId::DEFAULT); spyWindow->setTrustedOverlay(true); spyWindow->setSpy(true); - sp<FakeWindowHandle> firstWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "First", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> firstWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "First", + ui::LogicalDisplayId::DEFAULT); sp<FakeWindowHandle> secondWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Second", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Second", + ui::LogicalDisplayId::DEFAULT); // Add the windows to the dispatcher mDispatcher->onWindowInfosChanged( @@ -6116,7 +6164,8 @@ TEST_P(TransferTouchFixture, TransferTouch_MultipleWindowsWithSpy) { // Send down to the first window mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)); // Only the first window and spy should get the down event spyWindow->consumeMotionDown(); firstWindow->consumeMotionDown(); @@ -6128,15 +6177,17 @@ TEST_P(TransferTouchFixture, TransferTouch_MultipleWindowsWithSpy) { ASSERT_TRUE(success); // The first window gets cancel and the second gets down firstWindow->consumeMotionCancel(); - secondWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + secondWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); // Send up event to the second window mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT)); + ui::LogicalDisplayId::DEFAULT)); // The first window gets no events and the second+spy get up firstWindow->assertNoEvents(); spyWindow->consumeMotionUp(); - secondWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + secondWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); } TEST_P(TransferTouchFixture, TransferTouch_TwoPointersNonSplitTouch) { @@ -6147,11 +6198,11 @@ TEST_P(TransferTouchFixture, TransferTouch_TwoPointersNonSplitTouch) { // Create a couple of windows sp<FakeWindowHandle> firstWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "First Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); firstWindow->setPreventSplitting(true); sp<FakeWindowHandle> secondWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Second Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); secondWindow->setPreventSplitting(true); // Add the windows to the dispatcher @@ -6160,15 +6211,16 @@ TEST_P(TransferTouchFixture, TransferTouch_TwoPointersNonSplitTouch) { // Send down to the first window mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {touchPoint})); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {touchPoint})); // Only the first window should get the down event firstWindow->consumeMotionDown(); secondWindow->assertNoEvents(); // Send pointer down to the first window mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {touchPoint, touchPoint})); + ui::LogicalDisplayId::DEFAULT, + {touchPoint, touchPoint})); // Only the first window should get the pointer down event firstWindow->consumeMotionPointerDown(1); secondWindow->assertNoEvents(); @@ -6179,24 +6231,27 @@ TEST_P(TransferTouchFixture, TransferTouch_TwoPointersNonSplitTouch) { ASSERT_TRUE(success); // The first window gets cancel and the second gets down and pointer down firstWindow->consumeMotionCancel(); - secondWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); - secondWindow->consumeMotionPointerDown(1, ADISPLAY_ID_DEFAULT, + secondWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + secondWindow->consumeMotionPointerDown(1, ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); // Send pointer up to the second window mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {touchPoint, touchPoint})); + ui::LogicalDisplayId::DEFAULT, + {touchPoint, touchPoint})); // The first window gets nothing and the second gets pointer up firstWindow->assertNoEvents(); - secondWindow->consumeMotionPointerUp(1, ADISPLAY_ID_DEFAULT, + secondWindow->consumeMotionPointerUp(1, ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); // Send up event to the second window mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT)); + ui::LogicalDisplayId::DEFAULT)); // The first window gets nothing and the second gets up firstWindow->assertNoEvents(); - secondWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + secondWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); } TEST_P(TransferTouchFixture, TransferTouch_MultipleWallpapers) { @@ -6205,19 +6260,21 @@ TEST_P(TransferTouchFixture, TransferTouch_MultipleWallpapers) { // Create a couple of windows sp<FakeWindowHandle> firstWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "First Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); firstWindow->setDupTouchToWallpaper(true); sp<FakeWindowHandle> secondWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Second Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); secondWindow->setDupTouchToWallpaper(true); sp<FakeWindowHandle> wallpaper1 = - sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper1", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper1", + ui::LogicalDisplayId::DEFAULT); wallpaper1->setIsWallpaper(true); sp<FakeWindowHandle> wallpaper2 = - sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper2", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Wallpaper2", + ui::LogicalDisplayId::DEFAULT); wallpaper2->setIsWallpaper(true); // Add the windows to the dispatcher mDispatcher->onWindowInfosChanged({{*firstWindow->getInfo(), *wallpaper1->getInfo(), @@ -6228,12 +6285,13 @@ TEST_P(TransferTouchFixture, TransferTouch_MultipleWallpapers) { // Send down to the first window mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)); // Only the first window should get the down event firstWindow->consumeMotionDown(); secondWindow->assertNoEvents(); - wallpaper1->consumeMotionDown(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS); + wallpaper1->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS); wallpaper2->assertNoEvents(); // Transfer touch focus to the second window @@ -6243,19 +6301,21 @@ TEST_P(TransferTouchFixture, TransferTouch_MultipleWallpapers) { // The first window gets cancel and the second gets down firstWindow->consumeMotionCancel(); - secondWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); - wallpaper1->consumeMotionCancel(ADISPLAY_ID_DEFAULT, EXPECTED_WALLPAPER_FLAGS); - wallpaper2->consumeMotionDown(ADISPLAY_ID_DEFAULT, + secondWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + wallpaper1->consumeMotionCancel(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS); + wallpaper2->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS | AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); // Send up event to the second window mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT)); + ui::LogicalDisplayId::DEFAULT)); // The first window gets no events and the second gets up firstWindow->assertNoEvents(); - secondWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + secondWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); wallpaper1->assertNoEvents(); - wallpaper2->consumeMotionUp(ADISPLAY_ID_DEFAULT, + wallpaper2->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, EXPECTED_WALLPAPER_FLAGS | AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); } @@ -6268,7 +6328,7 @@ INSTANTIATE_TEST_SUITE_P( [&](const std::unique_ptr<InputDispatcher>& dispatcher, sp<IBinder> /*ignored*/, sp<IBinder> destChannelToken) { return dispatcher->transferTouchOnDisplay(destChannelToken, - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); }, [&](const std::unique_ptr<InputDispatcher>& dispatcher, sp<IBinder> from, sp<IBinder> to) { @@ -6281,12 +6341,12 @@ TEST_F(InputDispatcherTest, TransferTouch_TwoPointersSplitTouch) { sp<FakeWindowHandle> firstWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "First Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); firstWindow->setFrame(Rect(0, 0, 600, 400)); sp<FakeWindowHandle> secondWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Second Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); secondWindow->setFrame(Rect(0, 400, 600, 800)); // Add the windows to the dispatcher @@ -6298,15 +6358,15 @@ TEST_F(InputDispatcherTest, TransferTouch_TwoPointersSplitTouch) { // Send down to the first window mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {pointInFirst})); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {pointInFirst})); // Only the first window should get the down event firstWindow->consumeMotionDown(); secondWindow->assertNoEvents(); // Send down to the second window mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, + ui::LogicalDisplayId::DEFAULT, {pointInFirst, pointInSecond})); // The first window gets a move and the second a down firstWindow->consumeMotionMove(); @@ -6316,24 +6376,25 @@ TEST_F(InputDispatcherTest, TransferTouch_TwoPointersSplitTouch) { mDispatcher->transferTouchGesture(firstWindow->getToken(), secondWindow->getToken()); // The first window gets cancel and the new gets pointer down (it already saw down) firstWindow->consumeMotionCancel(); - secondWindow->consumeMotionPointerDown(1, ADISPLAY_ID_DEFAULT, + secondWindow->consumeMotionPointerDown(1, ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); // Send pointer up to the second window mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, + ui::LogicalDisplayId::DEFAULT, {pointInFirst, pointInSecond})); // The first window gets nothing and the second gets pointer up firstWindow->assertNoEvents(); - secondWindow->consumeMotionPointerUp(1, ADISPLAY_ID_DEFAULT, + secondWindow->consumeMotionPointerUp(1, ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); // Send up event to the second window mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT)); + ui::LogicalDisplayId::DEFAULT)); // The first window gets nothing and the second gets up firstWindow->assertNoEvents(); - secondWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + secondWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); } // Same as TransferTouch_TwoPointersSplitTouch, but using 'transferTouchOnDisplay' api. @@ -6345,12 +6406,12 @@ TEST_F(InputDispatcherTest, TransferTouchOnDisplay_TwoPointersSplitTouch) { sp<FakeWindowHandle> firstWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "First Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); firstWindow->setFrame(Rect(0, 0, 600, 400)); sp<FakeWindowHandle> secondWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Second Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); secondWindow->setFrame(Rect(0, 400, 600, 800)); // Add the windows to the dispatcher @@ -6362,23 +6423,23 @@ TEST_F(InputDispatcherTest, TransferTouchOnDisplay_TwoPointersSplitTouch) { // Send down to the first window mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {pointInFirst})); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {pointInFirst})); // Only the first window should get the down event firstWindow->consumeMotionDown(); secondWindow->assertNoEvents(); // Send down to the second window mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, + ui::LogicalDisplayId::DEFAULT, {pointInFirst, pointInSecond})); // The first window gets a move and the second a down firstWindow->consumeMotionMove(); secondWindow->consumeMotionDown(); // Transfer touch focus to the second window - const bool transferred = - mDispatcher->transferTouchOnDisplay(secondWindow->getToken(), ADISPLAY_ID_DEFAULT); + const bool transferred = mDispatcher->transferTouchOnDisplay(secondWindow->getToken(), + ui::LogicalDisplayId::DEFAULT); // The 'transferTouchOnDisplay' call should not succeed, because there are 2 touched windows ASSERT_FALSE(transferred); firstWindow->assertNoEvents(); @@ -6387,7 +6448,7 @@ TEST_F(InputDispatcherTest, TransferTouchOnDisplay_TwoPointersSplitTouch) { // The rest of the dispatch should proceed as normal // Send pointer up to the second window mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, + ui::LogicalDisplayId::DEFAULT, {pointInFirst, pointInSecond})); // The first window gets MOVE and the second gets pointer up firstWindow->consumeMotionMove(); @@ -6395,7 +6456,7 @@ TEST_F(InputDispatcherTest, TransferTouchOnDisplay_TwoPointersSplitTouch) { // Send up event to the first window mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT)); + ui::LogicalDisplayId::DEFAULT)); // The first window gets nothing and the second gets up firstWindow->consumeMotionUp(); secondWindow->assertNoEvents(); @@ -6407,13 +6468,16 @@ TEST_F(InputDispatcherTest, TransferTouchOnDisplay_TwoPointersSplitTouch) { TEST_F(InputDispatcherTest, TransferTouch_CloneSurface) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> firstWindowInPrimary = - sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W1", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W1", + ui::LogicalDisplayId::DEFAULT); firstWindowInPrimary->setFrame(Rect(0, 0, 100, 100)); sp<FakeWindowHandle> secondWindowInPrimary = - sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W2", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W2", + ui::LogicalDisplayId::DEFAULT); secondWindowInPrimary->setFrame(Rect(100, 0, 200, 100)); - sp<FakeWindowHandle> mirrorWindowInPrimary = firstWindowInPrimary->clone(ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> mirrorWindowInPrimary = + firstWindowInPrimary->clone(ui::LogicalDisplayId::DEFAULT); mirrorWindowInPrimary->setFrame(Rect(0, 100, 100, 200)); sp<FakeWindowHandle> firstWindowInSecondary = firstWindowInPrimary->clone(SECOND_DISPLAY_ID); @@ -6432,35 +6496,36 @@ TEST_F(InputDispatcherTest, TransferTouch_CloneSurface) { 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {50, 50})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {50, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; // Window should receive motion event. - firstWindowInPrimary->consumeMotionDown(ADISPLAY_ID_DEFAULT); + firstWindowInPrimary->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); // Transfer touch ASSERT_TRUE(mDispatcher->transferTouchGesture(firstWindowInPrimary->getToken(), secondWindowInPrimary->getToken())); // The first window gets cancel. firstWindowInPrimary->consumeMotionCancel(); - secondWindowInPrimary->consumeMotionDown(ADISPLAY_ID_DEFAULT, + secondWindowInPrimary->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {150, 50})) + ui::LogicalDisplayId::DEFAULT, {150, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; firstWindowInPrimary->assertNoEvents(); - secondWindowInPrimary->consumeMotionMove(ADISPLAY_ID_DEFAULT, + secondWindowInPrimary->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, + injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, {150, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; firstWindowInPrimary->assertNoEvents(); - secondWindowInPrimary->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + secondWindowInPrimary->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); } // Same as TransferTouch_CloneSurface, but this touch on the secondary display and use @@ -6468,13 +6533,16 @@ TEST_F(InputDispatcherTest, TransferTouch_CloneSurface) { TEST_F(InputDispatcherTest, TransferTouchOnDisplay_CloneSurface) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> firstWindowInPrimary = - sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W1", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W1", + ui::LogicalDisplayId::DEFAULT); firstWindowInPrimary->setFrame(Rect(0, 0, 100, 100)); sp<FakeWindowHandle> secondWindowInPrimary = - sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W2", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "D_1_W2", + ui::LogicalDisplayId::DEFAULT); secondWindowInPrimary->setFrame(Rect(100, 0, 200, 100)); - sp<FakeWindowHandle> mirrorWindowInPrimary = firstWindowInPrimary->clone(ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> mirrorWindowInPrimary = + firstWindowInPrimary->clone(ui::LogicalDisplayId::DEFAULT); mirrorWindowInPrimary->setFrame(Rect(0, 100, 100, 200)); sp<FakeWindowHandle> firstWindowInSecondary = firstWindowInPrimary->clone(SECOND_DISPLAY_ID); @@ -6527,8 +6595,9 @@ TEST_F(InputDispatcherTest, TransferTouchOnDisplay_CloneSurface) { TEST_F(InputDispatcherTest, FocusedWindow_ReceivesFocusEventAndKeyEvent) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); window->setFocusable(true); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -6536,10 +6605,10 @@ TEST_F(InputDispatcherTest, FocusedWindow_ReceivesFocusEventAndKeyEvent) { window->consumeFocusEvent(true); - mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT)); + mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT)); // Window should receive key down event. - window->consumeKeyDown(ADISPLAY_ID_DEFAULT); + window->consumeKeyDown(ui::LogicalDisplayId::DEFAULT); // Should have poked user activity mDispatcher->waitForIdle(); @@ -6548,8 +6617,9 @@ TEST_F(InputDispatcherTest, FocusedWindow_ReceivesFocusEventAndKeyEvent) { TEST_F(InputDispatcherTest, FocusedWindow_DisableUserActivity) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); window->setDisableUserActivity(true); window->setFocusable(true); @@ -6558,10 +6628,10 @@ TEST_F(InputDispatcherTest, FocusedWindow_DisableUserActivity) { window->consumeFocusEvent(true); - mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT)); + mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT)); // Window should receive key down event. - window->consumeKeyDown(ADISPLAY_ID_DEFAULT); + window->consumeKeyDown(ui::LogicalDisplayId::DEFAULT); // Should have poked user activity mDispatcher->waitForIdle(); @@ -6570,8 +6640,9 @@ TEST_F(InputDispatcherTest, FocusedWindow_DisableUserActivity) { TEST_F(InputDispatcherTest, FocusedWindow_DoesNotReceiveSystemShortcut) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); window->setFocusable(true); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -6579,7 +6650,8 @@ TEST_F(InputDispatcherTest, FocusedWindow_DoesNotReceiveSystemShortcut) { window->consumeFocusEvent(true); - mDispatcher->notifyKey(generateSystemShortcutArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT)); + mDispatcher->notifyKey( + generateSystemShortcutArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT)); mDispatcher->waitForIdle(); // System key is not passed down @@ -6591,8 +6663,9 @@ TEST_F(InputDispatcherTest, FocusedWindow_DoesNotReceiveSystemShortcut) { TEST_F(InputDispatcherTest, FocusedWindow_DoesNotReceiveAssistantKey) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); window->setFocusable(true); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -6600,7 +6673,8 @@ TEST_F(InputDispatcherTest, FocusedWindow_DoesNotReceiveAssistantKey) { window->consumeFocusEvent(true); - mDispatcher->notifyKey(generateAssistantKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT)); + mDispatcher->notifyKey( + generateAssistantKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT)); mDispatcher->waitForIdle(); // System key is not passed down @@ -6612,8 +6686,9 @@ TEST_F(InputDispatcherTest, FocusedWindow_DoesNotReceiveAssistantKey) { TEST_F(InputDispatcherTest, FocusedWindow_SystemKeyIgnoresDisableUserActivity) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); window->setDisableUserActivity(true); window->setFocusable(true); @@ -6622,7 +6697,8 @@ TEST_F(InputDispatcherTest, FocusedWindow_SystemKeyIgnoresDisableUserActivity) { window->consumeFocusEvent(true); - mDispatcher->notifyKey(generateSystemShortcutArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT)); + mDispatcher->notifyKey( + generateSystemShortcutArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT)); mDispatcher->waitForIdle(); // System key is not passed down @@ -6634,18 +6710,19 @@ TEST_F(InputDispatcherTest, FocusedWindow_SystemKeyIgnoresDisableUserActivity) { TEST_F(InputDispatcherTest, InjectedTouchesPokeUserActivity) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {100, 100})) + ui::LogicalDisplayId::DEFAULT, {100, 100})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; window->consumeMotionEvent( - AllOf(WithMotionAction(ACTION_DOWN), WithDisplayId(ADISPLAY_ID_DEFAULT))); + AllOf(WithMotionAction(ACTION_DOWN), WithDisplayId(ui::LogicalDisplayId::DEFAULT))); // Should have poked user activity mDispatcher->waitForIdle(); @@ -6654,12 +6731,13 @@ TEST_F(InputDispatcherTest, InjectedTouchesPokeUserActivity) { TEST_F(InputDispatcherTest, UnfocusedWindow_DoesNotReceiveFocusEventOrKeyEvent) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); - mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT)); + mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT)); mDispatcher->waitForIdle(); window->assertNoEvents(); @@ -6668,19 +6746,21 @@ TEST_F(InputDispatcherTest, UnfocusedWindow_DoesNotReceiveFocusEventOrKeyEvent) // If a window is touchable, but does not have focus, it should receive motion events, but not keys TEST_F(InputDispatcherTest, UnfocusedWindow_ReceivesMotionsButNotKeys) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); // Send key - mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT)); + mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT)); // Send motion mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)); // Window should receive only the motion event - window->consumeMotionDown(ADISPLAY_ID_DEFAULT); + window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); window->assertNoEvents(); // Key event or focus event will not be received } @@ -6689,12 +6769,12 @@ TEST_F(InputDispatcherTest, PointerCancel_SendCancelWhenSplitTouch) { sp<FakeWindowHandle> firstWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "First Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); firstWindow->setFrame(Rect(0, 0, 600, 400)); sp<FakeWindowHandle> secondWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Second Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); secondWindow->setFrame(Rect(0, 400, 600, 800)); // Add the windows to the dispatcher @@ -6706,15 +6786,15 @@ TEST_F(InputDispatcherTest, PointerCancel_SendCancelWhenSplitTouch) { // Send down to the first window mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {pointInFirst})); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {pointInFirst})); // Only the first window should get the down event firstWindow->consumeMotionDown(); secondWindow->assertNoEvents(); // Send down to the second window mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, + ui::LogicalDisplayId::DEFAULT, {pointInFirst, pointInSecond})); // The first window gets a move and the second a down firstWindow->consumeMotionMove(); @@ -6722,17 +6802,17 @@ TEST_F(InputDispatcherTest, PointerCancel_SendCancelWhenSplitTouch) { // Send pointer cancel to the second window NotifyMotionArgs pointerUpMotionArgs = - generateMotionArgs(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {pointInFirst, pointInSecond}); + generateMotionArgs(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {pointInFirst, pointInSecond}); pointerUpMotionArgs.flags |= AMOTION_EVENT_FLAG_CANCELED; mDispatcher->notifyMotion(pointerUpMotionArgs); // The first window gets move and the second gets cancel. - firstWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_CANCELED); - secondWindow->consumeMotionCancel(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_CANCELED); + firstWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_CANCELED); + secondWindow->consumeMotionCancel(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_CANCELED); // Send up event. mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT)); + ui::LogicalDisplayId::DEFAULT)); // The first window gets up and the second gets nothing. firstWindow->consumeMotionUp(); secondWindow->assertNoEvents(); @@ -6741,8 +6821,8 @@ TEST_F(InputDispatcherTest, PointerCancel_SendCancelWhenSplitTouch) { TEST_F(InputDispatcherTest, SendTimeline_DoesNotCrashDispatcher) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); std::array<nsecs_t, GraphicsTimeline::SIZE> graphicsTimeline; graphicsTimeline[GraphicsTimeline::GPU_COMPLETED_TIME] = 2; @@ -6765,28 +6845,29 @@ using InputDispatcherMonitorTest = InputDispatcherTest; */ TEST_F(InputDispatcherMonitorTest, MonitorTouchIsCanceledWhenForegroundWindowDisappears) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", + ui::LogicalDisplayId::DEFAULT); - FakeMonitorReceiver monitor = FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT); + FakeMonitorReceiver monitor = + FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {100, 200})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {100, 200})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; // Both the foreground window and the global monitor should receive the touch down window->consumeMotionDown(); - monitor.consumeMotionDown(ADISPLAY_ID_DEFAULT); + monitor.consumeMotionDown(ui::LogicalDisplayId::DEFAULT); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {110, 200})) + ui::LogicalDisplayId::DEFAULT, {110, 200})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; window->consumeMotionMove(); - monitor.consumeMotionMove(ADISPLAY_ID_DEFAULT); + monitor.consumeMotionMove(ui::LogicalDisplayId::DEFAULT); // Now the foreground window goes away mDispatcher->onWindowInfosChanged({{}, {}, 0, 0}); @@ -6797,41 +6878,47 @@ TEST_F(InputDispatcherMonitorTest, MonitorTouchIsCanceledWhenForegroundWindowDis // cause a cancel for the monitor, as well. ASSERT_EQ(InputEventInjectionResult::FAILED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {120, 200})) + ui::LogicalDisplayId::DEFAULT, {120, 200})) << "Injection should fail because the window was removed"; window->assertNoEvents(); // Global monitor now gets the cancel - monitor.consumeMotionCancel(ADISPLAY_ID_DEFAULT); + monitor.consumeMotionCancel(ui::LogicalDisplayId::DEFAULT); } TEST_F(InputDispatcherMonitorTest, ReceivesMotionEvents) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); - FakeMonitorReceiver monitor = FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT); + FakeMonitorReceiver monitor = + FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - window->consumeMotionDown(ADISPLAY_ID_DEFAULT); - monitor.consumeMotionDown(ADISPLAY_ID_DEFAULT); + window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); + monitor.consumeMotionDown(ui::LogicalDisplayId::DEFAULT); } TEST_F(InputDispatcherMonitorTest, MonitorCannotPilferPointers) { - FakeMonitorReceiver monitor = FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT); + FakeMonitorReceiver monitor = + FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - monitor.consumeMotionDown(ADISPLAY_ID_DEFAULT); - window->consumeMotionDown(ADISPLAY_ID_DEFAULT); + monitor.consumeMotionDown(ui::LogicalDisplayId::DEFAULT); + window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); // Pilfer pointers from the monitor. // This should not do anything and the window should continue to receive events. @@ -6839,27 +6926,30 @@ TEST_F(InputDispatcherMonitorTest, MonitorCannotPilferPointers) { ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT)) + ui::LogicalDisplayId::DEFAULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - monitor.consumeMotionMove(ADISPLAY_ID_DEFAULT); - window->consumeMotionMove(ADISPLAY_ID_DEFAULT); + monitor.consumeMotionMove(ui::LogicalDisplayId::DEFAULT); + window->consumeMotionMove(ui::LogicalDisplayId::DEFAULT); } TEST_F(InputDispatcherMonitorTest, NoWindowTransform) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); window->setWindowOffset(20, 40); window->setWindowTransform(0, 1, -1, 0); - FakeMonitorReceiver monitor = FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT); + FakeMonitorReceiver monitor = + FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - window->consumeMotionDown(ADISPLAY_ID_DEFAULT); + window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); std::unique_ptr<MotionEvent> event = monitor.consumeMotion(); ASSERT_NE(nullptr, event); // Even though window has transform, gesture monitor must not. @@ -6868,10 +6958,12 @@ TEST_F(InputDispatcherMonitorTest, NoWindowTransform) { TEST_F(InputDispatcherMonitorTest, InjectionFailsWithNoWindow) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - FakeMonitorReceiver monitor = FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT); + FakeMonitorReceiver monitor = + FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT); ASSERT_EQ(InputEventInjectionResult::FAILED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)) << "Injection should fail if there is a monitor, but no touchable window"; monitor.assertNoEvents(); } @@ -6889,20 +6981,21 @@ TEST_F(InputDispatcherMonitorTest, InjectionFailsWithNoWindow) { */ TEST_F(InputDispatcherMonitorTest, MonitorTouchIsNotCanceledWhenAnotherEmptyDisplayReceiveEvents) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", + ui::LogicalDisplayId::DEFAULT); - FakeMonitorReceiver monitor = FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT); + FakeMonitorReceiver monitor = + FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT); FakeMonitorReceiver secondMonitor = FakeMonitorReceiver(*mDispatcher, "M_2", SECOND_DISPLAY_ID); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {100, 200})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {100, 200})) << "The down event injected into the first display should succeed"; window->consumeMotionDown(); - monitor.consumeMotionDown(ADISPLAY_ID_DEFAULT); + monitor.consumeMotionDown(ui::LogicalDisplayId::DEFAULT); ASSERT_EQ(InputEventInjectionResult::FAILED, injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, SECOND_DISPLAY_ID, @@ -6913,19 +7006,19 @@ TEST_F(InputDispatcherMonitorTest, MonitorTouchIsNotCanceledWhenAnotherEmptyDisp // Continue to inject event to first display. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {110, 220})) + ui::LogicalDisplayId::DEFAULT, {110, 220})) << "The move event injected into the first display should succeed"; window->consumeMotionMove(); - monitor.consumeMotionMove(ADISPLAY_ID_DEFAULT); + monitor.consumeMotionMove(ui::LogicalDisplayId::DEFAULT); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, + injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, {110, 220})) << "The up event injected into the first display should succeed"; window->consumeMotionUp(); - monitor.consumeMotionUp(ADISPLAY_ID_DEFAULT); + monitor.consumeMotionUp(ui::LogicalDisplayId::DEFAULT); window->assertNoEvents(); monitor.assertNoEvents(); @@ -6949,24 +7042,25 @@ TEST_F(InputDispatcherMonitorTest, MonitorTouchIsNotCanceledWhenAnotherEmptyDisp */ TEST_F(InputDispatcherMonitorTest, MonitorTouchIsNotCancelWhenAnotherDisplayMonitorTouchCanceled) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", + ui::LogicalDisplayId::DEFAULT); sp<FakeWindowHandle> secondWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "SecondForeground", SECOND_DISPLAY_ID); - FakeMonitorReceiver monitor = FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT); + FakeMonitorReceiver monitor = + FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT); FakeMonitorReceiver secondMonitor = FakeMonitorReceiver(*mDispatcher, "M_2", SECOND_DISPLAY_ID); // There is a foreground window on both displays. mDispatcher->onWindowInfosChanged({{*window->getInfo(), *secondWindow->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {100, 200})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {100, 200})) << "The down event injected into the first display should succeed"; - window->consumeMotionDown(ADISPLAY_ID_DEFAULT); - monitor.consumeMotionDown(ADISPLAY_ID_DEFAULT); + window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); + monitor.consumeMotionDown(ui::LogicalDisplayId::DEFAULT); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, SECOND_DISPLAY_ID, @@ -6994,11 +7088,11 @@ TEST_F(InputDispatcherMonitorTest, MonitorTouchIsNotCancelWhenAnotherDisplayMoni ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {110, 200})) + ui::LogicalDisplayId::DEFAULT, {110, 200})) << "The move event injected into the first display should succeed"; window->consumeMotionMove(); - monitor.consumeMotionMove(ADISPLAY_ID_DEFAULT); + monitor.consumeMotionMove(ui::LogicalDisplayId::DEFAULT); ASSERT_EQ(InputEventInjectionResult::FAILED, injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, SECOND_DISPLAY_ID, @@ -7007,12 +7101,12 @@ TEST_F(InputDispatcherMonitorTest, MonitorTouchIsNotCancelWhenAnotherDisplayMoni "touchable window"; ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, + injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, {110, 220})) << "The up event injected into the first display should succeed"; - window->consumeMotionUp(ADISPLAY_ID_DEFAULT); - monitor.consumeMotionUp(ADISPLAY_ID_DEFAULT); + window->consumeMotionUp(ui::LogicalDisplayId::DEFAULT); + monitor.consumeMotionUp(ui::LogicalDisplayId::DEFAULT); window->assertNoEvents(); monitor.assertNoEvents(); @@ -7030,22 +7124,23 @@ TEST_F(InputDispatcherMonitorTest, MonitorTouchIsNotCancelWhenAnotherDisplayMoni */ TEST_F(InputDispatcherMonitorTest, MonitorTouchCancelEventWithDisplayTransform) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", ADISPLAY_ID_DEFAULT); - FakeMonitorReceiver monitor = FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Foreground", + ui::LogicalDisplayId::DEFAULT); + FakeMonitorReceiver monitor = + FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT); ui::Transform transform; transform.set({1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 0, 0, 1}); gui::DisplayInfo displayInfo; - displayInfo.displayId = ADISPLAY_ID_DEFAULT; + displayInfo.displayId = ui::LogicalDisplayId::DEFAULT; displayInfo.transform = transform; mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {displayInfo}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {100, 200})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {100, 200})) << "The down event injected should succeed"; window->consumeMotionDown(); @@ -7055,7 +7150,7 @@ TEST_F(InputDispatcherMonitorTest, MonitorTouchCancelEventWithDisplayTransform) ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {110, 220})) + ui::LogicalDisplayId::DEFAULT, {110, 220})) << "The move event injected should succeed"; window->consumeMotionMove(); @@ -7071,19 +7166,19 @@ TEST_F(InputDispatcherMonitorTest, MonitorTouchCancelEventWithDisplayTransform) ASSERT_EQ(InputEventInjectionResult::FAILED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {110, 220})) + ui::LogicalDisplayId::DEFAULT, {110, 220})) << "The move event injected should failed"; // Now foreground should not receive any events, but monitor should receive a cancel event // with transform that same as display's display. std::unique_ptr<MotionEvent> cancelMotionEvent = monitor.consumeMotion(); EXPECT_EQ(transform, cancelMotionEvent->getTransform()); - EXPECT_EQ(ADISPLAY_ID_DEFAULT, cancelMotionEvent->getDisplayId()); + EXPECT_EQ(ui::LogicalDisplayId::DEFAULT, cancelMotionEvent->getDisplayId()); EXPECT_EQ(AMOTION_EVENT_ACTION_CANCEL, cancelMotionEvent->getAction()); // Other event inject to this display should fail. ASSERT_EQ(InputEventInjectionResult::FAILED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {110, 220})) + ui::LogicalDisplayId::DEFAULT, {110, 220})) << "The up event injected should fail because the touched window was removed"; window->assertNoEvents(); monitor.assertNoEvents(); @@ -7091,18 +7186,19 @@ TEST_F(InputDispatcherMonitorTest, MonitorTouchCancelEventWithDisplayTransform) TEST_F(InputDispatcherTest, TestMoveEvent) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Fake Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); NotifyMotionArgs motionArgs = generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); mDispatcher->notifyMotion(motionArgs); // Window should receive motion down event. - window->consumeMotionDown(ADISPLAY_ID_DEFAULT); + window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); motionArgs.action = AMOTION_EVENT_ACTION_MOVE; motionArgs.id += 1; @@ -7111,7 +7207,7 @@ TEST_F(InputDispatcherTest, TestMoveEvent) { motionArgs.pointerCoords[0].getX() - 10); mDispatcher->notifyMotion(motionArgs); - window->consumeMotionMove(ADISPLAY_ID_DEFAULT, /*expectedFlags=*/0); + window->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, /*expectedFlags=*/0); } /** @@ -7121,12 +7217,13 @@ TEST_F(InputDispatcherTest, TestMoveEvent) { */ TEST_F(InputDispatcherTest, TouchModeState_IsSentToApps) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Test window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Test window", + ui::LogicalDisplayId::DEFAULT); const WindowInfo& windowInfo = *window->getInfo(); // Set focused application. - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); window->setFocusable(true); SCOPED_TRACE("Check default value of touch mode"); @@ -7141,7 +7238,7 @@ TEST_F(InputDispatcherTest, TouchModeState_IsSentToApps) { SCOPED_TRACE("Disable touch mode"); mDispatcher->setInTouchMode(false, windowInfo.ownerPid, windowInfo.ownerUid, - /*hasPermission=*/true, ADISPLAY_ID_DEFAULT); + /*hasPermission=*/true, ui::LogicalDisplayId::DEFAULT); window->consumeTouchModeEvent(false); window->setFocusable(true); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -7155,7 +7252,7 @@ TEST_F(InputDispatcherTest, TouchModeState_IsSentToApps) { SCOPED_TRACE("Enable touch mode again"); mDispatcher->setInTouchMode(true, windowInfo.ownerPid, windowInfo.ownerUid, - /*hasPermission=*/true, ADISPLAY_ID_DEFAULT); + /*hasPermission=*/true, ui::LogicalDisplayId::DEFAULT); window->consumeTouchModeEvent(true); window->setFocusable(true); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -7167,10 +7264,11 @@ TEST_F(InputDispatcherTest, TouchModeState_IsSentToApps) { TEST_F(InputDispatcherTest, VerifyInputEvent_KeyEvent) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Test window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Test window", + ui::LogicalDisplayId::DEFAULT); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); window->setFocusable(true); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -7205,23 +7303,24 @@ TEST_F(InputDispatcherTest, VerifyInputEvent_KeyEvent) { TEST_F(InputDispatcherTest, VerifyInputEvent_MotionEvent) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Test window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Test window", + ui::LogicalDisplayId::DEFAULT); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); ui::Transform transform; transform.set({1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 0, 0, 1}); gui::DisplayInfo displayInfo; - displayInfo.displayId = ADISPLAY_ID_DEFAULT; + displayInfo.displayId = ui::LogicalDisplayId::DEFAULT; displayInfo.transform = transform; mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {displayInfo}, 0, 0}); const NotifyMotionArgs motionArgs = generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); mDispatcher->notifyMotion(motionArgs); std::unique_ptr<MotionEvent> event = window->consumeMotionEvent(); @@ -7308,11 +7407,12 @@ TEST_F(InputDispatcherTest, GeneratedHmac_ChangesWhenFieldsChange) { TEST_F(InputDispatcherTest, SetFocusedWindow) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> windowTop = - sp<FakeWindowHandle>::make(application, mDispatcher, "Top", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> windowTop = sp<FakeWindowHandle>::make(application, mDispatcher, "Top", + ui::LogicalDisplayId::DEFAULT); sp<FakeWindowHandle> windowSecond = - sp<FakeWindowHandle>::make(application, mDispatcher, "Second", ADISPLAY_ID_DEFAULT); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + sp<FakeWindowHandle>::make(application, mDispatcher, "Second", + ui::LogicalDisplayId::DEFAULT); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); // Top window is also focusable but is not granted focus. windowTop->setFocusable(true); @@ -7326,15 +7426,15 @@ TEST_F(InputDispatcherTest, SetFocusedWindow) { << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; // Focused window should receive event. - windowSecond->consumeKeyDown(ui::ADISPLAY_ID_NONE); + windowSecond->consumeKeyDown(ui::LogicalDisplayId::INVALID); windowTop->assertNoEvents(); } TEST_F(InputDispatcherTest, SetFocusedWindow_DropRequestInvalidChannel) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "TestWindow", ADISPLAY_ID_DEFAULT); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "TestWindow", + ui::LogicalDisplayId::DEFAULT); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); window->setFocusable(true); // Release channel for window is no longer valid. @@ -7351,10 +7451,10 @@ TEST_F(InputDispatcherTest, SetFocusedWindow_DropRequestInvalidChannel) { TEST_F(InputDispatcherTest, SetFocusedWindow_DropRequestNoFocusableWindow) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "TestWindow", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "TestWindow", + ui::LogicalDisplayId::DEFAULT); window->setFocusable(false); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); setFocusedWindow(window); @@ -7368,11 +7468,12 @@ TEST_F(InputDispatcherTest, SetFocusedWindow_DropRequestNoFocusableWindow) { TEST_F(InputDispatcherTest, SetFocusedWindow_CheckFocusedToken) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> windowTop = - sp<FakeWindowHandle>::make(application, mDispatcher, "Top", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> windowTop = sp<FakeWindowHandle>::make(application, mDispatcher, "Top", + ui::LogicalDisplayId::DEFAULT); sp<FakeWindowHandle> windowSecond = - sp<FakeWindowHandle>::make(application, mDispatcher, "Second", ADISPLAY_ID_DEFAULT); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + sp<FakeWindowHandle>::make(application, mDispatcher, "Second", + ui::LogicalDisplayId::DEFAULT); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); windowTop->setFocusable(true); windowSecond->setFocusable(true); @@ -7391,16 +7492,17 @@ TEST_F(InputDispatcherTest, SetFocusedWindow_CheckFocusedToken) { << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; // Focused window should receive event. - windowSecond->consumeKeyDown(ui::ADISPLAY_ID_NONE); + windowSecond->consumeKeyDown(ui::LogicalDisplayId::INVALID); } TEST_F(InputDispatcherTest, SetFocusedWindow_TransferFocusTokenNotFocusable) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> windowTop = - sp<FakeWindowHandle>::make(application, mDispatcher, "Top", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> windowTop = sp<FakeWindowHandle>::make(application, mDispatcher, "Top", + ui::LogicalDisplayId::DEFAULT); sp<FakeWindowHandle> windowSecond = - sp<FakeWindowHandle>::make(application, mDispatcher, "Second", ADISPLAY_ID_DEFAULT); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + sp<FakeWindowHandle>::make(application, mDispatcher, "Second", + ui::LogicalDisplayId::DEFAULT); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); windowTop->setFocusable(true); windowSecond->setFocusable(false); @@ -7414,18 +7516,18 @@ TEST_F(InputDispatcherTest, SetFocusedWindow_TransferFocusTokenNotFocusable) { << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; // Event should be dropped. - windowTop->consumeKeyDown(ui::ADISPLAY_ID_NONE); + windowTop->consumeKeyDown(ui::LogicalDisplayId::INVALID); windowSecond->assertNoEvents(); } TEST_F(InputDispatcherTest, SetFocusedWindow_DeferInvisibleWindow) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "TestWindow", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "TestWindow", + ui::LogicalDisplayId::DEFAULT); sp<FakeWindowHandle> previousFocusedWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "previousFocusedWindow", - ADISPLAY_ID_DEFAULT); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + ui::LogicalDisplayId::DEFAULT); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); window->setFocusable(true); previousFocusedWindow->setFocusable(true); @@ -7442,7 +7544,7 @@ TEST_F(InputDispatcherTest, SetFocusedWindow_DeferInvisibleWindow) { // Injected key goes to pending queue. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, - ADISPLAY_ID_DEFAULT, InputEventInjectionSync::NONE)); + ui::LogicalDisplayId::DEFAULT, InputEventInjectionSync::NONE)); // Window does not get focus event or key down. window->assertNoEvents(); @@ -7454,14 +7556,14 @@ TEST_F(InputDispatcherTest, SetFocusedWindow_DeferInvisibleWindow) { // Window receives focus event. window->consumeFocusEvent(true); // Focused window receives key down. - window->consumeKeyDown(ADISPLAY_ID_DEFAULT); + window->consumeKeyDown(ui::LogicalDisplayId::DEFAULT); } TEST_F(InputDispatcherTest, DisplayRemoved) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "window", ADISPLAY_ID_DEFAULT); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "window", + ui::LogicalDisplayId::DEFAULT); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); // window is granted focus. window->setFocusable(true); @@ -7470,7 +7572,7 @@ TEST_F(InputDispatcherTest, DisplayRemoved) { window->consumeFocusEvent(true); // When a display is removed window loses focus. - mDispatcher->displayRemoved(ADISPLAY_ID_DEFAULT); + mDispatcher->displayRemoved(ui::LogicalDisplayId::DEFAULT); window->consumeFocusEvent(false); } @@ -7502,10 +7604,11 @@ TEST_F(InputDispatcherTest, SlipperyWindow_SetsFlagPartiallyObscured) { constexpr gui::Uid SLIPPERY_UID{WINDOW_UID.val() + 1}; std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); sp<FakeWindowHandle> slipperyExitWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Top", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Top", + ui::LogicalDisplayId::DEFAULT); slipperyExitWindow->setSlippery(true); // Make sure this one overlaps the bottom window slipperyExitWindow->setFrame(Rect(25, 25, 75, 75)); @@ -7514,7 +7617,8 @@ TEST_F(InputDispatcherTest, SlipperyWindow_SetsFlagPartiallyObscured) { slipperyExitWindow->setOwnerInfo(SLIPPERY_PID, SLIPPERY_UID); sp<FakeWindowHandle> slipperyEnterWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Second", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Second", + ui::LogicalDisplayId::DEFAULT); slipperyExitWindow->setFrame(Rect(0, 0, 100, 100)); mDispatcher->onWindowInfosChanged( @@ -7522,20 +7626,20 @@ TEST_F(InputDispatcherTest, SlipperyWindow_SetsFlagPartiallyObscured) { // Use notifyMotion instead of injecting to avoid dealing with injection permissions mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {{50, 50}})); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {{50, 50}})); slipperyExitWindow->consumeMotionDown(); slipperyExitWindow->setFrame(Rect(70, 70, 100, 100)); mDispatcher->onWindowInfosChanged( {{*slipperyExitWindow->getInfo(), *slipperyEnterWindow->getInfo()}, {}, 0, 0}); mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_MOVE, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {{51, 51}})); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {{51, 51}})); slipperyExitWindow->consumeMotionCancel(); - slipperyEnterWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, + slipperyEnterWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED); } @@ -7550,12 +7654,14 @@ TEST_F(InputDispatcherTest, TouchSlippingIntoWindowThatDropsTouches) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> leftSlipperyWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Left", + ui::LogicalDisplayId::DEFAULT); leftSlipperyWindow->setSlippery(true); leftSlipperyWindow->setFrame(Rect(0, 0, 100, 100)); sp<FakeWindowHandle> rightDropTouchesWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Right", + ui::LogicalDisplayId::DEFAULT); rightDropTouchesWindow->setFrame(Rect(100, 0, 200, 100)); rightDropTouchesWindow->setDropInput(true); @@ -7586,12 +7692,14 @@ TEST_F(InputDispatcherTest, TouchSlippingIntoWindowThatDropsTouches) { TEST_F(InputDispatcherTest, InjectedTouchSlips) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> originalWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Original", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Original", + ui::LogicalDisplayId::DEFAULT); originalWindow->setFrame(Rect(0, 0, 200, 200)); originalWindow->setSlippery(true); sp<FakeWindowHandle> appearingWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Appearing", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Appearing", + ui::LogicalDisplayId::DEFAULT); appearingWindow->setFrame(Rect(0, 0, 200, 200)); mDispatcher->onWindowInfosChanged({{*originalWindow->getInfo()}, {}, 0, 0}); @@ -7645,17 +7753,18 @@ TEST_F(InputDispatcherTest, MultiDeviceSpyWindowSlipTest) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect(0, 0, 100, 100)); leftWindow->setSlippery(true); sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); rightWindow->setFrame(Rect(100, 0, 200, 100)); sp<FakeWindowHandle> spyWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Spy Window", + ui::LogicalDisplayId::DEFAULT); spyWindow->setFrame(Rect(200, 0, 300, 100)); spyWindow->setSpy(true); spyWindow->setTrustedOverlay(true); @@ -7708,18 +7817,18 @@ TEST_F(InputDispatcherTest, MultiDeviceSlipperyWindowTest) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect(0, 0, 100, 100)); leftWindow->setSlippery(true); sp<FakeWindowHandle> middleWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "middle window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); middleWindow->setFrame(Rect(100, 0, 200, 100)); sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); rightWindow->setFrame(Rect(200, 0, 300, 100)); rightWindow->setSlippery(true); @@ -7778,20 +7887,21 @@ TEST_F(InputDispatcherTest, NotifiesDeviceInteractionsWithMotions) { using Uid = gui::Uid; std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> leftWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> leftWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Left", + ui::LogicalDisplayId::DEFAULT); leftWindow->setFrame(Rect(0, 0, 100, 100)); leftWindow->setOwnerInfo(gui::Pid{1}, Uid{101}); sp<FakeWindowHandle> rightSpy = - sp<FakeWindowHandle>::make(application, mDispatcher, "Right spy", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application, mDispatcher, "Right spy", + ui::LogicalDisplayId::DEFAULT); rightSpy->setFrame(Rect(100, 0, 200, 100)); rightSpy->setOwnerInfo(gui::Pid{2}, Uid{102}); rightSpy->setSpy(true); rightSpy->setTrustedOverlay(true); - sp<FakeWindowHandle> rightWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> rightWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Right", + ui::LogicalDisplayId::DEFAULT); rightWindow->setFrame(Rect(100, 0, 200, 100)); rightWindow->setOwnerInfo(gui::Pid{3}, Uid{103}); @@ -7856,8 +7966,8 @@ TEST_F(InputDispatcherTest, NotifiesDeviceInteractionsWithMotions) { TEST_F(InputDispatcherTest, NotifiesDeviceInteractionsWithKeys) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 100, 100)); window->setOwnerInfo(gui::Pid{1}, gui::Uid{101}); @@ -7866,14 +7976,14 @@ TEST_F(InputDispatcherTest, NotifiesDeviceInteractionsWithKeys) { ASSERT_NO_FATAL_FAILURE(window->consumeFocusEvent(true)); mDispatcher->notifyKey(KeyArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_KEYBOARD).build()); - ASSERT_NO_FATAL_FAILURE(window->consumeKeyDown(ADISPLAY_ID_DEFAULT)); + ASSERT_NO_FATAL_FAILURE(window->consumeKeyDown(ui::LogicalDisplayId::DEFAULT)); mDispatcher->waitForIdle(); ASSERT_NO_FATAL_FAILURE( mFakePolicy->assertNotifyDeviceInteractionWasCalled(DEVICE_ID, {gui::Uid{101}})); // The UP actions are not treated as device interaction. mDispatcher->notifyKey(KeyArgsBuilder(ACTION_UP, AINPUT_SOURCE_KEYBOARD).build()); - ASSERT_NO_FATAL_FAILURE(window->consumeKeyUp(ADISPLAY_ID_DEFAULT)); + ASSERT_NO_FATAL_FAILURE(window->consumeKeyUp(ui::LogicalDisplayId::DEFAULT)); mDispatcher->waitForIdle(); ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertNotifyDeviceInteractionWasNotCalled()); } @@ -7882,13 +7992,14 @@ TEST_F(InputDispatcherTest, HoverEnterExitSynthesisUsesNewEventId) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> left = sp<FakeWindowHandle>::make(application, mDispatcher, "Left Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); left->setFrame(Rect(0, 0, 100, 100)); - sp<FakeWindowHandle> right = sp<FakeWindowHandle>::make(application, mDispatcher, - "Right Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> right = + sp<FakeWindowHandle>::make(application, mDispatcher, "Right Window", + ui::LogicalDisplayId::DEFAULT); right->setFrame(Rect(100, 0, 200, 100)); - sp<FakeWindowHandle> spy = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> spy = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy Window", + ui::LogicalDisplayId::DEFAULT); spy->setFrame(Rect(0, 0, 200, 100)); spy->setTrustedOverlay(true); spy->setSpy(true); @@ -7897,8 +8008,9 @@ TEST_F(InputDispatcherTest, HoverEnterExitSynthesisUsesNewEventId) { {{*spy->getInfo(), *left->getInfo(), *right->getInfo()}, {}, 0, 0}); // Send hover move to the left window, and ensure hover enter is synthesized with a new eventId. - NotifyMotionArgs notifyArgs = generateMotionArgs(ACTION_HOVER_MOVE, AINPUT_SOURCE_STYLUS, - ADISPLAY_ID_DEFAULT, {PointF{50, 50}}); + NotifyMotionArgs notifyArgs = + generateMotionArgs(ACTION_HOVER_MOVE, AINPUT_SOURCE_STYLUS, + ui::LogicalDisplayId::DEFAULT, {PointF{50, 50}}); mDispatcher->notifyMotion(notifyArgs); std::unique_ptr<MotionEvent> leftEnter = left->consumeMotionEvent( @@ -7911,8 +8023,8 @@ TEST_F(InputDispatcherTest, HoverEnterExitSynthesisUsesNewEventId) { WithEventIdSource(IdGenerator::Source::INPUT_DISPATCHER))); // Send move to the right window, and ensure hover exit and enter are synthesized with new ids. - notifyArgs = generateMotionArgs(ACTION_HOVER_MOVE, AINPUT_SOURCE_STYLUS, ADISPLAY_ID_DEFAULT, - {PointF{150, 50}}); + notifyArgs = generateMotionArgs(ACTION_HOVER_MOVE, AINPUT_SOURCE_STYLUS, + ui::LogicalDisplayId::DEFAULT, {PointF{150, 50}}); mDispatcher->notifyMotion(notifyArgs); std::unique_ptr<MotionEvent> leftExit = left->consumeMotionEvent( @@ -7934,8 +8046,8 @@ TEST_F(InputDispatcherTest, HoverEnterExitSynthesisUsesNewEventId) { */ TEST_F(InputDispatcherMultiDeviceTest, SingleDevicePointerDownEventRetentionWithoutWindowTarget) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 100, 100)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -7960,8 +8072,8 @@ TEST_F(InputDispatcherMultiDeviceTest, SingleDevicePointerDownEventRetentionWith */ TEST_F(InputDispatcherMultiDeviceTest, SecondDeviceDownEventDroppedWithoutWindowTarget) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); window->setFrame(Rect(0, 0, 100, 100)); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); @@ -7991,7 +8103,8 @@ protected: mApp = std::make_shared<FakeApplicationHandle>(); - mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "Window", ADISPLAY_ID_DEFAULT); + mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "Window", + ui::LogicalDisplayId::DEFAULT); mWindow->setFrame(Rect(0, 0, 100, 100)); mDispatcher->onWindowInfosChanged({{*mWindow->getInfo()}, {}, 0, 0}); @@ -8303,7 +8416,8 @@ protected: void setUpWindow() { mApp = std::make_shared<FakeApplicationHandle>(); - mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "Fake Window", ADISPLAY_ID_DEFAULT); + mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "Fake Window", + ui::LogicalDisplayId::DEFAULT); mWindow->setFocusable(true); mDispatcher->onWindowInfosChanged({{*mWindow->getInfo()}, {}, 0, 0}); @@ -8312,13 +8426,14 @@ protected: } void sendAndConsumeKeyDown(int32_t deviceId) { - NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT); + NotifyKeyArgs keyArgs = + generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT); keyArgs.deviceId = deviceId; keyArgs.policyFlags |= POLICY_FLAG_TRUSTED; // Otherwise it won't generate repeat event mDispatcher->notifyKey(keyArgs); // Window should receive key down event. - mWindow->consumeKeyDown(ADISPLAY_ID_DEFAULT); + mWindow->consumeKeyDown(ui::LogicalDisplayId::DEFAULT); } void expectKeyRepeatOnce(int32_t repeatCount) { @@ -8328,19 +8443,21 @@ protected: } void sendAndConsumeKeyUp(int32_t deviceId) { - NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT); + NotifyKeyArgs keyArgs = + generateKeyArgs(AKEY_EVENT_ACTION_UP, ui::LogicalDisplayId::DEFAULT); keyArgs.deviceId = deviceId; keyArgs.policyFlags |= POLICY_FLAG_TRUSTED; // Unless it won't generate repeat event mDispatcher->notifyKey(keyArgs); // Window should receive key down event. - mWindow->consumeKeyUp(ADISPLAY_ID_DEFAULT, + mWindow->consumeKeyUp(ui::LogicalDisplayId::DEFAULT, /*expectedFlags=*/0); } void injectKeyRepeat(int32_t repeatCount) { ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, repeatCount, ADISPLAY_ID_DEFAULT)) + injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, repeatCount, + ui::LogicalDisplayId::DEFAULT)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; } }; @@ -8401,7 +8518,7 @@ TEST_F(InputDispatcherKeyRepeatTest, FocusedWindow_StopsKeyRepeatAfterDisableInp sendAndConsumeKeyDown(DEVICE_ID); expectKeyRepeatOnce(/*repeatCount=*/1); mDispatcher->notifyDeviceReset({/*id=*/10, /*eventTime=*/20, DEVICE_ID}); - mWindow->consumeKeyUp(ADISPLAY_ID_DEFAULT, + mWindow->consumeKeyUp(ui::LogicalDisplayId::DEFAULT, AKEY_EVENT_FLAG_CANCELED | AKEY_EVENT_FLAG_LONG_PRESS); mWindow->assertNoEvents(); } @@ -8433,7 +8550,7 @@ TEST_F(InputDispatcherKeyRepeatTest, FocusedWindow_RepeatKeyEventsUseUniqueEvent TEST_F(InputDispatcherKeyRepeatTest, FocusedWindow_CorrectRepeatCountWhenInjectKeyRepeat) { injectKeyRepeat(0); - mWindow->consumeKeyDown(ADISPLAY_ID_DEFAULT); + mWindow->consumeKeyDown(ui::LogicalDisplayId::DEFAULT); for (int32_t repeatCount = 1; repeatCount <= 2; ++repeatCount) { expectKeyRepeatOnce(repeatCount); } @@ -8449,11 +8566,11 @@ public: InputDispatcherTest::SetUp(); application1 = std::make_shared<FakeApplicationHandle>(); - windowInPrimary = - sp<FakeWindowHandle>::make(application1, mDispatcher, "D_1", ADISPLAY_ID_DEFAULT); + windowInPrimary = sp<FakeWindowHandle>::make(application1, mDispatcher, "D_1", + ui::LogicalDisplayId::DEFAULT); // Set focus window for primary display, but focused display would be second one. - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application1); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application1); windowInPrimary->setFocusable(true); mDispatcher->onWindowInfosChanged({{*windowInPrimary->getInfo()}, {}, 0, 0}); @@ -8494,9 +8611,10 @@ protected: TEST_F(InputDispatcherFocusOnTwoDisplaysTest, SetInputWindow_MultiDisplayTouch) { // Test touch down on primary display. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - windowInPrimary->consumeMotionDown(ADISPLAY_ID_DEFAULT); + windowInPrimary->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); windowInSecondary->assertNoEvents(); // Test touch down on second display. @@ -8510,22 +8628,22 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, SetInputWindow_MultiDisplayTouch) TEST_F(InputDispatcherFocusOnTwoDisplaysTest, SetInputWindow_MultiDisplayFocus) { // Test inject a key down with display id specified. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectKeyDownNoRepeat(*mDispatcher, ADISPLAY_ID_DEFAULT)) + injectKeyDownNoRepeat(*mDispatcher, ui::LogicalDisplayId::DEFAULT)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; - windowInPrimary->consumeKeyDown(ADISPLAY_ID_DEFAULT); + windowInPrimary->consumeKeyDown(ui::LogicalDisplayId::DEFAULT); windowInSecondary->assertNoEvents(); // Test inject a key down without display id specified. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDownNoRepeat(*mDispatcher)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; windowInPrimary->assertNoEvents(); - windowInSecondary->consumeKeyDown(ui::ADISPLAY_ID_NONE); + windowInSecondary->consumeKeyDown(ui::LogicalDisplayId::INVALID); // Remove all windows in secondary display. mDispatcher->onWindowInfosChanged({{*windowInPrimary->getInfo()}, {}, 0, 0}); // Old focus should receive a cancel event. - windowInSecondary->consumeKeyUp(ui::ADISPLAY_ID_NONE, AKEY_EVENT_FLAG_CANCELED); + windowInSecondary->consumeKeyUp(ui::LogicalDisplayId::INVALID, AKEY_EVENT_FLAG_CANCELED); // Test inject a key down, should timeout because of no target window. ASSERT_NO_FATAL_FAILURE(assertInjectedKeyTimesOut(*mDispatcher)); @@ -8537,16 +8655,17 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, SetInputWindow_MultiDisplayFocus) // Test per-display input monitors for motion event. TEST_F(InputDispatcherFocusOnTwoDisplaysTest, MonitorMotionEvent_MultiDisplay) { FakeMonitorReceiver monitorInPrimary = - FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT); + FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT); FakeMonitorReceiver monitorInSecondary = FakeMonitorReceiver(*mDispatcher, "M_2", SECOND_DISPLAY_ID); // Test touch down on primary display. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - windowInPrimary->consumeMotionDown(ADISPLAY_ID_DEFAULT); - monitorInPrimary.consumeMotionDown(ADISPLAY_ID_DEFAULT); + windowInPrimary->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); + monitorInPrimary.consumeMotionDown(ui::LogicalDisplayId::DEFAULT); windowInSecondary->assertNoEvents(); monitorInSecondary.assertNoEvents(); @@ -8570,19 +8689,20 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, MonitorMotionEvent_MultiDisplay) { // If specific a display, it will dispatch to the focused window of particular display, // or it will dispatch to the focused window of focused display. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TRACKBALL, ui::ADISPLAY_ID_NONE)) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TRACKBALL, + ui::LogicalDisplayId::INVALID)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; windowInPrimary->assertNoEvents(); monitorInPrimary.assertNoEvents(); - windowInSecondary->consumeMotionDown(ui::ADISPLAY_ID_NONE); - monitorInSecondary.consumeMotionDown(ui::ADISPLAY_ID_NONE); + windowInSecondary->consumeMotionDown(ui::LogicalDisplayId::INVALID); + monitorInSecondary.consumeMotionDown(ui::LogicalDisplayId::INVALID); } // Test per-display input monitors for key event. TEST_F(InputDispatcherFocusOnTwoDisplaysTest, MonitorKeyEvent_MultiDisplay) { // Input monitor per display. FakeMonitorReceiver monitorInPrimary = - FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT); + FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT); FakeMonitorReceiver monitorInSecondary = FakeMonitorReceiver(*mDispatcher, "M_2", SECOND_DISPLAY_ID); @@ -8591,13 +8711,14 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, MonitorKeyEvent_MultiDisplay) { << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; windowInPrimary->assertNoEvents(); monitorInPrimary.assertNoEvents(); - windowInSecondary->consumeKeyDown(ui::ADISPLAY_ID_NONE); - monitorInSecondary.consumeKeyDown(ui::ADISPLAY_ID_NONE); + windowInSecondary->consumeKeyDown(ui::LogicalDisplayId::INVALID); + monitorInSecondary.consumeKeyDown(ui::LogicalDisplayId::INVALID); } TEST_F(InputDispatcherFocusOnTwoDisplaysTest, CanFocusWindowOnUnfocusedDisplay) { sp<FakeWindowHandle> secondWindowInPrimary = - sp<FakeWindowHandle>::make(application1, mDispatcher, "D_1_W2", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(application1, mDispatcher, "D_1_W2", + ui::LogicalDisplayId::DEFAULT); secondWindowInPrimary->setFocusable(true); mDispatcher->onWindowInfosChanged( {{*windowInPrimary->getInfo(), *secondWindowInPrimary->getInfo(), @@ -8611,25 +8732,26 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, CanFocusWindowOnUnfocusedDisplay) // Test inject a key down. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectKeyDown(*mDispatcher, ADISPLAY_ID_DEFAULT)) + injectKeyDown(*mDispatcher, ui::LogicalDisplayId::DEFAULT)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; windowInPrimary->assertNoEvents(); windowInSecondary->assertNoEvents(); - secondWindowInPrimary->consumeKeyDown(ADISPLAY_ID_DEFAULT); + secondWindowInPrimary->consumeKeyDown(ui::LogicalDisplayId::DEFAULT); } TEST_F(InputDispatcherFocusOnTwoDisplaysTest, CancelTouch_MultiDisplay) { FakeMonitorReceiver monitorInPrimary = - FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT); + FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT); FakeMonitorReceiver monitorInSecondary = FakeMonitorReceiver(*mDispatcher, "M_2", SECOND_DISPLAY_ID); // Test touch down on primary display. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - windowInPrimary->consumeMotionDown(ADISPLAY_ID_DEFAULT); - monitorInPrimary.consumeMotionDown(ADISPLAY_ID_DEFAULT); + windowInPrimary->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); + monitorInPrimary.consumeMotionDown(ui::LogicalDisplayId::DEFAULT); // Test touch down on second display. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, @@ -8640,15 +8762,15 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, CancelTouch_MultiDisplay) { // Trigger cancel touch. mDispatcher->cancelCurrentTouch(); - windowInPrimary->consumeMotionCancel(ADISPLAY_ID_DEFAULT); - monitorInPrimary.consumeMotionCancel(ADISPLAY_ID_DEFAULT); + windowInPrimary->consumeMotionCancel(ui::LogicalDisplayId::DEFAULT); + monitorInPrimary.consumeMotionCancel(ui::LogicalDisplayId::DEFAULT); windowInSecondary->consumeMotionCancel(SECOND_DISPLAY_ID); monitorInSecondary.consumeMotionCancel(SECOND_DISPLAY_ID); // Test inject a move motion event, no window/monitor should receive the event. ASSERT_EQ(InputEventInjectionResult::FAILED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {110, 200})) + ui::LogicalDisplayId::DEFAULT, {110, 200})) << "Inject motion event should return InputEventInjectionResult::FAILED"; windowInPrimary->assertNoEvents(); monitorInPrimary.assertNoEvents(); @@ -8671,11 +8793,11 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, WhenDropKeyEvent_OnlyCancelCorresp // Send a key down on primary display mDispatcher->notifyKey( KeyArgsBuilder(AKEY_EVENT_ACTION_DOWN, AINPUT_SOURCE_KEYBOARD) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .policyFlags(DEFAULT_POLICY_FLAGS | POLICY_FLAG_DISABLE_KEY_REPEAT) .build()); - windowInPrimary->consumeKeyEvent( - AllOf(WithKeyAction(AKEY_EVENT_ACTION_DOWN), WithDisplayId(ADISPLAY_ID_DEFAULT))); + windowInPrimary->consumeKeyEvent(AllOf(WithKeyAction(AKEY_EVENT_ACTION_DOWN), + WithDisplayId(ui::LogicalDisplayId::DEFAULT))); windowInSecondary->assertNoEvents(); // Send a key down on second display @@ -8691,7 +8813,7 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, WhenDropKeyEvent_OnlyCancelCorresp // Send a valid key up event on primary display that will be dropped because it is stale NotifyKeyArgs staleKeyUp = KeyArgsBuilder(AKEY_EVENT_ACTION_UP, AINPUT_SOURCE_KEYBOARD) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .policyFlags(DEFAULT_POLICY_FLAGS | POLICY_FLAG_DISABLE_KEY_REPEAT) .build(); static constexpr std::chrono::duration STALE_EVENT_TIMEOUT = 10ms; @@ -8703,7 +8825,7 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, WhenDropKeyEvent_OnlyCancelCorresp // Therefore, windowInPrimary should get the cancel event and windowInSecondary should not // receive any events. windowInPrimary->consumeKeyEvent(AllOf(WithKeyAction(AKEY_EVENT_ACTION_UP), - WithDisplayId(ADISPLAY_ID_DEFAULT), + WithDisplayId(ui::LogicalDisplayId::DEFAULT), WithFlags(AKEY_EVENT_FLAG_CANCELED))); windowInSecondary->assertNoEvents(); } @@ -8716,10 +8838,10 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, WhenDropMotionEvent_OnlyCancelCorr mDispatcher->notifyMotion( MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(200)) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .build()); windowInPrimary->consumeMotionEvent( - AllOf(WithMotionAction(ACTION_DOWN), WithDisplayId(ADISPLAY_ID_DEFAULT))); + AllOf(WithMotionAction(ACTION_DOWN), WithDisplayId(ui::LogicalDisplayId::DEFAULT))); windowInSecondary->assertNoEvents(); // Send touch down on second display. @@ -8735,7 +8857,7 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, WhenDropMotionEvent_OnlyCancelCorr // inject a valid MotionEvent on primary display that will be stale when it arrives. NotifyMotionArgs staleMotionUp = MotionArgsBuilder(ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(200)) .build(); static constexpr std::chrono::duration STALE_EVENT_TIMEOUT = 10ms; @@ -8790,19 +8912,19 @@ protected: // Test InputFilter for MotionEvent TEST_F(InputFilterTest, MotionEvent_InputFilter) { // Since the InputFilter is disabled by default, check if touch events aren't filtered. - testNotifyMotion(ADISPLAY_ID_DEFAULT, /*expectToBeFiltered=*/false); + testNotifyMotion(ui::LogicalDisplayId::DEFAULT, /*expectToBeFiltered=*/false); testNotifyMotion(SECOND_DISPLAY_ID, /*expectToBeFiltered=*/false); // Enable InputFilter mDispatcher->setInputFilterEnabled(true); // Test touch on both primary and second display, and check if both events are filtered. - testNotifyMotion(ADISPLAY_ID_DEFAULT, /*expectToBeFiltered=*/true); + testNotifyMotion(ui::LogicalDisplayId::DEFAULT, /*expectToBeFiltered=*/true); testNotifyMotion(SECOND_DISPLAY_ID, /*expectToBeFiltered=*/true); // Disable InputFilter mDispatcher->setInputFilterEnabled(false); // Test touch on both primary and second display, and check if both events aren't filtered. - testNotifyMotion(ADISPLAY_ID_DEFAULT, /*expectToBeFiltered=*/false); + testNotifyMotion(ui::LogicalDisplayId::DEFAULT, /*expectToBeFiltered=*/false); testNotifyMotion(SECOND_DISPLAY_ID, /*expectToBeFiltered=*/false); } @@ -8831,7 +8953,7 @@ TEST_F(InputFilterTest, MotionEvent_UsesLogicalDisplayCoordinates_notifyMotion) secondDisplayTransform.set({-6.6, -5.5, -4.4, -3.3, -2.2, -1.1, 0, 0, 1}); std::vector<gui::DisplayInfo> displayInfos(2); - displayInfos[0].displayId = ADISPLAY_ID_DEFAULT; + displayInfos[0].displayId = ui::LogicalDisplayId::DEFAULT; displayInfos[0].transform = firstDisplayTransform; displayInfos[1].displayId = SECOND_DISPLAY_ID; displayInfos[1].transform = secondDisplayTransform; @@ -8842,7 +8964,8 @@ TEST_F(InputFilterTest, MotionEvent_UsesLogicalDisplayCoordinates_notifyMotion) mDispatcher->setInputFilterEnabled(true); // Ensure the correct transforms are used for the displays. - testNotifyMotion(ADISPLAY_ID_DEFAULT, /*expectToBeFiltered=*/true, firstDisplayTransform); + testNotifyMotion(ui::LogicalDisplayId::DEFAULT, /*expectToBeFiltered=*/true, + firstDisplayTransform); testNotifyMotion(SECOND_DISPLAY_ID, /*expectToBeFiltered=*/true, secondDisplayTransform); } @@ -8861,9 +8984,9 @@ protected: std::shared_ptr<InputApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); mWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Test Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); mWindow->setFocusable(true); mDispatcher->onWindowInfosChanged({{*mWindow->getInfo()}, {}, 0, 0}); setFocusedWindow(mWindow); @@ -8876,8 +8999,8 @@ protected: const nsecs_t eventTime = systemTime(SYSTEM_TIME_MONOTONIC); event.initialize(InputEvent::nextId(), injectedDeviceId, AINPUT_SOURCE_KEYBOARD, - ui::ADISPLAY_ID_NONE, INVALID_HMAC, AKEY_EVENT_ACTION_DOWN, 0, AKEYCODE_A, - KEY_A, AMETA_NONE, /*repeatCount=*/0, eventTime, eventTime); + ui::LogicalDisplayId::INVALID, INVALID_HMAC, AKEY_EVENT_ACTION_DOWN, 0, + AKEYCODE_A, KEY_A, AMETA_NONE, /*repeatCount=*/0, eventTime, eventTime); const int32_t additionalPolicyFlags = POLICY_FLAG_PASS_TO_USER | POLICY_FLAG_DISABLE_KEY_REPEAT; ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, @@ -8957,13 +9080,13 @@ protected: std::make_shared<FakeApplicationHandle>(); application->setDispatchingTimeout(100ms); mWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "TestWindow", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); mWindow->setFrame(Rect(0, 0, 100, 100)); mWindow->setDispatchingTimeout(100ms); mWindow->setFocusable(true); // Set focused application. - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); mDispatcher->onWindowInfosChanged({{*mWindow->getInfo()}, {}, 0, 0}); setFocusedWindow(mWindow); @@ -8991,50 +9114,55 @@ TEST_F_WITH_FLAGS( mDispatcher->setMinTimeBetweenUserActivityPokes(50ms); // First event of type TOUCH. Should poke. - notifyAndConsumeMotion(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, + notifyAndConsumeMotion(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, milliseconds_to_nanoseconds(50)); mFakePolicy->assertUserActivityPoked( - {{milliseconds_to_nanoseconds(50), USER_ACTIVITY_EVENT_TOUCH, ADISPLAY_ID_DEFAULT}}); + {{milliseconds_to_nanoseconds(50), USER_ACTIVITY_EVENT_TOUCH, + ui::LogicalDisplayId::DEFAULT}}); // 80ns > 50ns has passed since previous TOUCH event. Should poke. - notifyAndConsumeMotion(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, + notifyAndConsumeMotion(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, milliseconds_to_nanoseconds(130)); mFakePolicy->assertUserActivityPoked( - {{milliseconds_to_nanoseconds(130), USER_ACTIVITY_EVENT_TOUCH, ADISPLAY_ID_DEFAULT}}); + {{milliseconds_to_nanoseconds(130), USER_ACTIVITY_EVENT_TOUCH, + ui::LogicalDisplayId::DEFAULT}}); // First event of type OTHER. Should poke (despite being within 50ns of previous TOUCH event). - notifyAndConsumeMotion(ACTION_SCROLL, AINPUT_SOURCE_ROTARY_ENCODER, ADISPLAY_ID_DEFAULT, - milliseconds_to_nanoseconds(135)); + notifyAndConsumeMotion(ACTION_SCROLL, AINPUT_SOURCE_ROTARY_ENCODER, + ui::LogicalDisplayId::DEFAULT, milliseconds_to_nanoseconds(135)); mFakePolicy->assertUserActivityPoked( - {{milliseconds_to_nanoseconds(135), USER_ACTIVITY_EVENT_OTHER, ADISPLAY_ID_DEFAULT}}); + {{milliseconds_to_nanoseconds(135), USER_ACTIVITY_EVENT_OTHER, + ui::LogicalDisplayId::DEFAULT}}); // Within 50ns of previous TOUCH event. Should NOT poke. - notifyAndConsumeMotion(ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, + notifyAndConsumeMotion(ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, milliseconds_to_nanoseconds(140)); mFakePolicy->assertUserActivityNotPoked(); // Within 50ns of previous OTHER event. Should NOT poke. - notifyAndConsumeMotion(ACTION_SCROLL, AINPUT_SOURCE_ROTARY_ENCODER, ADISPLAY_ID_DEFAULT, - milliseconds_to_nanoseconds(150)); + notifyAndConsumeMotion(ACTION_SCROLL, AINPUT_SOURCE_ROTARY_ENCODER, + ui::LogicalDisplayId::DEFAULT, milliseconds_to_nanoseconds(150)); mFakePolicy->assertUserActivityNotPoked(); // Within 50ns of previous TOUCH event (which was at time 130). Should NOT poke. // Note that STYLUS is mapped to TOUCH user activity, since it's a pointer-type source. - notifyAndConsumeMotion(ACTION_DOWN, AINPUT_SOURCE_STYLUS, ADISPLAY_ID_DEFAULT, + notifyAndConsumeMotion(ACTION_DOWN, AINPUT_SOURCE_STYLUS, ui::LogicalDisplayId::DEFAULT, milliseconds_to_nanoseconds(160)); mFakePolicy->assertUserActivityNotPoked(); // 65ns > 50ns has passed since previous OTHER event. Should poke. - notifyAndConsumeMotion(ACTION_SCROLL, AINPUT_SOURCE_ROTARY_ENCODER, ADISPLAY_ID_DEFAULT, - milliseconds_to_nanoseconds(200)); + notifyAndConsumeMotion(ACTION_SCROLL, AINPUT_SOURCE_ROTARY_ENCODER, + ui::LogicalDisplayId::DEFAULT, milliseconds_to_nanoseconds(200)); mFakePolicy->assertUserActivityPoked( - {{milliseconds_to_nanoseconds(200), USER_ACTIVITY_EVENT_OTHER, ADISPLAY_ID_DEFAULT}}); + {{milliseconds_to_nanoseconds(200), USER_ACTIVITY_EVENT_OTHER, + ui::LogicalDisplayId::DEFAULT}}); // 170ns > 50ns has passed since previous TOUCH event. Should poke. - notifyAndConsumeMotion(ACTION_UP, AINPUT_SOURCE_STYLUS, ADISPLAY_ID_DEFAULT, + notifyAndConsumeMotion(ACTION_UP, AINPUT_SOURCE_STYLUS, ui::LogicalDisplayId::DEFAULT, milliseconds_to_nanoseconds(300)); mFakePolicy->assertUserActivityPoked( - {{milliseconds_to_nanoseconds(300), USER_ACTIVITY_EVENT_TOUCH, ADISPLAY_ID_DEFAULT}}); + {{milliseconds_to_nanoseconds(300), USER_ACTIVITY_EVENT_TOUCH, + ui::LogicalDisplayId::DEFAULT}}); // Assert that there's no more user activity poke event. mFakePolicy->assertUserActivityNotPoked(); @@ -9044,19 +9172,21 @@ TEST_F_WITH_FLAGS( InputDispatcherUserActivityPokeTests, DefaultMinPokeTimeOf100MsUsed, REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(com::android::input::flags, rate_limit_user_activity_poke_in_dispatcher))) { - notifyAndConsumeMotion(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, + notifyAndConsumeMotion(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, milliseconds_to_nanoseconds(200)); mFakePolicy->assertUserActivityPoked( - {{milliseconds_to_nanoseconds(200), USER_ACTIVITY_EVENT_TOUCH, ADISPLAY_ID_DEFAULT}}); + {{milliseconds_to_nanoseconds(200), USER_ACTIVITY_EVENT_TOUCH, + ui::LogicalDisplayId::DEFAULT}}); - notifyAndConsumeMotion(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, + notifyAndConsumeMotion(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, milliseconds_to_nanoseconds(280)); mFakePolicy->assertUserActivityNotPoked(); - notifyAndConsumeMotion(ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, + notifyAndConsumeMotion(ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, milliseconds_to_nanoseconds(340)); mFakePolicy->assertUserActivityPoked( - {{milliseconds_to_nanoseconds(340), USER_ACTIVITY_EVENT_TOUCH, ADISPLAY_ID_DEFAULT}}); + {{milliseconds_to_nanoseconds(340), USER_ACTIVITY_EVENT_TOUCH, + ui::LogicalDisplayId::DEFAULT}}); } TEST_F_WITH_FLAGS( @@ -9065,10 +9195,12 @@ TEST_F_WITH_FLAGS( rate_limit_user_activity_poke_in_dispatcher))) { mDispatcher->setMinTimeBetweenUserActivityPokes(0ms); - notifyAndConsumeMotion(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, 20); + notifyAndConsumeMotion(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, + 20); mFakePolicy->assertUserActivityPoked(); - notifyAndConsumeMotion(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, 30); + notifyAndConsumeMotion(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, + 30); mFakePolicy->assertUserActivityPoked(); } @@ -9078,16 +9210,16 @@ class InputDispatcherOnPointerDownOutsideFocus : public InputDispatcherTest { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - mUnfocusedWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Top", ADISPLAY_ID_DEFAULT); + mUnfocusedWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Top", + ui::LogicalDisplayId::DEFAULT); mUnfocusedWindow->setFrame(Rect(0, 0, 30, 30)); - mFocusedWindow = - sp<FakeWindowHandle>::make(application, mDispatcher, "Second", ADISPLAY_ID_DEFAULT); + mFocusedWindow = sp<FakeWindowHandle>::make(application, mDispatcher, "Second", + ui::LogicalDisplayId::DEFAULT); mFocusedWindow->setFrame(Rect(50, 50, 100, 100)); // Set focused application. - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); mFocusedWindow->setFocusable(true); // Expect one focus window exist in display. @@ -9115,8 +9247,8 @@ protected: // the onPointerDownOutsideFocus callback. TEST_F(InputDispatcherOnPointerDownOutsideFocus, OnPointerDownOutsideFocus_Success) { ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {20, 20})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {20, 20})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; mUnfocusedWindow->consumeMotionDown(); @@ -9129,7 +9261,7 @@ TEST_F(InputDispatcherOnPointerDownOutsideFocus, OnPointerDownOutsideFocus_Succe // onPointerDownOutsideFocus callback. TEST_F(InputDispatcherOnPointerDownOutsideFocus, OnPointerDownOutsideFocus_NonPointerSource) { ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TRACKBALL, ADISPLAY_ID_DEFAULT, + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TRACKBALL, ui::LogicalDisplayId::DEFAULT, {20, 20})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; mFocusedWindow->consumeMotionDown(); @@ -9142,9 +9274,9 @@ TEST_F(InputDispatcherOnPointerDownOutsideFocus, OnPointerDownOutsideFocus_NonPo // have focus. Ensure no window received the onPointerDownOutsideFocus callback. TEST_F(InputDispatcherOnPointerDownOutsideFocus, OnPointerDownOutsideFocus_NonMotionFailure) { ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectKeyDownNoRepeat(*mDispatcher, ADISPLAY_ID_DEFAULT)) + injectKeyDownNoRepeat(*mDispatcher, ui::LogicalDisplayId::DEFAULT)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; - mFocusedWindow->consumeKeyDown(ADISPLAY_ID_DEFAULT); + mFocusedWindow->consumeKeyDown(ui::LogicalDisplayId::DEFAULT); ASSERT_TRUE(mDispatcher->waitForIdle()); mFakePolicy->assertOnPointerDownWasNotCalled(); @@ -9155,8 +9287,8 @@ TEST_F(InputDispatcherOnPointerDownOutsideFocus, OnPointerDownOutsideFocus_NonMo // onPointerDownOutsideFocus callback. TEST_F(InputDispatcherOnPointerDownOutsideFocus, OnPointerDownOutsideFocus_OnAlreadyFocusedWindow) { ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - FOCUSED_WINDOW_TOUCH_POINT)) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, FOCUSED_WINDOW_TOUCH_POINT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; mFocusedWindow->consumeMotionDown(); @@ -9175,7 +9307,8 @@ TEST_F(InputDispatcherOnPointerDownOutsideFocus, NoFocusChangeFlag) { .build(); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, event)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mUnfocusedWindow->consumeAnyMotionDown(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mUnfocusedWindow->consumeAnyMotionDown(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); ASSERT_TRUE(mDispatcher->waitForIdle()); mFakePolicy->assertOnPointerDownWasNotCalled(); @@ -9192,10 +9325,10 @@ class InputDispatcherMultiWindowSameTokenTests : public InputDispatcherTest { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); mWindow1 = sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window 1", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); mWindow1->setFrame(Rect(0, 0, 100, 100)); - mWindow2 = mWindow1->clone(ADISPLAY_ID_DEFAULT); + mWindow2 = mWindow1->clone(ui::LogicalDisplayId::DEFAULT); mWindow2->setFrame(Rect(100, 100, 200, 200)); mDispatcher->onWindowInfosChanged({{*mWindow1->getInfo(), *mWindow2->getInfo()}, {}, 0, 0}); @@ -9236,7 +9369,7 @@ protected: const std::vector<PointF>& touchedPoints, std::vector<PointF> expectedPoints) { mDispatcher->notifyMotion(generateMotionArgs(action, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, touchedPoints)); + ui::LogicalDisplayId::DEFAULT, touchedPoints)); consumeMotionEvent(touchedWindow, action, expectedPoints); } @@ -9383,14 +9516,14 @@ TEST_F(InputDispatcherMultiWindowSameTokenTests, TouchDoesNotSlipEvenIfSlippery) // Touch down in window 1 mDispatcher->notifyMotion(generateMotionArgs(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {{50, 50}})); + ui::LogicalDisplayId::DEFAULT, {{50, 50}})); consumeMotionEvent(mWindow1, ACTION_DOWN, {{50, 50}}); // Move touch to be above window 2. Even though window 1 is slippery, touch should not slip. // That means the gesture should continue normally, without any ACTION_CANCEL or ACTION_DOWN // getting generated. mDispatcher->notifyMotion(generateMotionArgs(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {{150, 150}})); + ui::LogicalDisplayId::DEFAULT, {{150, 150}})); consumeMotionEvent(mWindow1, ACTION_MOVE, {{150, 150}}); } @@ -9425,13 +9558,13 @@ class InputDispatcherSingleWindowAnr : public InputDispatcherTest { mApplication = std::make_shared<FakeApplicationHandle>(); mApplication->setDispatchingTimeout(100ms); mWindow = sp<FakeWindowHandle>::make(mApplication, mDispatcher, "TestWindow", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); mWindow->setFrame(Rect(0, 0, 30, 30)); mWindow->setDispatchingTimeout(100ms); mWindow->setFocusable(true); // Set focused application. - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApplication); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, mApplication); mDispatcher->onWindowInfosChanged({{*mWindow->getInfo()}, {}, 0, 0}); setFocusedWindow(mWindow); @@ -9462,8 +9595,8 @@ protected: } sp<FakeWindowHandle> addSpyWindow() { - sp<FakeWindowHandle> spy = - sp<FakeWindowHandle>::make(mApplication, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> spy = sp<FakeWindowHandle>::make(mApplication, mDispatcher, "Spy", + ui::LogicalDisplayId::DEFAULT); spy->setTrustedOverlay(true); spy->setFocusable(false); spy->setSpy(true); @@ -9485,7 +9618,7 @@ TEST_F(InputDispatcherSingleWindowAnr, WhenTouchIsConsumed_NoAnr) { // Send a regular key and respond, which should not cause an ANR. TEST_F(InputDispatcherSingleWindowAnr, WhenKeyIsConsumed_NoAnr) { ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDownNoRepeat(*mDispatcher)); - mWindow->consumeKeyDown(ui::ADISPLAY_ID_NONE); + mWindow->consumeKeyDown(ui::LogicalDisplayId::INVALID); ASSERT_TRUE(mDispatcher->waitForIdle()); mFakePolicy->assertNotifyAnrWasNotCalled(); } @@ -9496,15 +9629,16 @@ TEST_F(InputDispatcherSingleWindowAnr, WhenFocusedApplicationChanges_NoAnr) { mWindow->consumeFocusEvent(false); InputEventInjectionResult result = - injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, ADISPLAY_ID_DEFAULT, - InputEventInjectionSync::NONE, CONSUME_TIMEOUT_EVENT_EXPECTED, + injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, + ui::LogicalDisplayId::DEFAULT, InputEventInjectionSync::NONE, + CONSUME_TIMEOUT_EVENT_EXPECTED, /*allowKeyRepeat=*/false); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, result); // Key will not go to window because we have no focused window. // The 'no focused window' ANR timer should start instead. // Now, the focused application goes away. - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, nullptr); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, nullptr); // The key should get dropped and there should be no ANR. ASSERT_TRUE(mDispatcher->waitForIdle()); @@ -9516,8 +9650,8 @@ TEST_F(InputDispatcherSingleWindowAnr, WhenFocusedApplicationChanges_NoAnr) { // So InputDispatcher will enqueue ACTION_CANCEL event as well. TEST_F(InputDispatcherSingleWindowAnr, OnPointerDown_BasicAnr) { ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - WINDOW_LOCATION)); + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, WINDOW_LOCATION)); const auto [sequenceNum, _] = mWindow->receiveEvent(); // ACTION_DOWN ASSERT_TRUE(sequenceNum); @@ -9526,7 +9660,7 @@ TEST_F(InputDispatcherSingleWindowAnr, OnPointerDown_BasicAnr) { mWindow->finishEvent(*sequenceNum); mWindow->consumeMotionEvent( - AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ADISPLAY_ID_DEFAULT))); + AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ui::LogicalDisplayId::DEFAULT))); ASSERT_TRUE(mDispatcher->waitForIdle()); mFakePolicy->assertNotifyWindowResponsiveWasCalled(mWindow->getToken(), mWindow->getPid()); } @@ -9550,8 +9684,8 @@ TEST_F(InputDispatcherSingleWindowAnr, FocusedApplication_NoFocusedWindow) { // taps on the window work as normal ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - WINDOW_LOCATION)); + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, WINDOW_LOCATION)); ASSERT_NO_FATAL_FAILURE(mWindow->consumeMotionDown()); mDispatcher->waitForIdle(); mFakePolicy->assertNotifyAnrWasNotCalled(); @@ -9560,8 +9694,8 @@ TEST_F(InputDispatcherSingleWindowAnr, FocusedApplication_NoFocusedWindow) { // We specify the injection timeout to be smaller than the application timeout, to ensure that // injection times out (instead of failing). const InputEventInjectionResult result = - injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, ADISPLAY_ID_DEFAULT, - InputEventInjectionSync::WAIT_FOR_RESULT, 50ms, + injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, + ui::LogicalDisplayId::DEFAULT, InputEventInjectionSync::WAIT_FOR_RESULT, 50ms, /*allowKeyRepeat=*/false); ASSERT_EQ(InputEventInjectionResult::TIMED_OUT, result); const std::chrono::duration timeout = mApplication->getDispatchingTimeout(DISPATCHING_TIMEOUT); @@ -9585,9 +9719,10 @@ TEST_F(InputDispatcherSingleWindowAnr, StaleKeyEventDoesNotAnr) { std::chrono::nanoseconds(STALE_EVENT_TIMEOUT).count(); // Define a valid key down event that is stale (too old). - event.initialize(InputEvent::nextId(), DEVICE_ID, AINPUT_SOURCE_KEYBOARD, ui::ADISPLAY_ID_NONE, - INVALID_HMAC, AKEY_EVENT_ACTION_DOWN, /*flags=*/0, AKEYCODE_A, KEY_A, - AMETA_NONE, /*repeatCount=*/0, eventTime, eventTime); + event.initialize(InputEvent::nextId(), DEVICE_ID, AINPUT_SOURCE_KEYBOARD, + ui::LogicalDisplayId::INVALID, INVALID_HMAC, AKEY_EVENT_ACTION_DOWN, + /*flags=*/0, AKEYCODE_A, KEY_A, AMETA_NONE, /*repeatCount=*/0, eventTime, + eventTime); const int32_t policyFlags = POLICY_FLAG_FILTERED | POLICY_FLAG_PASS_TO_USER | POLICY_FLAG_DISABLE_KEY_REPEAT; @@ -9609,7 +9744,7 @@ TEST_F(InputDispatcherSingleWindowAnr, StaleKeyEventDoesNotAnr) { TEST_F(InputDispatcherSingleWindowAnr, NoFocusedWindow_DoesNotSendDuplicateAnr) { const std::chrono::duration appTimeout = 400ms; mApplication->setDispatchingTimeout(appTimeout); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApplication); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, mApplication); mWindow->setFocusable(false); mDispatcher->onWindowInfosChanged({{*mWindow->getInfo()}, {}, 0, 0}); @@ -9621,8 +9756,9 @@ TEST_F(InputDispatcherSingleWindowAnr, NoFocusedWindow_DoesNotSendDuplicateAnr) const std::chrono::duration eventInjectionTimeout = 100ms; ASSERT_LT(eventInjectionTimeout, appTimeout); const InputEventInjectionResult result = - injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, ADISPLAY_ID_DEFAULT, - InputEventInjectionSync::WAIT_FOR_RESULT, eventInjectionTimeout, + injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, + ui::LogicalDisplayId::DEFAULT, InputEventInjectionSync::WAIT_FOR_RESULT, + eventInjectionTimeout, /*allowKeyRepeat=*/false); ASSERT_EQ(InputEventInjectionResult::TIMED_OUT, result) << "result=" << ftl::enum_string(result); @@ -9670,20 +9806,20 @@ TEST_F(InputDispatcherSingleWindowAnr, NoFocusedWindow_DropsFocusedEvents) { TEST_F(InputDispatcherSingleWindowAnr, Anr_HandlesEventsWithIdenticalTimestamps) { nsecs_t currentTime = systemTime(SYSTEM_TIME_MONOTONIC); injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, WINDOW_LOCATION, + ui::LogicalDisplayId::DEFAULT, WINDOW_LOCATION, {AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_CURSOR_POSITION}, 500ms, InputEventInjectionSync::WAIT_FOR_RESULT, currentTime); // Now send ACTION_UP, with identical timestamp injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, WINDOW_LOCATION, + ui::LogicalDisplayId::DEFAULT, WINDOW_LOCATION, {AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_CURSOR_POSITION}, 500ms, InputEventInjectionSync::WAIT_FOR_RESULT, currentTime); // We have now sent down and up. Let's consume first event and then ANR on the second. - mWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT); + mWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); const std::chrono::duration timeout = mWindow->getDispatchingTimeout(DISPATCHING_TIMEOUT); mFakePolicy->assertNotifyWindowUnresponsiveWasCalled(timeout, mWindow); } @@ -9693,8 +9829,8 @@ TEST_F(InputDispatcherSingleWindowAnr, SpyWindowAnr) { sp<FakeWindowHandle> spy = addSpyWindow(); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - WINDOW_LOCATION)); + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, WINDOW_LOCATION)); mWindow->consumeMotionDown(); const auto [sequenceNum, _] = spy->receiveEvent(); // ACTION_DOWN @@ -9704,7 +9840,7 @@ TEST_F(InputDispatcherSingleWindowAnr, SpyWindowAnr) { spy->finishEvent(*sequenceNum); spy->consumeMotionEvent( - AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ADISPLAY_ID_DEFAULT))); + AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ui::LogicalDisplayId::DEFAULT))); ASSERT_TRUE(mDispatcher->waitForIdle()); mFakePolicy->assertNotifyWindowResponsiveWasCalled(spy->getToken(), mWindow->getPid()); } @@ -9715,9 +9851,10 @@ TEST_F(InputDispatcherSingleWindowAnr, SpyWindowReceivesEventsDuringAppAnrOnKey) sp<FakeWindowHandle> spy = addSpyWindow(); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectKeyDown(*mDispatcher, ADISPLAY_ID_DEFAULT)); - mWindow->consumeKeyDown(ADISPLAY_ID_DEFAULT); - ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyUp(*mDispatcher, ADISPLAY_ID_DEFAULT)); + injectKeyDown(*mDispatcher, ui::LogicalDisplayId::DEFAULT)); + mWindow->consumeKeyDown(ui::LogicalDisplayId::DEFAULT); + ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, + injectKeyUp(*mDispatcher, ui::LogicalDisplayId::DEFAULT)); // Stuck on the ACTION_UP const std::chrono::duration timeout = mWindow->getDispatchingTimeout(DISPATCHING_TIMEOUT); @@ -9725,10 +9862,10 @@ TEST_F(InputDispatcherSingleWindowAnr, SpyWindowReceivesEventsDuringAppAnrOnKey) // New tap will go to the spy window, but not to the window tapOnWindow(); - spy->consumeMotionDown(ADISPLAY_ID_DEFAULT); - spy->consumeMotionUp(ADISPLAY_ID_DEFAULT); + spy->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); + spy->consumeMotionUp(ui::LogicalDisplayId::DEFAULT); - mWindow->consumeKeyUp(ADISPLAY_ID_DEFAULT); // still the previous motion + mWindow->consumeKeyUp(ui::LogicalDisplayId::DEFAULT); // still the previous motion mDispatcher->waitForIdle(); mFakePolicy->assertNotifyWindowResponsiveWasCalled(mWindow->getToken(), mWindow->getPid()); mWindow->assertNoEvents(); @@ -9741,8 +9878,8 @@ TEST_F(InputDispatcherSingleWindowAnr, SpyWindowReceivesEventsDuringAppAnrOnMoti sp<FakeWindowHandle> spy = addSpyWindow(); tapOnWindow(); - spy->consumeMotionDown(ADISPLAY_ID_DEFAULT); - spy->consumeMotionUp(ADISPLAY_ID_DEFAULT); + spy->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); + spy->consumeMotionUp(ui::LogicalDisplayId::DEFAULT); mWindow->consumeMotionDown(); // Stuck on the ACTION_UP @@ -9751,10 +9888,10 @@ TEST_F(InputDispatcherSingleWindowAnr, SpyWindowReceivesEventsDuringAppAnrOnMoti // New tap will go to the spy window, but not to the window tapOnWindow(); - spy->consumeMotionDown(ADISPLAY_ID_DEFAULT); - spy->consumeMotionUp(ADISPLAY_ID_DEFAULT); + spy->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); + spy->consumeMotionUp(ui::LogicalDisplayId::DEFAULT); - mWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT); // still the previous motion + mWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT); // still the previous motion mDispatcher->waitForIdle(); mFakePolicy->assertNotifyWindowResponsiveWasCalled(mWindow->getToken(), mWindow->getPid()); mWindow->assertNoEvents(); @@ -9764,13 +9901,14 @@ TEST_F(InputDispatcherSingleWindowAnr, SpyWindowReceivesEventsDuringAppAnrOnMoti TEST_F(InputDispatcherSingleWindowAnr, UnresponsiveMonitorAnr) { mDispatcher->setMonitorDispatchingTimeoutForTest(SPY_TIMEOUT); - FakeMonitorReceiver monitor = FakeMonitorReceiver(*mDispatcher, "M_1", ADISPLAY_ID_DEFAULT); + FakeMonitorReceiver monitor = + FakeMonitorReceiver(*mDispatcher, "M_1", ui::LogicalDisplayId::DEFAULT); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - WINDOW_LOCATION)); + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, WINDOW_LOCATION)); - mWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT); + mWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); const std::optional<uint32_t> consumeSeq = monitor.receiveEvent(); ASSERT_TRUE(consumeSeq); @@ -9778,7 +9916,7 @@ TEST_F(InputDispatcherSingleWindowAnr, UnresponsiveMonitorAnr) { MONITOR_PID); monitor.finishEvent(*consumeSeq); - monitor.consumeMotionCancel(ADISPLAY_ID_DEFAULT); + monitor.consumeMotionCancel(ui::LogicalDisplayId::DEFAULT); ASSERT_TRUE(mDispatcher->waitForIdle()); mFakePolicy->assertNotifyWindowResponsiveWasCalled(monitor.getToken(), MONITOR_PID); @@ -9817,8 +9955,8 @@ TEST_F(InputDispatcherSingleWindowAnr, SameWindow_CanReceiveAnrTwice) { // it. TEST_F(InputDispatcherSingleWindowAnr, Policy_DoesNotGetDuplicateAnr) { ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - WINDOW_LOCATION)); + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, WINDOW_LOCATION)); const std::chrono::duration windowTimeout = mWindow->getDispatchingTimeout(DISPATCHING_TIMEOUT); mFakePolicy->assertNotifyWindowUnresponsiveWasCalled(windowTimeout, mWindow); @@ -9828,7 +9966,7 @@ TEST_F(InputDispatcherSingleWindowAnr, Policy_DoesNotGetDuplicateAnr) { // When the ANR happened, dispatcher should abort the current event stream via ACTION_CANCEL mWindow->consumeMotionDown(); mWindow->consumeMotionEvent( - AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ADISPLAY_ID_DEFAULT))); + AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ui::LogicalDisplayId::DEFAULT))); mWindow->assertNoEvents(); mDispatcher->waitForIdle(); mFakePolicy->assertNotifyWindowResponsiveWasCalled(mWindow->getToken(), mWindow->getPid()); @@ -9865,7 +10003,7 @@ TEST_F(InputDispatcherSingleWindowAnr, Key_StaysPendingWhileMotionIsProcessed) { std::this_thread::sleep_for(400ms); // if we wait long enough though, dispatcher will give up, and still send the key // to the focused window, even though we have not yet finished the motion event - mWindow->consumeKeyDown(ADISPLAY_ID_DEFAULT); + mWindow->consumeKeyDown(ui::LogicalDisplayId::DEFAULT); mWindow->finishEvent(*downSequenceNum); mWindow->finishEvent(*upSequenceNum); } @@ -9969,8 +10107,8 @@ TEST_F(InputDispatcherSingleWindowAnr, TwoGesturesWithAnr) { // So InputDispatcher will enqueue ACTION_CANCEL event as well. TEST_F(InputDispatcherSingleWindowAnr, AnrAfterWindowRemoval) { mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {WINDOW_LOCATION})); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {WINDOW_LOCATION})); const auto [sequenceNum, _] = mWindow->receiveEvent(); // ACTION_DOWN ASSERT_TRUE(sequenceNum); @@ -9987,7 +10125,7 @@ TEST_F(InputDispatcherSingleWindowAnr, AnrAfterWindowRemoval) { mWindow->finishEvent(*sequenceNum); // The cancellation was generated when the window was removed, along with the focus event. mWindow->consumeMotionEvent( - AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ADISPLAY_ID_DEFAULT))); + AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ui::LogicalDisplayId::DEFAULT))); mWindow->consumeFocusEvent(false); ASSERT_TRUE(mDispatcher->waitForIdle()); mFakePolicy->assertNotifyWindowResponsiveWasCalled(mWindow->getToken(), /*pid=*/std::nullopt); @@ -9997,8 +10135,8 @@ TEST_F(InputDispatcherSingleWindowAnr, AnrAfterWindowRemoval) { // notified of the unresponsive window, then remove the app window. TEST_F(InputDispatcherSingleWindowAnr, AnrFollowedByWindowRemoval) { mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {WINDOW_LOCATION})); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {WINDOW_LOCATION})); const auto [sequenceNum, _] = mWindow->receiveEvent(); // ACTION_DOWN ASSERT_TRUE(sequenceNum); @@ -10011,7 +10149,7 @@ TEST_F(InputDispatcherSingleWindowAnr, AnrFollowedByWindowRemoval) { mWindow->finishEvent(*sequenceNum); // The cancellation was generated during the ANR, and the window lost focus when it was removed. mWindow->consumeMotionEvent( - AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ADISPLAY_ID_DEFAULT))); + AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ui::LogicalDisplayId::DEFAULT))); mWindow->consumeFocusEvent(false); ASSERT_TRUE(mDispatcher->waitForIdle()); // Since the window was removed, Dispatcher does not know the PID associated with the window @@ -10026,18 +10164,18 @@ class InputDispatcherMultiWindowAnr : public InputDispatcherTest { mApplication = std::make_shared<FakeApplicationHandle>(); mApplication->setDispatchingTimeout(100ms); mUnfocusedWindow = sp<FakeWindowHandle>::make(mApplication, mDispatcher, "Unfocused", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); mUnfocusedWindow->setFrame(Rect(0, 0, 30, 30)); // Adding FLAG_WATCH_OUTSIDE_TOUCH to receive ACTION_OUTSIDE when another window is tapped mUnfocusedWindow->setWatchOutsideTouch(true); mFocusedWindow = sp<FakeWindowHandle>::make(mApplication, mDispatcher, "Focused", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); mFocusedWindow->setDispatchingTimeout(100ms); mFocusedWindow->setFrame(Rect(50, 50, 100, 100)); // Set focused application. - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApplication); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, mApplication); mFocusedWindow->setFocusable(true); // Expect one focus window exist in display. @@ -10069,11 +10207,11 @@ protected: private: void tap(const PointF& location) { ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - location)); + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, location)); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - location)); + injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, location)); } }; @@ -10098,7 +10236,7 @@ TEST_F(InputDispatcherMultiWindowAnr, TwoWindows_BothUnresponsive) { .build())); mFocusedWindow->consumeMotionDown(); mFocusedWindow->consumeMotionUp(); - mUnfocusedWindow->consumeMotionOutside(ADISPLAY_ID_DEFAULT, /*flags=*/0); + mUnfocusedWindow->consumeMotionOutside(ui::LogicalDisplayId::DEFAULT, /*flags=*/0); // We consumed all events, so no ANR ASSERT_TRUE(mDispatcher->waitForIdle()); mFakePolicy->assertNotifyAnrWasNotCalled(); @@ -10174,7 +10312,7 @@ TEST_F(InputDispatcherMultiWindowAnr, TwoWindows_BothUnresponsiveWithSameTimeout // At the same time, FLAG_WATCH_OUTSIDE_TOUCH targets should not receive any events. TEST_F(InputDispatcherMultiWindowAnr, DuringAnr_SecondTapIsIgnored) { tapOnFocusedWindow(); - mUnfocusedWindow->consumeMotionOutside(ADISPLAY_ID_DEFAULT, /*flags=*/0); + mUnfocusedWindow->consumeMotionOutside(ui::LogicalDisplayId::DEFAULT, /*flags=*/0); // Receive the events, but don't respond const auto [downEventSequenceNum, downEvent] = mFocusedWindow->receiveEvent(); // ACTION_DOWN ASSERT_TRUE(downEventSequenceNum); @@ -10187,10 +10325,10 @@ TEST_F(InputDispatcherMultiWindowAnr, DuringAnr_SecondTapIsIgnored) { // Tap once again // We cannot use "tapOnFocusedWindow" because it asserts the injection result to be success ASSERT_EQ(InputEventInjectionResult::FAILED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - FOCUSED_WINDOW_LOCATION)); + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, FOCUSED_WINDOW_LOCATION)); ASSERT_EQ(InputEventInjectionResult::FAILED, - injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, + injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, FOCUSED_WINDOW_LOCATION)); // Unfocused window does not receive ACTION_OUTSIDE because the tapped window is not a // valid touch target @@ -10211,8 +10349,8 @@ TEST_F(InputDispatcherMultiWindowAnr, DuringAnr_SecondTapIsIgnored) { // If you tap outside of all windows, there will not be ANR TEST_F(InputDispatcherMultiWindowAnr, TapOutsideAllWindows_DoesNotAnr) { ASSERT_EQ(InputEventInjectionResult::FAILED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - LOCATION_OUTSIDE_ALL_WINDOWS)); + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, LOCATION_OUTSIDE_ALL_WINDOWS)); ASSERT_TRUE(mDispatcher->waitForIdle()); mFakePolicy->assertNotifyAnrWasNotCalled(); } @@ -10224,8 +10362,8 @@ TEST_F(InputDispatcherMultiWindowAnr, Window_CanBePaused) { {{*mUnfocusedWindow->getInfo(), *mFocusedWindow->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::FAILED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - FOCUSED_WINDOW_LOCATION)); + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, FOCUSED_WINDOW_LOCATION)); std::this_thread::sleep_for(mFocusedWindow->getDispatchingTimeout(DISPATCHING_TIMEOUT)); ASSERT_TRUE(mDispatcher->waitForIdle()); @@ -10265,8 +10403,8 @@ TEST_F(InputDispatcherMultiWindowAnr, PendingKey_GoesToNewlyFocusedWindow) { // window even if motions are still being processed. InputEventInjectionResult result = - injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, ADISPLAY_ID_DEFAULT, - InputEventInjectionSync::NONE, + injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, + ui::LogicalDisplayId::DEFAULT, InputEventInjectionSync::NONE, /*injectionTimeout=*/100ms); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, result); // Key will not be sent to the window, yet, because the window is still processing events @@ -10293,7 +10431,7 @@ TEST_F(InputDispatcherMultiWindowAnr, PendingKey_GoesToNewlyFocusedWindow) { // Now that all queues are cleared and no backlog in the connections, the key event // can finally go to the newly focused "mUnfocusedWindow". - mUnfocusedWindow->consumeKeyDown(ADISPLAY_ID_DEFAULT); + mUnfocusedWindow->consumeKeyDown(ui::LogicalDisplayId::DEFAULT); mFocusedWindow->assertNoEvents(); mUnfocusedWindow->assertNoEvents(); mFakePolicy->assertNotifyAnrWasNotCalled(); @@ -10304,14 +10442,15 @@ TEST_F(InputDispatcherMultiWindowAnr, PendingKey_GoesToNewlyFocusedWindow) { // The other window should not be affected by that. TEST_F(InputDispatcherMultiWindowAnr, SplitTouch_SingleWindowAnr) { // Touch Window 1 - mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {FOCUSED_WINDOW_LOCATION})); - mUnfocusedWindow->consumeMotionOutside(ADISPLAY_ID_DEFAULT, /*flags=*/0); + mDispatcher->notifyMotion( + generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {FOCUSED_WINDOW_LOCATION})); + mUnfocusedWindow->consumeMotionOutside(ui::LogicalDisplayId::DEFAULT, /*flags=*/0); // Touch Window 2 mDispatcher->notifyMotion( - generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, + generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {FOCUSED_WINDOW_LOCATION, UNFOCUSED_WINDOW_LOCATION})); const std::chrono::duration timeout = @@ -10357,7 +10496,7 @@ TEST_F(InputDispatcherMultiWindowAnr, FocusedWindowWithoutSetFocusedApplication_ std::shared_ptr<FakeApplicationHandle> focusedApplication = std::make_shared<FakeApplicationHandle>(); focusedApplication->setDispatchingTimeout(300ms); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, focusedApplication); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, focusedApplication); // The application that owns 'mFocusedWindow' and 'mUnfocusedWindow' is not focused. mFocusedWindow->setFocusable(false); @@ -10369,8 +10508,8 @@ TEST_F(InputDispatcherMultiWindowAnr, FocusedWindowWithoutSetFocusedApplication_ // 'focusedApplication' will get blamed if this timer completes. // Key will not be sent anywhere because we have no focused window. It will remain pending. InputEventInjectionResult result = - injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, ADISPLAY_ID_DEFAULT, - InputEventInjectionSync::NONE, + injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, + ui::LogicalDisplayId::DEFAULT, InputEventInjectionSync::NONE, /*injectionTimeout=*/100ms, /*allowKeyRepeat=*/false); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, result); @@ -10385,9 +10524,9 @@ TEST_F(InputDispatcherMultiWindowAnr, FocusedWindowWithoutSetFocusedApplication_ std::this_thread::sleep_for(100ms); // Touch unfocused window. This should force the pending key to get dropped. - mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {UNFOCUSED_WINDOW_LOCATION})); + mDispatcher->notifyMotion( + generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {UNFOCUSED_WINDOW_LOCATION})); // We do not consume the motion right away, because that would require dispatcher to first // process (== drop) the key event, and by that time, ANR will be raised. @@ -10440,20 +10579,20 @@ TEST_F(InputDispatcherMultiWindowAnr, PruningInputQueueShouldNotDropPointerEvent mFakePolicy->setStaleEventTimeout(3000ms); sp<FakeWindowHandle> navigationBar = sp<FakeWindowHandle>::make(systemUiApplication, mDispatcher, "NavigationBar", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); navigationBar->setFocusable(false); navigationBar->setWatchOutsideTouch(true); navigationBar->setFrame(Rect(0, 0, 100, 100)); mApplication->setDispatchingTimeout(3000ms); // 'mApplication' is already focused, but we call it again here to make it explicit. - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApplication); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, mApplication); std::shared_ptr<FakeApplicationHandle> anotherApplication = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> appWindow = sp<FakeWindowHandle>::make(anotherApplication, mDispatcher, "Another window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); appWindow->setFocusable(false); appWindow->setFrame(Rect(100, 100, 200, 200)); @@ -10472,8 +10611,8 @@ TEST_F(InputDispatcherMultiWindowAnr, PruningInputQueueShouldNotDropPointerEvent // Key will not be sent anywhere because we have no focused window. It will remain pending. // Pretend we are injecting KEYCODE_BACK, but it doesn't actually matter what key it is. InputEventInjectionResult result = - injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, ADISPLAY_ID_DEFAULT, - InputEventInjectionSync::NONE, + injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, + ui::LogicalDisplayId::DEFAULT, InputEventInjectionSync::NONE, /*injectionTimeout=*/100ms, /*allowKeyRepeat=*/false); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, result); @@ -10482,8 +10621,8 @@ TEST_F(InputDispatcherMultiWindowAnr, PruningInputQueueShouldNotDropPointerEvent mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN) .pointer(PointerBuilder(0, ToolType::FINGER).x(50).y(50)) .build()); - result = injectKey(*mDispatcher, AKEY_EVENT_ACTION_UP, /*repeatCount=*/0, ADISPLAY_ID_DEFAULT, - InputEventInjectionSync::NONE, + result = injectKey(*mDispatcher, AKEY_EVENT_ACTION_UP, /*repeatCount=*/0, + ui::LogicalDisplayId::DEFAULT, InputEventInjectionSync::NONE, /*injectionTimeout=*/100ms, /*allowKeyRepeat=*/false); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, result); @@ -10519,16 +10658,16 @@ class InputDispatcherMultiWindowOcclusionTests : public InputDispatcherTest { InputDispatcherTest::SetUp(); mApplication = std::make_shared<FakeApplicationHandle>(); - mNoInputWindow = - sp<FakeWindowHandle>::make(mApplication, mDispatcher, - "Window without input channel", ADISPLAY_ID_DEFAULT, - /*createInputChannel=*/false); + mNoInputWindow = sp<FakeWindowHandle>::make(mApplication, mDispatcher, + "Window without input channel", + ui::LogicalDisplayId::DEFAULT, + /*createInputChannel=*/false); mNoInputWindow->setNoInputChannel(true); mNoInputWindow->setFrame(Rect(0, 0, 100, 100)); // It's perfectly valid for this window to not have an associated input channel mBottomWindow = sp<FakeWindowHandle>::make(mApplication, mDispatcher, "Bottom window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); mBottomWindow->setFrame(Rect(0, 0, 100, 100)); mDispatcher->onWindowInfosChanged( @@ -10545,8 +10684,8 @@ TEST_F(InputDispatcherMultiWindowOcclusionTests, NoInputChannelFeature_DropsTouc PointF touchedPoint = {10, 10}; mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {touchedPoint})); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {touchedPoint})); mNoInputWindow->assertNoEvents(); // Even though the window 'mNoInputWindow' positioned above 'mBottomWindow' does not have @@ -10563,7 +10702,7 @@ TEST_F(InputDispatcherMultiWindowOcclusionTests, NoInputChannelFeature_DropsTouchesWithValidChannel) { mNoInputWindow = sp<FakeWindowHandle>::make(mApplication, mDispatcher, "Window with input channel and NO_INPUT_CHANNEL", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); mNoInputWindow->setNoInputChannel(true); mNoInputWindow->setFrame(Rect(0, 0, 100, 100)); @@ -10573,8 +10712,8 @@ TEST_F(InputDispatcherMultiWindowOcclusionTests, PointF touchedPoint = {10, 10}; mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {touchedPoint})); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {touchedPoint})); mNoInputWindow->assertNoEvents(); mBottomWindow->assertNoEvents(); @@ -10589,9 +10728,10 @@ protected: virtual void SetUp() override { InputDispatcherTest::SetUp(); mApp = std::make_shared<FakeApplicationHandle>(); - mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow", ADISPLAY_ID_DEFAULT); - mMirror = mWindow->clone(ADISPLAY_ID_DEFAULT); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApp); + mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow", + ui::LogicalDisplayId::DEFAULT); + mMirror = mWindow->clone(ui::LogicalDisplayId::DEFAULT); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, mApp); mWindow->setFocusable(true); mMirror->setFocusable(true); mDispatcher->onWindowInfosChanged({{*mWindow->getInfo(), *mMirror->getInfo()}, {}, 0, 0}); @@ -10606,7 +10746,7 @@ TEST_F(InputDispatcherMirrorWindowFocusTests, CanGetFocus) { mWindow->consumeFocusEvent(true); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDown(*mDispatcher)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; - mWindow->consumeKeyDown(ui::ADISPLAY_ID_NONE); + mWindow->consumeKeyDown(ui::LogicalDisplayId::INVALID); } // A focused & mirrored window remains focused only if the window and its mirror are both @@ -10618,10 +10758,10 @@ TEST_F(InputDispatcherMirrorWindowFocusTests, FocusedIfAllWindowsFocusable) { mWindow->consumeFocusEvent(true); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDown(*mDispatcher)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; - mWindow->consumeKeyDown(ui::ADISPLAY_ID_NONE); + mWindow->consumeKeyDown(ui::LogicalDisplayId::INVALID); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyUp(*mDispatcher)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; - mWindow->consumeKeyUp(ui::ADISPLAY_ID_NONE); + mWindow->consumeKeyUp(ui::LogicalDisplayId::INVALID); mMirror->setFocusable(false); mDispatcher->onWindowInfosChanged({{*mWindow->getInfo(), *mMirror->getInfo()}, {}, 0, 0}); @@ -10643,20 +10783,20 @@ TEST_F(InputDispatcherMirrorWindowFocusTests, FocusedIfAnyWindowVisible) { mWindow->consumeFocusEvent(true); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDown(*mDispatcher)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; - mWindow->consumeKeyDown(ui::ADISPLAY_ID_NONE); + mWindow->consumeKeyDown(ui::LogicalDisplayId::INVALID); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyUp(*mDispatcher)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; - mWindow->consumeKeyUp(ui::ADISPLAY_ID_NONE); + mWindow->consumeKeyUp(ui::LogicalDisplayId::INVALID); mMirror->setVisible(false); mDispatcher->onWindowInfosChanged({{*mWindow->getInfo(), *mMirror->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDown(*mDispatcher)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; - mWindow->consumeKeyDown(ui::ADISPLAY_ID_NONE); + mWindow->consumeKeyDown(ui::LogicalDisplayId::INVALID); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyUp(*mDispatcher)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; - mWindow->consumeKeyUp(ui::ADISPLAY_ID_NONE); + mWindow->consumeKeyUp(ui::LogicalDisplayId::INVALID); mWindow->setVisible(false); mDispatcher->onWindowInfosChanged({{*mWindow->getInfo(), *mMirror->getInfo()}, {}, 0, 0}); @@ -10677,20 +10817,20 @@ TEST_F(InputDispatcherMirrorWindowFocusTests, FocusedWhileWindowsAlive) { mWindow->consumeFocusEvent(true); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDown(*mDispatcher)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; - mWindow->consumeKeyDown(ui::ADISPLAY_ID_NONE); + mWindow->consumeKeyDown(ui::LogicalDisplayId::INVALID); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyUp(*mDispatcher)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; - mWindow->consumeKeyUp(ui::ADISPLAY_ID_NONE); + mWindow->consumeKeyUp(ui::LogicalDisplayId::INVALID); // single window is removed but the window token remains focused mDispatcher->onWindowInfosChanged({{*mMirror->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDown(*mDispatcher)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; - mMirror->consumeKeyDown(ui::ADISPLAY_ID_NONE); + mMirror->consumeKeyDown(ui::LogicalDisplayId::INVALID); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyUp(*mDispatcher)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; - mMirror->consumeKeyUp(ui::ADISPLAY_ID_NONE); + mMirror->consumeKeyUp(ui::LogicalDisplayId::INVALID); // Both windows are removed mDispatcher->onWindowInfosChanged({{}, {}, 0, 0}); @@ -10712,7 +10852,7 @@ TEST_F(InputDispatcherMirrorWindowFocusTests, DeferFocusWhenInvisible) { // Injected key goes to pending queue. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKey(*mDispatcher, AKEY_EVENT_ACTION_DOWN, /*repeatCount=*/0, - ADISPLAY_ID_DEFAULT, InputEventInjectionSync::NONE)); + ui::LogicalDisplayId::DEFAULT, InputEventInjectionSync::NONE)); mMirror->setVisible(true); mDispatcher->onWindowInfosChanged({{*mWindow->getInfo(), *mMirror->getInfo()}, {}, 0, 0}); @@ -10720,7 +10860,7 @@ TEST_F(InputDispatcherMirrorWindowFocusTests, DeferFocusWhenInvisible) { // window gets focused mWindow->consumeFocusEvent(true); // window gets the pending key event - mWindow->consumeKeyDown(ADISPLAY_ID_DEFAULT); + mWindow->consumeKeyDown(ui::LogicalDisplayId::DEFAULT); } class InputDispatcherPointerCaptureTests : public InputDispatcherTest { @@ -10732,13 +10872,14 @@ protected: void SetUp() override { InputDispatcherTest::SetUp(); mApp = std::make_shared<FakeApplicationHandle>(); - mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow", ADISPLAY_ID_DEFAULT); + mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow", + ui::LogicalDisplayId::DEFAULT); mWindow->setFocusable(true); - mSecondWindow = - sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow2", ADISPLAY_ID_DEFAULT); + mSecondWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow2", + ui::LogicalDisplayId::DEFAULT); mSecondWindow->setFocusable(true); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApp); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, mApp); mDispatcher->onWindowInfosChanged( {{*mWindow->getInfo(), *mSecondWindow->getInfo()}, {}, 0, 0}); @@ -10977,7 +11118,7 @@ protected: sp<FakeWindowHandle> getWindow(gui::Uid uid, std::string name) { std::shared_ptr<FakeApplicationHandle> app = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> window = - sp<FakeWindowHandle>::make(app, mDispatcher, name, ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle>::make(app, mDispatcher, name, ui::LogicalDisplayId::DEFAULT); // Generate an arbitrary PID based on the UID window->setOwnerInfo(gui::Pid{static_cast<pid_t>(1777 + (uid.val() % 10000))}, uid); return window; @@ -10985,8 +11126,8 @@ protected: void touch(const std::vector<PointF>& points = {PointF{100, 200}}) { mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - points)); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, points)); } }; @@ -11351,20 +11492,21 @@ protected: void SetUp() override { InputDispatcherTest::SetUp(); mApp = std::make_shared<FakeApplicationHandle>(); - mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow", ADISPLAY_ID_DEFAULT); + mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow", + ui::LogicalDisplayId::DEFAULT); mWindow->setFrame(Rect(0, 0, 100, 100)); - mSecondWindow = - sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow2", ADISPLAY_ID_DEFAULT); + mSecondWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow2", + ui::LogicalDisplayId::DEFAULT); mSecondWindow->setFrame(Rect(100, 0, 200, 100)); - mSpyWindow = - sp<FakeWindowHandle>::make(mApp, mDispatcher, "SpyWindow", ADISPLAY_ID_DEFAULT); + mSpyWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "SpyWindow", + ui::LogicalDisplayId::DEFAULT); mSpyWindow->setSpy(true); mSpyWindow->setTrustedOverlay(true); mSpyWindow->setFrame(Rect(0, 0, 200, 100)); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApp); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, mApp); mDispatcher->onWindowInfosChanged( {{*mSpyWindow->getInfo(), *mWindow->getInfo(), *mSecondWindow->getInfo()}, {}, @@ -11377,7 +11519,7 @@ protected: case AINPUT_SOURCE_TOUCHSCREEN: ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {50, 50})) + ui::LogicalDisplayId::DEFAULT, {50, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; break; case AINPUT_SOURCE_STYLUS: @@ -11409,9 +11551,9 @@ protected: } // Window should receive motion event. - mWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT); + mWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); // Spy window should also receive motion event - mSpyWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT); + mSpyWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); } // Start performing drag, we will create a drag window and transfer touch to it. @@ -11423,8 +11565,8 @@ protected: } // The drag window covers the entire display - mDragWindow = - sp<FakeWindowHandle>::make(mApp, mDispatcher, "DragWindow", ADISPLAY_ID_DEFAULT); + mDragWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "DragWindow", + ui::LogicalDisplayId::DEFAULT); mDragWindow->setTouchableRegion(Region{{0, 0, 0, 0}}); mDispatcher->onWindowInfosChanged({{*mDragWindow->getInfo(), *mSpyWindow->getInfo(), *mWindow->getInfo(), *mSecondWindow->getInfo()}, @@ -11438,7 +11580,8 @@ protected: /*isDragDrop=*/true); if (transferred) { mWindow->consumeMotionCancel(); - mDragWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); } return transferred; } @@ -11450,35 +11593,38 @@ TEST_F(InputDispatcherDragTests, DragEnterAndDragExit) { // Move on window. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {50, 50})) + ui::LogicalDisplayId::DEFAULT, {50, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mWindow->consumeDragEvent(false, 50, 50); mSecondWindow->assertNoEvents(); // Move to another window. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {150, 50})) + ui::LogicalDisplayId::DEFAULT, {150, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mWindow->consumeDragEvent(true, 150, 50); mSecondWindow->consumeDragEvent(false, 50, 50); // Move back to original window. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {50, 50})) + ui::LogicalDisplayId::DEFAULT, {50, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mWindow->consumeDragEvent(false, 50, 50); mSecondWindow->consumeDragEvent(true, -50, 50); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, + injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, {50, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mWindow->assertNoEvents(); mSecondWindow->assertNoEvents(); } @@ -11513,27 +11659,29 @@ TEST_F(InputDispatcherDragTests, DragAndDrop) { // Move on window. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {50, 50})) + ui::LogicalDisplayId::DEFAULT, {50, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mWindow->consumeDragEvent(false, 50, 50); mSecondWindow->assertNoEvents(); // Move to another window. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {150, 50})) + ui::LogicalDisplayId::DEFAULT, {150, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mWindow->consumeDragEvent(true, 150, 50); mSecondWindow->consumeDragEvent(false, 50, 50); // drop to another window. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, + injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, {150, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mFakePolicy->assertDropTargetEquals(*mDispatcher, mSecondWindow->getToken()); mWindow->assertNoEvents(); mSecondWindow->assertNoEvents(); @@ -11595,7 +11743,8 @@ TEST_F(InputDispatcherDragTests, StylusDragAndDrop) { .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50)) .build())) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mWindow->consumeDragEvent(false, 50, 50); mSecondWindow->assertNoEvents(); @@ -11607,7 +11756,8 @@ TEST_F(InputDispatcherDragTests, StylusDragAndDrop) { .pointer(PointerBuilder(0, ToolType::STYLUS).x(150).y(50)) .build())) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mWindow->assertNoEvents(); mSecondWindow->assertNoEvents(); mFakePolicy->assertDropTargetEquals(*mDispatcher, mSecondWindow->getToken()); @@ -11620,7 +11770,7 @@ TEST_F(InputDispatcherDragTests, StylusDragAndDrop) { .pointer(PointerBuilder(0, ToolType::STYLUS).x(150).y(50)) .build())) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mWindow->assertNoEvents(); mSecondWindow->assertNoEvents(); } @@ -11636,27 +11786,29 @@ TEST_F(InputDispatcherDragTests, DragAndDropOnInvalidWindow) { // Move on window. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {50, 50})) + ui::LogicalDisplayId::DEFAULT, {50, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mWindow->consumeDragEvent(false, 50, 50); mSecondWindow->assertNoEvents(); // Move to another window. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {150, 50})) + ui::LogicalDisplayId::DEFAULT, {150, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mWindow->consumeDragEvent(true, 150, 50); mSecondWindow->assertNoEvents(); // drop to another window. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, + injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, {150, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mFakePolicy->assertDropTargetEquals(*mDispatcher, nullptr); mWindow->assertNoEvents(); mSecondWindow->assertNoEvents(); @@ -11667,14 +11819,14 @@ TEST_F(InputDispatcherDragTests, NoDragAndDropWhenMultiFingers) { mWindow->setPreventSplitting(true); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {50, 50})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {50, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT); + mWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); const MotionEvent secondFingerDownEvent = MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .eventTime(systemTime(SYSTEM_TIME_MONOTONIC)) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(50).y(50)) .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(75).y(50)) @@ -11692,16 +11844,16 @@ TEST_F(InputDispatcherDragTests, NoDragAndDropWhenMultiFingers) { TEST_F(InputDispatcherDragTests, DragAndDropWhenSplitTouch) { // First down on second window. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {150, 50})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {150, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mSecondWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT); + mSecondWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); // Second down on first window. const MotionEvent secondFingerDownEvent = MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .eventTime(systemTime(SYSTEM_TIME_MONOTONIC)) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(150).y(50)) .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50)) @@ -11710,8 +11862,8 @@ TEST_F(InputDispatcherDragTests, DragAndDropWhenSplitTouch) { injectMotionEvent(*mDispatcher, secondFingerDownEvent, INJECT_EVENT_TIMEOUT, InputEventInjectionSync::WAIT_FOR_RESULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mWindow->consumeMotionDown(ADISPLAY_ID_DEFAULT); - mSecondWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT); + mWindow->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); + mSecondWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT); // Perform drag and drop from first window. ASSERT_TRUE(startDrag(false)); @@ -11726,7 +11878,8 @@ TEST_F(InputDispatcherDragTests, DragAndDropWhenSplitTouch) { ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, secondFingerMoveEvent, INJECT_EVENT_TIMEOUT, InputEventInjectionSync::WAIT_FOR_RESULT)); - mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mWindow->consumeDragEvent(false, 50, 50); mSecondWindow->consumeMotionMove(); @@ -11740,7 +11893,7 @@ TEST_F(InputDispatcherDragTests, DragAndDropWhenSplitTouch) { ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, secondFingerUpEvent, INJECT_EVENT_TIMEOUT, InputEventInjectionSync::WAIT_FOR_RESULT)); - mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mFakePolicy->assertDropTargetEquals(*mDispatcher, mWindow->getToken()); mWindow->assertNoEvents(); mSecondWindow->consumeMotionMove(); @@ -11779,27 +11932,29 @@ TEST_F(InputDispatcherDragTests, DragAndDropWhenMultiDisplays) { // Move on window. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {50, 50})) + ui::LogicalDisplayId::DEFAULT, {50, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mWindow->consumeDragEvent(false, 50, 50); mSecondWindow->assertNoEvents(); // Move to another window. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {150, 50})) + ui::LogicalDisplayId::DEFAULT, {150, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mWindow->consumeDragEvent(true, 150, 50); mSecondWindow->consumeDragEvent(false, 50, 50); // drop to another window. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, + injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, {150, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mFakePolicy->assertDropTargetEquals(*mDispatcher, mSecondWindow->getToken()); mWindow->assertNoEvents(); mSecondWindow->assertNoEvents(); @@ -11817,7 +11972,8 @@ TEST_F(InputDispatcherDragTests, MouseDragAndDrop) { .y(50)) .build())) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mWindow->consumeDragEvent(false, 50, 50); mSecondWindow->assertNoEvents(); @@ -11831,7 +11987,8 @@ TEST_F(InputDispatcherDragTests, MouseDragAndDrop) { .y(50)) .build())) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionMove(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mWindow->consumeDragEvent(true, 150, 50); mSecondWindow->consumeDragEvent(false, 50, 50); @@ -11845,7 +12002,7 @@ TEST_F(InputDispatcherDragTests, MouseDragAndDrop) { .y(50)) .build())) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); + mDragWindow->consumeMotionUp(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE); mFakePolicy->assertDropTargetEquals(*mDispatcher, mSecondWindow->getToken()); mWindow->assertNoEvents(); mSecondWindow->assertNoEvents(); @@ -11858,8 +12015,8 @@ TEST_F(InputDispatcherDragTests, MouseDragAndDrop) { TEST_F(InputDispatcherDragTests, DragAndDropFinishedWhenCancelCurrentTouch) { // Down on second window ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {150, 50})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {150, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; ASSERT_NO_FATAL_FAILURE(mSecondWindow->consumeMotionDown()); @@ -11868,7 +12025,7 @@ TEST_F(InputDispatcherDragTests, DragAndDropFinishedWhenCancelCurrentTouch) { // Down on first window const MotionEvent secondFingerDownEvent = MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(150).y(50)) .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50)) .build(); @@ -11886,7 +12043,7 @@ TEST_F(InputDispatcherDragTests, DragAndDropFinishedWhenCancelCurrentTouch) { // Trigger cancel mDispatcher->cancelCurrentTouch(); ASSERT_NO_FATAL_FAILURE(mSecondWindow->consumeMotionCancel()); - ASSERT_NO_FATAL_FAILURE(mDragWindow->consumeMotionCancel(ADISPLAY_ID_DEFAULT, + ASSERT_NO_FATAL_FAILURE(mDragWindow->consumeMotionCancel(ui::LogicalDisplayId::DEFAULT, AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE)); ASSERT_NO_FATAL_FAILURE(mSpyWindow->consumeMotionCancel()); @@ -11899,14 +12056,14 @@ TEST_F(InputDispatcherDragTests, DragAndDropFinishedWhenCancelCurrentTouch) { // Inject a simple gesture, ensure dispatcher not crashed ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - PointF{50, 50})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, PointF{50, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; ASSERT_NO_FATAL_FAILURE(mWindow->consumeMotionDown()); const MotionEvent moveEvent = MotionEventBuilder(AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(50).y(50)) .build(); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, @@ -11916,7 +12073,7 @@ TEST_F(InputDispatcherDragTests, DragAndDropFinishedWhenCancelCurrentTouch) { ASSERT_NO_FATAL_FAILURE(mWindow->consumeMotionMove()); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, + injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ui::LogicalDisplayId::DEFAULT, {50, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; ASSERT_NO_FATAL_FAILURE(mWindow->consumeMotionUp()); @@ -11926,7 +12083,7 @@ TEST_F(InputDispatcherDragTests, NoDragAndDropWithHoveringPointer) { // Start hovering over the window. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, ACTION_HOVER_ENTER, AINPUT_SOURCE_MOUSE, - ADISPLAY_ID_DEFAULT, {50, 50})); + ui::LogicalDisplayId::DEFAULT, {50, 50})); ASSERT_NO_FATAL_FAILURE(mWindow->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER))); ASSERT_NO_FATAL_FAILURE(mSpyWindow->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER))); @@ -11939,23 +12096,25 @@ class InputDispatcherDropInputFeatureTest : public InputDispatcherTest {}; TEST_F(InputDispatcherDropInputFeatureTest, WindowDropsInput) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Test window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Test window", + ui::LogicalDisplayId::DEFAULT); window->setDropInput(true); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); window->setFocusable(true); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); setFocusedWindow(window); window->consumeFocusEvent(/*hasFocus=*/true, /*inTouchMode=*/true); // With the flag set, window should not get any input - mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT)); + mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT)); window->assertNoEvents(); mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)); mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT)); + ui::LogicalDisplayId::DEFAULT)); mDispatcher->waitForIdle(); window->assertNoEvents(); @@ -11963,12 +12122,13 @@ TEST_F(InputDispatcherDropInputFeatureTest, WindowDropsInput) { window->setDropInput(false); mDispatcher->onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0}); - mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT)); - window->consumeKeyUp(ADISPLAY_ID_DEFAULT); + mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ui::LogicalDisplayId::DEFAULT)); + window->consumeKeyUp(ui::LogicalDisplayId::DEFAULT); mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)); - window->consumeMotionDown(ADISPLAY_ID_DEFAULT); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)); + window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); window->assertNoEvents(); } @@ -11977,16 +12137,17 @@ TEST_F(InputDispatcherDropInputFeatureTest, ObscuredWindowDropsInput) { std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> obscuringWindow = sp<FakeWindowHandle>::make(obscuringApplication, mDispatcher, "obscuringWindow", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); obscuringWindow->setFrame(Rect(0, 0, 50, 50)); obscuringWindow->setOwnerInfo(gui::Pid{111}, gui::Uid{111}); obscuringWindow->setTouchable(false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Test window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Test window", + ui::LogicalDisplayId::DEFAULT); window->setDropInputIfObscured(true); window->setOwnerInfo(gui::Pid{222}, gui::Uid{222}); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); window->setFocusable(true); mDispatcher->onWindowInfosChanged( {{*obscuringWindow->getInfo(), *window->getInfo()}, {}, 0, 0}); @@ -11994,13 +12155,14 @@ TEST_F(InputDispatcherDropInputFeatureTest, ObscuredWindowDropsInput) { window->consumeFocusEvent(/*hasFocus=*/true, /*inTouchMode=*/true); // With the flag set, window should not get any input - mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT)); + mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT)); window->assertNoEvents(); mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)); mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT)); + ui::LogicalDisplayId::DEFAULT)); window->assertNoEvents(); // With the flag cleared, the window should get input @@ -12008,12 +12170,14 @@ TEST_F(InputDispatcherDropInputFeatureTest, ObscuredWindowDropsInput) { mDispatcher->onWindowInfosChanged( {{*obscuringWindow->getInfo(), *window->getInfo()}, {}, 0, 0}); - mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT)); - window->consumeKeyUp(ADISPLAY_ID_DEFAULT); + mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ui::LogicalDisplayId::DEFAULT)); + window->consumeKeyUp(ui::LogicalDisplayId::DEFAULT); mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)); - window->consumeMotionDown(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)); + window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED); window->assertNoEvents(); } @@ -12022,16 +12186,17 @@ TEST_F(InputDispatcherDropInputFeatureTest, UnobscuredWindowGetsInput) { std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> obscuringWindow = sp<FakeWindowHandle>::make(obscuringApplication, mDispatcher, "obscuringWindow", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); obscuringWindow->setFrame(Rect(0, 0, 50, 50)); obscuringWindow->setOwnerInfo(gui::Pid{111}, gui::Uid{111}); obscuringWindow->setTouchable(false); std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, - "Test window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(application, mDispatcher, "Test window", + ui::LogicalDisplayId::DEFAULT); window->setDropInputIfObscured(true); window->setOwnerInfo(gui::Pid{222}, gui::Uid{222}); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); window->setFocusable(true); mDispatcher->onWindowInfosChanged( {{*obscuringWindow->getInfo(), *window->getInfo()}, {}, 0, 0}); @@ -12039,25 +12204,27 @@ TEST_F(InputDispatcherDropInputFeatureTest, UnobscuredWindowGetsInput) { window->consumeFocusEvent(/*hasFocus=*/true, /*inTouchMode=*/true); // With the flag set, window should not get any input - mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT)); + mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ui::LogicalDisplayId::DEFAULT)); window->assertNoEvents(); mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)); mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT)); + ui::LogicalDisplayId::DEFAULT)); window->assertNoEvents(); // When the window is no longer obscured because it went on top, it should get input mDispatcher->onWindowInfosChanged( {{*window->getInfo(), *obscuringWindow->getInfo()}, {}, 0, 0}); - mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT)); - window->consumeKeyUp(ADISPLAY_ID_DEFAULT); + mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ui::LogicalDisplayId::DEFAULT)); + window->consumeKeyUp(ui::LogicalDisplayId::DEFAULT); mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, - AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)); - window->consumeMotionDown(ADISPLAY_ID_DEFAULT); + AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)); + window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); window->assertNoEvents(); } @@ -12074,18 +12241,19 @@ protected: mApp = std::make_shared<FakeApplicationHandle>(); mSecondaryApp = std::make_shared<FakeApplicationHandle>(); - mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow", ADISPLAY_ID_DEFAULT); + mWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow", + ui::LogicalDisplayId::DEFAULT); mWindow->setFocusable(true); setFocusedWindow(mWindow); - mSecondWindow = - sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow2", ADISPLAY_ID_DEFAULT); + mSecondWindow = sp<FakeWindowHandle>::make(mApp, mDispatcher, "TestWindow2", + ui::LogicalDisplayId::DEFAULT); mSecondWindow->setFocusable(true); mThirdWindow = sp<FakeWindowHandle>::make(mSecondaryApp, mDispatcher, "TestWindow3_SecondaryDisplay", SECOND_DISPLAY_ID); mThirdWindow->setFocusable(true); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApp); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, mApp); mDispatcher->onWindowInfosChanged( {{*mWindow->getInfo(), *mSecondWindow->getInfo(), *mThirdWindow->getInfo()}, {}, @@ -12096,7 +12264,8 @@ protected: // Set main display initial touch mode to InputDispatcher::kDefaultInTouchMode. if (mDispatcher->setInTouchMode(InputDispatcher::kDefaultInTouchMode, WINDOW_PID, - WINDOW_UID, /*hasPermission=*/true, ADISPLAY_ID_DEFAULT)) { + WINDOW_UID, /*hasPermission=*/true, + ui::LogicalDisplayId::DEFAULT)) { mWindow->consumeTouchModeEvent(InputDispatcher::kDefaultInTouchMode); mSecondWindow->consumeTouchModeEvent(InputDispatcher::kDefaultInTouchMode); mThirdWindow->assertNoEvents(); @@ -12115,7 +12284,7 @@ protected: void changeAndVerifyTouchModeInMainDisplayOnly(bool inTouchMode, gui::Pid pid, gui::Uid uid, bool hasPermission) { ASSERT_TRUE(mDispatcher->setInTouchMode(inTouchMode, pid, uid, hasPermission, - ADISPLAY_ID_DEFAULT)); + ui::LogicalDisplayId::DEFAULT)); mWindow->consumeTouchModeEvent(inTouchMode); mSecondWindow->consumeTouchModeEvent(inTouchMode); mThirdWindow->assertNoEvents(); @@ -12136,7 +12305,7 @@ TEST_F(InputDispatcherTouchModeChangedTests, NonFocusedWindowOwnerCannotChangeTo mWindow->setOwnerInfo(gui::Pid::INVALID, gui::Uid::INVALID); ASSERT_FALSE(mDispatcher->setInTouchMode(InputDispatcher::kDefaultInTouchMode, ownerPid, ownerUid, /*hasPermission=*/false, - ADISPLAY_ID_DEFAULT)); + ui::LogicalDisplayId::DEFAULT)); mWindow->assertNoEvents(); mSecondWindow->assertNoEvents(); } @@ -12154,7 +12323,8 @@ TEST_F(InputDispatcherTouchModeChangedTests, EventIsNotGeneratedIfNotChangingTou const WindowInfo& windowInfo = *mWindow->getInfo(); ASSERT_FALSE(mDispatcher->setInTouchMode(InputDispatcher::kDefaultInTouchMode, windowInfo.ownerPid, windowInfo.ownerUid, - /*hasPermission=*/true, ADISPLAY_ID_DEFAULT)); + /*hasPermission=*/true, + ui::LogicalDisplayId::DEFAULT)); mWindow->assertNoEvents(); mSecondWindow->assertNoEvents(); } @@ -12172,9 +12342,9 @@ TEST_F(InputDispatcherTouchModeChangedTests, ChangeTouchOnSecondaryDisplayOnly) TEST_F(InputDispatcherTouchModeChangedTests, CanChangeTouchModeWhenOwningLastInteractedWindow) { // Interact with the window first. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectKeyDown(*mDispatcher, ADISPLAY_ID_DEFAULT)) + injectKeyDown(*mDispatcher, ui::LogicalDisplayId::DEFAULT)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; - mWindow->consumeKeyDown(ADISPLAY_ID_DEFAULT); + mWindow->consumeKeyDown(ui::LogicalDisplayId::DEFAULT); // Then remove focus. mWindow->setFocusable(false); @@ -12184,7 +12354,8 @@ TEST_F(InputDispatcherTouchModeChangedTests, CanChangeTouchModeWhenOwningLastInt const WindowInfo& windowInfo = *mWindow->getInfo(); ASSERT_TRUE(mDispatcher->setInTouchMode(!InputDispatcher::kDefaultInTouchMode, windowInfo.ownerPid, windowInfo.ownerUid, - /*hasPermission=*/false, ADISPLAY_ID_DEFAULT)); + /*hasPermission=*/false, + ui::LogicalDisplayId::DEFAULT)); } class InputDispatcherSpyWindowTest : public InputDispatcherTest { @@ -12194,8 +12365,9 @@ public: std::make_shared<FakeApplicationHandle>(); std::string name = "Fake Spy "; name += std::to_string(mSpyCount++); - sp<FakeWindowHandle> spy = sp<FakeWindowHandle>::make(application, mDispatcher, - name.c_str(), ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> spy = + sp<FakeWindowHandle>::make(application, mDispatcher, name.c_str(), + ui::LogicalDisplayId::DEFAULT); spy->setSpy(true); spy->setTrustedOverlay(true); return spy; @@ -12206,7 +12378,7 @@ public: std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Fake Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); window->setFocusable(true); return window; } @@ -12237,9 +12409,10 @@ TEST_F(InputDispatcherSpyWindowTest, NoForegroundWindow) { mDispatcher->onWindowInfosChanged({{*spy->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - spy->consumeMotionDown(ADISPLAY_ID_DEFAULT); + spy->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); } /** @@ -12277,7 +12450,8 @@ TEST_F(InputDispatcherSpyWindowTest, ReceivesInputInOrder) { } ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; std::vector<size_t> eventOrder; @@ -12315,9 +12489,10 @@ TEST_F(InputDispatcherSpyWindowTest, NotTouchable) { mDispatcher->onWindowInfosChanged({{*spy->getInfo(), *window->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - window->consumeMotionDown(ADISPLAY_ID_DEFAULT); + window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); spy->assertNoEvents(); } @@ -12334,20 +12509,22 @@ TEST_F(InputDispatcherSpyWindowTest, TouchableRegion) { // Inject an event outside the spy window's touchable region. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; window->consumeMotionDown(); spy->assertNoEvents(); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) + injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; window->consumeMotionUp(); spy->assertNoEvents(); // Inject an event inside the spy window's touchable region. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {5, 10})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {5, 10})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; window->consumeMotionDown(); spy->consumeMotionDown(); @@ -12368,8 +12545,8 @@ TEST_F(InputDispatcherSpyWindowTest, WatchOutsideTouches) { // Inject an event outside the spy window's frame and touchable region. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {100, 200})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {100, 200})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; window->consumeMotionDown(); spy->consumeMotionOutsideWithZeroedCoords(); @@ -12390,8 +12567,8 @@ TEST_F(InputDispatcherSpyWindowTest, ReceivesMultiplePointers) { {{*spy->getInfo(), *windowLeft->getInfo(), *windowRight->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {50, 50})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {50, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; windowLeft->consumeMotionDown(); spy->consumeMotionDown(); @@ -12422,8 +12599,8 @@ TEST_F(InputDispatcherSpyWindowTest, ReceivesSecondPointerAsDown) { mDispatcher->onWindowInfosChanged({{*spyRight->getInfo(), *window->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {50, 50})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {50, 50})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; window->consumeMotionDown(); spyRight->assertNoEvents(); @@ -12459,16 +12636,16 @@ TEST_F(InputDispatcherSpyWindowTest, SplitIfNoForegroundWindowTouched) { // First finger down, no window touched. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {100, 200})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {100, 200})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - spy->consumeMotionDown(ADISPLAY_ID_DEFAULT); + spy->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); window->assertNoEvents(); // Second finger down on window, the window should receive touch down. const MotionEvent secondFingerDownEvent = MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .eventTime(systemTime(SYSTEM_TIME_MONOTONIC)) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(200)) .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50)) @@ -12478,7 +12655,7 @@ TEST_F(InputDispatcherSpyWindowTest, SplitIfNoForegroundWindowTouched) { InputEventInjectionSync::WAIT_FOR_RESULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - window->consumeMotionDown(ADISPLAY_ID_DEFAULT); + window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); spy->consumeMotionPointerDown(/*pointerIndex=*/1); } @@ -12497,11 +12674,11 @@ TEST_F(InputDispatcherSpyWindowTest, UnfocusableSpyDoesNotReceiveKeyEvents) { ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDown(*mDispatcher)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; - window->consumeKeyDown(ui::ADISPLAY_ID_NONE); + window->consumeKeyDown(ui::LogicalDisplayId::INVALID); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyUp(*mDispatcher)) << "Inject key event should return InputEventInjectionResult::SUCCEEDED"; - window->consumeKeyUp(ui::ADISPLAY_ID_NONE); + window->consumeKeyUp(ui::LogicalDisplayId::INVALID); spy->assertNoEvents(); } @@ -12520,7 +12697,8 @@ TEST_F(InputDispatcherPilferPointersTest, PilferPointers) { {{*spy1->getInfo(), *spy2->getInfo(), *window->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; window->consumeMotionDown(); spy1->consumeMotionDown(); @@ -12535,7 +12713,7 @@ TEST_F(InputDispatcherPilferPointersTest, PilferPointers) { // The rest of the gesture should only be sent to the second spy window. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT)) + ui::LogicalDisplayId::DEFAULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; spy2->consumeMotionMove(); spy1->assertNoEvents(); @@ -12552,19 +12730,21 @@ TEST_F(InputDispatcherPilferPointersTest, CanPilferAfterWindowIsRemovedMidStream mDispatcher->onWindowInfosChanged({{*spy->getInfo(), *window->getInfo()}, {}, 0, 0}); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - window->consumeMotionDown(ADISPLAY_ID_DEFAULT); - spy->consumeMotionDown(ADISPLAY_ID_DEFAULT); + window->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); + spy->consumeMotionDown(ui::LogicalDisplayId::DEFAULT); window->releaseChannel(); EXPECT_EQ(OK, mDispatcher->pilferPointers(spy->getToken())); ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) + injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT)) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; - spy->consumeMotionUp(ADISPLAY_ID_DEFAULT); + spy->consumeMotionUp(ui::LogicalDisplayId::DEFAULT); } /** @@ -12579,8 +12759,8 @@ TEST_F(InputDispatcherPilferPointersTest, ContinuesToReceiveGestureAfterPilfer) // First finger down on the window and the spy. ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {100, 200})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {100, 200})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; spy->consumeMotionDown(); window->consumeMotionDown(); @@ -12592,7 +12772,7 @@ TEST_F(InputDispatcherPilferPointersTest, ContinuesToReceiveGestureAfterPilfer) // Second finger down on the window and spy, but the window should not receive the pointer down. const MotionEvent secondFingerDownEvent = MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .eventTime(systemTime(SYSTEM_TIME_MONOTONIC)) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(200)) .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50)) @@ -12607,7 +12787,7 @@ TEST_F(InputDispatcherPilferPointersTest, ContinuesToReceiveGestureAfterPilfer) // Third finger goes down outside all windows, so injection should fail. const MotionEvent thirdFingerDownEvent = MotionEventBuilder(POINTER_2_DOWN, AINPUT_SOURCE_TOUCHSCREEN) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .eventTime(systemTime(SYSTEM_TIME_MONOTONIC)) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(200)) .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50)) @@ -12635,15 +12815,15 @@ TEST_F(InputDispatcherPilferPointersTest, PartiallyPilferRequiredPointers) { // First finger down on the window only ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {150, 150})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {150, 150})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; window->consumeMotionDown(); // Second finger down on the spy and window const MotionEvent secondFingerDownEvent = MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .eventTime(systemTime(SYSTEM_TIME_MONOTONIC)) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(150).y(150)) .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(10).y(10)) @@ -12658,7 +12838,7 @@ TEST_F(InputDispatcherPilferPointersTest, PartiallyPilferRequiredPointers) { // Third finger down on the spy and window const MotionEvent thirdFingerDownEvent = MotionEventBuilder(POINTER_2_DOWN, AINPUT_SOURCE_TOUCHSCREEN) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .eventTime(systemTime(SYSTEM_TIME_MONOTONIC)) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(150).y(150)) .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(10).y(10)) @@ -12673,8 +12853,10 @@ TEST_F(InputDispatcherPilferPointersTest, PartiallyPilferRequiredPointers) { // Spy window pilfers the pointers. EXPECT_EQ(OK, mDispatcher->pilferPointers(spy->getToken())); - window->consumeMotionPointerUp(/*idx=*/2, ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_CANCELED); - window->consumeMotionPointerUp(/*idx=*/1, ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_CANCELED); + window->consumeMotionPointerUp(/*idx=*/2, ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_CANCELED); + window->consumeMotionPointerUp(/*idx=*/1, ui::LogicalDisplayId::DEFAULT, + AMOTION_EVENT_FLAG_CANCELED); spy->assertNoEvents(); window->assertNoEvents(); @@ -12695,8 +12877,8 @@ TEST_F(InputDispatcherPilferPointersTest, PilferAllRequiredPointers) { // First finger down on both spy and window ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {10, 10})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {10, 10})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; window->consumeMotionDown(); spy->consumeMotionDown(); @@ -12704,7 +12886,7 @@ TEST_F(InputDispatcherPilferPointersTest, PilferAllRequiredPointers) { // Second finger down on the spy and window const MotionEvent secondFingerDownEvent = MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .eventTime(systemTime(SYSTEM_TIME_MONOTONIC)) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(10).y(10)) .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50)) @@ -12738,8 +12920,8 @@ TEST_F(InputDispatcherPilferPointersTest, CanReceivePointersAfterPilfer) { // First finger down on both window and spy ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, - injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, - {10, 10})) + injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, + ui::LogicalDisplayId::DEFAULT, {10, 10})) << "Inject motion event should return InputEventInjectionResult::SUCCEEDED"; window->consumeMotionDown(); spy->consumeMotionDown(); @@ -12751,7 +12933,7 @@ TEST_F(InputDispatcherPilferPointersTest, CanReceivePointersAfterPilfer) { // Second finger down on the window only const MotionEvent secondFingerDownEvent = MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN) - .displayId(ADISPLAY_ID_DEFAULT) + .displayId(ui::LogicalDisplayId::DEFAULT) .eventTime(systemTime(SYSTEM_TIME_MONOTONIC)) .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(10).y(10)) .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(150).y(150)) @@ -12936,9 +13118,9 @@ public: std::pair<sp<FakeWindowHandle>, sp<FakeWindowHandle>> setupStylusOverlayScenario() { std::shared_ptr<FakeApplicationHandle> overlayApplication = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> overlay = - sp<FakeWindowHandle>::make(overlayApplication, mDispatcher, - "Stylus interceptor window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> overlay = sp<FakeWindowHandle>::make(overlayApplication, mDispatcher, + "Stylus interceptor window", + ui::LogicalDisplayId::DEFAULT); overlay->setFocusable(false); overlay->setOwnerInfo(gui::Pid{111}, gui::Uid{111}); overlay->setTouchable(false); @@ -12949,11 +13131,11 @@ public: std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(application, mDispatcher, "Application window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); window->setFocusable(true); window->setOwnerInfo(gui::Pid{222}, gui::Uid{222}); - mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application); + mDispatcher->setFocusedApplication(ui::LogicalDisplayId::DEFAULT, application); mDispatcher->onWindowInfosChanged({{*overlay->getInfo(), *window->getInfo()}, {}, 0, 0}); setFocusedWindow(window); window->consumeFocusEvent(/*hasFocus=*/true, /*inTouchMode=*/true); @@ -12963,13 +13145,13 @@ public: void sendFingerEvent(int32_t action) { mDispatcher->notifyMotion( generateMotionArgs(action, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS, - ADISPLAY_ID_DEFAULT, {PointF{20, 20}})); + ui::LogicalDisplayId::DEFAULT, {PointF{20, 20}})); } void sendStylusEvent(int32_t action) { NotifyMotionArgs motionArgs = generateMotionArgs(action, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS, - ADISPLAY_ID_DEFAULT, {PointF{30, 40}}); + ui::LogicalDisplayId::DEFAULT, {PointF{30, 40}}); motionArgs.pointerProperties[0].toolType = ToolType::STYLUS; mDispatcher->notifyMotion(motionArgs); } @@ -13073,7 +13255,7 @@ struct User { InputEventInjectionResult injectTargetedMotion(int32_t action) const { return injectMotionEvent(*mDispatcher, action, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT, {100, 200}, + ui::LogicalDisplayId::DEFAULT, {100, 200}, {AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_CURSOR_POSITION}, INJECT_EVENT_TIMEOUT, InputEventInjectionSync::WAIT_FOR_RESULT, @@ -13082,7 +13264,7 @@ struct User { InputEventInjectionResult injectTargetedKey(int32_t action) const { return inputdispatcher::injectKey(*mDispatcher, action, /*repeatCount=*/0, - ui::ADISPLAY_ID_NONE, + ui::LogicalDisplayId::INVALID, InputEventInjectionSync::WAIT_FOR_RESULT, INJECT_EVENT_TIMEOUT, /*allowKeyRepeat=*/false, {mUid}, mPolicyFlags); @@ -13091,8 +13273,9 @@ struct User { sp<FakeWindowHandle> createWindow(const char* name) const { std::shared_ptr<FakeApplicationHandle> overlayApplication = std::make_shared<FakeApplicationHandle>(); - sp<FakeWindowHandle> window = sp<FakeWindowHandle>::make(overlayApplication, mDispatcher, - name, ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> window = + sp<FakeWindowHandle>::make(overlayApplication, mDispatcher, name, + ui::LogicalDisplayId::DEFAULT); window->setOwnerInfo(mPid, mUid); return window; } @@ -13114,7 +13297,7 @@ TEST_F(InputDispatcherTargetedInjectionTest, CanInjectIntoOwnedWindow) { EXPECT_EQ(InputEventInjectionResult::SUCCEEDED, owner.injectTargetedKey(AKEY_EVENT_ACTION_DOWN)); - window->consumeKeyDown(ui::ADISPLAY_ID_NONE); + window->consumeKeyDown(ui::LogicalDisplayId::INVALID); } TEST_F(InputDispatcherTargetedInjectionTest, CannotInjectIntoUnownedWindow) { @@ -13179,7 +13362,7 @@ TEST_F(InputDispatcherTargetedInjectionTest, CanInjectIntoAnyWindowWhenNotTarget // A user that has injection permission can inject into any window. EXPECT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, - ADISPLAY_ID_DEFAULT)); + ui::LogicalDisplayId::DEFAULT)); randosSpy->consumeMotionDown(); window->consumeMotionDown(); @@ -13187,7 +13370,7 @@ TEST_F(InputDispatcherTargetedInjectionTest, CanInjectIntoAnyWindowWhenNotTarget randosSpy->consumeFocusEvent(true); EXPECT_EQ(InputEventInjectionResult::SUCCEEDED, injectKeyDown(*mDispatcher)); - randosSpy->consumeKeyDown(ui::ADISPLAY_ID_NONE); + randosSpy->consumeKeyDown(ui::LogicalDisplayId::INVALID); window->assertNoEvents(); } @@ -13214,13 +13397,14 @@ TEST_F(InputDispatcherPointerInWindowTest, PointerInWindowWhenHovering) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> left = sp<FakeWindowHandle>::make(application, mDispatcher, "Left Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); left->setFrame(Rect(0, 0, 100, 100)); - sp<FakeWindowHandle> right = sp<FakeWindowHandle>::make(application, mDispatcher, - "Right Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> right = + sp<FakeWindowHandle>::make(application, mDispatcher, "Right Window", + ui::LogicalDisplayId::DEFAULT); right->setFrame(Rect(100, 0, 200, 100)); - sp<FakeWindowHandle> spy = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> spy = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy Window", + ui::LogicalDisplayId::DEFAULT); spy->setFrame(Rect(0, 0, 200, 100)); spy->setTrustedOverlay(true); spy->setSpy(true); @@ -13237,11 +13421,14 @@ TEST_F(InputDispatcherPointerInWindowTest, PointerInWindowWhenHovering) { left->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER)); spy->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER)); - ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); // Hover move to the right window. @@ -13254,11 +13441,14 @@ TEST_F(InputDispatcherPointerInWindowTest, PointerInWindowWhenHovering) { right->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER)); spy->consumeMotionEvent(WithMotionAction(ACTION_HOVER_MOVE)); - ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_TRUE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_TRUE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); // Stop hovering. @@ -13270,11 +13460,14 @@ TEST_F(InputDispatcherPointerInWindowTest, PointerInWindowWhenHovering) { right->consumeMotionEvent(WithMotionAction(ACTION_HOVER_EXIT)); spy->consumeMotionEvent(WithMotionAction(ACTION_HOVER_EXIT)); - ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_FALSE(mDispatcher->isPointerInWindow(spy->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(spy->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); } @@ -13282,13 +13475,14 @@ TEST_F(InputDispatcherPointerInWindowTest, PointerInWindowWithSplitTouch) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> left = sp<FakeWindowHandle>::make(application, mDispatcher, "Left Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); left->setFrame(Rect(0, 0, 100, 100)); - sp<FakeWindowHandle> right = sp<FakeWindowHandle>::make(application, mDispatcher, - "Right Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> right = + sp<FakeWindowHandle>::make(application, mDispatcher, "Right Window", + ui::LogicalDisplayId::DEFAULT); right->setFrame(Rect(100, 0, 200, 100)); - sp<FakeWindowHandle> spy = - sp<FakeWindowHandle>::make(application, mDispatcher, "Spy Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> spy = sp<FakeWindowHandle>::make(application, mDispatcher, "Spy Window", + ui::LogicalDisplayId::DEFAULT); spy->setFrame(Rect(0, 0, 200, 100)); spy->setTrustedOverlay(true); spy->setSpy(true); @@ -13305,11 +13499,14 @@ TEST_F(InputDispatcherPointerInWindowTest, PointerInWindowWithSplitTouch) { left->consumeMotionDown(); spy->consumeMotionDown(); - ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); // Second pointer down on right window. @@ -13323,17 +13520,23 @@ TEST_F(InputDispatcherPointerInWindowTest, PointerInWindowWithSplitTouch) { right->consumeMotionDown(); spy->consumeMotionEvent(WithMotionAction(POINTER_1_DOWN)); - ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/1)); - ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/1)); - ASSERT_TRUE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_TRUE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/1)); // Second pointer up. @@ -13347,17 +13550,23 @@ TEST_F(InputDispatcherPointerInWindowTest, PointerInWindowWithSplitTouch) { right->consumeMotionUp(); spy->consumeMotionEvent(WithMotionAction(POINTER_1_UP)); - ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_TRUE(mDispatcher->isPointerInWindow(spy->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/1)); - ASSERT_FALSE(mDispatcher->isPointerInWindow(spy->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(spy->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/1)); - ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/1)); // First pointer up. @@ -13369,11 +13578,14 @@ TEST_F(InputDispatcherPointerInWindowTest, PointerInWindowWithSplitTouch) { left->consumeMotionUp(); spy->consumeMotionUp(); - ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_FALSE(mDispatcher->isPointerInWindow(spy->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(spy->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); } @@ -13382,17 +13594,20 @@ TEST_F(InputDispatcherPointerInWindowTest, MultipleDevicesControllingOneMouse_le std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> left = sp<FakeWindowHandle>::make(application, mDispatcher, "Left Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); left->setFrame(Rect(0, 0, 100, 100)); - sp<FakeWindowHandle> right = sp<FakeWindowHandle>::make(application, mDispatcher, - "Right Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> right = + sp<FakeWindowHandle>::make(application, mDispatcher, "Right Window", + ui::LogicalDisplayId::DEFAULT); right->setFrame(Rect(100, 0, 200, 100)); mDispatcher->onWindowInfosChanged({{*left->getInfo(), *right->getInfo()}, {}, 0, 0}); - ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); // Hover move into the window. @@ -13406,7 +13621,8 @@ TEST_F(InputDispatcherPointerInWindowTest, MultipleDevicesControllingOneMouse_le left->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER)); - ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); // Move the mouse with another device. This cancels the hovering pointer from the first device. @@ -13423,9 +13639,10 @@ TEST_F(InputDispatcherPointerInWindowTest, MultipleDevicesControllingOneMouse_le // TODO(b/313689709): InputDispatcher's touch state is not updated, even though the window gets // a HOVER_EXIT from the first device. - ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, + ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, SECOND_DEVICE_ID, /*pointerId=*/0)); @@ -13441,9 +13658,10 @@ TEST_F(InputDispatcherPointerInWindowTest, MultipleDevicesControllingOneMouse_le left->consumeMotionEvent(WithMotionAction(ACTION_HOVER_EXIT)); right->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER)); - ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, + ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, SECOND_DEVICE_ID, /*pointerId=*/0)); } @@ -13457,17 +13675,20 @@ TEST_F(InputDispatcherPointerInWindowTest, MultipleDevicesControllingOneMouse) { std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>(); sp<FakeWindowHandle> left = sp<FakeWindowHandle>::make(application, mDispatcher, "Left Window", - ADISPLAY_ID_DEFAULT); + ui::LogicalDisplayId::DEFAULT); left->setFrame(Rect(0, 0, 100, 100)); - sp<FakeWindowHandle> right = sp<FakeWindowHandle>::make(application, mDispatcher, - "Right Window", ADISPLAY_ID_DEFAULT); + sp<FakeWindowHandle> right = + sp<FakeWindowHandle>::make(application, mDispatcher, "Right Window", + ui::LogicalDisplayId::DEFAULT); right->setFrame(Rect(100, 0, 200, 100)); mDispatcher->onWindowInfosChanged({{*left->getInfo(), *right->getInfo()}, {}, 0, 0}); - ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_FALSE(mDispatcher->isPointerInWindow(right->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); // Hover move into the window. @@ -13481,7 +13702,8 @@ TEST_F(InputDispatcherPointerInWindowTest, MultipleDevicesControllingOneMouse) { left->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER)); - ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); // Move the mouse with another device @@ -13496,9 +13718,10 @@ TEST_F(InputDispatcherPointerInWindowTest, MultipleDevicesControllingOneMouse) { // TODO(b/313689709): InputDispatcher's touch state is not updated, even though the window gets // a HOVER_EXIT from the first device. - ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, + ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, SECOND_DEVICE_ID, /*pointerId=*/0)); @@ -13513,9 +13736,10 @@ TEST_F(InputDispatcherPointerInWindowTest, MultipleDevicesControllingOneMouse) { .build()); right->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER)); - ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, DEVICE_ID, + ASSERT_TRUE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, + DEVICE_ID, /*pointerId=*/0)); - ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ADISPLAY_ID_DEFAULT, + ASSERT_FALSE(mDispatcher->isPointerInWindow(left->getToken(), ui::LogicalDisplayId::DEFAULT, SECOND_DEVICE_ID, /*pointerId=*/0)); } diff --git a/services/inputflinger/tests/InputProcessorConverter_test.cpp b/services/inputflinger/tests/InputProcessorConverter_test.cpp index 15565326b1..bdf156c49a 100644 --- a/services/inputflinger/tests/InputProcessorConverter_test.cpp +++ b/services/inputflinger/tests/InputProcessorConverter_test.cpp @@ -38,7 +38,7 @@ static NotifyMotionArgs generateBasicMotionArgs() { coords.setAxisValue(AMOTION_EVENT_AXIS_SIZE, 0.5); static constexpr nsecs_t downTime = 2; NotifyMotionArgs motionArgs(/*sequenceNum=*/1, /*eventTime=*/downTime, /*readTime=*/2, - /*deviceId=*/3, AINPUT_SOURCE_ANY, ui::ADISPLAY_ID_DEFAULT, + /*deviceId=*/3, AINPUT_SOURCE_ANY, ui::LogicalDisplayId::DEFAULT, /*policyFlags=*/4, AMOTION_EVENT_ACTION_DOWN, /*actionButton=*/0, /*flags=*/0, AMETA_NONE, /*buttonState=*/0, MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE, diff --git a/services/inputflinger/tests/InputProcessor_test.cpp b/services/inputflinger/tests/InputProcessor_test.cpp index 5606a91a0b..f7e5e6783b 100644 --- a/services/inputflinger/tests/InputProcessor_test.cpp +++ b/services/inputflinger/tests/InputProcessor_test.cpp @@ -44,7 +44,7 @@ static NotifyMotionArgs generateBasicMotionArgs() { coords.setAxisValue(AMOTION_EVENT_AXIS_Y, 1); static constexpr nsecs_t downTime = 2; NotifyMotionArgs motionArgs(/*sequenceNum=*/1, /*eventTime=*/downTime, /*readTime=*/2, - /*deviceId=*/3, AINPUT_SOURCE_ANY, ui::ADISPLAY_ID_DEFAULT, + /*deviceId=*/3, AINPUT_SOURCE_ANY, ui::LogicalDisplayId::DEFAULT, /*policyFlags=*/4, AMOTION_EVENT_ACTION_DOWN, /*actionButton=*/0, /*flags=*/0, AMETA_NONE, /*buttonState=*/0, MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE, @@ -80,7 +80,7 @@ TEST_F(InputProcessorTest, SendToNextStage_NotifyConfigurationChangedArgs) { TEST_F(InputProcessorTest, SendToNextStage_NotifyKeyArgs) { // Create a basic key event and send to processor NotifyKeyArgs args(/*sequenceNum=*/1, /*eventTime=*/2, /*readTime=*/21, /*deviceId=*/3, - AINPUT_SOURCE_KEYBOARD, ui::ADISPLAY_ID_DEFAULT, /*policyFlags=*/0, + AINPUT_SOURCE_KEYBOARD, ui::LogicalDisplayId::DEFAULT, /*policyFlags=*/0, AKEY_EVENT_ACTION_DOWN, /*flags=*/4, AKEYCODE_HOME, /*scanCode=*/5, AMETA_NONE, /*downTime=*/6); diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp index fcc52a8f31..a0abb61cdc 100644 --- a/services/inputflinger/tests/InputReader_test.cpp +++ b/services/inputflinger/tests/InputReader_test.cpp @@ -59,11 +59,10 @@ using std::chrono_literals::operator""ms; using std::chrono_literals::operator""s; // Arbitrary display properties. -static constexpr ui::LogicalDisplayId DISPLAY_ID = ui::ADISPLAY_ID_DEFAULT; +static constexpr ui::LogicalDisplayId DISPLAY_ID = ui::LogicalDisplayId::DEFAULT; static const std::string DISPLAY_UNIQUE_ID = "local:1"; static constexpr ui::LogicalDisplayId SECONDARY_DISPLAY_ID = ui::LogicalDisplayId{DISPLAY_ID.val() + 1}; -static const std::string SECONDARY_DISPLAY_UNIQUE_ID = "local:2"; static constexpr int32_t DISPLAY_WIDTH = 480; static constexpr int32_t DISPLAY_HEIGHT = 800; static constexpr ui::LogicalDisplayId VIRTUAL_DISPLAY_ID = ui::LogicalDisplayId{1}; @@ -521,12 +520,12 @@ TEST_F(InputReaderPolicyTest, Viewports_ByTypeReturnsDefaultForInternal) { const std::string uniqueId1 = "uniqueId1"; const std::string uniqueId2 = "uniqueId2"; constexpr ui::LogicalDisplayId nonDefaultDisplayId = ui::LogicalDisplayId{2}; - ASSERT_NE(nonDefaultDisplayId, ui::ADISPLAY_ID_DEFAULT) - << "Test display ID should not be ui::ADISPLAY_ID_DEFAULT "; + ASSERT_NE(nonDefaultDisplayId, ui::LogicalDisplayId::DEFAULT) + << "Test display ID should not be ui::LogicalDisplayId::DEFAULT "; // Add the default display first and ensure it gets returned. mFakePolicy->clearViewports(); - mFakePolicy->addDisplayViewport(ui::ADISPLAY_ID_DEFAULT, DISPLAY_WIDTH, DISPLAY_HEIGHT, + mFakePolicy->addDisplayViewport(ui::LogicalDisplayId::DEFAULT, DISPLAY_WIDTH, DISPLAY_HEIGHT, ui::ROTATION_0, /*isActive=*/true, uniqueId1, NO_PORT, ViewportType::INTERNAL); mFakePolicy->addDisplayViewport(nonDefaultDisplayId, DISPLAY_WIDTH, DISPLAY_HEIGHT, @@ -536,7 +535,7 @@ TEST_F(InputReaderPolicyTest, Viewports_ByTypeReturnsDefaultForInternal) { std::optional<DisplayViewport> viewport = mFakePolicy->getDisplayViewportByType(ViewportType::INTERNAL); ASSERT_TRUE(viewport); - ASSERT_EQ(ui::ADISPLAY_ID_DEFAULT, viewport->displayId); + ASSERT_EQ(ui::LogicalDisplayId::DEFAULT, viewport->displayId); ASSERT_EQ(ViewportType::INTERNAL, viewport->type); // Add the default display second to make sure order doesn't matter. @@ -544,13 +543,13 @@ TEST_F(InputReaderPolicyTest, Viewports_ByTypeReturnsDefaultForInternal) { mFakePolicy->addDisplayViewport(nonDefaultDisplayId, DISPLAY_WIDTH, DISPLAY_HEIGHT, ui::ROTATION_0, /*isActive=*/true, uniqueId2, NO_PORT, ViewportType::INTERNAL); - mFakePolicy->addDisplayViewport(ui::ADISPLAY_ID_DEFAULT, DISPLAY_WIDTH, DISPLAY_HEIGHT, + mFakePolicy->addDisplayViewport(ui::LogicalDisplayId::DEFAULT, DISPLAY_WIDTH, DISPLAY_HEIGHT, ui::ROTATION_0, /*isActive=*/true, uniqueId1, NO_PORT, ViewportType::INTERNAL); viewport = mFakePolicy->getDisplayViewportByType(ViewportType::INTERNAL); ASSERT_TRUE(viewport); - ASSERT_EQ(ui::ADISPLAY_ID_DEFAULT, viewport->displayId); + ASSERT_EQ(ui::LogicalDisplayId::DEFAULT, viewport->displayId); ASSERT_EQ(ViewportType::INTERNAL, viewport->type); } @@ -3244,7 +3243,7 @@ protected: void testDPadKeyRotation(KeyboardInputMapper& mapper, int32_t originalScanCode, int32_t originalKeyCode, int32_t rotatedKeyCode, - ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE); + ui::LogicalDisplayId displayId = ui::LogicalDisplayId::INVALID); }; /* Similar to setDisplayInfoAndReconfigure, but pre-populates all parameters except for the @@ -3579,19 +3578,19 @@ TEST_F(KeyboardInputMapperTest, DisplayIdConfigurationChange_NotOrientationAware AINPUT_KEYBOARD_TYPE_ALPHABETIC); NotifyKeyArgs args; - // Display id should be ADISPLAY_ID_NONE without any display configuration. + // Display id should be LogicalDisplayId::INVALID without any display configuration. process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_UP, 1); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args)); process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_UP, 0); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args)); - ASSERT_EQ(ui::ADISPLAY_ID_NONE, args.displayId); + ASSERT_EQ(ui::LogicalDisplayId::INVALID, args.displayId); prepareDisplay(ui::ROTATION_0); process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_UP, 1); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args)); process(mapper, ARBITRARY_TIME, READ_TIME, EV_KEY, KEY_UP, 0); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args)); - ASSERT_EQ(ui::ADISPLAY_ID_NONE, args.displayId); + ASSERT_EQ(ui::LogicalDisplayId::INVALID, args.displayId); } TEST_F(KeyboardInputMapperTest, DisplayIdConfigurationChange_OrientationAware) { @@ -3605,7 +3604,7 @@ TEST_F(KeyboardInputMapperTest, DisplayIdConfigurationChange_OrientationAware) { AINPUT_KEYBOARD_TYPE_ALPHABETIC); NotifyKeyArgs args; - // Display id should be ADISPLAY_ID_NONE without any display configuration. + // Display id should be LogicalDisplayId::INVALID without any display configuration. // ^--- already checked by the previous test setDisplayInfoAndReconfigure(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, ui::ROTATION_0, @@ -8675,7 +8674,7 @@ TEST_F(MultiTouchInputMapperTest, Process_Pointer_ShouldHandleDisplayId) { ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs)); ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action); - ASSERT_EQ(ui::ADISPLAY_ID_NONE, motionArgs.displayId); + ASSERT_EQ(ui::LogicalDisplayId::INVALID, motionArgs.displayId); } /** @@ -9572,7 +9571,7 @@ TEST_F(MultiTouchInputMapperTest_ExternalDevice, Viewports_Fallback) { processPosition(mapper, 100, 100); processSync(mapper); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs)); - ASSERT_EQ(ui::ADISPLAY_ID_DEFAULT, motionArgs.displayId); + ASSERT_EQ(ui::LogicalDisplayId::DEFAULT, motionArgs.displayId); // Expect the event to be sent to the external viewport if it is present. prepareSecondaryDisplay(ViewportType::EXTERNAL); diff --git a/services/inputflinger/tests/InputTracingTest.cpp b/services/inputflinger/tests/InputTracingTest.cpp index dfbbce3b1a..617d67f34d 100644 --- a/services/inputflinger/tests/InputTracingTest.cpp +++ b/services/inputflinger/tests/InputTracingTest.cpp @@ -41,7 +41,7 @@ using perfetto::protos::pbzero::AndroidInputEventConfig; namespace { -constexpr ui::LogicalDisplayId DISPLAY_ID = ui::ADISPLAY_ID_DEFAULT; +constexpr ui::LogicalDisplayId DISPLAY_ID = ui::LogicalDisplayId::DEFAULT; // Ensure common actions are interchangeable between keys and motions for convenience. static_assert(static_cast<int32_t>(AMOTION_EVENT_ACTION_DOWN) == diff --git a/services/inputflinger/tests/LatencyTracker_test.cpp b/services/inputflinger/tests/LatencyTracker_test.cpp index 01fd03e874..4fcffddee2 100644 --- a/services/inputflinger/tests/LatencyTracker_test.cpp +++ b/services/inputflinger/tests/LatencyTracker_test.cpp @@ -43,7 +43,7 @@ static InputDeviceInfo generateTestDeviceInfo(uint16_t vendorId, uint16_t produc identifier.product = productId; auto info = InputDeviceInfo(); info.initialize(deviceId, /*generation=*/1, /*controllerNumber=*/1, identifier, "Test Device", - /*isExternal=*/false, /*hasMic=*/false, ui::ADISPLAY_ID_NONE); + /*isExternal=*/false, /*hasMic=*/false, ui::LogicalDisplayId::INVALID); return info; } diff --git a/services/inputflinger/tests/MultiTouchInputMapper_test.cpp b/services/inputflinger/tests/MultiTouchInputMapper_test.cpp index 437020f48a..b5f897154b 100644 --- a/services/inputflinger/tests/MultiTouchInputMapper_test.cpp +++ b/services/inputflinger/tests/MultiTouchInputMapper_test.cpp @@ -35,7 +35,7 @@ using testing::Return; using testing::SetArgPointee; using testing::VariantWith; -static constexpr ui::LogicalDisplayId DISPLAY_ID = ui::ADISPLAY_ID_DEFAULT; +static constexpr ui::LogicalDisplayId DISPLAY_ID = ui::LogicalDisplayId::DEFAULT; static constexpr int32_t DISPLAY_WIDTH = 480; static constexpr int32_t DISPLAY_HEIGHT = 800; static constexpr std::optional<uint8_t> NO_PORT = std::nullopt; // no physical port is specified diff --git a/services/inputflinger/tests/PointerChoreographer_test.cpp b/services/inputflinger/tests/PointerChoreographer_test.cpp index 33e7277034..1689b33fe5 100644 --- a/services/inputflinger/tests/PointerChoreographer_test.cpp +++ b/services/inputflinger/tests/PointerChoreographer_test.cpp @@ -203,14 +203,16 @@ TEST_F(PointerChoreographerTest, ForwardsArgsToInnerListener) { TEST_F(PointerChoreographerTest, WhenMouseIsAddedCreatesPointerController) { mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); assertPointerControllerCreated(ControllerType::MOUSE); } TEST_F(PointerChoreographerTest, WhenMouseIsRemovedRemovesPointerController) { mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); // Remove the mouse. @@ -221,7 +223,8 @@ TEST_F(PointerChoreographerTest, WhenMouseIsRemovedRemovesPointerController) { TEST_F(PointerChoreographerTest, WhenKeyboardIsAddedDoesNotCreatePointerController) { mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_KEYBOARD, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_KEYBOARD, + ui::LogicalDisplayId::INVALID)}}); assertPointerControllerNotCreated(); } @@ -256,7 +259,8 @@ TEST_F(PointerChoreographerTest, SetsDefaultMouseViewportForPointerController) { // the PointerController. mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); pc->assertViewportSet(DISPLAY_ID); ASSERT_TRUE(pc->isPointerShown()); @@ -269,7 +273,8 @@ TEST_F(PointerChoreographerTest, mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); auto firstDisplayPc = assertPointerControllerCreated(ControllerType::MOUSE); firstDisplayPc->assertViewportSet(DISPLAY_ID); ASSERT_TRUE(firstDisplayPc->isPointerShown()); @@ -289,7 +294,8 @@ TEST_F(PointerChoreographerTest, CallsNotifyPointerDisplayIdChanged) { mChoreographer.setDisplayViewports(createViewports({DISPLAY_ID})); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); assertPointerControllerCreated(ControllerType::MOUSE); assertPointerDisplayIdNotified(DISPLAY_ID); @@ -299,7 +305,8 @@ TEST_F(PointerChoreographerTest, WhenViewportIsSetLaterCallsNotifyPointerDisplay mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); assertPointerControllerCreated(ControllerType::MOUSE); assertPointerDisplayIdNotNotified(); @@ -312,12 +319,13 @@ TEST_F(PointerChoreographerTest, WhenMouseIsRemovedCallsNotifyPointerDisplayIdCh mChoreographer.setDisplayViewports(createViewports({DISPLAY_ID})); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); assertPointerDisplayIdNotified(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged({/*id=*/1, {}}); - assertPointerDisplayIdNotified(ui::ADISPLAY_ID_NONE); + assertPointerDisplayIdNotified(ui::LogicalDisplayId::INVALID); assertPointerControllerRemoved(pc); } @@ -329,7 +337,8 @@ TEST_F(PointerChoreographerTest, WhenDefaultMouseDisplayChangesCallsNotifyPointe mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); auto firstDisplayPc = assertPointerControllerCreated(ControllerType::MOUSE); assertPointerDisplayIdNotified(DISPLAY_ID); @@ -346,7 +355,8 @@ TEST_F(PointerChoreographerTest, MouseMovesPointerAndReturnsNewArgs) { mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); ASSERT_EQ(DISPLAY_ID, pc->getDisplayId()); @@ -358,7 +368,7 @@ TEST_F(PointerChoreographerTest, MouseMovesPointerAndReturnsNewArgs) { MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE, AINPUT_SOURCE_MOUSE) .pointer(MOUSE_POINTER) .deviceId(DEVICE_ID) - .displayId(ui::ADISPLAY_ID_NONE) + .displayId(ui::LogicalDisplayId::INVALID) .build()); // Check that the PointerController updated the position and the pointer is shown. @@ -375,7 +385,8 @@ TEST_F(PointerChoreographerTest, AbsoluteMouseMovesPointerAndReturnsNewArgs) { mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); ASSERT_EQ(DISPLAY_ID, pc->getDisplayId()); @@ -390,7 +401,7 @@ TEST_F(PointerChoreographerTest, AbsoluteMouseMovesPointerAndReturnsNewArgs) { MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE, AINPUT_SOURCE_MOUSE) .pointer(absoluteMousePointer) .deviceId(DEVICE_ID) - .displayId(ui::ADISPLAY_ID_NONE) + .displayId(ui::LogicalDisplayId::INVALID) .build()); // Check that the PointerController updated the position and the pointer is shown. @@ -412,7 +423,7 @@ TEST_F(PointerChoreographerTest, // Add two devices, one unassociated and the other associated with non-default mouse display. mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE), + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID), generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_MOUSE, ANOTHER_DISPLAY_ID)}}); auto unassociatedMousePc = assertPointerControllerCreated(ControllerType::MOUSE); ASSERT_EQ(DISPLAY_ID, unassociatedMousePc->getDisplayId()); @@ -449,7 +460,8 @@ TEST_F(PointerChoreographerTest, DoesNotMovePointerForMouseRelativeSource) { mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); ASSERT_EQ(DISPLAY_ID, pc->getDisplayId()); @@ -460,7 +472,7 @@ TEST_F(PointerChoreographerTest, DoesNotMovePointerForMouseRelativeSource) { mChoreographer.notifyInputDevicesChanged( {/*id=*/1, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE_RELATIVE, - ui::ADISPLAY_ID_NONE)}}); + ui::LogicalDisplayId::INVALID)}}); mChoreographer.notifyPointerCaptureChanged( NotifyPointerCaptureChangedArgs(/*id=*/2, systemTime(SYSTEM_TIME_MONOTONIC), PointerCaptureRequest(/*window=*/sp<BBinder>::make(), @@ -475,7 +487,7 @@ TEST_F(PointerChoreographerTest, DoesNotMovePointerForMouseRelativeSource) { .axis(AMOTION_EVENT_AXIS_RELATIVE_X, 10) .axis(AMOTION_EVENT_AXIS_RELATIVE_Y, 20)) .deviceId(DEVICE_ID) - .displayId(ui::ADISPLAY_ID_NONE) + .displayId(ui::LogicalDisplayId::INVALID) .build()); // Check that there's no update on the PointerController. @@ -485,7 +497,7 @@ TEST_F(PointerChoreographerTest, DoesNotMovePointerForMouseRelativeSource) { // Check x-y coordinates, displayId and cursor position are not changed. mTestListener.assertNotifyMotionWasCalled( AllOf(WithCoords(10, 20), WithRelativeMotion(10, 20), - WithDisplayId(ui::ADISPLAY_ID_NONE), + WithDisplayId(ui::LogicalDisplayId::INVALID), WithCursorPosition(AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_CURSOR_POSITION))); } @@ -495,7 +507,8 @@ TEST_F(PointerChoreographerTest, WhenPointerCaptureEnabledHidesPointer) { mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); ASSERT_EQ(DISPLAY_ID, pc->getDisplayId()); ASSERT_TRUE(pc->isPointerShown()); @@ -515,7 +528,8 @@ TEST_F(PointerChoreographerTest, MultipleMiceConnectionAndRemoval) { // A mouse is connected, and the pointer is shown. mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); ASSERT_TRUE(pc->isPointerShown()); @@ -525,9 +539,9 @@ TEST_F(PointerChoreographerTest, MultipleMiceConnectionAndRemoval) { // Add a second mouse is added, the pointer is shown again. mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE), + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID), generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_MOUSE, - ui::ADISPLAY_ID_NONE)}}); + ui::LogicalDisplayId::INVALID)}}); ASSERT_TRUE(pc->isPointerShown()); // One of the mice is removed, and it does not cause the mouse pointer to fade, because @@ -535,7 +549,7 @@ TEST_F(PointerChoreographerTest, MultipleMiceConnectionAndRemoval) { mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_MOUSE, - ui::ADISPLAY_ID_NONE)}}); + ui::LogicalDisplayId::INVALID)}}); assertPointerControllerNotRemoved(pc); ASSERT_TRUE(pc->isPointerShown()); @@ -549,7 +563,8 @@ TEST_F(PointerChoreographerTest, UnrelatedChangeDoesNotUnfadePointer) { mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); ASSERT_TRUE(pc->isPointerShown()); @@ -559,7 +574,7 @@ TEST_F(PointerChoreographerTest, UnrelatedChangeDoesNotUnfadePointer) { // Adding a touchscreen device does not unfade the mouse pointer. mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE), + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID), generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS, DISPLAY_ID)}}); @@ -576,7 +591,7 @@ TEST_F(PointerChoreographerTest, DisabledMouseConnected) { mChoreographer.setDisplayViewports(createViewports({DISPLAY_ID})); mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID); InputDeviceInfo mouseDeviceInfo = - generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE); + generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID); // Disable this mouse device. mouseDeviceInfo.setEnabled(false); mChoreographer.notifyInputDevicesChanged({/*id=*/0, {mouseDeviceInfo}}); @@ -589,7 +604,7 @@ TEST_F(PointerChoreographerTest, MouseDeviceDisableLater) { mChoreographer.setDisplayViewports(createViewports({DISPLAY_ID})); mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID); InputDeviceInfo mouseDeviceInfo = - generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE); + generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID); mChoreographer.notifyInputDevicesChanged({/*id=*/0, {mouseDeviceInfo}}); @@ -608,14 +623,16 @@ TEST_F(PointerChoreographerTest, MultipleEnabledAndDisabledMiceConnectionAndRemo mChoreographer.setDisplayViewports(createViewports({DISPLAY_ID})); mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID); InputDeviceInfo disabledMouseDeviceInfo = - generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE); + generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID); disabledMouseDeviceInfo.setEnabled(false); InputDeviceInfo enabledMouseDeviceInfo = - generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE); + generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID); InputDeviceInfo anotherEnabledMouseDeviceInfo = - generateTestDeviceInfo(THIRD_DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE); + generateTestDeviceInfo(THIRD_DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, @@ -1177,7 +1194,7 @@ TEST_F(PointerChoreographerTest, WhenTouchpadIsAddedCreatesPointerController) { mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD, - ui::ADISPLAY_ID_NONE)}}); + ui::LogicalDisplayId::INVALID)}}); assertPointerControllerCreated(ControllerType::MOUSE); } @@ -1185,7 +1202,7 @@ TEST_F(PointerChoreographerTest, WhenTouchpadIsRemovedRemovesPointerController) mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD, - ui::ADISPLAY_ID_NONE)}}); + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); // Remove the touchpad. @@ -1227,7 +1244,8 @@ TEST_F(PointerChoreographerTest, SetsDefaultTouchpadViewportForPointerController // the PointerController. mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); pc->assertViewportSet(DISPLAY_ID); } @@ -1240,7 +1258,7 @@ TEST_F(PointerChoreographerTest, mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD, - ui::ADISPLAY_ID_NONE)}}); + ui::LogicalDisplayId::INVALID)}}); auto firstDisplayPc = assertPointerControllerCreated(ControllerType::MOUSE); firstDisplayPc->assertViewportSet(DISPLAY_ID); @@ -1258,7 +1276,7 @@ TEST_F(PointerChoreographerTest, TouchpadCallsNotifyPointerDisplayIdChanged) { mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD, - ui::ADISPLAY_ID_NONE)}}); + ui::LogicalDisplayId::INVALID)}}); assertPointerControllerCreated(ControllerType::MOUSE); assertPointerDisplayIdNotified(DISPLAY_ID); @@ -1269,7 +1287,7 @@ TEST_F(PointerChoreographerTest, WhenViewportIsSetLaterTouchpadCallsNotifyPointe mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD, - ui::ADISPLAY_ID_NONE)}}); + ui::LogicalDisplayId::INVALID)}}); assertPointerControllerCreated(ControllerType::MOUSE); assertPointerDisplayIdNotNotified(); @@ -1283,12 +1301,12 @@ TEST_F(PointerChoreographerTest, WhenTouchpadIsRemovedCallsNotifyPointerDisplayI mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD, - ui::ADISPLAY_ID_NONE)}}); + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); assertPointerDisplayIdNotified(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged({/*id=*/1, {}}); - assertPointerDisplayIdNotified(ui::ADISPLAY_ID_NONE); + assertPointerDisplayIdNotified(ui::LogicalDisplayId::INVALID); assertPointerControllerRemoved(pc); } @@ -1302,12 +1320,12 @@ TEST_F(PointerChoreographerTest, mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD, - ui::ADISPLAY_ID_NONE)}}); + ui::LogicalDisplayId::INVALID)}}); auto firstDisplayPc = assertPointerControllerCreated(ControllerType::MOUSE); assertPointerDisplayIdNotified(DISPLAY_ID); - // Set another viewport as a default mouse display ID. ui::ADISPLAY_ID_NONE will be notified - // before a touchpad event. + // Set another viewport as a default mouse display ID. ui::LogicalDisplayId::INVALID will be + // notified before a touchpad event. mChoreographer.setDefaultMouseDisplayId(ANOTHER_DISPLAY_ID); assertPointerControllerRemoved(firstDisplayPc); @@ -1321,7 +1339,7 @@ TEST_F(PointerChoreographerTest, TouchpadMovesPointerAndReturnsNewArgs) { mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD, - ui::ADISPLAY_ID_NONE)}}); + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); ASSERT_EQ(DISPLAY_ID, pc->getDisplayId()); @@ -1333,7 +1351,7 @@ TEST_F(PointerChoreographerTest, TouchpadMovesPointerAndReturnsNewArgs) { MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE, AINPUT_SOURCE_MOUSE) .pointer(TOUCHPAD_POINTER) .deviceId(DEVICE_ID) - .displayId(ui::ADISPLAY_ID_NONE) + .displayId(ui::LogicalDisplayId::INVALID) .build()); // Check that the PointerController updated the position and the pointer is shown. @@ -1351,7 +1369,7 @@ TEST_F(PointerChoreographerTest, TouchpadAddsPointerPositionToTheCoords) { mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD, - ui::ADISPLAY_ID_NONE)}}); + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); ASSERT_EQ(DISPLAY_ID, pc->getDisplayId()); @@ -1365,7 +1383,7 @@ TEST_F(PointerChoreographerTest, TouchpadAddsPointerPositionToTheCoords) { .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(-100).y(0)) .classification(MotionClassification::MULTI_FINGER_SWIPE) .deviceId(DEVICE_ID) - .displayId(ui::ADISPLAY_ID_NONE) + .displayId(ui::LogicalDisplayId::INVALID) .build()); mTestListener.assertNotifyMotionWasCalled( AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), @@ -1379,7 +1397,7 @@ TEST_F(PointerChoreographerTest, TouchpadAddsPointerPositionToTheCoords) { .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(0).y(0)) .classification(MotionClassification::MULTI_FINGER_SWIPE) .deviceId(DEVICE_ID) - .displayId(ui::ADISPLAY_ID_NONE) + .displayId(ui::LogicalDisplayId::INVALID) .build()); mTestListener.assertNotifyMotionWasCalled( AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN | @@ -1396,7 +1414,7 @@ TEST_F(PointerChoreographerTest, TouchpadAddsPointerPositionToTheCoords) { .pointer(PointerBuilder(/*id=*/2, ToolType::FINGER).x(100).y(0)) .classification(MotionClassification::MULTI_FINGER_SWIPE) .deviceId(DEVICE_ID) - .displayId(ui::ADISPLAY_ID_NONE) + .displayId(ui::LogicalDisplayId::INVALID) .build()); mTestListener.assertNotifyMotionWasCalled( AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN | @@ -1411,7 +1429,7 @@ TEST_F(PointerChoreographerTest, TouchpadAddsPointerPositionToTheCoords) { .pointer(PointerBuilder(/*id=*/2, ToolType::FINGER).x(110).y(10)) .classification(MotionClassification::MULTI_FINGER_SWIPE) .deviceId(DEVICE_ID) - .displayId(ui::ADISPLAY_ID_NONE) + .displayId(ui::LogicalDisplayId::INVALID) .build()); mTestListener.assertNotifyMotionWasCalled( AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), @@ -1430,7 +1448,7 @@ TEST_F(PointerChoreographerTest, mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD, - ui::ADISPLAY_ID_NONE), + ui::LogicalDisplayId::INVALID), generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD, ANOTHER_DISPLAY_ID)}}); auto unassociatedMousePc = assertPointerControllerCreated(ControllerType::MOUSE); @@ -1469,7 +1487,7 @@ TEST_F(PointerChoreographerTest, DoesNotMovePointerForTouchpadSource) { mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD, - ui::ADISPLAY_ID_NONE)}}); + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); ASSERT_EQ(DISPLAY_ID, pc->getDisplayId()); @@ -1486,7 +1504,7 @@ TEST_F(PointerChoreographerTest, DoesNotMovePointerForTouchpadSource) { mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHPAD) .pointer(FIRST_TOUCH_POINTER) .deviceId(DEVICE_ID) - .displayId(ui::ADISPLAY_ID_NONE) + .displayId(ui::LogicalDisplayId::INVALID) .build()); // Check that there's no update on the PointerController. @@ -1495,7 +1513,7 @@ TEST_F(PointerChoreographerTest, DoesNotMovePointerForTouchpadSource) { // Check x-y coordinates, displayId and cursor position are not changed. mTestListener.assertNotifyMotionWasCalled( - AllOf(WithCoords(100, 200), WithDisplayId(ui::ADISPLAY_ID_NONE), + AllOf(WithCoords(100, 200), WithDisplayId(ui::LogicalDisplayId::INVALID), WithCursorPosition(AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_CURSOR_POSITION))); } @@ -1506,7 +1524,7 @@ TEST_F(PointerChoreographerTest, WhenPointerCaptureEnabledTouchpadHidesPointer) mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD, - ui::ADISPLAY_ID_NONE)}}); + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); ASSERT_EQ(DISPLAY_ID, pc->getDisplayId()); ASSERT_TRUE(pc->isPointerShown()); @@ -1525,7 +1543,8 @@ TEST_F(PointerChoreographerTest, SetsPointerIconForMouse) { mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); pc->assertPointerIconNotSet(); @@ -1540,7 +1559,8 @@ TEST_F(PointerChoreographerTest, DoesNotSetMousePointerIconForWrongDisplayId) { mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); pc->assertPointerIconNotSet(); @@ -1556,7 +1576,8 @@ TEST_F(PointerChoreographerTest, DoesNotSetPointerIconForWrongDeviceId) { mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); pc->assertPointerIconNotSet(); @@ -1572,7 +1593,8 @@ TEST_F(PointerChoreographerTest, SetsCustomPointerIconForMouse) { mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); pc->assertCustomPointerIconNotSet(); @@ -1595,7 +1617,7 @@ TEST_F(PointerChoreographerTest, SetsPointerIconForMouseOnTwoDisplays) { mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE), + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID), generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_MOUSE, ANOTHER_DISPLAY_ID)}}); auto firstMousePc = assertPointerControllerCreated(ControllerType::MOUSE); ASSERT_EQ(DISPLAY_ID, firstMousePc->getDisplayId()); @@ -1790,14 +1812,14 @@ TEST_P(StylusTestFixture, SetsPointerIconForMouseAndStylus) { mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE), + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID), generateTestDeviceInfo(SECOND_DEVICE_ID, source, DISPLAY_ID)}}); mChoreographer.setDisplayViewports(createViewports({DISPLAY_ID})); mChoreographer.notifyMotion( MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE, AINPUT_SOURCE_MOUSE) .pointer(MOUSE_POINTER) .deviceId(DEVICE_ID) - .displayId(ui::ADISPLAY_ID_NONE) + .displayId(ui::LogicalDisplayId::INVALID) .build()); auto mousePc = assertPointerControllerCreated(ControllerType::MOUSE); mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_ENTER, source) @@ -1825,7 +1847,7 @@ TEST_F(PointerChoreographerTest, SetPointerIconVisibilityHidesPointerOnDisplay) mChoreographer.setDefaultMouseDisplayId(DISPLAY_ID); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE), + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::LogicalDisplayId::INVALID), generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_MOUSE, ANOTHER_DISPLAY_ID)}}); auto firstMousePc = assertPointerControllerCreated(ControllerType::MOUSE); ASSERT_EQ(DISPLAY_ID, firstMousePc->getDisplayId()); @@ -1882,7 +1904,8 @@ TEST_F(PointerChoreographerTest, SetPointerIconVisibilityHidesPointerWhenDeviceC mChoreographer.setPointerIconVisibility(DISPLAY_ID, false); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE, + ui::LogicalDisplayId::INVALID)}}); auto mousePc = assertPointerControllerCreated(ControllerType::MOUSE); ASSERT_EQ(DISPLAY_ID, mousePc->getDisplayId()); @@ -1900,7 +1923,7 @@ TEST_F(PointerChoreographerTest, SetPointerIconVisibilityHidesPointerForTouchpad mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD, - ui::ADISPLAY_ID_NONE)}}); + ui::LogicalDisplayId::INVALID)}}); auto touchpadPc = assertPointerControllerCreated(ControllerType::MOUSE); ASSERT_EQ(DISPLAY_ID, touchpadPc->getDisplayId()); @@ -1945,7 +1968,8 @@ TEST_F(PointerChoreographerTest, DrawingTabletCanReportMouseEvent) { mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE, + ui::LogicalDisplayId::INVALID)}}); // There should be no controller created when a drawing tablet is connected assertPointerControllerNotCreated(); @@ -1972,7 +1996,8 @@ TEST_F(PointerChoreographerTest, MultipleDrawingTabletsReportMouseEvents) { // First drawing tablet is added mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE, + ui::LogicalDisplayId::INVALID)}}); assertPointerControllerNotCreated(); mChoreographer.notifyMotion( @@ -1987,9 +2012,10 @@ TEST_F(PointerChoreographerTest, MultipleDrawingTabletsReportMouseEvents) { // Second drawing tablet is added mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE, ui::ADISPLAY_ID_NONE), + {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE, + ui::LogicalDisplayId::INVALID), generateTestDeviceInfo(SECOND_DEVICE_ID, DRAWING_TABLET_SOURCE, - ui::ADISPLAY_ID_NONE)}}); + ui::LogicalDisplayId::INVALID)}}); assertPointerControllerNotRemoved(pc); mChoreographer.notifyMotion( @@ -2002,7 +2028,8 @@ TEST_F(PointerChoreographerTest, MultipleDrawingTabletsReportMouseEvents) { // First drawing tablet is removed mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE, + ui::LogicalDisplayId::INVALID)}}); assertPointerControllerNotRemoved(pc); // Second drawing tablet is removed @@ -2017,9 +2044,10 @@ TEST_F(PointerChoreographerTest, MouseAndDrawingTabletReportMouseEvents) { // Mouse and drawing tablet connected mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE, ui::ADISPLAY_ID_NONE), + {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE, + ui::LogicalDisplayId::INVALID), generateTestDeviceInfo(SECOND_DEVICE_ID, AINPUT_SOURCE_MOUSE, - ui::ADISPLAY_ID_NONE)}}); + ui::LogicalDisplayId::INVALID)}}); auto pc = assertPointerControllerCreated(ControllerType::MOUSE); ASSERT_TRUE(pc->isPointerShown()); @@ -2034,7 +2062,8 @@ TEST_F(PointerChoreographerTest, MouseAndDrawingTabletReportMouseEvents) { // Remove the mouse device mChoreographer.notifyInputDevicesChanged( {/*id=*/0, - {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE, ui::ADISPLAY_ID_NONE)}}); + {generateTestDeviceInfo(DEVICE_ID, DRAWING_TABLET_SOURCE, + ui::LogicalDisplayId::INVALID)}}); // The mouse controller should not be removed, because the drawing tablet has produced a // mouse event, so we are treating it as a mouse too. diff --git a/services/inputflinger/tests/PreferStylusOverTouch_test.cpp b/services/inputflinger/tests/PreferStylusOverTouch_test.cpp index c273e92de6..a36d526913 100644 --- a/services/inputflinger/tests/PreferStylusOverTouch_test.cpp +++ b/services/inputflinger/tests/PreferStylusOverTouch_test.cpp @@ -64,7 +64,7 @@ static NotifyMotionArgs generateMotionArgs(nsecs_t downTime, nsecs_t eventTime, // Define a valid motion event. NotifyMotionArgs args(/*id=*/0, eventTime, /*readTime=*/0, deviceId, source, - /*displayId=*/ui::ADISPLAY_ID_DEFAULT, POLICY_FLAG_PASS_TO_USER, action, + ui::LogicalDisplayId::DEFAULT, POLICY_FLAG_PASS_TO_USER, action, /* actionButton */ 0, /*flags=*/0, AMETA_NONE, /*buttonState=*/0, MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE, pointerCount, pointerProperties, @@ -439,7 +439,7 @@ TEST_F(PreferStylusOverTouchTest, MixedStylusAndTouchDeviceIsCanceledAtFirst) { InputDeviceInfo stylusDevice; stylusDevice.initialize(STYLUS_DEVICE_ID, /*generation=*/1, /*controllerNumber=*/1, /*identifier=*/{}, "stylus device", /*external=*/false, - /*hasMic=*/false, ui::ADISPLAY_ID_NONE); + /*hasMic=*/false, ui::LogicalDisplayId::INVALID); notifyInputDevicesChanged({stylusDevice}); // The touchscreen device was removed, so we no longer remember anything about it. We should // again start blocking touch events from it. diff --git a/services/inputflinger/tests/TouchpadInputMapper_test.cpp b/services/inputflinger/tests/TouchpadInputMapper_test.cpp index 245497ca4c..2b62dd13ef 100644 --- a/services/inputflinger/tests/TouchpadInputMapper_test.cpp +++ b/services/inputflinger/tests/TouchpadInputMapper_test.cpp @@ -37,7 +37,7 @@ constexpr auto BUTTON_RELEASE = AMOTION_EVENT_ACTION_BUTTON_RELEASE; constexpr auto HOVER_MOVE = AMOTION_EVENT_ACTION_HOVER_MOVE; constexpr auto HOVER_ENTER = AMOTION_EVENT_ACTION_HOVER_ENTER; constexpr auto HOVER_EXIT = AMOTION_EVENT_ACTION_HOVER_EXIT; -constexpr ui::LogicalDisplayId DISPLAY_ID = ui::ADISPLAY_ID_DEFAULT; +constexpr ui::LogicalDisplayId DISPLAY_ID = ui::LogicalDisplayId::DEFAULT; constexpr int32_t DISPLAY_WIDTH = 480; constexpr int32_t DISPLAY_HEIGHT = 800; constexpr std::optional<uint8_t> NO_PORT = std::nullopt; // no physical port is specified diff --git a/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp b/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp index 80430d1d22..853f628a13 100644 --- a/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp +++ b/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp @@ -88,7 +88,7 @@ static NotifyMotionArgs generateMotionArgs(nsecs_t downTime, nsecs_t eventTime, // Define a valid motion event. NotifyMotionArgs args(/*id=*/0, eventTime, /*readTime=*/0, DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, - /*displayId=*/ui::ADISPLAY_ID_DEFAULT, POLICY_FLAG_PASS_TO_USER, action, + ui::LogicalDisplayId::DEFAULT, POLICY_FLAG_PASS_TO_USER, action, /*actionButton=*/0, /*flags=*/0, AMETA_NONE, /*buttonState=*/0, MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE, pointerCount, pointerProperties, @@ -104,7 +104,7 @@ static InputDeviceInfo generateTestDeviceInfo() { auto info = InputDeviceInfo(); info.initialize(DEVICE_ID, /*generation=*/1, /*controllerNumber=*/1, identifier, "alias", - /*isExternal=*/false, /*hasMic=*/false, ui::ADISPLAY_ID_NONE); + /*isExternal=*/false, /*hasMic=*/false, ui::LogicalDisplayId::INVALID); info.addSource(AINPUT_SOURCE_TOUCHSCREEN); info.addMotionRange(AMOTION_EVENT_AXIS_X, AINPUT_SOURCE_TOUCHSCREEN, 0, 1599, /*flat=*/0, /*fuzz=*/0, X_RESOLUTION); @@ -434,7 +434,7 @@ TEST_F(UnwantedInteractionBlockerTest, ConfigurationChangedIsPassedToNextListene TEST_F(UnwantedInteractionBlockerTest, KeyIsPassedToNextListener) { // Create a basic key event and send to blocker NotifyKeyArgs args(/*sequenceNum=*/1, /*eventTime=*/2, /*readTime=*/21, /*deviceId=*/3, - AINPUT_SOURCE_KEYBOARD, ui::ADISPLAY_ID_DEFAULT, /*policyFlags=*/0, + AINPUT_SOURCE_KEYBOARD, ui::LogicalDisplayId::DEFAULT, /*policyFlags=*/0, AKEY_EVENT_ACTION_DOWN, /*flags=*/4, AKEYCODE_HOME, /*scanCode=*/5, AMETA_NONE, /*downTime=*/6); diff --git a/services/inputflinger/tests/fuzzers/InputClassifierFuzzer.cpp b/services/inputflinger/tests/fuzzers/InputClassifierFuzzer.cpp index 0446d76218..0b4ac1fe86 100644 --- a/services/inputflinger/tests/fuzzers/InputClassifierFuzzer.cpp +++ b/services/inputflinger/tests/fuzzers/InputClassifierFuzzer.cpp @@ -54,7 +54,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) { mClassifier->notifyKey({/*sequenceNum=*/fdp.ConsumeIntegral<int32_t>(), eventTime, readTime, /*deviceId=*/fdp.ConsumeIntegral<int32_t>(), - AINPUT_SOURCE_KEYBOARD, ui::ADISPLAY_ID_DEFAULT, + AINPUT_SOURCE_KEYBOARD, ui::LogicalDisplayId::DEFAULT, /*policyFlags=*/fdp.ConsumeIntegral<uint32_t>(), AKEY_EVENT_ACTION_DOWN, /*flags=*/fdp.ConsumeIntegral<int32_t>(), AKEYCODE_HOME, |