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

Commit d1ed39db authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11343021 from 6d503b9e to 24Q2-release

Change-Id: Ida9af0fc77c2136260d7b19e0d42ce43c5f0aed5
parents 93f8d0a3 6d503b9e
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,10 @@
#include <sys/cdefs.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/types.h>


#if defined(__APPLE__)
typedef off_t off64_t; // Mac OSX does not define off64_t
#endif

#ifdef __cplusplus
#ifdef __cplusplus
extern "C" {
extern "C" {
#endif
#endif
+37 −5
Original line number Original line Diff line number Diff line
@@ -109,7 +109,9 @@ NotifyMotionArgs PointerChoreographer::processMouseEventLocked(const NotifyMotio
    const float deltaX = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X);
    const float deltaX = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X);
    const float deltaY = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y);
    const float deltaY = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y);
    pc.move(deltaX, deltaY);
    pc.move(deltaX, deltaY);
    if (canUnfadeOnDisplay(displayId)) {
        pc.unfade(PointerControllerInterface::Transition::IMMEDIATE);
        pc.unfade(PointerControllerInterface::Transition::IMMEDIATE);
    }


    const auto [x, y] = pc.getPosition();
    const auto [x, y] = pc.getPosition();
    NotifyMotionArgs newArgs(args);
    NotifyMotionArgs newArgs(args);
@@ -131,7 +133,9 @@ NotifyMotionArgs PointerChoreographer::processTouchpadEventLocked(const NotifyMo
        const float deltaX = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X);
        const float deltaX = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X);
        const float deltaY = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y);
        const float deltaY = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y);
        pc.move(deltaX, deltaY);
        pc.move(deltaX, deltaY);
        if (canUnfadeOnDisplay(displayId)) {
            pc.unfade(PointerControllerInterface::Transition::IMMEDIATE);
            pc.unfade(PointerControllerInterface::Transition::IMMEDIATE);
        }


        const auto [x, y] = pc.getPosition();
        const auto [x, y] = pc.getPosition();
        newArgs.pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, x);
        newArgs.pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, x);
@@ -140,7 +144,9 @@ NotifyMotionArgs PointerChoreographer::processTouchpadEventLocked(const NotifyMo
        newArgs.yCursorPosition = y;
        newArgs.yCursorPosition = y;
    } else {
    } else {
        // This is a trackpad gesture with fake finger(s) that should not move the mouse pointer.
        // This is a trackpad gesture with fake finger(s) that should not move the mouse pointer.
        if (canUnfadeOnDisplay(displayId)) {
            pc.unfade(PointerControllerInterface::Transition::IMMEDIATE);
            pc.unfade(PointerControllerInterface::Transition::IMMEDIATE);
        }


        const auto [x, y] = pc.getPosition();
        const auto [x, y] = pc.getPosition();
        for (uint32_t i = 0; i < newArgs.getPointerCount(); i++) {
        for (uint32_t i = 0; i < newArgs.getPointerCount(); i++) {
@@ -223,7 +229,7 @@ void PointerChoreographer::processStylusHoverEventLocked(const NotifyMotionArgs&
    if (args.action == AMOTION_EVENT_ACTION_HOVER_EXIT) {
    if (args.action == AMOTION_EVENT_ACTION_HOVER_EXIT) {
        pc.fade(PointerControllerInterface::Transition::IMMEDIATE);
        pc.fade(PointerControllerInterface::Transition::IMMEDIATE);
        pc.updatePointerIcon(PointerIconStyle::TYPE_NOT_SPECIFIED);
        pc.updatePointerIcon(PointerIconStyle::TYPE_NOT_SPECIFIED);
    } else {
    } else if (canUnfadeOnDisplay(args.displayId)) {
        pc.unfade(PointerControllerInterface::Transition::IMMEDIATE);
        pc.unfade(PointerControllerInterface::Transition::IMMEDIATE);
    }
    }
}
}
@@ -323,6 +329,10 @@ InputDeviceInfo* PointerChoreographer::findInputDeviceLocked(DeviceId deviceId)
    return it != mInputDeviceInfos.end() ? &(*it) : nullptr;
    return it != mInputDeviceInfos.end() ? &(*it) : nullptr;
}
}


bool PointerChoreographer::canUnfadeOnDisplay(int32_t displayId) {
    return mDisplaysWithPointersHidden.find(displayId) == mDisplaysWithPointersHidden.end();
}

