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

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

Merge "Introduce PointerChoreographer stage in C++" into main

parents 931a8975 b56e92c4
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -77,6 +77,7 @@ filegroup {
        "InputCommonConverter.cpp",
        "InputCommonConverter.cpp",
        "InputDeviceMetricsCollector.cpp",
        "InputDeviceMetricsCollector.cpp",
        "InputProcessor.cpp",
        "InputProcessor.cpp",
        "PointerChoreographer.cpp",
        "PreferStylusOverTouchBlocker.cpp",
        "PreferStylusOverTouchBlocker.cpp",
        "UnwantedInteractionBlocker.cpp",
        "UnwantedInteractionBlocker.cpp",
    ],
    ],
+21 −1
Original line number Original line Diff line number Diff line
@@ -38,6 +38,9 @@ namespace {
const bool ENABLE_INPUT_DEVICE_USAGE_METRICS =
const bool ENABLE_INPUT_DEVICE_USAGE_METRICS =
        sysprop::InputProperties::enable_input_device_usage_metrics().value_or(true);
        sysprop::InputProperties::enable_input_device_usage_metrics().value_or(true);


const bool ENABLE_POINTER_CHOREOGRAPHER =
        sysprop::InputProperties::enable_pointer_choreographer().value_or(false);

int32_t exceptionCodeFromStatusT(status_t status) {
int32_t exceptionCodeFromStatusT(status_t status) {
    switch (status) {
    switch (status) {
        case OK:
        case OK:
@@ -113,12 +116,14 @@ std::shared_ptr<IInputFlingerRust> createInputFlingerRust() {
 * The event flow is via the "InputListener" interface, as follows:
 * The event flow is via the "InputListener" interface, as follows:
 *   InputReader
 *   InputReader
 *     -> UnwantedInteractionBlocker
 *     -> UnwantedInteractionBlocker
 *     -> PointerChoreographer
 *     -> InputProcessor
 *     -> InputProcessor
 *     -> InputDeviceMetricsCollector
 *     -> InputDeviceMetricsCollector
 *     -> InputDispatcher
 *     -> InputDispatcher
 */
 */
InputManager::InputManager(const sp<InputReaderPolicyInterface>& readerPolicy,
InputManager::InputManager(const sp<InputReaderPolicyInterface>& readerPolicy,
                           InputDispatcherPolicyInterface& dispatcherPolicy) {
                           InputDispatcherPolicyInterface& dispatcherPolicy,
                           PointerChoreographerPolicyInterface& choreographerPolicy) {
    mInputFlingerRust = createInputFlingerRust();
    mInputFlingerRust = createInputFlingerRust();


    mDispatcher = createInputDispatcher(dispatcherPolicy);
    mDispatcher = createInputDispatcher(dispatcherPolicy);
@@ -135,6 +140,13 @@ InputManager::InputManager(const sp<InputReaderPolicyInterface>& readerPolicy,
    mTracingStages.emplace_back(
    mTracingStages.emplace_back(
            std::make_unique<TracedInputListener>("InputProcessor", *mProcessor));
            std::make_unique<TracedInputListener>("InputProcessor", *mProcessor));


    if (ENABLE_POINTER_CHOREOGRAPHER) {
        mChoreographer =
                std::make_unique<PointerChoreographer>(*mTracingStages.back(), choreographerPolicy);
        mTracingStages.emplace_back(
                std::make_unique<TracedInputListener>("PointerChoreographer", *mChoreographer));
    }

    mBlocker = std::make_unique<UnwantedInteractionBlocker>(*mTracingStages.back());
    mBlocker = std::make_unique<UnwantedInteractionBlocker>(*mTracingStages.back());
    mTracingStages.emplace_back(
    mTracingStages.emplace_back(
            std::make_unique<TracedInputListener>("UnwantedInteractionBlocker", *mBlocker));
            std::make_unique<TracedInputListener>("UnwantedInteractionBlocker", *mBlocker));
@@ -186,6 +198,10 @@ InputReaderInterface& InputManager::getReader() {
    return *mReader;
    return *mReader;
}
}


PointerChoreographerInterface& InputManager::getChoreographer() {
    return *mChoreographer;
}

InputProcessorInterface& InputManager::getProcessor() {
InputProcessorInterface& InputManager::getProcessor() {
    return *mProcessor;
    return *mProcessor;
}
}
@@ -210,6 +226,10 @@ void InputManager::dump(std::string& dump) {
    dump += '\n';
    dump += '\n';
    mBlocker->dump(dump);
    mBlocker->dump(dump);
    dump += '\n';
    dump += '\n';
    if (ENABLE_POINTER_CHOREOGRAPHER) {
        mChoreographer->dump(dump);
        dump += '\n';
    }
    mProcessor->dump(dump);
    mProcessor->dump(dump);
    dump += '\n';
    dump += '\n';
    if (ENABLE_INPUT_DEVICE_USAGE_METRICS) {
    if (ENABLE_INPUT_DEVICE_USAGE_METRICS) {
+10 −1
Original line number Original line Diff line number Diff line
@@ -23,10 +23,12 @@
#include "InputDeviceMetricsCollector.h"
#include "InputDeviceMetricsCollector.h"
#include "InputProcessor.h"
#include "InputProcessor.h"
#include "InputReaderBase.h"
#include "InputReaderBase.h"
#include "PointerChoreographer.h"
#include "include/UnwantedInteractionBlockerInterface.h"
#include "include/UnwantedInteractionBlockerInterface.h"


#include <InputDispatcherInterface.h>
#include <InputDispatcherInterface.h>
#include <InputDispatcherPolicyInterface.h>
#include <InputDispatcherPolicyInterface.h>
#include <PointerChoreographerPolicyInterface.h>
#include <input/Input.h>
#include <input/Input.h>
#include <input/InputTransport.h>
#include <input/InputTransport.h>


@@ -86,6 +88,9 @@ public:
    /* Gets the input reader. */
    /* Gets the input reader. */
    virtual InputReaderInterface& getReader() = 0;
    virtual InputReaderInterface& getReader() = 0;


    /* Gets the PointerChoreographer. */
    virtual PointerChoreographerInterface& getChoreographer() = 0;

    /* Gets the input processor. */
    /* Gets the input processor. */
    virtual InputProcessorInterface& getProcessor() = 0;
    virtual InputProcessorInterface& getProcessor() = 0;


@@ -108,12 +113,14 @@ protected:


public:
public:
    InputManager(const sp<InputReaderPolicyInterface>& readerPolicy,
    InputManager(const sp<InputReaderPolicyInterface>& readerPolicy,
                 InputDispatcherPolicyInterface& dispatcherPolicy);
                 InputDispatcherPolicyInterface& dispatcherPolicy,
                 PointerChoreographerPolicyInterface& choreographerPolicy);


    status_t start() override;
    status_t start() override;
    status_t stop() override;
    status_t stop() override;


    InputReaderInterface& getReader() override;
    InputReaderInterface& getReader() override;
    PointerChoreographerInterface& getChoreographer() override;
    InputProcessorInterface& getProcessor() override;
    InputProcessorInterface& getProcessor() override;
    InputDeviceMetricsCollectorInterface& getMetricsCollector() override;
    InputDeviceMetricsCollectorInterface& getMetricsCollector() override;
    InputDispatcherInterface& getDispatcher() override;
    InputDispatcherInterface& getDispatcher() override;
@@ -130,6 +137,8 @@ private:


    std::unique_ptr<UnwantedInteractionBlockerInterface> mBlocker;
    std::unique_ptr<UnwantedInteractionBlockerInterface> mBlocker;


    std::unique_ptr<PointerChoreographerInterface> mChoreographer;

    std::unique_ptr<InputProcessorInterface> mProcessor;
    std::unique_ptr<InputProcessorInterface> mProcessor;


    std::unique_ptr<InputDeviceMetricsCollectorInterface> mCollector;
    std::unique_ptr<InputDeviceMetricsCollectorInterface> mCollector;
+70 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define LOG_TAG "PointerChoreographer"

#include "PointerChoreographer.h"

namespace android {

// --- PointerChoreographer ---

PointerChoreographer::PointerChoreographer(InputListenerInterface& listener,
                                           PointerChoreographerPolicyInterface& policy)
      : mNextListener(listener) {}

void PointerChoreographer::notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) {
    mNextListener.notify(args);
}

void PointerChoreographer::notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) {
    mNextListener.notify(args);
}

void PointerChoreographer::notifyKey(const NotifyKeyArgs& args) {
    mNextListener.notify(args);
}

void PointerChoreographer::notifyMotion(const NotifyMotionArgs& args) {
    mNextListener.notify(args);
}

void PointerChoreographer::notifySwitch(const NotifySwitchArgs& args) {
    mNextListener.notify(args);
}

void PointerChoreographer::notifySensor(const NotifySensorArgs& args) {
    mNextListener.notify(args);
}

void PointerChoreographer::notifyVibratorState(const NotifyVibratorStateArgs& args) {
    mNextListener.notify(args);
}

void PointerChoreographer::notifyDeviceReset(const NotifyDeviceResetArgs& args) {
    mNextListener.notify(args);
}

void PointerChoreographer::notifyPointerCaptureChanged(
        const NotifyPointerCaptureChangedArgs& args) {
    mNextListener.notify(args);
}

void PointerChoreographer::dump(std::string& dump) {
    dump += "PointerChoreographer:\n";
}

} // namespace android
+61 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include "InputListener.h"
#include "NotifyArgs.h"
#include "PointerChoreographerPolicyInterface.h"

namespace android {

/**
 * PointerChoreographer manages the icons shown by the system for input interactions.
 * This includes showing the mouse cursor, stylus hover icons, and touch spots.
 * It is responsible for accumulating the location of the mouse cursor, and populating
 * the cursor position for incoming events, if necessary.
 */
class PointerChoreographerInterface : public InputListenerInterface {
public:
    /**
     * This method may be called on any thread (usually by the input manager on a binder thread).
     */
    virtual void dump(std::string& dump) = 0;
};

class PointerChoreographer : public PointerChoreographerInterface {
public:
    explicit PointerChoreographer(InputListenerInterface& listener,
                                  PointerChoreographerPolicyInterface&);
    ~PointerChoreographer() override = default;

    void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override;
    void notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) override;
    void notifyKey(const NotifyKeyArgs& args) override;
    void notifyMotion(const NotifyMotionArgs& args) override;
    void notifySwitch(const NotifySwitchArgs& args) override;
    void notifySensor(const NotifySensorArgs& args) override;
    void notifyVibratorState(const NotifyVibratorStateArgs& args) override;
    void notifyDeviceReset(const NotifyDeviceResetArgs& args) override;
    void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override;

    void dump(std::string& dump) override;

private:
    InputListenerInterface& mNextListener;
};

} // namespace android
Loading