Loading libs/input/PointerController.cpp +0 −14 Original line number Diff line number Diff line Loading @@ -142,7 +142,6 @@ PointerController::PointerController(const sp<PointerControllerPolicyInterface>& PointerController::~PointerController() { mDisplayInfoListener->onPointerControllerDestroyed(); mUnregisterWindowInfosListener(mDisplayInfoListener); mContext.getPolicy()->onPointerDisplayIdChanged(ADISPLAY_ID_NONE, FloatPoint{0, 0}); } std::mutex& PointerController::getLock() const { Loading Loading @@ -313,12 +312,6 @@ void PointerController::reloadPointerResources() { } void PointerController::setDisplayViewport(const DisplayViewport& viewport) { struct PointerDisplayChangeArgs { int32_t displayId; FloatPoint cursorPosition; }; std::optional<PointerDisplayChangeArgs> pointerDisplayChanged; { // acquire lock std::scoped_lock lock(getLock()); Loading @@ -330,15 +323,8 @@ void PointerController::setDisplayViewport(const DisplayViewport& viewport) { mCursorController.setDisplayViewport(viewport, getAdditionalMouseResources); if (viewport.displayId != mLocked.pointerDisplayId) { mLocked.pointerDisplayId = viewport.displayId; pointerDisplayChanged = {viewport.displayId, mCursorController.getPosition()}; } } // release lock if (pointerDisplayChanged) { // Notify the policy without holding the pointer controller lock. mContext.getPolicy()->onPointerDisplayIdChanged(pointerDisplayChanged->displayId, pointerDisplayChanged->cursorPosition); } } void PointerController::updatePointerIcon(PointerIconStyle iconId) { Loading libs/input/PointerControllerContext.h +0 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,6 @@ public: virtual PointerIconStyle getDefaultPointerIconId() = 0; virtual PointerIconStyle getDefaultStylusIconId() = 0; virtual PointerIconStyle getCustomPointerIconId() = 0; virtual void onPointerDisplayIdChanged(int32_t displayId, const FloatPoint& position) = 0; }; /* Loading libs/input/tests/PointerController_test.cpp +0 −33 Original line number Diff line number Diff line Loading @@ -64,11 +64,9 @@ public: virtual PointerIconStyle getDefaultPointerIconId() override; virtual PointerIconStyle getDefaultStylusIconId() override; virtual PointerIconStyle getCustomPointerIconId() override; virtual void onPointerDisplayIdChanged(int32_t displayId, const FloatPoint& position) override; bool allResourcesAreLoaded(); bool noResourcesAreLoaded(); std::optional<int32_t> getLastReportedPointerDisplayId() { return latestPointerDisplayId; } private: void loadPointerIconForType(SpriteIcon* icon, int32_t cursorType); Loading @@ -76,7 +74,6 @@ private: bool pointerIconLoaded{false}; bool pointerResourcesLoaded{false}; bool additionalMouseResourcesLoaded{false}; std::optional<int32_t /*displayId*/> latestPointerDisplayId; }; void MockPointerControllerPolicyInterface::loadPointerIcon(SpriteIcon* icon, int32_t) { Loading Loading @@ -146,12 +143,6 @@ void MockPointerControllerPolicyInterface::loadPointerIconForType(SpriteIcon* ic icon->hotSpotY = hotSpot.second; } void MockPointerControllerPolicyInterface::onPointerDisplayIdChanged(int32_t displayId, const FloatPoint& /*position*/ ) { latestPointerDisplayId = displayId; } class TestPointerController : public PointerController { public: TestPointerController(sp<android::gui::WindowInfosListener>& registeredListener, Loading Loading @@ -348,30 +339,6 @@ TEST_F(PointerControllerTest, doesNotGetResourcesBeforeSettingViewport) { ensureDisplayViewportIsSet(); } TEST_F(PointerControllerTest, notifiesPolicyWhenPointerDisplayChanges) { EXPECT_FALSE(mPolicy->getLastReportedPointerDisplayId()) << "A pointer display change does not occur when PointerController is created."; ensureDisplayViewportIsSet(ADISPLAY_ID_DEFAULT); const auto lastReportedPointerDisplayId = mPolicy->getLastReportedPointerDisplayId(); ASSERT_TRUE(lastReportedPointerDisplayId) << "The policy is notified of a pointer display change when the viewport is first set."; EXPECT_EQ(ADISPLAY_ID_DEFAULT, *lastReportedPointerDisplayId) << "Incorrect pointer display notified."; ensureDisplayViewportIsSet(42); EXPECT_EQ(42, *mPolicy->getLastReportedPointerDisplayId()) << "The policy is notified when the pointer display changes."; // Release the PointerController. mPointerController = nullptr; EXPECT_EQ(ADISPLAY_ID_NONE, *mPolicy->getLastReportedPointerDisplayId()) << "The pointer display changes to invalid when PointerController is destroyed."; } TEST_F(PointerControllerTest, updatesSkipScreenshotFlagForTouchSpots) { ensureDisplayViewportIsSet(); Loading services/core/jni/com_android_server_input_InputManagerService.cpp +9 −149 Original line number Diff line number Diff line Loading @@ -88,7 +88,6 @@ namespace input_flags = com::android::input::flags; namespace android { static const bool ENABLE_POINTER_CHOREOGRAPHER = input_flags::enable_pointer_choreographer(); static const bool ENABLE_INPUT_FILTER_RUST = input_flags::enable_input_filter_rust_impl(); // The exponent used to calculate the pointer speed scaling factor. Loading Loading @@ -298,10 +297,8 @@ public: void setShowTouches(bool enabled); void setInteractive(bool interactive); void reloadCalibration(); void setPointerIconType(PointerIconStyle iconId); void reloadPointerIcons(); void requestPointerCapture(const sp<IBinder>& windowToken, bool enabled); void setCustomPointerIcon(const SpriteIcon& icon); bool setPointerIcon(std::variant<std::unique_ptr<SpriteIcon>, PointerIconStyle> icon, int32_t displayId, DeviceId deviceId, int32_t pointerId, const sp<IBinder>& inputToken); Loading @@ -316,7 +313,6 @@ public: /* --- InputReaderPolicyInterface implementation --- */ void getReaderConfiguration(InputReaderConfiguration* outConfig) override; std::shared_ptr<PointerControllerInterface> obtainPointerController(int32_t deviceId) override; void notifyInputDevicesChanged(const std::vector<InputDeviceInfo>& inputDevices) override; std::shared_ptr<KeyCharacterMap> getKeyboardLayoutOverlay( const InputDeviceIdentifier& identifier, Loading Loading @@ -375,7 +371,6 @@ public: virtual PointerIconStyle getDefaultPointerIconId(); virtual PointerIconStyle getDefaultStylusIconId(); virtual PointerIconStyle getCustomPointerIconId(); virtual void onPointerDisplayIdChanged(int32_t displayId, const FloatPoint& position); /* --- PointerChoreographerPolicyInterface implementation --- */ std::shared_ptr<PointerControllerInterface> createPointerController( Loading Loading @@ -409,19 +404,12 @@ private: // True if pointer gestures are enabled. bool pointerGesturesEnabled{true}; // Show touches feature enable/disable. bool showTouches{false}; // The latest request to enable or disable Pointer Capture. PointerCaptureRequest pointerCaptureRequest{}; // Sprite controller singleton, created on first use. std::shared_ptr<SpriteController> spriteController{}; // TODO(b/293587049): Remove when the PointerChoreographer refactoring is complete. // Pointer controller singleton, created and destroyed as needed. std::weak_ptr<PointerController> legacyPointerController{}; // The list of PointerControllers created and managed by the PointerChoreographer. std::list<std::weak_ptr<PointerController>> pointerControllers{}; Loading Loading @@ -505,13 +493,9 @@ void NativeInputManager::dump(std::string& dump) { dumpSet(mLocked.displaysWithMousePointerAccelerationDisabled).c_str()); dump += StringPrintf(INDENT "Pointer Gestures Enabled: %s\n", toString(mLocked.pointerGesturesEnabled)); dump += StringPrintf(INDENT "Show Touches: %s\n", toString(mLocked.showTouches)); dump += StringPrintf(INDENT "Pointer Capture: %s, seq=%" PRIu32 "\n", mLocked.pointerCaptureRequest.isEnable() ? "Enabled" : "Disabled", mLocked.pointerCaptureRequest.seq); if (auto pc = mLocked.legacyPointerController.lock(); pc) { dump += pc->dump(); } } // release lock dump += "\n"; Loading Loading @@ -556,9 +540,7 @@ void NativeInputManager::setDisplayViewports(JNIEnv* env, jobjectArray viewportO [&viewports](PointerController& pc) { pc.onDisplayViewportsUpdated(viewports); }); } // release lock if (ENABLE_POINTER_CHOREOGRAPHER) { mInputManager->getChoreographer().setDisplayViewports(viewports); } mInputManager->getReader().requestRefreshConfiguration( InputReaderConfiguration::Change::DISPLAY_INFO); } Loading Loading @@ -700,8 +682,6 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon : 1; outConfig->pointerGesturesEnabled = mLocked.pointerGesturesEnabled; outConfig->showTouches = mLocked.showTouches; outConfig->pointerCaptureRequest = mLocked.pointerCaptureRequest; outConfig->setDisplayViewports(mLocked.viewports); Loading Loading @@ -743,10 +723,6 @@ std::unordered_map<std::string, T> NativeInputManager::readMapFromInterleavedJav void NativeInputManager::forEachPointerControllerLocked( std::function<void(PointerController&)> apply) { if (auto pc = mLocked.legacyPointerController.lock(); pc) { apply(*pc); } auto it = mLocked.pointerControllers.begin(); while (it != mLocked.pointerControllers.end()) { auto pc = it->lock(); Loading Loading @@ -780,28 +756,6 @@ PointerIcon NativeInputManager::loadPointerIcon(JNIEnv* env, int32_t displayId, return android_view_PointerIcon_toNative(env, pointerIconObj.get()); } // TODO(b/293587049): Remove the old way of obtaining PointerController when the // PointerChoreographer refactoring is complete. std::shared_ptr<PointerControllerInterface> NativeInputManager::obtainPointerController( int32_t /* deviceId */) { ATRACE_CALL(); std::scoped_lock _l(mLock); std::shared_ptr<PointerController> controller = mLocked.legacyPointerController.lock(); if (controller == nullptr) { ensureSpriteControllerLocked(); // Disable the functionality of the legacy PointerController if PointerChoreographer is // enabled. controller = PointerController::create(this, mLooper, *mLocked.spriteController, /*enabled=*/!ENABLE_POINTER_CHOREOGRAPHER); mLocked.legacyPointerController = controller; updateInactivityTimeoutLocked(); } return controller; } std::shared_ptr<PointerControllerInterface> NativeInputManager::createPointerController( PointerControllerInterface::ControllerType type) { std::scoped_lock _l(mLock); Loading @@ -813,17 +767,6 @@ std::shared_ptr<PointerControllerInterface> NativeInputManager::createPointerCon return pc; } void NativeInputManager::onPointerDisplayIdChanged(int32_t pointerDisplayId, const FloatPoint& position) { if (ENABLE_POINTER_CHOREOGRAPHER) { return; } JNIEnv* env = jniEnv(); env->CallVoidMethod(mServiceObj, gServiceClassInfo.onPointerDisplayIdChanged, pointerDisplayId, position.x, position.y); checkAndClearExceptionFromCallback(env, "onPointerDisplayIdChanged"); } void NativeInputManager::notifyPointerDisplayIdChanged(int32_t pointerDisplayId, const FloatPoint& position) { // Notify the Reader so that devices can be reconfigured. Loading Loading @@ -1210,23 +1153,7 @@ void NativeInputManager::updateInactivityTimeoutLocked() REQUIRES(mLock) { } void NativeInputManager::setPointerDisplayId(int32_t displayId) { if (ENABLE_POINTER_CHOREOGRAPHER) { mInputManager->getChoreographer().setDefaultMouseDisplayId(displayId); } else { { // acquire lock std::scoped_lock _l(mLock); if (mLocked.pointerDisplayId == displayId) { return; } ALOGI("Setting pointer display id to %d.", displayId); mLocked.pointerDisplayId = displayId; } // release lock mInputManager->getReader().requestRefreshConfiguration( InputReaderConfiguration::Change::DISPLAY_INFO); } } int32_t NativeInputManager::getMousePointerSpeed() { Loading Loading @@ -1378,24 +1305,7 @@ void NativeInputManager::setInputDeviceEnabled(uint32_t deviceId, bool enabled) } void NativeInputManager::setShowTouches(bool enabled) { if (ENABLE_POINTER_CHOREOGRAPHER) { mInputManager->getChoreographer().setShowTouchesEnabled(enabled); return; } { // acquire lock std::scoped_lock _l(mLock); if (mLocked.showTouches == enabled) { return; } ALOGI("Setting show touches feature to %s.", enabled ? "enabled" : "disabled"); mLocked.showTouches = enabled; } // release lock mInputManager->getReader().requestRefreshConfiguration( InputReaderConfiguration::Change::SHOW_TOUCHES); } void NativeInputManager::requestPointerCapture(const sp<IBinder>& windowToken, bool enabled) { Loading @@ -1411,27 +1321,11 @@ void NativeInputManager::reloadCalibration() { InputReaderConfiguration::Change::TOUCH_AFFINE_TRANSFORMATION); } void NativeInputManager::setPointerIconType(PointerIconStyle iconId) { std::scoped_lock _l(mLock); std::shared_ptr<PointerController> controller = mLocked.legacyPointerController.lock(); if (controller != nullptr) { controller->updatePointerIcon(iconId); } } void NativeInputManager::reloadPointerIcons() { std::scoped_lock _l(mLock); forEachPointerControllerLocked([](PointerController& pc) { pc.reloadPointerResources(); }); } void NativeInputManager::setCustomPointerIcon(const SpriteIcon& icon) { std::scoped_lock _l(mLock); std::shared_ptr<PointerController> controller = mLocked.legacyPointerController.lock(); if (controller != nullptr) { controller->setCustomPointerIcon(icon); } } bool NativeInputManager::setPointerIcon( std::variant<std::unique_ptr<SpriteIcon>, PointerIconStyle> icon, int32_t displayId, DeviceId deviceId, int32_t pointerId, const sp<IBinder>& inputToken) { Loading @@ -1447,9 +1341,6 @@ bool NativeInputManager::setPointerIcon( } void NativeInputManager::setPointerIconVisibility(int32_t displayId, bool visible) { if (!ENABLE_POINTER_CHOREOGRAPHER) { return; } mInputManager->getChoreographer().setPointerIconVisibility(displayId, visible); } Loading Loading @@ -1819,38 +1710,14 @@ void NativeInputManager::setStylusButtonMotionEventsEnabled(bool enabled) { } FloatPoint NativeInputManager::getMouseCursorPosition(int32_t displayId) { if (ENABLE_POINTER_CHOREOGRAPHER) { return mInputManager->getChoreographer().getMouseCursorPosition(displayId); } // To maintain the status-quo, the displayId parameter (used when PointerChoreographer is // enabled) is ignored in the old pipeline. std::scoped_lock _l(mLock); const auto pc = mLocked.legacyPointerController.lock(); if (!pc) return {AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_CURSOR_POSITION}; return pc->getPosition(); } void NativeInputManager::setStylusPointerIconEnabled(bool enabled) { if (ENABLE_POINTER_CHOREOGRAPHER) { mInputManager->getChoreographer().setStylusPointerIconEnabled(enabled); return; } { // acquire lock std::scoped_lock _l(mLock); if (mLocked.stylusPointerIconEnabled == enabled) { return; } mLocked.stylusPointerIconEnabled = enabled; } // release lock mInputManager->getReader().requestRefreshConfiguration( InputReaderConfiguration::Change::DISPLAY_INFO); } void NativeInputManager::setInputMethodConnectionIsActive(bool isActive) { { // acquire lock std::scoped_lock _l(mLock); Loading Loading @@ -2598,13 +2465,7 @@ static void nativeDisableInputDevice(JNIEnv* env, jobject nativeImplObj, jint de } static void nativeSetPointerIconType(JNIEnv* env, jobject nativeImplObj, jint iconId) { // iconId is set in java from from frameworks/base/core/java/android/view/PointerIcon.java, // where the definition in <input/Input.h> is duplicated as a sealed class (type safe enum // equivalent in Java). NativeInputManager* im = getNativeInputManager(env, nativeImplObj); im->setPointerIconType(static_cast<PointerIconStyle>(iconId)); // TODO(b/311416205): Remove } static void nativeReloadPointerIcons(JNIEnv* env, jobject nativeImplObj) { Loading @@ -2614,8 +2475,7 @@ static void nativeReloadPointerIcons(JNIEnv* env, jobject nativeImplObj) { } static void nativeSetCustomPointerIcon(JNIEnv* env, jobject nativeImplObj, jobject iconObj) { NativeInputManager* im = getNativeInputManager(env, nativeImplObj); im->setCustomPointerIcon(toSpriteIcon(android_view_PointerIcon_toNative(env, iconObj))); // TODO(b/311416205): Remove } static bool nativeSetPointerIcon(JNIEnv* env, jobject nativeImplObj, jobject iconObj, Loading Loading
libs/input/PointerController.cpp +0 −14 Original line number Diff line number Diff line Loading @@ -142,7 +142,6 @@ PointerController::PointerController(const sp<PointerControllerPolicyInterface>& PointerController::~PointerController() { mDisplayInfoListener->onPointerControllerDestroyed(); mUnregisterWindowInfosListener(mDisplayInfoListener); mContext.getPolicy()->onPointerDisplayIdChanged(ADISPLAY_ID_NONE, FloatPoint{0, 0}); } std::mutex& PointerController::getLock() const { Loading Loading @@ -313,12 +312,6 @@ void PointerController::reloadPointerResources() { } void PointerController::setDisplayViewport(const DisplayViewport& viewport) { struct PointerDisplayChangeArgs { int32_t displayId; FloatPoint cursorPosition; }; std::optional<PointerDisplayChangeArgs> pointerDisplayChanged; { // acquire lock std::scoped_lock lock(getLock()); Loading @@ -330,15 +323,8 @@ void PointerController::setDisplayViewport(const DisplayViewport& viewport) { mCursorController.setDisplayViewport(viewport, getAdditionalMouseResources); if (viewport.displayId != mLocked.pointerDisplayId) { mLocked.pointerDisplayId = viewport.displayId; pointerDisplayChanged = {viewport.displayId, mCursorController.getPosition()}; } } // release lock if (pointerDisplayChanged) { // Notify the policy without holding the pointer controller lock. mContext.getPolicy()->onPointerDisplayIdChanged(pointerDisplayChanged->displayId, pointerDisplayChanged->cursorPosition); } } void PointerController::updatePointerIcon(PointerIconStyle iconId) { Loading
libs/input/PointerControllerContext.h +0 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,6 @@ public: virtual PointerIconStyle getDefaultPointerIconId() = 0; virtual PointerIconStyle getDefaultStylusIconId() = 0; virtual PointerIconStyle getCustomPointerIconId() = 0; virtual void onPointerDisplayIdChanged(int32_t displayId, const FloatPoint& position) = 0; }; /* Loading
libs/input/tests/PointerController_test.cpp +0 −33 Original line number Diff line number Diff line Loading @@ -64,11 +64,9 @@ public: virtual PointerIconStyle getDefaultPointerIconId() override; virtual PointerIconStyle getDefaultStylusIconId() override; virtual PointerIconStyle getCustomPointerIconId() override; virtual void onPointerDisplayIdChanged(int32_t displayId, const FloatPoint& position) override; bool allResourcesAreLoaded(); bool noResourcesAreLoaded(); std::optional<int32_t> getLastReportedPointerDisplayId() { return latestPointerDisplayId; } private: void loadPointerIconForType(SpriteIcon* icon, int32_t cursorType); Loading @@ -76,7 +74,6 @@ private: bool pointerIconLoaded{false}; bool pointerResourcesLoaded{false}; bool additionalMouseResourcesLoaded{false}; std::optional<int32_t /*displayId*/> latestPointerDisplayId; }; void MockPointerControllerPolicyInterface::loadPointerIcon(SpriteIcon* icon, int32_t) { Loading Loading @@ -146,12 +143,6 @@ void MockPointerControllerPolicyInterface::loadPointerIconForType(SpriteIcon* ic icon->hotSpotY = hotSpot.second; } void MockPointerControllerPolicyInterface::onPointerDisplayIdChanged(int32_t displayId, const FloatPoint& /*position*/ ) { latestPointerDisplayId = displayId; } class TestPointerController : public PointerController { public: TestPointerController(sp<android::gui::WindowInfosListener>& registeredListener, Loading Loading @@ -348,30 +339,6 @@ TEST_F(PointerControllerTest, doesNotGetResourcesBeforeSettingViewport) { ensureDisplayViewportIsSet(); } TEST_F(PointerControllerTest, notifiesPolicyWhenPointerDisplayChanges) { EXPECT_FALSE(mPolicy->getLastReportedPointerDisplayId()) << "A pointer display change does not occur when PointerController is created."; ensureDisplayViewportIsSet(ADISPLAY_ID_DEFAULT); const auto lastReportedPointerDisplayId = mPolicy->getLastReportedPointerDisplayId(); ASSERT_TRUE(lastReportedPointerDisplayId) << "The policy is notified of a pointer display change when the viewport is first set."; EXPECT_EQ(ADISPLAY_ID_DEFAULT, *lastReportedPointerDisplayId) << "Incorrect pointer display notified."; ensureDisplayViewportIsSet(42); EXPECT_EQ(42, *mPolicy->getLastReportedPointerDisplayId()) << "The policy is notified when the pointer display changes."; // Release the PointerController. mPointerController = nullptr; EXPECT_EQ(ADISPLAY_ID_NONE, *mPolicy->getLastReportedPointerDisplayId()) << "The pointer display changes to invalid when PointerController is destroyed."; } TEST_F(PointerControllerTest, updatesSkipScreenshotFlagForTouchSpots) { ensureDisplayViewportIsSet(); Loading
services/core/jni/com_android_server_input_InputManagerService.cpp +9 −149 Original line number Diff line number Diff line Loading @@ -88,7 +88,6 @@ namespace input_flags = com::android::input::flags; namespace android { static const bool ENABLE_POINTER_CHOREOGRAPHER = input_flags::enable_pointer_choreographer(); static const bool ENABLE_INPUT_FILTER_RUST = input_flags::enable_input_filter_rust_impl(); // The exponent used to calculate the pointer speed scaling factor. Loading Loading @@ -298,10 +297,8 @@ public: void setShowTouches(bool enabled); void setInteractive(bool interactive); void reloadCalibration(); void setPointerIconType(PointerIconStyle iconId); void reloadPointerIcons(); void requestPointerCapture(const sp<IBinder>& windowToken, bool enabled); void setCustomPointerIcon(const SpriteIcon& icon); bool setPointerIcon(std::variant<std::unique_ptr<SpriteIcon>, PointerIconStyle> icon, int32_t displayId, DeviceId deviceId, int32_t pointerId, const sp<IBinder>& inputToken); Loading @@ -316,7 +313,6 @@ public: /* --- InputReaderPolicyInterface implementation --- */ void getReaderConfiguration(InputReaderConfiguration* outConfig) override; std::shared_ptr<PointerControllerInterface> obtainPointerController(int32_t deviceId) override; void notifyInputDevicesChanged(const std::vector<InputDeviceInfo>& inputDevices) override; std::shared_ptr<KeyCharacterMap> getKeyboardLayoutOverlay( const InputDeviceIdentifier& identifier, Loading Loading @@ -375,7 +371,6 @@ public: virtual PointerIconStyle getDefaultPointerIconId(); virtual PointerIconStyle getDefaultStylusIconId(); virtual PointerIconStyle getCustomPointerIconId(); virtual void onPointerDisplayIdChanged(int32_t displayId, const FloatPoint& position); /* --- PointerChoreographerPolicyInterface implementation --- */ std::shared_ptr<PointerControllerInterface> createPointerController( Loading Loading @@ -409,19 +404,12 @@ private: // True if pointer gestures are enabled. bool pointerGesturesEnabled{true}; // Show touches feature enable/disable. bool showTouches{false}; // The latest request to enable or disable Pointer Capture. PointerCaptureRequest pointerCaptureRequest{}; // Sprite controller singleton, created on first use. std::shared_ptr<SpriteController> spriteController{}; // TODO(b/293587049): Remove when the PointerChoreographer refactoring is complete. // Pointer controller singleton, created and destroyed as needed. std::weak_ptr<PointerController> legacyPointerController{}; // The list of PointerControllers created and managed by the PointerChoreographer. std::list<std::weak_ptr<PointerController>> pointerControllers{}; Loading Loading @@ -505,13 +493,9 @@ void NativeInputManager::dump(std::string& dump) { dumpSet(mLocked.displaysWithMousePointerAccelerationDisabled).c_str()); dump += StringPrintf(INDENT "Pointer Gestures Enabled: %s\n", toString(mLocked.pointerGesturesEnabled)); dump += StringPrintf(INDENT "Show Touches: %s\n", toString(mLocked.showTouches)); dump += StringPrintf(INDENT "Pointer Capture: %s, seq=%" PRIu32 "\n", mLocked.pointerCaptureRequest.isEnable() ? "Enabled" : "Disabled", mLocked.pointerCaptureRequest.seq); if (auto pc = mLocked.legacyPointerController.lock(); pc) { dump += pc->dump(); } } // release lock dump += "\n"; Loading Loading @@ -556,9 +540,7 @@ void NativeInputManager::setDisplayViewports(JNIEnv* env, jobjectArray viewportO [&viewports](PointerController& pc) { pc.onDisplayViewportsUpdated(viewports); }); } // release lock if (ENABLE_POINTER_CHOREOGRAPHER) { mInputManager->getChoreographer().setDisplayViewports(viewports); } mInputManager->getReader().requestRefreshConfiguration( InputReaderConfiguration::Change::DISPLAY_INFO); } Loading Loading @@ -700,8 +682,6 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon : 1; outConfig->pointerGesturesEnabled = mLocked.pointerGesturesEnabled; outConfig->showTouches = mLocked.showTouches; outConfig->pointerCaptureRequest = mLocked.pointerCaptureRequest; outConfig->setDisplayViewports(mLocked.viewports); Loading Loading @@ -743,10 +723,6 @@ std::unordered_map<std::string, T> NativeInputManager::readMapFromInterleavedJav void NativeInputManager::forEachPointerControllerLocked( std::function<void(PointerController&)> apply) { if (auto pc = mLocked.legacyPointerController.lock(); pc) { apply(*pc); } auto it = mLocked.pointerControllers.begin(); while (it != mLocked.pointerControllers.end()) { auto pc = it->lock(); Loading Loading @@ -780,28 +756,6 @@ PointerIcon NativeInputManager::loadPointerIcon(JNIEnv* env, int32_t displayId, return android_view_PointerIcon_toNative(env, pointerIconObj.get()); } // TODO(b/293587049): Remove the old way of obtaining PointerController when the // PointerChoreographer refactoring is complete. std::shared_ptr<PointerControllerInterface> NativeInputManager::obtainPointerController( int32_t /* deviceId */) { ATRACE_CALL(); std::scoped_lock _l(mLock); std::shared_ptr<PointerController> controller = mLocked.legacyPointerController.lock(); if (controller == nullptr) { ensureSpriteControllerLocked(); // Disable the functionality of the legacy PointerController if PointerChoreographer is // enabled. controller = PointerController::create(this, mLooper, *mLocked.spriteController, /*enabled=*/!ENABLE_POINTER_CHOREOGRAPHER); mLocked.legacyPointerController = controller; updateInactivityTimeoutLocked(); } return controller; } std::shared_ptr<PointerControllerInterface> NativeInputManager::createPointerController( PointerControllerInterface::ControllerType type) { std::scoped_lock _l(mLock); Loading @@ -813,17 +767,6 @@ std::shared_ptr<PointerControllerInterface> NativeInputManager::createPointerCon return pc; } void NativeInputManager::onPointerDisplayIdChanged(int32_t pointerDisplayId, const FloatPoint& position) { if (ENABLE_POINTER_CHOREOGRAPHER) { return; } JNIEnv* env = jniEnv(); env->CallVoidMethod(mServiceObj, gServiceClassInfo.onPointerDisplayIdChanged, pointerDisplayId, position.x, position.y); checkAndClearExceptionFromCallback(env, "onPointerDisplayIdChanged"); } void NativeInputManager::notifyPointerDisplayIdChanged(int32_t pointerDisplayId, const FloatPoint& position) { // Notify the Reader so that devices can be reconfigured. Loading Loading @@ -1210,23 +1153,7 @@ void NativeInputManager::updateInactivityTimeoutLocked() REQUIRES(mLock) { } void NativeInputManager::setPointerDisplayId(int32_t displayId) { if (ENABLE_POINTER_CHOREOGRAPHER) { mInputManager->getChoreographer().setDefaultMouseDisplayId(displayId); } else { { // acquire lock std::scoped_lock _l(mLock); if (mLocked.pointerDisplayId == displayId) { return; } ALOGI("Setting pointer display id to %d.", displayId); mLocked.pointerDisplayId = displayId; } // release lock mInputManager->getReader().requestRefreshConfiguration( InputReaderConfiguration::Change::DISPLAY_INFO); } } int32_t NativeInputManager::getMousePointerSpeed() { Loading Loading @@ -1378,24 +1305,7 @@ void NativeInputManager::setInputDeviceEnabled(uint32_t deviceId, bool enabled) } void NativeInputManager::setShowTouches(bool enabled) { if (ENABLE_POINTER_CHOREOGRAPHER) { mInputManager->getChoreographer().setShowTouchesEnabled(enabled); return; } { // acquire lock std::scoped_lock _l(mLock); if (mLocked.showTouches == enabled) { return; } ALOGI("Setting show touches feature to %s.", enabled ? "enabled" : "disabled"); mLocked.showTouches = enabled; } // release lock mInputManager->getReader().requestRefreshConfiguration( InputReaderConfiguration::Change::SHOW_TOUCHES); } void NativeInputManager::requestPointerCapture(const sp<IBinder>& windowToken, bool enabled) { Loading @@ -1411,27 +1321,11 @@ void NativeInputManager::reloadCalibration() { InputReaderConfiguration::Change::TOUCH_AFFINE_TRANSFORMATION); } void NativeInputManager::setPointerIconType(PointerIconStyle iconId) { std::scoped_lock _l(mLock); std::shared_ptr<PointerController> controller = mLocked.legacyPointerController.lock(); if (controller != nullptr) { controller->updatePointerIcon(iconId); } } void NativeInputManager::reloadPointerIcons() { std::scoped_lock _l(mLock); forEachPointerControllerLocked([](PointerController& pc) { pc.reloadPointerResources(); }); } void NativeInputManager::setCustomPointerIcon(const SpriteIcon& icon) { std::scoped_lock _l(mLock); std::shared_ptr<PointerController> controller = mLocked.legacyPointerController.lock(); if (controller != nullptr) { controller->setCustomPointerIcon(icon); } } bool NativeInputManager::setPointerIcon( std::variant<std::unique_ptr<SpriteIcon>, PointerIconStyle> icon, int32_t displayId, DeviceId deviceId, int32_t pointerId, const sp<IBinder>& inputToken) { Loading @@ -1447,9 +1341,6 @@ bool NativeInputManager::setPointerIcon( } void NativeInputManager::setPointerIconVisibility(int32_t displayId, bool visible) { if (!ENABLE_POINTER_CHOREOGRAPHER) { return; } mInputManager->getChoreographer().setPointerIconVisibility(displayId, visible); } Loading Loading @@ -1819,38 +1710,14 @@ void NativeInputManager::setStylusButtonMotionEventsEnabled(bool enabled) { } FloatPoint NativeInputManager::getMouseCursorPosition(int32_t displayId) { if (ENABLE_POINTER_CHOREOGRAPHER) { return mInputManager->getChoreographer().getMouseCursorPosition(displayId); } // To maintain the status-quo, the displayId parameter (used when PointerChoreographer is // enabled) is ignored in the old pipeline. std::scoped_lock _l(mLock); const auto pc = mLocked.legacyPointerController.lock(); if (!pc) return {AMOTION_EVENT_INVALID_CURSOR_POSITION, AMOTION_EVENT_INVALID_CURSOR_POSITION}; return pc->getPosition(); } void NativeInputManager::setStylusPointerIconEnabled(bool enabled) { if (ENABLE_POINTER_CHOREOGRAPHER) { mInputManager->getChoreographer().setStylusPointerIconEnabled(enabled); return; } { // acquire lock std::scoped_lock _l(mLock); if (mLocked.stylusPointerIconEnabled == enabled) { return; } mLocked.stylusPointerIconEnabled = enabled; } // release lock mInputManager->getReader().requestRefreshConfiguration( InputReaderConfiguration::Change::DISPLAY_INFO); } void NativeInputManager::setInputMethodConnectionIsActive(bool isActive) { { // acquire lock std::scoped_lock _l(mLock); Loading Loading @@ -2598,13 +2465,7 @@ static void nativeDisableInputDevice(JNIEnv* env, jobject nativeImplObj, jint de } static void nativeSetPointerIconType(JNIEnv* env, jobject nativeImplObj, jint iconId) { // iconId is set in java from from frameworks/base/core/java/android/view/PointerIcon.java, // where the definition in <input/Input.h> is duplicated as a sealed class (type safe enum // equivalent in Java). NativeInputManager* im = getNativeInputManager(env, nativeImplObj); im->setPointerIconType(static_cast<PointerIconStyle>(iconId)); // TODO(b/311416205): Remove } static void nativeReloadPointerIcons(JNIEnv* env, jobject nativeImplObj) { Loading @@ -2614,8 +2475,7 @@ static void nativeReloadPointerIcons(JNIEnv* env, jobject nativeImplObj) { } static void nativeSetCustomPointerIcon(JNIEnv* env, jobject nativeImplObj, jobject iconObj) { NativeInputManager* im = getNativeInputManager(env, nativeImplObj); im->setCustomPointerIcon(toSpriteIcon(android_view_PointerIcon_toNative(env, iconObj))); // TODO(b/311416205): Remove } static bool nativeSetPointerIcon(JNIEnv* env, jobject nativeImplObj, jobject iconObj, Loading