Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef _UI_INPUT_DISPATCHER_H |
| 18 | #define _UI_INPUT_DISPATCHER_H |
| 19 | |
Garfield Tan | 73007b6 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 20 | #include "CancelationOptions.h" |
| 21 | #include "Entry.h" |
| 22 | #include "InjectionState.h" |
| 23 | #include "InputDispatcherConfiguration.h" |
| 24 | #include "InputDispatcherInterface.h" |
| 25 | #include "InputDispatcherPolicyInterface.h" |
| 26 | #include "InputState.h" |
| 27 | #include "InputTarget.h" |
| 28 | #include "Monitor.h" |
| 29 | #include "Queue.h" |
| 30 | #include "TouchState.h" |
| 31 | #include "TouchedWindow.h" |
| 32 | |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 33 | #include <cutils/atomic.h> |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 34 | #include <input/Input.h> |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 35 | #include <input/InputApplication.h> |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 36 | #include <input/InputTransport.h> |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 37 | #include <input/InputWindow.h> |
Garfield Tan | 73007b6 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 38 | #include <limits.h> |
| 39 | #include <stddef.h> |
Michael Wright | 3dd60e2 | 2019-03-27 22:06:44 +0000 | [diff] [blame] | 40 | #include <ui/Region.h> |
Garfield Tan | 73007b6 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 41 | #include <unistd.h> |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 42 | #include <utils/BitSet.h> |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 43 | #include <utils/Looper.h> |
| 44 | #include <utils/RefBase.h> |
| 45 | #include <utils/Timers.h> |
| 46 | #include <utils/threads.h> |
| 47 | #include <condition_variable> |
Garfield Tan | 73007b6 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 48 | #include <deque> |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 49 | #include <optional> |
Robert Carr | 5c8a026 | 2018-10-03 16:30:44 -0700 | [diff] [blame] | 50 | #include <unordered_map> |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 51 | |
Garfield Tan | 73007b6 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 52 | #include <InputListener.h> |
| 53 | #include <InputReporterInterface.h> |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 54 | |
Garfield Tan | 73007b6 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 55 | namespace android::inputdispatcher { |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 56 | |
Garfield Tan | 73007b6 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 57 | class Connection; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 58 | |
| 59 | /* Dispatches events to input targets. Some functions of the input dispatcher, such as |
| 60 | * identifying input targets, are controlled by a separate policy object. |
| 61 | * |
| 62 | * IMPORTANT INVARIANT: |
| 63 | * Because the policy can potentially block or cause re-entrance into the input dispatcher, |
| 64 | * the input dispatcher never calls into the policy while holding its internal locks. |
| 65 | * The implementation is also carefully designed to recover from scenarios such as an |
| 66 | * input channel becoming unregistered while identifying input targets or processing timeouts. |
| 67 | * |
| 68 | * Methods marked 'Locked' must be called with the lock acquired. |
| 69 | * |
| 70 | * Methods marked 'LockedInterruptible' must be called with the lock acquired but |
| 71 | * may during the course of their execution release the lock, call into the policy, and |
| 72 | * then reacquire the lock. The caller is responsible for recovering gracefully. |
| 73 | * |
| 74 | * A 'LockedInterruptible' method may called a 'Locked' method, but NOT vice-versa. |
| 75 | */ |
Garfield Tan | 73007b6 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 76 | class InputDispatcher : public android::InputDispatcherInterface { |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 77 | protected: |
| 78 | virtual ~InputDispatcher(); |
| 79 | |
| 80 | public: |
| 81 | explicit InputDispatcher(const sp<InputDispatcherPolicyInterface>& policy); |
| 82 | |
Michael Wright | 3dd60e2 | 2019-03-27 22:06:44 +0000 | [diff] [blame] | 83 | virtual void dump(std::string& dump) override; |
| 84 | virtual void monitor() override; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 85 | |
Michael Wright | 3dd60e2 | 2019-03-27 22:06:44 +0000 | [diff] [blame] | 86 | virtual void dispatchOnce() override; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 87 | |
Michael Wright | 3dd60e2 | 2019-03-27 22:06:44 +0000 | [diff] [blame] | 88 | virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override; |
| 89 | virtual void notifyKey(const NotifyKeyArgs* args) override; |
| 90 | virtual void notifyMotion(const NotifyMotionArgs* args) override; |
| 91 | virtual void notifySwitch(const NotifySwitchArgs* args) override; |
| 92 | virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args) override; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 93 | |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 94 | virtual int32_t injectInputEvent(const InputEvent* event, int32_t injectorPid, |
| 95 | int32_t injectorUid, int32_t syncMode, int32_t timeoutMillis, |
| 96 | uint32_t policyFlags) override; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 97 | |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 98 | virtual void setInputWindows( |
| 99 | const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId, |
Michael Wright | 3dd60e2 | 2019-03-27 22:06:44 +0000 | [diff] [blame] | 100 | const sp<ISetInputWindowsListener>& setInputWindowsListener = nullptr) override; |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 101 | virtual void setFocusedApplication( |
| 102 | int32_t displayId, const sp<InputApplicationHandle>& inputApplicationHandle) override; |
Michael Wright | 3dd60e2 | 2019-03-27 22:06:44 +0000 | [diff] [blame] | 103 | virtual void setFocusedDisplay(int32_t displayId) override; |
| 104 | virtual void setInputDispatchMode(bool enabled, bool frozen) override; |
| 105 | virtual void setInputFilterEnabled(bool enabled) override; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 106 | |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 107 | virtual bool transferTouchFocus(const sp<IBinder>& fromToken, |
| 108 | const sp<IBinder>& toToken) override; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 109 | |
| 110 | virtual status_t registerInputChannel(const sp<InputChannel>& inputChannel, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 111 | int32_t displayId) override; |
| 112 | virtual status_t registerInputMonitor(const sp<InputChannel>& inputChannel, int32_t displayId, |
| 113 | bool isGestureMonitor) override; |
Michael Wright | 3dd60e2 | 2019-03-27 22:06:44 +0000 | [diff] [blame] | 114 | virtual status_t unregisterInputChannel(const sp<InputChannel>& inputChannel) override; |
| 115 | virtual status_t pilferPointers(const sp<IBinder>& token) override; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 116 | |
| 117 | private: |
Michael Wright | 3dd60e2 | 2019-03-27 22:06:44 +0000 | [diff] [blame] | 118 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 119 | enum DropReason { |
| 120 | DROP_REASON_NOT_DROPPED = 0, |
| 121 | DROP_REASON_POLICY = 1, |
| 122 | DROP_REASON_APP_SWITCH = 2, |
| 123 | DROP_REASON_DISABLED = 3, |
| 124 | DROP_REASON_BLOCKED = 4, |
| 125 | DROP_REASON_STALE = 5, |
| 126 | }; |
| 127 | |
| 128 | sp<InputDispatcherPolicyInterface> mPolicy; |
Garfield Tan | 73007b6 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 129 | android::InputDispatcherConfiguration mConfig; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 130 | |
Siarhei Vishniakou | 443ad90 | 2019-03-06 17:25:41 -0800 | [diff] [blame] | 131 | std::mutex mLock; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 132 | |
Siarhei Vishniakou | 443ad90 | 2019-03-06 17:25:41 -0800 | [diff] [blame] | 133 | std::condition_variable mDispatcherIsAlive; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 134 | |
| 135 | sp<Looper> mLooper; |
| 136 | |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 137 | EventEntry* mPendingEvent GUARDED_BY(mLock); |
| 138 | Queue<EventEntry> mInboundQueue GUARDED_BY(mLock); |
| 139 | Queue<EventEntry> mRecentQueue GUARDED_BY(mLock); |
| 140 | Queue<CommandEntry> mCommandQueue GUARDED_BY(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 141 | |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 142 | DropReason mLastDropReason GUARDED_BY(mLock); |
Michael Wright | 3a98172 | 2015-06-10 15:26:13 +0100 | [diff] [blame] | 143 | |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 144 | void dispatchOnceInnerLocked(nsecs_t* nextWakeupTime) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 145 | |
| 146 | // Enqueues an inbound event. Returns true if mLooper->wake() should be called. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 147 | bool enqueueInboundEventLocked(EventEntry* entry) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 148 | |
| 149 | // Cleans up input state when dropping an inbound event. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 150 | void dropInboundEventLocked(EventEntry* entry, DropReason dropReason) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 151 | |
| 152 | // Adds an event to a queue of recent events for debugging purposes. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 153 | void addRecentEventLocked(EventEntry* entry) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 154 | |
| 155 | // App switch latency optimization. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 156 | bool mAppSwitchSawKeyDown GUARDED_BY(mLock); |
| 157 | nsecs_t mAppSwitchDueTime GUARDED_BY(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 158 | |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 159 | bool isAppSwitchKeyEvent(KeyEntry* keyEntry); |
| 160 | bool isAppSwitchPendingLocked() REQUIRES(mLock); |
| 161 | void resetPendingAppSwitchLocked(bool handled) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 162 | |
| 163 | // Stale event latency optimization. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 164 | static bool isStaleEvent(nsecs_t currentTime, EventEntry* entry); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 165 | |
| 166 | // Blocked event latency optimization. Drops old events when the user intends |
| 167 | // to transfer focus to a new application. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 168 | EventEntry* mNextUnblockedEvent GUARDED_BY(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 169 | |
Tiger Huang | 85b8c5e | 2019-01-17 18:34:54 +0800 | [diff] [blame] | 170 | sp<InputWindowHandle> findTouchedWindowAtLocked(int32_t displayId, int32_t x, int32_t y, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 171 | bool addOutsideTargets = false, |
| 172 | bool addPortalWindows = false) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 173 | |
| 174 | // All registered connections mapped by channel file descriptor. |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 175 | KeyedVector<int, sp<Connection>> mConnectionsByFd GUARDED_BY(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 176 | |
Robert Carr | 5c8a026 | 2018-10-03 16:30:44 -0700 | [diff] [blame] | 177 | struct IBinderHash { |
| 178 | std::size_t operator()(const sp<IBinder>& b) const { |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 179 | return std::hash<IBinder*>{}(b.get()); |
Robert Carr | 5c8a026 | 2018-10-03 16:30:44 -0700 | [diff] [blame] | 180 | } |
| 181 | }; |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 182 | std::unordered_map<sp<IBinder>, sp<InputChannel>, IBinderHash> mInputChannelsByToken |
| 183 | GUARDED_BY(mLock); |
Robert Carr | 5c8a026 | 2018-10-03 16:30:44 -0700 | [diff] [blame] | 184 | |
Michael Wright | 3dd60e2 | 2019-03-27 22:06:44 +0000 | [diff] [blame] | 185 | // Finds the display ID of the gesture monitor identified by the provided token. |
| 186 | std::optional<int32_t> findGestureMonitorDisplayByTokenLocked(const sp<IBinder>& token) |
| 187 | REQUIRES(mLock); |
| 188 | |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 189 | ssize_t getConnectionIndexLocked(const sp<InputChannel>& inputChannel) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 190 | |
Arthur Hung | 2fbf37f | 2018-09-13 18:16:41 +0800 | [diff] [blame] | 191 | // Input channels that will receive a copy of all input events sent to the provided display. |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 192 | std::unordered_map<int32_t, std::vector<Monitor>> mGlobalMonitorsByDisplay GUARDED_BY(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 193 | |
Michael Wright | 3dd60e2 | 2019-03-27 22:06:44 +0000 | [diff] [blame] | 194 | // Input channels that will receive pointer events that start within the corresponding display. |
| 195 | // These are a bit special when compared to global monitors since they'll cause gesture streams |
| 196 | // to continue even when there isn't a touched window,and have the ability to steal the rest of |
| 197 | // the pointer stream in order to claim it for a system gesture. |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 198 | std::unordered_map<int32_t, std::vector<Monitor>> mGestureMonitorsByDisplay GUARDED_BY(mLock); |
Michael Wright | 3dd60e2 | 2019-03-27 22:06:44 +0000 | [diff] [blame] | 199 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 200 | // Event injection and synchronization. |
Siarhei Vishniakou | 443ad90 | 2019-03-06 17:25:41 -0800 | [diff] [blame] | 201 | std::condition_variable mInjectionResultAvailable; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 202 | bool hasInjectionPermission(int32_t injectorPid, int32_t injectorUid); |
Siarhei Vishniakou | 62683e8 | 2019-03-06 17:59:56 -0800 | [diff] [blame] | 203 | void setInjectionResult(EventEntry* entry, int32_t injectionResult); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 204 | |
Siarhei Vishniakou | 443ad90 | 2019-03-06 17:25:41 -0800 | [diff] [blame] | 205 | std::condition_variable mInjectionSyncFinished; |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 206 | void incrementPendingForegroundDispatches(EventEntry* entry); |
Siarhei Vishniakou | 62683e8 | 2019-03-06 17:59:56 -0800 | [diff] [blame] | 207 | void decrementPendingForegroundDispatches(EventEntry* entry); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 208 | |
| 209 | // Key repeat tracking. |
| 210 | struct KeyRepeatState { |
| 211 | KeyEntry* lastKeyEntry; // or null if no repeat |
| 212 | nsecs_t nextRepeatTime; |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 213 | } mKeyRepeatState GUARDED_BY(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 214 | |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 215 | void resetKeyRepeatLocked() REQUIRES(mLock); |
| 216 | KeyEntry* synthesizeKeyRepeatLocked(nsecs_t currentTime) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 217 | |
Michael Wright | 78f2444 | 2014-08-06 15:55:28 -0700 | [diff] [blame] | 218 | // Key replacement tracking |
| 219 | struct KeyReplacement { |
| 220 | int32_t keyCode; |
| 221 | int32_t deviceId; |
| 222 | bool operator==(const KeyReplacement& rhs) const { |
| 223 | return keyCode == rhs.keyCode && deviceId == rhs.deviceId; |
| 224 | } |
| 225 | bool operator<(const KeyReplacement& rhs) const { |
| 226 | return keyCode != rhs.keyCode ? keyCode < rhs.keyCode : deviceId < rhs.deviceId; |
| 227 | } |
| 228 | }; |
| 229 | // Maps the key code replaced, device id tuple to the key code it was replaced with |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 230 | KeyedVector<KeyReplacement, int32_t> mReplacedKeys GUARDED_BY(mLock); |
Siarhei Vishniakou | 61fafdd | 2018-04-13 11:00:58 -0500 | [diff] [blame] | 231 | // Process certain Meta + Key combinations |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 232 | void accelerateMetaShortcuts(const int32_t deviceId, const int32_t action, int32_t& keyCode, |
| 233 | int32_t& metaState); |
Michael Wright | 78f2444 | 2014-08-06 15:55:28 -0700 | [diff] [blame] | 234 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 235 | // Deferred command processing. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 236 | bool haveCommandsLocked() const REQUIRES(mLock); |
| 237 | bool runCommandsLockedInterruptible() REQUIRES(mLock); |
| 238 | CommandEntry* postCommandLocked(Command command) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 239 | |
| 240 | // Input filter processing. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 241 | bool shouldSendKeyToInputFilterLocked(const NotifyKeyArgs* args) REQUIRES(mLock); |
| 242 | bool shouldSendMotionToInputFilterLocked(const NotifyMotionArgs* args) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 243 | |
| 244 | // Inbound event processing. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 245 | void drainInboundQueueLocked() REQUIRES(mLock); |
| 246 | void releasePendingEventLocked() REQUIRES(mLock); |
| 247 | void releaseInboundEventLocked(EventEntry* entry) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 248 | |
| 249 | // Dispatch state. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 250 | bool mDispatchEnabled GUARDED_BY(mLock); |
| 251 | bool mDispatchFrozen GUARDED_BY(mLock); |
| 252 | bool mInputFilterEnabled GUARDED_BY(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 253 | |
Arthur Hung | 7c3ae9c | 2019-03-11 11:23:03 +0800 | [diff] [blame] | 254 | std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>> mWindowHandlesByDisplay |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 255 | GUARDED_BY(mLock); |
Arthur Hung | b92218b | 2018-08-14 12:00:21 +0800 | [diff] [blame] | 256 | // Get window handles by display, return an empty vector if not found. |
Arthur Hung | 7c3ae9c | 2019-03-11 11:23:03 +0800 | [diff] [blame] | 257 | std::vector<sp<InputWindowHandle>> getWindowHandlesLocked(int32_t displayId) const |
| 258 | REQUIRES(mLock); |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 259 | sp<InputWindowHandle> getWindowHandleLocked(const sp<IBinder>& windowHandleToken) const |
| 260 | REQUIRES(mLock); |
| 261 | sp<InputChannel> getInputChannelLocked(const sp<IBinder>& windowToken) const REQUIRES(mLock); |
| 262 | bool hasWindowHandleLocked(const sp<InputWindowHandle>& windowHandle) const REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 263 | |
| 264 | // Focus tracking for keys, trackball, etc. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 265 | std::unordered_map<int32_t, sp<InputWindowHandle>> mFocusedWindowHandlesByDisplay |
| 266 | GUARDED_BY(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 267 | |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 268 | KeyedVector<int32_t, TouchState> mTouchStatesByDisplay GUARDED_BY(mLock); |
| 269 | TouchState mTempTouchState GUARDED_BY(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 270 | |
Tiger Huang | 721e26f | 2018-07-24 22:26:19 +0800 | [diff] [blame] | 271 | // Focused applications. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 272 | std::unordered_map<int32_t, sp<InputApplicationHandle>> mFocusedApplicationHandlesByDisplay |
| 273 | GUARDED_BY(mLock); |
Tiger Huang | 721e26f | 2018-07-24 22:26:19 +0800 | [diff] [blame] | 274 | |
| 275 | // Top focused display. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 276 | int32_t mFocusedDisplayId GUARDED_BY(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 277 | |
| 278 | // Dispatcher state at time of last ANR. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 279 | std::string mLastANRState GUARDED_BY(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 280 | |
| 281 | // Dispatch inbound events. |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 282 | bool dispatchConfigurationChangedLocked(nsecs_t currentTime, ConfigurationChangedEntry* entry) |
| 283 | REQUIRES(mLock); |
| 284 | bool dispatchDeviceResetLocked(nsecs_t currentTime, DeviceResetEntry* entry) REQUIRES(mLock); |
| 285 | bool dispatchKeyLocked(nsecs_t currentTime, KeyEntry* entry, DropReason* dropReason, |
| 286 | nsecs_t* nextWakeupTime) REQUIRES(mLock); |
| 287 | bool dispatchMotionLocked(nsecs_t currentTime, MotionEntry* entry, DropReason* dropReason, |
| 288 | nsecs_t* nextWakeupTime) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 289 | void dispatchEventLocked(nsecs_t currentTime, EventEntry* entry, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 290 | const std::vector<InputTarget>& inputTargets) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 291 | |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 292 | void logOutboundKeyDetails(const char* prefix, const KeyEntry* entry); |
| 293 | void logOutboundMotionDetails(const char* prefix, const MotionEntry* entry); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 294 | |
| 295 | // Keeping track of ANR timeouts. |
| 296 | enum InputTargetWaitCause { |
| 297 | INPUT_TARGET_WAIT_CAUSE_NONE, |
| 298 | INPUT_TARGET_WAIT_CAUSE_SYSTEM_NOT_READY, |
| 299 | INPUT_TARGET_WAIT_CAUSE_APPLICATION_NOT_READY, |
| 300 | }; |
| 301 | |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 302 | InputTargetWaitCause mInputTargetWaitCause GUARDED_BY(mLock); |
| 303 | nsecs_t mInputTargetWaitStartTime GUARDED_BY(mLock); |
| 304 | nsecs_t mInputTargetWaitTimeoutTime GUARDED_BY(mLock); |
| 305 | bool mInputTargetWaitTimeoutExpired GUARDED_BY(mLock); |
| 306 | sp<IBinder> mInputTargetWaitApplicationToken GUARDED_BY(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 307 | |
| 308 | // Contains the last window which received a hover event. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 309 | sp<InputWindowHandle> mLastHoverWindowHandle GUARDED_BY(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 310 | |
| 311 | // Finding targets for input events. |
| 312 | int32_t handleTargetsNotReadyLocked(nsecs_t currentTime, const EventEntry* entry, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 313 | const sp<InputApplicationHandle>& applicationHandle, |
| 314 | const sp<InputWindowHandle>& windowHandle, |
| 315 | nsecs_t* nextWakeupTime, const char* reason) |
| 316 | REQUIRES(mLock); |
Robert Carr | 803535b | 2018-08-02 16:38:15 -0700 | [diff] [blame] | 317 | |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 318 | void removeWindowByTokenLocked(const sp<IBinder>& token) REQUIRES(mLock); |
Robert Carr | 803535b | 2018-08-02 16:38:15 -0700 | [diff] [blame] | 319 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 320 | void resumeAfterTargetsNotReadyTimeoutLocked(nsecs_t newTimeout, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 321 | const sp<InputChannel>& inputChannel) |
| 322 | REQUIRES(mLock); |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 323 | nsecs_t getTimeSpentWaitingForApplicationLocked(nsecs_t currentTime) REQUIRES(mLock); |
| 324 | void resetANRTimeoutsLocked() REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 325 | |
Tiger Huang | 721e26f | 2018-07-24 22:26:19 +0800 | [diff] [blame] | 326 | int32_t getTargetDisplayId(const EventEntry* entry); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 327 | int32_t findFocusedWindowTargetsLocked(nsecs_t currentTime, const EventEntry* entry, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 328 | std::vector<InputTarget>& inputTargets, |
| 329 | nsecs_t* nextWakeupTime) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 330 | int32_t findTouchedWindowTargetsLocked(nsecs_t currentTime, const MotionEntry* entry, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 331 | std::vector<InputTarget>& inputTargets, |
| 332 | nsecs_t* nextWakeupTime, |
| 333 | bool* outConflictingPointerActions) REQUIRES(mLock); |
| 334 | std::vector<TouchedMonitor> findTouchedGestureMonitorsLocked( |
| 335 | int32_t displayId, const std::vector<sp<InputWindowHandle>>& portalWindows) |
| 336 | REQUIRES(mLock); |
Michael Wright | 3dd60e2 | 2019-03-27 22:06:44 +0000 | [diff] [blame] | 337 | void addGestureMonitors(const std::vector<Monitor>& monitors, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 338 | std::vector<TouchedMonitor>& outTouchedMonitors, float xOffset = 0, |
| 339 | float yOffset = 0); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 340 | |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 341 | void addWindowTargetLocked(const sp<InputWindowHandle>& windowHandle, int32_t targetFlags, |
| 342 | BitSet32 pointerIds, std::vector<InputTarget>& inputTargets) |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 343 | REQUIRES(mLock); |
Michael Wright | 3dd60e2 | 2019-03-27 22:06:44 +0000 | [diff] [blame] | 344 | void addMonitoringTargetLocked(const Monitor& monitor, float xOffset, float yOffset, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 345 | std::vector<InputTarget>& inputTargets) REQUIRES(mLock); |
| 346 | void addGlobalMonitoringTargetsLocked(std::vector<InputTarget>& inputTargets, int32_t displayId, |
| 347 | float xOffset = 0, float yOffset = 0) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 348 | |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 349 | void pokeUserActivityLocked(const EventEntry* eventEntry) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 350 | bool checkInjectionPermission(const sp<InputWindowHandle>& windowHandle, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 351 | const InjectionState* injectionState); |
| 352 | bool isWindowObscuredAtPointLocked(const sp<InputWindowHandle>& windowHandle, int32_t x, |
| 353 | int32_t y) const REQUIRES(mLock); |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 354 | bool isWindowObscuredLocked(const sp<InputWindowHandle>& windowHandle) const REQUIRES(mLock); |
| 355 | std::string getApplicationWindowLabel(const sp<InputApplicationHandle>& applicationHandle, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 356 | const sp<InputWindowHandle>& windowHandle); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 357 | |
Siarhei Vishniakou | f93fcf4 | 2017-11-22 16:00:14 -0800 | [diff] [blame] | 358 | std::string checkWindowReadyForMoreInputLocked(nsecs_t currentTime, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 359 | const sp<InputWindowHandle>& windowHandle, |
| 360 | const EventEntry* eventEntry, |
| 361 | const char* targetType) REQUIRES(mLock); |
Jeff Brown | ffb4977 | 2014-10-10 19:01:34 -0700 | [diff] [blame] | 362 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 363 | // Manage the dispatch cycle for a single connection. |
| 364 | // These methods are deliberately not Interruptible because doing all of the work |
| 365 | // with the mutex held makes it easier to ensure that connection invariants are maintained. |
| 366 | // If needed, the methods post commands to run later once the critical bits are done. |
| 367 | void prepareDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 368 | EventEntry* eventEntry, const InputTarget* inputTarget) |
| 369 | REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 370 | void enqueueDispatchEntriesLocked(nsecs_t currentTime, const sp<Connection>& connection, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 371 | EventEntry* eventEntry, const InputTarget* inputTarget) |
| 372 | REQUIRES(mLock); |
| 373 | void enqueueDispatchEntryLocked(const sp<Connection>& connection, EventEntry* eventEntry, |
| 374 | const InputTarget* inputTarget, int32_t dispatchMode) |
chaviw | 8c9cf54 | 2019-03-25 13:02:48 -0700 | [diff] [blame] | 375 | REQUIRES(mLock); |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 376 | void startDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection) |
| 377 | REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 378 | void finishDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 379 | uint32_t seq, bool handled) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 380 | void abortBrokenDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 381 | bool notify) REQUIRES(mLock); |
Siarhei Vishniakou | 62683e8 | 2019-03-06 17:59:56 -0800 | [diff] [blame] | 382 | void drainDispatchQueue(Queue<DispatchEntry>* queue); |
| 383 | void releaseDispatchEntry(DispatchEntry* dispatchEntry); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 384 | static int handleReceiveCallback(int fd, int events, void* data); |
chaviw | 8c9cf54 | 2019-03-25 13:02:48 -0700 | [diff] [blame] | 385 | // The action sent should only be of type AMOTION_EVENT_* |
chaviw | fd6d351 | 2019-03-25 13:23:49 -0700 | [diff] [blame] | 386 | void dispatchPointerDownOutsideFocus(uint32_t source, int32_t action, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 387 | const sp<IBinder>& newToken) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 388 | |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 389 | void synthesizeCancelationEventsForAllConnectionsLocked(const CancelationOptions& options) |
| 390 | REQUIRES(mLock); |
| 391 | void synthesizeCancelationEventsForMonitorsLocked(const CancelationOptions& options) |
| 392 | REQUIRES(mLock); |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 393 | void synthesizeCancelationEventsForMonitorsLocked( |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 394 | const CancelationOptions& options, |
Michael Wright | 3dd60e2 | 2019-03-27 22:06:44 +0000 | [diff] [blame] | 395 | std::unordered_map<int32_t, std::vector<Monitor>>& monitorsByDisplay) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 396 | void synthesizeCancelationEventsForInputChannelLocked(const sp<InputChannel>& channel, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 397 | const CancelationOptions& options) |
| 398 | REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 399 | void synthesizeCancelationEventsForConnectionLocked(const sp<Connection>& connection, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 400 | const CancelationOptions& options) |
| 401 | REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 402 | |
| 403 | // Splitting motion events across windows. |
| 404 | MotionEntry* splitMotionEvent(const MotionEntry* originalMotionEntry, BitSet32 pointerIds); |
| 405 | |
| 406 | // Reset and drop everything the dispatcher is doing. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 407 | void resetAndDropEverythingLocked(const char* reason) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 408 | |
| 409 | // Dump state. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 410 | void dumpDispatchStateLocked(std::string& dump) REQUIRES(mLock); |
Michael Wright | 3dd60e2 | 2019-03-27 22:06:44 +0000 | [diff] [blame] | 411 | void dumpMonitors(std::string& dump, const std::vector<Monitor>& monitors); |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 412 | void logDispatchStateLocked() REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 413 | |
| 414 | // Registration. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 415 | void removeMonitorChannelLocked(const sp<InputChannel>& inputChannel) REQUIRES(mLock); |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 416 | void removeMonitorChannelLocked( |
| 417 | const sp<InputChannel>& inputChannel, |
| 418 | std::unordered_map<int32_t, std::vector<Monitor>>& monitorsByDisplay) REQUIRES(mLock); |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 419 | status_t unregisterInputChannelLocked(const sp<InputChannel>& inputChannel, bool notify) |
| 420 | REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 421 | |
| 422 | // Interesting events that we might like to log or tell the framework about. |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 423 | void onDispatchCycleFinishedLocked(nsecs_t currentTime, const sp<Connection>& connection, |
| 424 | uint32_t seq, bool handled) REQUIRES(mLock); |
| 425 | void onDispatchCycleBrokenLocked(nsecs_t currentTime, const sp<Connection>& connection) |
| 426 | REQUIRES(mLock); |
chaviw | 0c06c6e | 2019-01-09 13:27:07 -0800 | [diff] [blame] | 427 | void onFocusChangedLocked(const sp<InputWindowHandle>& oldFocus, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 428 | const sp<InputWindowHandle>& newFocus) REQUIRES(mLock); |
| 429 | void onANRLocked(nsecs_t currentTime, const sp<InputApplicationHandle>& applicationHandle, |
| 430 | const sp<InputWindowHandle>& windowHandle, nsecs_t eventTime, |
| 431 | nsecs_t waitStartTime, const char* reason) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 432 | |
| 433 | // Outbound policy interactions. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 434 | void doNotifyConfigurationChangedLockedInterruptible(CommandEntry* commandEntry) |
| 435 | REQUIRES(mLock); |
| 436 | void doNotifyInputChannelBrokenLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock); |
| 437 | void doNotifyFocusChangedLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock); |
| 438 | void doNotifyANRLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock); |
| 439 | void doInterceptKeyBeforeDispatchingLockedInterruptible(CommandEntry* commandEntry) |
| 440 | REQUIRES(mLock); |
| 441 | void doDispatchCycleFinishedLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 442 | bool afterKeyEventLockedInterruptible(const sp<Connection>& connection, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 443 | DispatchEntry* dispatchEntry, KeyEntry* keyEntry, |
| 444 | bool handled) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 445 | bool afterMotionEventLockedInterruptible(const sp<Connection>& connection, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 446 | DispatchEntry* dispatchEntry, MotionEntry* motionEntry, |
| 447 | bool handled) REQUIRES(mLock); |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 448 | void doPokeUserActivityLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 449 | void initializeKeyEvent(KeyEvent* event, const KeyEntry* entry); |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 450 | void doOnPointerDownOutsideFocusLockedInterruptible(CommandEntry* commandEntry) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 451 | |
| 452 | // Statistics gathering. |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 453 | void updateDispatchStatistics(nsecs_t currentTime, const EventEntry* entry, |
Garfield Tan | e4fc010 | 2019-09-11 13:16:25 -0700 | [diff] [blame] | 454 | int32_t injectionResult, nsecs_t timeSpentWaitingForApplication); |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 455 | void traceInboundQueueLengthLocked() REQUIRES(mLock); |
| 456 | void traceOutboundQueueLength(const sp<Connection>& connection); |
| 457 | void traceWaitQueueLength(const sp<Connection>& connection); |
Prabir Pradhan | f93562f | 2018-11-29 12:13:37 -0800 | [diff] [blame] | 458 | |
Prabir Pradhan | 79a4f0c | 2019-01-09 11:24:01 -0800 | [diff] [blame] | 459 | sp<InputReporterInterface> mReporter; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 460 | }; |
| 461 | |
Garfield Tan | 73007b6 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 462 | } // namespace android::inputdispatcher |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 463 | |
| 464 | #endif // _UI_INPUT_DISPATCHER_H |