void PointerChoreographer::updatePointerControllersLocked() {
void PointerChoreographer::updatePointerControllersLocked() {
    std::set<int32_t /*displayId*/> mouseDisplaysToKeep;
    std::set<int32_t /*displayId*/> mouseDisplaysToKeep;
    std::set<DeviceId> touchDevicesToKeep;
    std::set<DeviceId> touchDevicesToKeep;
@@ -342,7 +352,7 @@ void PointerChoreographer::updatePointerControllersLocked() {
                    mMousePointersByDisplay.try_emplace(displayId,
                    mMousePointersByDisplay.try_emplace(displayId,
                                                        getMouseControllerConstructor(displayId));
                                                        getMouseControllerConstructor(displayId));
            auto [_, isNewMouseDevice] = mMouseDevices.emplace(info.getId());
            auto [_, isNewMouseDevice] = mMouseDevices.emplace(info.getId());
            if (isNewMouseDevice || isNewMousePointer) {
            if ((isNewMouseDevice || isNewMousePointer) && canUnfadeOnDisplay(displayId)) {
                mousePointerIt->second->unfade(PointerControllerInterface::Transition::IMMEDIATE);
                mousePointerIt->second->unfade(PointerControllerInterface::Transition::IMMEDIATE);
            }
            }
        }
        }
@@ -513,6 +523,28 @@ bool PointerChoreographer::setPointerIcon(
    return true;
    return true;
}
}


void PointerChoreographer::setPointerIconVisibility(int32_t displayId, bool visible) {
    std::scoped_lock lock(mLock);
    if (visible) {
        mDisplaysWithPointersHidden.erase(displayId);
        // We do not unfade the icons here, because we don't know when the last event happened.
        return;
    }

    mDisplaysWithPointersHidden.emplace(displayId);

    // Hide any icons that are currently visible on the display.
    if (auto it = mMousePointersByDisplay.find(displayId); it != mMousePointersByDisplay.end()) {
        const auto& [_, controller] = *it;
        controller->fade(PointerControllerInterface::Transition::IMMEDIATE);
    }
    for (const auto& [_, controller] : mStylusPointersByDevice) {
        if (controller->getDisplayId() == displayId) {
            controller->fade(PointerControllerInterface::Transition::IMMEDIATE);
        }
    }
}

