Loading libs/input/PointerController.cpp +17 −78 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ #include <SkColor.h> #include <android-base/stringprintf.h> #include <android-base/thread_annotations.h> #include <com_android_input_flags.h> #include <ftl/enum.h> #include <mutex> Loading @@ -35,14 +34,10 @@ #define INDENT2 " " #define INDENT3 " " namespace input_flags = com::android::input::flags; namespace android { namespace { static const bool ENABLE_POINTER_CHOREOGRAPHER = input_flags::enable_pointer_choreographer(); const ui::Transform kIdentityTransform; } // namespace Loading @@ -68,27 +63,24 @@ void PointerController::DisplayInfoListener::onPointerControllerDestroyed() { std::shared_ptr<PointerController> PointerController::create( const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled, ControllerType type) { SpriteController& spriteController, ControllerType type) { // using 'new' to access non-public constructor std::shared_ptr<PointerController> controller; switch (type) { case ControllerType::MOUSE: controller = std::shared_ptr<PointerController>( new MousePointerController(policy, looper, spriteController, enabled)); new MousePointerController(policy, looper, spriteController)); break; case ControllerType::TOUCH: controller = std::shared_ptr<PointerController>( new TouchPointerController(policy, looper, spriteController, enabled)); new TouchPointerController(policy, looper, spriteController)); break; case ControllerType::STYLUS: controller = std::shared_ptr<PointerController>( new StylusPointerController(policy, looper, spriteController, enabled)); new StylusPointerController(policy, looper, spriteController)); break; case ControllerType::LEGACY: default: controller = std::shared_ptr<PointerController>( new PointerController(policy, looper, spriteController, enabled)); break; LOG_ALWAYS_FATAL("Invalid ControllerType: %d", static_cast<int>(type)); } /* Loading @@ -108,10 +100,9 @@ std::shared_ptr<PointerController> PointerController::create( } PointerController::PointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled) const sp<Looper>& looper, SpriteController& spriteController) : PointerController( policy, looper, spriteController, enabled, policy, looper, spriteController, [](const sp<android::gui::WindowInfosListener>& listener) { auto initialInfo = std::make_pair(std::vector<android::gui::WindowInfo>{}, std::vector<android::gui::DisplayInfo>{}); Loading @@ -125,11 +116,9 @@ PointerController::PointerController(const sp<PointerControllerPolicyInterface>& PointerController::PointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled, const WindowListenerRegisterConsumer& registerListener, WindowListenerUnregisterConsumer unregisterListener) : mEnabled(enabled), mContext(policy, looper, spriteController, *this), : mContext(policy, looper, spriteController, *this), mCursorController(mContext), mDisplayInfoListener(sp<DisplayInfoListener>::make(this)), mUnregisterWindowInfosListener(std::move(unregisterListener)) { Loading @@ -149,14 +138,10 @@ std::mutex& PointerController::getLock() const { } std::optional<FloatRect> PointerController::getBounds() const { if (!mEnabled) return {}; return mCursorController.getBounds(); } void PointerController::move(float deltaX, float deltaY) { if (!mEnabled) return; const int32_t displayId = mCursorController.getDisplayId(); vec2 transformed; { Loading @@ -168,8 +153,6 @@ void PointerController::move(float deltaX, float deltaY) { } void PointerController::setPosition(float x, float y) { if (!mEnabled) return; const int32_t displayId = mCursorController.getDisplayId(); vec2 transformed; { Loading @@ -181,10 +164,6 @@ void PointerController::setPosition(float x, float y) { } FloatPoint PointerController::getPosition() const { if (!mEnabled) { return FloatPoint{0, 0}; } const int32_t displayId = mCursorController.getDisplayId(); const auto p = mCursorController.getPosition(); { Loading @@ -195,28 +174,20 @@ FloatPoint PointerController::getPosition() const { } int32_t PointerController::getDisplayId() const { if (!mEnabled) return ADISPLAY_ID_NONE; return mCursorController.getDisplayId(); } void PointerController::fade(Transition transition) { if (!mEnabled) return; std::scoped_lock lock(getLock()); mCursorController.fade(transition); } void PointerController::unfade(Transition transition) { if (!mEnabled) return; std::scoped_lock lock(getLock()); mCursorController.unfade(transition); } void PointerController::setPresentation(Presentation presentation) { if (!mEnabled) return; std::scoped_lock lock(getLock()); if (mLocked.presentation == presentation) { Loading @@ -225,33 +196,13 @@ void PointerController::setPresentation(Presentation presentation) { mLocked.presentation = presentation; if (ENABLE_POINTER_CHOREOGRAPHER) { // When pointer choreographer is enabled, the presentation mode is only set once when the // PointerController is constructed, before the display viewport is provided. // TODO(b/293587049): Clean up the PointerController interface after pointer choreographer // is permanently enabled. The presentation can be set in the constructor. // The presentation mode is only set once when the PointerController is constructed, // before the display viewport is provided. mCursorController.setStylusHoverMode(presentation == Presentation::STYLUS_HOVER); return; } if (!mCursorController.isViewportValid()) { return; } if (presentation == Presentation::POINTER || presentation == Presentation::STYLUS_HOVER) { // For now, we support stylus hover using the mouse cursor implementation. // TODO: Add proper support for stylus hover icons. mCursorController.setStylusHoverMode(presentation == Presentation::STYLUS_HOVER); mCursorController.getAdditionalMouseResources(); clearSpotsLocked(); } } void PointerController::setSpots(const PointerCoords* spotCoords, const uint32_t* spotIdToIndex, BitSet32 spotIdBits, int32_t displayId) { if (!mEnabled) return; std::scoped_lock lock(getLock()); std::array<PointerCoords, MAX_POINTERS> outSpotCoords{}; const ui::Transform& transform = getTransformForDisplayLocked(displayId); Loading @@ -278,8 +229,6 @@ void PointerController::setSpots(const PointerCoords* spotCoords, const uint32_t } void PointerController::clearSpots() { if (!mEnabled) return; std::scoped_lock lock(getLock()); clearSpotsLocked(); } Loading Loading @@ -328,22 +277,16 @@ void PointerController::setDisplayViewport(const DisplayViewport& viewport) { } void PointerController::updatePointerIcon(PointerIconStyle iconId) { if (!mEnabled) return; std::scoped_lock lock(getLock()); mCursorController.updatePointerIcon(iconId); } void PointerController::setCustomPointerIcon(const SpriteIcon& icon) { if (!mEnabled) return; std::scoped_lock lock(getLock()); mCursorController.setCustomPointerIcon(icon); } void PointerController::setSkipScreenshot(int32_t displayId, bool skip) { if (!mEnabled) return; std::scoped_lock lock(getLock()); if (skip) { mLocked.displaysToSkipScreenshot.insert(displayId); Loading Loading @@ -392,10 +335,6 @@ const ui::Transform& PointerController::getTransformForDisplayLocked(int display } std::string PointerController::dump() { if (!mEnabled) { return INDENT "PointerController: DISABLED due to ongoing PointerChoreographer refactor\n"; } std::string dump = INDENT "PointerController:\n"; std::scoped_lock lock(getLock()); dump += StringPrintf(INDENT2 "Presentation: %s\n", Loading @@ -416,8 +355,8 @@ std::string PointerController::dump() { MousePointerController::MousePointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled) : PointerController(policy, looper, spriteController, enabled) { SpriteController& spriteController) : PointerController(policy, looper, spriteController) { PointerController::setPresentation(Presentation::POINTER); } Loading @@ -429,8 +368,8 @@ MousePointerController::~MousePointerController() { TouchPointerController::TouchPointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled) : PointerController(policy, looper, spriteController, enabled) { SpriteController& spriteController) : PointerController(policy, looper, spriteController) { PointerController::setPresentation(Presentation::SPOT); } Loading @@ -442,8 +381,8 @@ TouchPointerController::~TouchPointerController() { StylusPointerController::StylusPointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled) : PointerController(policy, looper, spriteController, enabled) { SpriteController& spriteController) : PointerController(policy, looper, spriteController) { PointerController::setPresentation(Presentation::STYLUS_HOVER); } Loading libs/input/PointerController.h +6 −12 Original line number Diff line number Diff line Loading @@ -47,8 +47,7 @@ class PointerController : public PointerControllerInterface { public: static std::shared_ptr<PointerController> create( const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled, ControllerType type = ControllerType::LEGACY); SpriteController& spriteController, ControllerType type); ~PointerController() override; Loading Loading @@ -87,12 +86,12 @@ protected: // Constructor used to test WindowInfosListener registration. PointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled, SpriteController& spriteController, const WindowListenerRegisterConsumer& registerListener, WindowListenerUnregisterConsumer unregisterListener); PointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled); SpriteController& spriteController); private: friend PointerControllerContext::LooperCallback; Loading @@ -104,8 +103,6 @@ private: // we use the DisplayInfoListener's lock in PointerController. std::mutex& getLock() const; const bool mEnabled; PointerControllerContext mContext; MouseCursorController mCursorController; Loading Loading @@ -144,8 +141,7 @@ class MousePointerController : public PointerController { public: /** A version of PointerController that controls one mouse pointer. */ MousePointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled); const sp<Looper>& looper, SpriteController& spriteController); ~MousePointerController() override; Loading @@ -164,8 +160,7 @@ class TouchPointerController : public PointerController { public: /** A version of PointerController that controls touch spots. */ TouchPointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled); const sp<Looper>& looper, SpriteController& spriteController); ~TouchPointerController() override; Loading Loading @@ -210,8 +205,7 @@ class StylusPointerController : public PointerController { public: /** A version of PointerController that controls one stylus pointer. */ StylusPointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled); const sp<Looper>& looper, SpriteController& spriteController); ~StylusPointerController() override; Loading libs/input/tests/PointerController_test.cpp +2 −26 Original line number Diff line number Diff line Loading @@ -14,7 +14,6 @@ * limitations under the License. */ #include <com_android_input_flags.h> #include <flag_macros.h> #include <gmock/gmock.h> #include <gtest/gtest.h> Loading @@ -30,8 +29,6 @@ namespace android { namespace input_flags = com::android::input::flags; enum TestCursorType { CURSOR_TYPE_DEFAULT = 0, CURSOR_TYPE_HOVER, Loading Loading @@ -150,7 +147,6 @@ public: SpriteController& spriteController) : PointerController( policy, looper, spriteController, /*enabled=*/true, [®isteredListener](const sp<android::gui::WindowInfosListener>& listener) -> std::vector<gui::DisplayInfo> { // Register listener Loading Loading @@ -258,8 +254,7 @@ TEST_F(PointerControllerTest, useStylusTypeForStylusHover) { mPointerController->reloadPointerResources(); } TEST_F_WITH_FLAGS(PointerControllerTest, setPresentationBeforeDisplayViewportDoesNotLoadResources, REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(input_flags, enable_pointer_choreographer))) { TEST_F(PointerControllerTest, setPresentationBeforeDisplayViewportDoesNotLoadResources) { // Setting the presentation mode before a display viewport is set will not load any resources. mPointerController->setPresentation(PointerController::Presentation::POINTER); ASSERT_TRUE(mPolicy->noResourcesAreLoaded()); Loading @@ -269,26 +264,7 @@ TEST_F_WITH_FLAGS(PointerControllerTest, setPresentationBeforeDisplayViewportDoe ASSERT_TRUE(mPolicy->allResourcesAreLoaded()); } TEST_F_WITH_FLAGS(PointerControllerTest, updatePointerIcon, REQUIRES_FLAGS_DISABLED(ACONFIG_FLAG(input_flags, enable_pointer_choreographer))) { ensureDisplayViewportIsSet(); mPointerController->setPresentation(PointerController::Presentation::POINTER); mPointerController->unfade(PointerController::Transition::IMMEDIATE); int32_t type = CURSOR_TYPE_ADDITIONAL; std::pair<float, float> hotspot = getHotSpotCoordinatesForType(type); EXPECT_CALL(*mPointerSprite, setVisible(true)); EXPECT_CALL(*mPointerSprite, setAlpha(1.0f)); EXPECT_CALL(*mPointerSprite, setIcon(AllOf(Field(&SpriteIcon::style, static_cast<PointerIconStyle>(type)), Field(&SpriteIcon::hotSpotX, hotspot.first), Field(&SpriteIcon::hotSpotY, hotspot.second)))); mPointerController->updatePointerIcon(static_cast<PointerIconStyle>(type)); } TEST_F_WITH_FLAGS(PointerControllerTest, updatePointerIconWithChoreographer, REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(input_flags, enable_pointer_choreographer))) { TEST_F(PointerControllerTest, updatePointerIconWithChoreographer) { // When PointerChoreographer is enabled, the presentation mode is set before the viewport. mPointerController->setPresentation(PointerController::Presentation::POINTER); ensureDisplayViewportIsSet(); Loading services/core/jni/com_android_server_input_InputManagerService.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -761,8 +761,7 @@ std::shared_ptr<PointerControllerInterface> NativeInputManager::createPointerCon std::scoped_lock _l(mLock); ensureSpriteControllerLocked(); std::shared_ptr<PointerController> pc = PointerController::create(this, mLooper, *mLocked.spriteController, /*enabled=*/true, type); PointerController::create(this, mLooper, *mLocked.spriteController, type); mLocked.pointerControllers.emplace_back(pc); return pc; } Loading Loading
libs/input/PointerController.cpp +17 −78 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ #include <SkColor.h> #include <android-base/stringprintf.h> #include <android-base/thread_annotations.h> #include <com_android_input_flags.h> #include <ftl/enum.h> #include <mutex> Loading @@ -35,14 +34,10 @@ #define INDENT2 " " #define INDENT3 " " namespace input_flags = com::android::input::flags; namespace android { namespace { static const bool ENABLE_POINTER_CHOREOGRAPHER = input_flags::enable_pointer_choreographer(); const ui::Transform kIdentityTransform; } // namespace Loading @@ -68,27 +63,24 @@ void PointerController::DisplayInfoListener::onPointerControllerDestroyed() { std::shared_ptr<PointerController> PointerController::create( const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled, ControllerType type) { SpriteController& spriteController, ControllerType type) { // using 'new' to access non-public constructor std::shared_ptr<PointerController> controller; switch (type) { case ControllerType::MOUSE: controller = std::shared_ptr<PointerController>( new MousePointerController(policy, looper, spriteController, enabled)); new MousePointerController(policy, looper, spriteController)); break; case ControllerType::TOUCH: controller = std::shared_ptr<PointerController>( new TouchPointerController(policy, looper, spriteController, enabled)); new TouchPointerController(policy, looper, spriteController)); break; case ControllerType::STYLUS: controller = std::shared_ptr<PointerController>( new StylusPointerController(policy, looper, spriteController, enabled)); new StylusPointerController(policy, looper, spriteController)); break; case ControllerType::LEGACY: default: controller = std::shared_ptr<PointerController>( new PointerController(policy, looper, spriteController, enabled)); break; LOG_ALWAYS_FATAL("Invalid ControllerType: %d", static_cast<int>(type)); } /* Loading @@ -108,10 +100,9 @@ std::shared_ptr<PointerController> PointerController::create( } PointerController::PointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled) const sp<Looper>& looper, SpriteController& spriteController) : PointerController( policy, looper, spriteController, enabled, policy, looper, spriteController, [](const sp<android::gui::WindowInfosListener>& listener) { auto initialInfo = std::make_pair(std::vector<android::gui::WindowInfo>{}, std::vector<android::gui::DisplayInfo>{}); Loading @@ -125,11 +116,9 @@ PointerController::PointerController(const sp<PointerControllerPolicyInterface>& PointerController::PointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled, const WindowListenerRegisterConsumer& registerListener, WindowListenerUnregisterConsumer unregisterListener) : mEnabled(enabled), mContext(policy, looper, spriteController, *this), : mContext(policy, looper, spriteController, *this), mCursorController(mContext), mDisplayInfoListener(sp<DisplayInfoListener>::make(this)), mUnregisterWindowInfosListener(std::move(unregisterListener)) { Loading @@ -149,14 +138,10 @@ std::mutex& PointerController::getLock() const { } std::optional<FloatRect> PointerController::getBounds() const { if (!mEnabled) return {}; return mCursorController.getBounds(); } void PointerController::move(float deltaX, float deltaY) { if (!mEnabled) return; const int32_t displayId = mCursorController.getDisplayId(); vec2 transformed; { Loading @@ -168,8 +153,6 @@ void PointerController::move(float deltaX, float deltaY) { } void PointerController::setPosition(float x, float y) { if (!mEnabled) return; const int32_t displayId = mCursorController.getDisplayId(); vec2 transformed; { Loading @@ -181,10 +164,6 @@ void PointerController::setPosition(float x, float y) { } FloatPoint PointerController::getPosition() const { if (!mEnabled) { return FloatPoint{0, 0}; } const int32_t displayId = mCursorController.getDisplayId(); const auto p = mCursorController.getPosition(); { Loading @@ -195,28 +174,20 @@ FloatPoint PointerController::getPosition() const { } int32_t PointerController::getDisplayId() const { if (!mEnabled) return ADISPLAY_ID_NONE; return mCursorController.getDisplayId(); } void PointerController::fade(Transition transition) { if (!mEnabled) return; std::scoped_lock lock(getLock()); mCursorController.fade(transition); } void PointerController::unfade(Transition transition) { if (!mEnabled) return; std::scoped_lock lock(getLock()); mCursorController.unfade(transition); } void PointerController::setPresentation(Presentation presentation) { if (!mEnabled) return; std::scoped_lock lock(getLock()); if (mLocked.presentation == presentation) { Loading @@ -225,33 +196,13 @@ void PointerController::setPresentation(Presentation presentation) { mLocked.presentation = presentation; if (ENABLE_POINTER_CHOREOGRAPHER) { // When pointer choreographer is enabled, the presentation mode is only set once when the // PointerController is constructed, before the display viewport is provided. // TODO(b/293587049): Clean up the PointerController interface after pointer choreographer // is permanently enabled. The presentation can be set in the constructor. // The presentation mode is only set once when the PointerController is constructed, // before the display viewport is provided. mCursorController.setStylusHoverMode(presentation == Presentation::STYLUS_HOVER); return; } if (!mCursorController.isViewportValid()) { return; } if (presentation == Presentation::POINTER || presentation == Presentation::STYLUS_HOVER) { // For now, we support stylus hover using the mouse cursor implementation. // TODO: Add proper support for stylus hover icons. mCursorController.setStylusHoverMode(presentation == Presentation::STYLUS_HOVER); mCursorController.getAdditionalMouseResources(); clearSpotsLocked(); } } void PointerController::setSpots(const PointerCoords* spotCoords, const uint32_t* spotIdToIndex, BitSet32 spotIdBits, int32_t displayId) { if (!mEnabled) return; std::scoped_lock lock(getLock()); std::array<PointerCoords, MAX_POINTERS> outSpotCoords{}; const ui::Transform& transform = getTransformForDisplayLocked(displayId); Loading @@ -278,8 +229,6 @@ void PointerController::setSpots(const PointerCoords* spotCoords, const uint32_t } void PointerController::clearSpots() { if (!mEnabled) return; std::scoped_lock lock(getLock()); clearSpotsLocked(); } Loading Loading @@ -328,22 +277,16 @@ void PointerController::setDisplayViewport(const DisplayViewport& viewport) { } void PointerController::updatePointerIcon(PointerIconStyle iconId) { if (!mEnabled) return; std::scoped_lock lock(getLock()); mCursorController.updatePointerIcon(iconId); } void PointerController::setCustomPointerIcon(const SpriteIcon& icon) { if (!mEnabled) return; std::scoped_lock lock(getLock()); mCursorController.setCustomPointerIcon(icon); } void PointerController::setSkipScreenshot(int32_t displayId, bool skip) { if (!mEnabled) return; std::scoped_lock lock(getLock()); if (skip) { mLocked.displaysToSkipScreenshot.insert(displayId); Loading Loading @@ -392,10 +335,6 @@ const ui::Transform& PointerController::getTransformForDisplayLocked(int display } std::string PointerController::dump() { if (!mEnabled) { return INDENT "PointerController: DISABLED due to ongoing PointerChoreographer refactor\n"; } std::string dump = INDENT "PointerController:\n"; std::scoped_lock lock(getLock()); dump += StringPrintf(INDENT2 "Presentation: %s\n", Loading @@ -416,8 +355,8 @@ std::string PointerController::dump() { MousePointerController::MousePointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled) : PointerController(policy, looper, spriteController, enabled) { SpriteController& spriteController) : PointerController(policy, looper, spriteController) { PointerController::setPresentation(Presentation::POINTER); } Loading @@ -429,8 +368,8 @@ MousePointerController::~MousePointerController() { TouchPointerController::TouchPointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled) : PointerController(policy, looper, spriteController, enabled) { SpriteController& spriteController) : PointerController(policy, looper, spriteController) { PointerController::setPresentation(Presentation::SPOT); } Loading @@ -442,8 +381,8 @@ TouchPointerController::~TouchPointerController() { StylusPointerController::StylusPointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled) : PointerController(policy, looper, spriteController, enabled) { SpriteController& spriteController) : PointerController(policy, looper, spriteController) { PointerController::setPresentation(Presentation::STYLUS_HOVER); } Loading
libs/input/PointerController.h +6 −12 Original line number Diff line number Diff line Loading @@ -47,8 +47,7 @@ class PointerController : public PointerControllerInterface { public: static std::shared_ptr<PointerController> create( const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled, ControllerType type = ControllerType::LEGACY); SpriteController& spriteController, ControllerType type); ~PointerController() override; Loading Loading @@ -87,12 +86,12 @@ protected: // Constructor used to test WindowInfosListener registration. PointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled, SpriteController& spriteController, const WindowListenerRegisterConsumer& registerListener, WindowListenerUnregisterConsumer unregisterListener); PointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled); SpriteController& spriteController); private: friend PointerControllerContext::LooperCallback; Loading @@ -104,8 +103,6 @@ private: // we use the DisplayInfoListener's lock in PointerController. std::mutex& getLock() const; const bool mEnabled; PointerControllerContext mContext; MouseCursorController mCursorController; Loading Loading @@ -144,8 +141,7 @@ class MousePointerController : public PointerController { public: /** A version of PointerController that controls one mouse pointer. */ MousePointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled); const sp<Looper>& looper, SpriteController& spriteController); ~MousePointerController() override; Loading @@ -164,8 +160,7 @@ class TouchPointerController : public PointerController { public: /** A version of PointerController that controls touch spots. */ TouchPointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled); const sp<Looper>& looper, SpriteController& spriteController); ~TouchPointerController() override; Loading Loading @@ -210,8 +205,7 @@ class StylusPointerController : public PointerController { public: /** A version of PointerController that controls one stylus pointer. */ StylusPointerController(const sp<PointerControllerPolicyInterface>& policy, const sp<Looper>& looper, SpriteController& spriteController, bool enabled); const sp<Looper>& looper, SpriteController& spriteController); ~StylusPointerController() override; Loading
libs/input/tests/PointerController_test.cpp +2 −26 Original line number Diff line number Diff line Loading @@ -14,7 +14,6 @@ * limitations under the License. */ #include <com_android_input_flags.h> #include <flag_macros.h> #include <gmock/gmock.h> #include <gtest/gtest.h> Loading @@ -30,8 +29,6 @@ namespace android { namespace input_flags = com::android::input::flags; enum TestCursorType { CURSOR_TYPE_DEFAULT = 0, CURSOR_TYPE_HOVER, Loading Loading @@ -150,7 +147,6 @@ public: SpriteController& spriteController) : PointerController( policy, looper, spriteController, /*enabled=*/true, [®isteredListener](const sp<android::gui::WindowInfosListener>& listener) -> std::vector<gui::DisplayInfo> { // Register listener Loading Loading @@ -258,8 +254,7 @@ TEST_F(PointerControllerTest, useStylusTypeForStylusHover) { mPointerController->reloadPointerResources(); } TEST_F_WITH_FLAGS(PointerControllerTest, setPresentationBeforeDisplayViewportDoesNotLoadResources, REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(input_flags, enable_pointer_choreographer))) { TEST_F(PointerControllerTest, setPresentationBeforeDisplayViewportDoesNotLoadResources) { // Setting the presentation mode before a display viewport is set will not load any resources. mPointerController->setPresentation(PointerController::Presentation::POINTER); ASSERT_TRUE(mPolicy->noResourcesAreLoaded()); Loading @@ -269,26 +264,7 @@ TEST_F_WITH_FLAGS(PointerControllerTest, setPresentationBeforeDisplayViewportDoe ASSERT_TRUE(mPolicy->allResourcesAreLoaded()); } TEST_F_WITH_FLAGS(PointerControllerTest, updatePointerIcon, REQUIRES_FLAGS_DISABLED(ACONFIG_FLAG(input_flags, enable_pointer_choreographer))) { ensureDisplayViewportIsSet(); mPointerController->setPresentation(PointerController::Presentation::POINTER); mPointerController->unfade(PointerController::Transition::IMMEDIATE); int32_t type = CURSOR_TYPE_ADDITIONAL; std::pair<float, float> hotspot = getHotSpotCoordinatesForType(type); EXPECT_CALL(*mPointerSprite, setVisible(true)); EXPECT_CALL(*mPointerSprite, setAlpha(1.0f)); EXPECT_CALL(*mPointerSprite, setIcon(AllOf(Field(&SpriteIcon::style, static_cast<PointerIconStyle>(type)), Field(&SpriteIcon::hotSpotX, hotspot.first), Field(&SpriteIcon::hotSpotY, hotspot.second)))); mPointerController->updatePointerIcon(static_cast<PointerIconStyle>(type)); } TEST_F_WITH_FLAGS(PointerControllerTest, updatePointerIconWithChoreographer, REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(input_flags, enable_pointer_choreographer))) { TEST_F(PointerControllerTest, updatePointerIconWithChoreographer) { // When PointerChoreographer is enabled, the presentation mode is set before the viewport. mPointerController->setPresentation(PointerController::Presentation::POINTER); ensureDisplayViewportIsSet(); Loading
services/core/jni/com_android_server_input_InputManagerService.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -761,8 +761,7 @@ std::shared_ptr<PointerControllerInterface> NativeInputManager::createPointerCon std::scoped_lock _l(mLock); ensureSpriteControllerLocked(); std::shared_ptr<PointerController> pc = PointerController::create(this, mLooper, *mLocked.spriteController, /*enabled=*/true, type); PointerController::create(this, mLooper, *mLocked.spriteController, type); mLocked.pointerControllers.emplace_back(pc); return pc; } Loading