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

Commit f706ffe2 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7464903 from 6123a6d9 to sc-d1-release

Change-Id: Ia1330d1bc51c137129eb77761638700b4c2ee127
parents c3fdc24c 6123a6d9
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@
 */

#include <android/input.h>
#ifdef __linux__
#include <android/os/IInputConstants.h>
#endif
#include <math.h>
#include <stdint.h>
#include <ui/Transform.h>
@@ -219,7 +222,16 @@ enum {
    POLICY_FLAG_GESTURE = 0x00000008,

    POLICY_FLAG_RAW_MASK = 0x0000ffff,
#ifdef __linux__
    POLICY_FLAG_INPUTFILTER_TRUSTED = android::os::IInputConstants::POLICY_FLAG_INPUTFILTER_TRUSTED,

    POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY =
            android::os::IInputConstants::POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY,
#else
    POLICY_FLAG_INPUTFILTER_TRUSTED = 0x10000,

    POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY = 0x20000,
#endif
    /* These flags are set by the input dispatcher. */

    // Indicates that the input event was injected.
+2 −0
Original line number Diff line number Diff line
@@ -318,6 +318,8 @@ extern std::string getInputDeviceConfigurationFilePathByName(
        const std::string& name, InputDeviceConfigurationFileType type);

enum ReservedInputDeviceId : int32_t {
    // Device id assigned to input events generated inside accessibility service
    ACCESSIBILITY_DEVICE_ID = -2,
    // Device id of a special "virtual" keyboard that is always present.
    VIRTUAL_KEYBOARD_ID = -1,
    // Device id of the "built-in" keyboard if there is one.
+8 −5
Original line number Diff line number Diff line
@@ -182,12 +182,12 @@ CallbackId TransactionCompletedListener::addCallbackFunction(

void TransactionCompletedListener::addJankListener(const sp<JankDataListener>& listener,
                                                   sp<SurfaceControl> surfaceControl) {
    std::lock_guard<std::mutex> lock(mMutex);
    std::scoped_lock<std::recursive_mutex> lock(mJankListenerMutex);
    mJankListeners.insert({surfaceControl->getHandle(), listener});
}

void TransactionCompletedListener::removeJankListener(const sp<JankDataListener>& listener) {
    std::lock_guard<std::mutex> lock(mMutex);
    std::scoped_lock<std::recursive_mutex> lock(mJankListenerMutex);
    for (auto it = mJankListeners.begin(); it != mJankListeners.end();) {
        if (it->second == listener) {
            it = mJankListeners.erase(it);
@@ -242,7 +242,6 @@ void TransactionCompletedListener::addSurfaceControlToCallbacks(

void TransactionCompletedListener::onTransactionCompleted(ListenerStats listenerStats) {
    std::unordered_map<CallbackId, CallbackTranslation, CallbackIdHash> callbacksMap;
    std::multimap<sp<IBinder>, sp<JankDataListener>> jankListenersMap;
    std::multimap<sp<IBinder>, SurfaceStatsCallbackEntry> surfaceListeners;
    {
        std::lock_guard<std::mutex> lock(mMutex);
@@ -259,7 +258,6 @@ void TransactionCompletedListener::onTransactionCompleted(ListenerStats listener
         * sp<SurfaceControl> that could possibly exist for the callbacks.
         */
        callbacksMap = mCallbacks;
        jankListenersMap = mJankListeners;
        surfaceListeners = mSurfaceStatsListeners;
        for (const auto& transactionStats : listenerStats.transactionStats) {
            for (auto& callbackId : transactionStats.callbackIds) {
@@ -349,7 +347,12 @@ void TransactionCompletedListener::onTransactionCompleted(ListenerStats listener
            }

            if (surfaceStats.jankData.empty()) continue;
            auto jankRange = jankListenersMap.equal_range(surfaceStats.surfaceControl);

            // Acquire jank listener lock such that we guarantee that after calling unregister,
            // there won't be any further callback.
            std::scoped_lock<std::recursive_mutex> lock(mJankListenerMutex);
            auto copy = mJankListeners;
            auto jankRange = copy.equal_range(surfaceStats.surfaceControl);
            for (auto it = jankRange.first; it != jankRange.second; it++) {
                it->second->onJankDataAvailable(surfaceStats.jankData);
            }
+7 −1
Original line number Diff line number Diff line
@@ -652,6 +652,9 @@ class TransactionCompletedListener : public BnTransactionCompletedListener {

    std::mutex mMutex;

    // This lock needs to be recursive so we can unregister a callback from within that callback.
    std::recursive_mutex mJankListenerMutex;

    bool mListening GUARDED_BY(mMutex) = false;

    int64_t mCallbackIdCounter GUARDED_BY(mMutex) = 1;
@@ -674,7 +677,10 @@ class TransactionCompletedListener : public BnTransactionCompletedListener {

    std::unordered_map<CallbackId, CallbackTranslation, CallbackIdHash> mCallbacks
            GUARDED_BY(mMutex);
    std::multimap<sp<IBinder>, sp<JankDataListener>> mJankListeners GUARDED_BY(mMutex);

    // This is protected by mJankListenerMutex, but GUARDED_BY isn't supported for
    // std::recursive_mutex
    std::multimap<sp<IBinder>, sp<JankDataListener>> mJankListeners;
    std::unordered_map<uint64_t /* graphicsBufferId */, ReleaseBufferCallback>
            mReleaseBufferCallbacks GUARDED_BY(mMutex);
    std::multimap<sp<IBinder>, SurfaceStatsCallbackEntry>
+14 −0
Original line number Diff line number Diff line
@@ -40,4 +40,18 @@ interface IInputConstants
     * available.
     */
    const int INVALID_INPUT_EVENT_ID = 0;

    /**
     * The injected event was originally sent from InputDispatcher. Most likely, the journey of the
     * event looked as follows:
     * InputDispatcherPolicyInterface::filterInputEvent -> InputFilter.java::onInputEvent ->
     * InputFilter.java::sendInputEvent -> InputDispatcher::injectInputEvent, without being modified
     * along the way.
     */
    const int POLICY_FLAG_INPUTFILTER_TRUSTED = 0x10000;

    /**
     * The input event was injected from accessibility
     */
    const int POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY = 0x20000;
}
Loading