PointerChoreographer::ControllerConstructor PointerChoreographer::getMouseControllerConstructor(
PointerChoreographer::ControllerConstructor PointerChoreographer::getMouseControllerConstructor(
        int32_t displayId) {
        int32_t displayId) {
    std::function<std::shared_ptr<PointerControllerInterface>()> ctor =
    std::function<std::shared_ptr<PointerControllerInterface>()> ctor =
+8 −0
Original line number Original line Diff line number Diff line
@@ -67,6 +67,11 @@ public:
     */
     */
    virtual bool setPointerIcon(std::variant<std::unique_ptr<SpriteIcon>, PointerIconStyle> icon,
    virtual bool setPointerIcon(std::variant<std::unique_ptr<SpriteIcon>, PointerIconStyle> icon,
                                int32_t displayId, DeviceId deviceId) = 0;
                                int32_t displayId, DeviceId deviceId) = 0;
    /**
     * Set whether pointer icons for mice, touchpads, and styluses should be visible on the
     * given display.
     */
    virtual void setPointerIconVisibility(int32_t displayId, bool visible) = 0;


    /**
    /**
     * This method may be called on any thread (usually by the input manager on a binder thread).
     * This method may be called on any thread (usually by the input manager on a binder thread).
@@ -89,6 +94,7 @@ public:
    void setStylusPointerIconEnabled(bool enabled) override;
    void setStylusPointerIconEnabled(bool enabled) override;
    bool setPointerIcon(std::variant<std::unique_ptr<SpriteIcon>, PointerIconStyle> icon,
    bool setPointerIcon(std::variant<std::unique_ptr<SpriteIcon>, PointerIconStyle> icon,
                        int32_t displayId, DeviceId deviceId) override;
                        int32_t displayId, DeviceId deviceId) override;
    void setPointerIconVisibility(int32_t displayId, bool visible) override;


    void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override;
    void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override;
    void notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) override;
    void notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) override;
@@ -110,6 +116,7 @@ private:
    std::pair<int32_t, PointerControllerInterface&> getDisplayIdAndMouseControllerLocked(
    std::pair<int32_t, PointerControllerInterface&> getDisplayIdAndMouseControllerLocked(
            int32_t associatedDisplayId) REQUIRES(mLock);
            int32_t associatedDisplayId) REQUIRES(mLock);
    InputDeviceInfo* findInputDeviceLocked(DeviceId deviceId) REQUIRES(mLock);
    InputDeviceInfo* findInputDeviceLocked(DeviceId deviceId) REQUIRES(mLock);
    bool canUnfadeOnDisplay(int32_t displayId) REQUIRES(mLock);


    NotifyMotionArgs processMotion(const NotifyMotionArgs& args);
    NotifyMotionArgs processMotion(const NotifyMotionArgs& args);
    NotifyMotionArgs processMouseEventLocked(const NotifyMotionArgs& args) REQUIRES(mLock);
    NotifyMotionArgs processMouseEventLocked(const NotifyMotionArgs& args) REQUIRES(mLock);
@@ -143,6 +150,7 @@ private:
    std::vector<DisplayViewport> mViewports GUARDED_BY(mLock);
    std::vector<DisplayViewport> mViewports GUARDED_BY(mLock);
    bool mShowTouchesEnabled GUARDED_BY(mLock);
    bool mShowTouchesEnabled GUARDED_BY(mLock);
    bool mStylusPointerIconEnabled GUARDED_BY(mLock);
    bool mStylusPointerIconEnabled GUARDED_BY(mLock);
    std::set<int32_t /*displayId*/> mDisplaysWithPointersHidden;
};
};


} // namespace android
} // namespace android
+3 −3
Original line number Original line Diff line number Diff line
@@ -131,10 +131,10 @@ struct InputReaderConfiguration {
    // Currently only used when the enable_new_mouse_pointer_ballistics flag is enabled.
    // Currently only used when the enable_new_mouse_pointer_ballistics flag is enabled.
    int32_t mousePointerSpeed;
    int32_t mousePointerSpeed;


    // Whether to apply an acceleration curve to pointer movements from mice.
    // Displays on which an acceleration curve shouldn't be applied for pointer movements from mice.
    //
    //
    // Currently only used when the enable_new_mouse_pointer_ballistics flag is enabled.
    // Currently only used when the enable_new_mouse_pointer_ballistics flag is enabled.
    bool mousePointerAccelerationEnabled;
    std::set<int32_t> displaysWithMousePointerAccelerationDisabled;


    // Velocity control parameters for mouse pointer movements.
    // Velocity control parameters for mouse pointer movements.
    //
    //
@@ -243,7 +243,7 @@ struct InputReaderConfiguration {
    InputReaderConfiguration()
    InputReaderConfiguration()
          : virtualKeyQuietTime(0),
          : virtualKeyQuietTime(0),
            mousePointerSpeed(0),
            mousePointerSpeed(0),
            mousePointerAccelerationEnabled(true),
            displaysWithMousePointerAccelerationDisabled(),
            pointerVelocityControlParameters(1.0f, 500.0f, 3000.0f,
            pointerVelocityControlParameters(1.0f, 500.0f, 3000.0f,
                                             static_cast<float>(
                                             static_cast<float>(
                                                     android::os::IInputConstants::
                                                     android::os::IInputConstants::
+6 −5
Original line number Original line Diff line number Diff line
@@ -159,14 +159,14 @@ std::list<NotifyArgs> CursorInputMapper::reconfigure(nsecs_t when,
        out.push_back(NotifyDeviceResetArgs(getContext()->getNextId(), when, getDeviceId()));
        out.push_back(NotifyDeviceResetArgs(getContext()->getNextId(), when, getDeviceId()));
    }
    }


    if (!changes.any() || changes.test(InputReaderConfiguration::Change::POINTER_SPEED) ||
    if (!changes.any() || changes.test(InputReaderConfiguration::Change::DISPLAY_INFO) ||
        configurePointerCapture) {
        configurePointerCapture) {
        configureOnChangePointerSpeed(readerConfig);
        configureOnChangeDisplayInfo(readerConfig);
    }
    }


    if (!changes.any() || changes.test(InputReaderConfiguration::Change::DISPLAY_INFO) ||
    if (!changes.any() || changes.test(InputReaderConfiguration::Change::POINTER_SPEED) ||
        configurePointerCapture) {
        configurePointerCapture) {
        configureOnChangeDisplayInfo(readerConfig);
        configureOnChangePointerSpeed(readerConfig);
    }
    }
    return out;
    return out;
}
}
@@ -510,7 +510,8 @@ void CursorInputMapper::configureOnChangePointerSpeed(const InputReaderConfigura
    } else {
    } else {
        if (mEnableNewMousePointerBallistics) {
        if (mEnableNewMousePointerBallistics) {
            mNewPointerVelocityControl.setAccelerationEnabled(
            mNewPointerVelocityControl.setAccelerationEnabled(
                    config.mousePointerAccelerationEnabled);
                    config.displaysWithMousePointerAccelerationDisabled.count(
                            mDisplayId.value_or(ADISPLAY_ID_NONE)) == 0);
            mNewPointerVelocityControl.setCurve(
            mNewPointerVelocityControl.setCurve(
                    createAccelerationCurveForPointerSensitivity(config.mousePointerSpeed));
                    createAccelerationCurveForPointerSensitivity(config.mousePointerSpeed));
        } else {
        } else {
Loading