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

Commit abd6d329 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "InputReader: Cleanup after PointerChoreographer refactor" into main

parents 24b52741 2120b9e4
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -61,9 +61,6 @@ struct InputReaderConfiguration {
        // The display size or orientation changed.
        DISPLAY_INFO = 1u << 2,

        // The visible touches option changed.
        SHOW_TOUCHES = 1u << 3,

        // The keyboard layouts must be reloaded.
        KEYBOARD_LAYOUTS = 1u << 4,

@@ -214,9 +211,6 @@ struct InputReaderConfiguration {
    // will cover this portion of the display diagonal.
    float pointerGestureZoomSpeedRatio;

    // True to show the location of touches on the touch screen as spots.
    bool showTouches;

    // The latest request to enable or disable Pointer Capture.
    PointerCaptureRequest pointerCaptureRequest;

@@ -268,7 +262,6 @@ struct InputReaderConfiguration {
            pointerGestureSwipeMaxWidthRatio(0.25f),
            pointerGestureMovementSpeedRatio(0.8f),
            pointerGestureZoomSpeedRatio(0.3f),
            showTouches(false),
            pointerCaptureRequest(),
            touchpadPointerSpeed(0),
            touchpadNaturalScrollingEnabled(true),
@@ -449,10 +442,6 @@ public:
    /* Gets the input reader configuration. */
    virtual void getReaderConfiguration(InputReaderConfiguration* outConfig) = 0;

    /* Gets a pointer controller associated with the specified cursor device (ie. a mouse). */
    virtual std::shared_ptr<PointerControllerInterface> obtainPointerController(
            int32_t deviceId) = 0;

    /* Notifies the input reader policy that some input devices have changed
     * and provides information about all current input devices.
     */
+0 −56
Original line number Diff line number Diff line
@@ -402,10 +402,6 @@ void InputReader::refreshConfigurationLocked(ConfigurationChanges changes) {
    ALOGI("Reconfiguring input devices, changes=%s", changes.string().c_str());
    nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC);

    if (changes.test(Change::DISPLAY_INFO)) {
        updatePointerDisplayLocked();
    }

    if (changes.test(Change::MUST_REOPEN)) {
        mEventHub->requestReopenDevices();
    } else {
@@ -490,47 +486,6 @@ bool InputReader::shouldDropVirtualKeyLocked(nsecs_t now, int32_t keyCode, int32
    }
}

std::shared_ptr<PointerControllerInterface> InputReader::getPointerControllerLocked(
        int32_t deviceId) {
    std::shared_ptr<PointerControllerInterface> controller = mPointerController.lock();
    if (controller == nullptr) {
        controller = mPolicy->obtainPointerController(deviceId);
        mPointerController = controller;
        updatePointerDisplayLocked();
    }
    return controller;
}

void InputReader::updatePointerDisplayLocked() {
    std::shared_ptr<PointerControllerInterface> controller = mPointerController.lock();
    if (controller == nullptr) {
        return;
    }

    std::optional<DisplayViewport> viewport =
            mConfig.getDisplayViewportById(mConfig.defaultPointerDisplayId);
    if (!viewport) {
        ALOGW("Can't find the designated viewport with ID %" PRId32 " to update cursor input "
              "mapper. Fall back to default display",
              mConfig.defaultPointerDisplayId);
        viewport = mConfig.getDisplayViewportById(ADISPLAY_ID_DEFAULT);
    }
    if (!viewport) {
        ALOGE("Still can't find a viable viewport to update cursor input mapper. Skip setting it to"
              " PointerController.");
        return;
    }

    controller->setDisplayViewport(*viewport);
}

void InputReader::fadePointerLocked() {
    std::shared_ptr<PointerControllerInterface> controller = mPointerController.lock();
    if (controller != nullptr) {
        controller->fade(PointerControllerInterface::Transition::GRADUAL);
    }
}

void InputReader::requestTimeoutAtTimeLocked(nsecs_t when) {
    if (when < mNextTimeout) {
        mNextTimeout = when;
@@ -1067,17 +1022,6 @@ bool InputReader::ContextImpl::shouldDropVirtualKey(nsecs_t now, int32_t keyCode
    return mReader->shouldDropVirtualKeyLocked(now, keyCode, scanCode);
}

void InputReader::ContextImpl::fadePointer() {
    // lock is already held by the input loop
    mReader->fadePointerLocked();
}

std::shared_ptr<PointerControllerInterface> InputReader::ContextImpl::getPointerController(
        int32_t deviceId) {
    // lock is already held by the input loop
    return mReader->getPointerControllerLocked(deviceId);
}

void InputReader::ContextImpl::requestTimeoutAtTime(nsecs_t when) {
    // lock is already held by the input loop
    mReader->requestTimeoutAtTimeLocked(when);
+0 −11
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

#pragma once

#include <PointerControllerInterface.h>
#include <android-base/thread_annotations.h>
#include <utils/Condition.h>
#include <utils/Mutex.h>
@@ -141,9 +140,6 @@ protected:
        void disableVirtualKeysUntil(nsecs_t time) REQUIRES(mReader->mLock) override;
        bool shouldDropVirtualKey(nsecs_t now, int32_t keyCode, int32_t scanCode)
                REQUIRES(mReader->mLock) override;
        void fadePointer() REQUIRES(mReader->mLock) override;
        std::shared_ptr<PointerControllerInterface> getPointerController(int32_t deviceId)
                REQUIRES(mReader->mLock) override;
        void requestTimeoutAtTime(nsecs_t when) REQUIRES(mReader->mLock) override;
        int32_t bumpGeneration() NO_THREAD_SAFETY_ANALYSIS override;
        void getExternalStylusDevices(std::vector<InputDeviceInfo>& outDevices)
@@ -230,13 +226,6 @@ private:
    [[nodiscard]] std::list<NotifyArgs> dispatchExternalStylusStateLocked(const StylusState& state)
            REQUIRES(mLock);

    // The PointerController that is shared among all the input devices that need it.
    std::weak_ptr<PointerControllerInterface> mPointerController;
    std::shared_ptr<PointerControllerInterface> getPointerControllerLocked(int32_t deviceId)
            REQUIRES(mLock);
    void updatePointerDisplayLocked() REQUIRES(mLock);
    void fadePointerLocked() REQUIRES(mLock);

    int32_t mGeneration GUARDED_BY(mLock);
    int32_t bumpGenerationLocked() REQUIRES(mLock);

+0 −4
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ class InputDevice;
class InputListenerInterface;
class InputMapper;
class InputReaderPolicyInterface;
class PointerControllerInterface;
struct StylusState;

/* Internal interface used by individual input devices to access global input device state
@@ -45,9 +44,6 @@ public:
    virtual void disableVirtualKeysUntil(nsecs_t time) = 0;
    virtual bool shouldDropVirtualKey(nsecs_t now, int32_t keyCode, int32_t scanCode) = 0;

    virtual void fadePointer() = 0;
    virtual std::shared_ptr<PointerControllerInterface> getPointerController(int32_t deviceId) = 0;

    virtual void requestTimeoutAtTime(nsecs_t when) = 0;
    virtual int32_t bumpGeneration() = 0;

+1 −6
Original line number Diff line number Diff line
@@ -483,16 +483,11 @@ std::list<NotifyArgs> KeyboardInputMapper::cancelAllDownKeys(nsecs_t when) {
void KeyboardInputMapper::onKeyDownProcessed(nsecs_t downTime) {
    InputReaderContext& context = *getContext();
    context.setLastKeyDownTimestamp(downTime);
    if (context.isPreventingTouchpadTaps()) {
        // avoid pinging java service unnecessarily, just fade pointer again if it became visible
        context.fadePointer();
        return;
    }
    // TODO(b/338652288): Move cursor fading logic into PointerChoreographer.
    // Ignore meta keys or multiple simultaneous down keys as they are likely to be keyboard
    // shortcuts
    bool shouldHideCursor = mKeyDowns.size() == 1 && !isMetaKey(mKeyDowns[0].keyCode);
    if (shouldHideCursor && context.getPolicy()->isInputMethodConnectionActive()) {
        context.fadePointer();
        context.setPreventingTouchpadTaps(true);
    }
}
Loading