Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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 | |
Prabir Pradhan | 4810866 | 2022-09-09 21:22:04 +0000 | [diff] [blame] | 17 | #pragma once |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 18 | |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 19 | #include <android-base/thread_annotations.h> |
Siarhei Vishniakou | 34d6fef | 2022-02-01 19:03:45 -0800 | [diff] [blame] | 20 | #include <future> |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 21 | #include <thread> |
Siarhei Vishniakou | 1652397 | 2020-03-04 17:48:39 -0800 | [diff] [blame] | 22 | #include <unordered_map> |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 23 | |
Siarhei Vishniakou | 34d6fef | 2022-02-01 19:03:45 -0800 | [diff] [blame] | 24 | #include <aidl/android/hardware/input/processor/IInputProcessor.h> |
Siarhei Vishniakou | 3782af6 | 2024-03-07 21:56:39 -0800 | [diff] [blame] | 25 | #include <input/BlockingQueue.h> |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 26 | #include "InputListener.h" |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 27 | namespace android { |
| 28 | |
| 29 | enum class ClassifierEventType : uint8_t { |
| 30 | MOTION = 0, |
| 31 | DEVICE_RESET = 1, |
| 32 | HAL_RESET = 2, |
| 33 | EXIT = 3, |
| 34 | }; |
| 35 | |
| 36 | struct ClassifierEvent { |
| 37 | ClassifierEventType type; |
Siarhei Vishniakou | 096257c | 2022-09-15 17:02:20 -0700 | [diff] [blame] | 38 | std::optional<NotifyArgs> args; |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 39 | |
Siarhei Vishniakou | 096257c | 2022-09-15 17:02:20 -0700 | [diff] [blame] | 40 | ClassifierEvent(ClassifierEventType type, std::optional<NotifyArgs> args); |
| 41 | ClassifierEvent(const NotifyMotionArgs& args); |
| 42 | ClassifierEvent(const NotifyDeviceResetArgs& args); |
| 43 | ClassifierEvent(ClassifierEvent&& other) = default; |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 44 | ClassifierEvent& operator=(ClassifierEvent&& other); |
| 45 | |
| 46 | // Convenience function to create a HAL_RESET event |
| 47 | static ClassifierEvent createHalResetEvent(); |
| 48 | // Convenience function to create an EXIT event |
| 49 | static ClassifierEvent createExitEvent(); |
| 50 | |
| 51 | std::optional<int32_t> getDeviceId() const; |
| 52 | }; |
| 53 | |
| 54 | // --- Interfaces --- |
| 55 | |
| 56 | /** |
| 57 | * Interface for adding a MotionClassification to NotifyMotionArgs. |
| 58 | * |
| 59 | * To implement, override the classify function. |
| 60 | */ |
| 61 | class MotionClassifierInterface { |
| 62 | public: |
Siarhei Vishniakou | 9899603 | 2022-08-03 11:54:47 -0700 | [diff] [blame] | 63 | MotionClassifierInterface() {} |
| 64 | virtual ~MotionClassifierInterface() {} |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 65 | /** |
| 66 | * Based on the motion event described by NotifyMotionArgs, |
| 67 | * provide a MotionClassification for the current gesture. |
| 68 | */ |
| 69 | virtual MotionClassification classify(const NotifyMotionArgs& args) = 0; |
Siarhei Vishniakou | 15b66d1 | 2019-02-04 14:27:29 -0800 | [diff] [blame] | 70 | /** |
| 71 | * Reset all internal HAL state. |
| 72 | */ |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 73 | virtual void reset() = 0; |
Siarhei Vishniakou | 15b66d1 | 2019-02-04 14:27:29 -0800 | [diff] [blame] | 74 | /** |
| 75 | * Reset HAL state for a specific device. |
| 76 | */ |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 77 | virtual void reset(const NotifyDeviceResetArgs& args) = 0; |
Siarhei Vishniakou | a028c44 | 2019-02-04 14:33:23 -0800 | [diff] [blame] | 78 | |
| 79 | /** |
Prabir Pradhan | d7740d6 | 2022-07-01 17:54:18 +0000 | [diff] [blame] | 80 | * Dump the state of the motion classifier. |
Siarhei Vishniakou | a028c44 | 2019-02-04 14:33:23 -0800 | [diff] [blame] | 81 | */ |
| 82 | virtual void dump(std::string& dump) = 0; |
Prabir Pradhan | d7740d6 | 2022-07-01 17:54:18 +0000 | [diff] [blame] | 83 | |
| 84 | /** |
| 85 | * Called by the heartbeat to ensure the HAL is still processing normally. |
| 86 | */ |
| 87 | virtual void monitor() = 0; |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | /** |
| 91 | * Base interface for an InputListener stage. |
| 92 | * Provides classification to events. |
| 93 | */ |
Siarhei Vishniakou | 9899603 | 2022-08-03 11:54:47 -0700 | [diff] [blame] | 94 | class InputProcessorInterface : public InputListenerInterface { |
Siarhei Vishniakou | a028c44 | 2019-02-04 14:33:23 -0800 | [diff] [blame] | 95 | public: |
Siarhei Vishniakou | c9ac19e | 2020-03-19 11:55:01 -0700 | [diff] [blame] | 96 | virtual void setMotionClassifierEnabled(bool enabled) = 0; |
Siarhei Vishniakou | a028c44 | 2019-02-04 14:33:23 -0800 | [diff] [blame] | 97 | /** |
| 98 | * Dump the state of the input classifier. |
| 99 | * This method may be called on any thread (usually by the input manager). |
| 100 | */ |
| 101 | virtual void dump(std::string& dump) = 0; |
Siarhei Vishniakou | 1805009 | 2021-09-01 13:32:49 -0700 | [diff] [blame] | 102 | |
Prabir Pradhan | d7740d6 | 2022-07-01 17:54:18 +0000 | [diff] [blame] | 103 | /** Called by the heartbeat to ensure that the classifier has not deadlocked. */ |
Siarhei Vishniakou | 9f330c5 | 2022-05-17 05:03:42 -0700 | [diff] [blame] | 104 | virtual void monitor() = 0; |
| 105 | |
Siarhei Vishniakou | 9899603 | 2022-08-03 11:54:47 -0700 | [diff] [blame] | 106 | InputProcessorInterface() {} |
| 107 | virtual ~InputProcessorInterface() {} |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | // --- Implementations --- |
| 111 | |
Siarhei Vishniakou | 34d6fef | 2022-02-01 19:03:45 -0800 | [diff] [blame] | 112 | class ScopedDeathRecipient { |
| 113 | public: |
| 114 | explicit ScopedDeathRecipient(AIBinder_DeathRecipient_onBinderDied onBinderDied, void* cookie); |
| 115 | ScopedDeathRecipient(const ScopedDeathRecipient&) = delete; |
| 116 | ScopedDeathRecipient& operator=(ScopedDeathRecipient const&) = delete; |
| 117 | void linkToDeath(AIBinder* binder); |
| 118 | ~ScopedDeathRecipient(); |
| 119 | |
| 120 | private: |
| 121 | AIBinder_DeathRecipient* mRecipient; |
| 122 | void* mCookie; |
| 123 | }; |
| 124 | |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 125 | /** |
Siarhei Vishniakou | 9899603 | 2022-08-03 11:54:47 -0700 | [diff] [blame] | 126 | * Implementation of MotionClassifierInterface that calls the InputProcessor HAL |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 127 | * in order to determine the classification for the current gesture. |
| 128 | * |
Siarhei Vishniakou | 9899603 | 2022-08-03 11:54:47 -0700 | [diff] [blame] | 129 | * The InputProcessor HAL may keep track of the entire gesture in order to determine |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 130 | * the classification, and may be hardware-specific. It may use the data in |
| 131 | * NotifyMotionArgs::videoFrames field to drive the classification decisions. |
| 132 | * The HAL is called from a separate thread. |
| 133 | */ |
Greg Kaiser | 04b3a05 | 2019-01-29 07:10:14 -0800 | [diff] [blame] | 134 | class MotionClassifier final : public MotionClassifierInterface { |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 135 | public: |
Siarhei Vishniakou | 1652397 | 2020-03-04 17:48:39 -0800 | [diff] [blame] | 136 | /* |
| 137 | * Create an instance of MotionClassifier. |
| 138 | * The death recipient, if provided, will be subscribed to the HAL death. |
| 139 | * The death recipient could be used to destroy MotionClassifier. |
| 140 | * |
| 141 | * This function should be called asynchronously, because getService takes a long time. |
Siarhei Vishniakou | 15b66d1 | 2019-02-04 14:27:29 -0800 | [diff] [blame] | 142 | */ |
Siarhei Vishniakou | 1652397 | 2020-03-04 17:48:39 -0800 | [diff] [blame] | 143 | static std::unique_ptr<MotionClassifierInterface> create( |
Siarhei Vishniakou | 34d6fef | 2022-02-01 19:03:45 -0800 | [diff] [blame] | 144 | std::shared_ptr<aidl::android::hardware::input::processor::IInputProcessor> service); |
Siarhei Vishniakou | 1652397 | 2020-03-04 17:48:39 -0800 | [diff] [blame] | 145 | |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 146 | ~MotionClassifier(); |
Siarhei Vishniakou | 4bdbb6a | 2019-04-11 09:42:09 -0700 | [diff] [blame] | 147 | |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 148 | /** |
| 149 | * Classifies events asynchronously; that is, it doesn't block events on a classification, |
Siarhei Vishniakou | 1652397 | 2020-03-04 17:48:39 -0800 | [diff] [blame] | 150 | * but instead sends them over to the classifier HAL. After a classification of a specific |
| 151 | * event is determined, MotionClassifier then marks the next event in the stream with this |
| 152 | * classification. |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 153 | * |
| 154 | * Therefore, it is acceptable to have the classifications be delayed by 1-2 events |
| 155 | * in a particular gesture. |
| 156 | */ |
| 157 | virtual MotionClassification classify(const NotifyMotionArgs& args) override; |
| 158 | virtual void reset() override; |
| 159 | virtual void reset(const NotifyDeviceResetArgs& args) override; |
| 160 | |
Siarhei Vishniakou | a028c44 | 2019-02-04 14:33:23 -0800 | [diff] [blame] | 161 | virtual void dump(std::string& dump) override; |
Prabir Pradhan | d7740d6 | 2022-07-01 17:54:18 +0000 | [diff] [blame] | 162 | virtual void monitor() override; |
Siarhei Vishniakou | a028c44 | 2019-02-04 14:33:23 -0800 | [diff] [blame] | 163 | |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 164 | private: |
Siarhei Vishniakou | 1652397 | 2020-03-04 17:48:39 -0800 | [diff] [blame] | 165 | friend class MotionClassifierTest; // to create MotionClassifier with a test HAL implementation |
| 166 | explicit MotionClassifier( |
Siarhei Vishniakou | 34d6fef | 2022-02-01 19:03:45 -0800 | [diff] [blame] | 167 | std::shared_ptr<aidl::android::hardware::input::processor::IInputProcessor> service); |
Siarhei Vishniakou | 4bdbb6a | 2019-04-11 09:42:09 -0700 | [diff] [blame] | 168 | |
Prabir Pradhan | d7740d6 | 2022-07-01 17:54:18 +0000 | [diff] [blame] | 169 | /** The events that need to be sent to the HAL. */ |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 170 | BlockingQueue<ClassifierEvent> mEvents; |
| 171 | /** |
Siarhei Vishniakou | 15b66d1 | 2019-02-04 14:27:29 -0800 | [diff] [blame] | 172 | * Add an event to the queue mEvents. |
| 173 | */ |
| 174 | void enqueueEvent(ClassifierEvent&& event); |
| 175 | /** |
Siarhei Vishniakou | 9899603 | 2022-08-03 11:54:47 -0700 | [diff] [blame] | 176 | * Thread that will communicate with InputProcessor HAL. |
| 177 | * This should be the only thread that communicates with InputProcessor HAL, |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 178 | * because this thread is allowed to block on the HAL calls. |
| 179 | */ |
| 180 | std::thread mHalThread; |
| 181 | /** |
Siarhei Vishniakou | 9899603 | 2022-08-03 11:54:47 -0700 | [diff] [blame] | 182 | * Process events and call the InputProcessor HAL |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 183 | */ |
Siarhei Vishniakou | 1652397 | 2020-03-04 17:48:39 -0800 | [diff] [blame] | 184 | void processEvents(); |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 185 | /** |
Siarhei Vishniakou | 34d6fef | 2022-02-01 19:03:45 -0800 | [diff] [blame] | 186 | * Access to the InputProcessor HAL. May be null if init() hasn't completed yet. |
Siarhei Vishniakou | 4bdbb6a | 2019-04-11 09:42:09 -0700 | [diff] [blame] | 187 | * When init() successfully completes, mService is guaranteed to remain non-null and to not |
| 188 | * change its value until MotionClassifier is destroyed. |
Siarhei Vishniakou | 9899603 | 2022-08-03 11:54:47 -0700 | [diff] [blame] | 189 | * This variable is *not* guarded by mLock in the InputProcessor thread, because |
Siarhei Vishniakou | 4bdbb6a | 2019-04-11 09:42:09 -0700 | [diff] [blame] | 190 | * that thread knows exactly when this variable is initialized. |
| 191 | * When accessed in any other thread, mService is checked for nullness with a lock. |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 192 | */ |
Siarhei Vishniakou | 34d6fef | 2022-02-01 19:03:45 -0800 | [diff] [blame] | 193 | std::shared_ptr<aidl::android::hardware::input::processor::IInputProcessor> mService; |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 194 | std::mutex mLock; |
| 195 | /** |
| 196 | * Per-device input classifications. Should only be accessed using the |
| 197 | * getClassification / setClassification methods. |
| 198 | */ |
Siarhei Vishniakou | 9899603 | 2022-08-03 11:54:47 -0700 | [diff] [blame] | 199 | std::unordered_map<int32_t /*deviceId*/, MotionClassification> mClassifications |
| 200 | GUARDED_BY(mLock); |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 201 | /** |
| 202 | * Set the current classification for a given device. |
| 203 | */ |
| 204 | void setClassification(int32_t deviceId, MotionClassification classification); |
| 205 | /** |
| 206 | * Get the current classification for a given device. |
| 207 | */ |
| 208 | MotionClassification getClassification(int32_t deviceId); |
| 209 | void updateClassification(int32_t deviceId, nsecs_t eventTime, |
Siarhei Vishniakou | 9899603 | 2022-08-03 11:54:47 -0700 | [diff] [blame] | 210 | MotionClassification classification); |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 211 | /** |
| 212 | * Clear all current classifications |
| 213 | */ |
| 214 | void clearClassifications(); |
| 215 | /** |
| 216 | * Per-device times when the last ACTION_DOWN was received. |
| 217 | * Used to reject late classifications that do not belong to the current gesture. |
| 218 | * |
Siarhei Vishniakou | 9899603 | 2022-08-03 11:54:47 -0700 | [diff] [blame] | 219 | * Accessed indirectly by both InputProcessor thread and the thread that receives notifyMotion. |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 220 | */ |
Siarhei Vishniakou | 61291d4 | 2019-02-11 18:13:20 -0800 | [diff] [blame] | 221 | std::unordered_map<int32_t /*deviceId*/, nsecs_t /*downTime*/> mLastDownTimes GUARDED_BY(mLock); |
| 222 | |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 223 | void updateLastDownTime(int32_t deviceId, nsecs_t downTime); |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 224 | |
Siarhei Vishniakou | e3021d7 | 2020-02-28 15:25:41 -0800 | [diff] [blame] | 225 | void clearDeviceState(int32_t deviceId); |
| 226 | |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 227 | /** |
Siarhei Vishniakou | 9899603 | 2022-08-03 11:54:47 -0700 | [diff] [blame] | 228 | * Exit the InputProcessor HAL thread. |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 229 | * Useful for tests to ensure proper cleanup. |
| 230 | */ |
| 231 | void requestExit(); |
Siarhei Vishniakou | 4bdbb6a | 2019-04-11 09:42:09 -0700 | [diff] [blame] | 232 | /** |
| 233 | * Return string status of mService |
| 234 | */ |
| 235 | const char* getServiceStatus() REQUIRES(mLock); |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 236 | }; |
| 237 | |
| 238 | /** |
Siarhei Vishniakou | 9899603 | 2022-08-03 11:54:47 -0700 | [diff] [blame] | 239 | * Implementation of the InputProcessorInterface. |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 240 | * Represents a separate stage of input processing. All of the input events go through this stage. |
| 241 | * Acts as a passthrough for all input events except for motion events. |
| 242 | * The events of motion type are sent to MotionClassifier. |
| 243 | */ |
Siarhei Vishniakou | 9899603 | 2022-08-03 11:54:47 -0700 | [diff] [blame] | 244 | class InputProcessor : public InputProcessorInterface { |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 245 | public: |
Siarhei Vishniakou | 9899603 | 2022-08-03 11:54:47 -0700 | [diff] [blame] | 246 | explicit InputProcessor(InputListenerInterface& listener); |
Siarhei Vishniakou | 45bb088 | 2019-02-04 14:25:28 -0800 | [diff] [blame] | 247 | |
Prabir Pradhan | e3da4bb | 2023-04-05 23:51:23 +0000 | [diff] [blame] | 248 | void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override; |
Prabir Pradhan | c392d8f | 2023-04-13 19:32:51 +0000 | [diff] [blame] | 249 | void notifyKey(const NotifyKeyArgs& args) override; |
| 250 | void notifyMotion(const NotifyMotionArgs& args) override; |
| 251 | void notifySwitch(const NotifySwitchArgs& args) override; |
| 252 | void notifySensor(const NotifySensorArgs& args) override; |
| 253 | void notifyVibratorState(const NotifyVibratorStateArgs& args) override; |
| 254 | void notifyDeviceReset(const NotifyDeviceResetArgs& args) override; |
| 255 | void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override; |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 256 | |
Siarhei Vishniakou | 34d6fef | 2022-02-01 19:03:45 -0800 | [diff] [blame] | 257 | void dump(std::string& dump) override; |
Siarhei Vishniakou | 9f330c5 | 2022-05-17 05:03:42 -0700 | [diff] [blame] | 258 | void monitor() override; |
Siarhei Vishniakou | a028c44 | 2019-02-04 14:33:23 -0800 | [diff] [blame] | 259 | |
Siarhei Vishniakou | 9899603 | 2022-08-03 11:54:47 -0700 | [diff] [blame] | 260 | ~InputProcessor(); |
Siarhei Vishniakou | 1652397 | 2020-03-04 17:48:39 -0800 | [diff] [blame] | 261 | |
Siarhei Vishniakou | c9ac19e | 2020-03-19 11:55:01 -0700 | [diff] [blame] | 262 | // Called from InputManager |
Siarhei Vishniakou | 34d6fef | 2022-02-01 19:03:45 -0800 | [diff] [blame] | 263 | void setMotionClassifierEnabled(bool enabled) override; |
Siarhei Vishniakou | c9ac19e | 2020-03-19 11:55:01 -0700 | [diff] [blame] | 264 | |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 265 | private: |
Siarhei Vishniakou | 15b66d1 | 2019-02-04 14:27:29 -0800 | [diff] [blame] | 266 | // Protect access to mMotionClassifier, since it may become null via a hidl callback |
| 267 | std::mutex mLock; |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 268 | // The next stage to pass input events to |
Siarhei Vishniakou | 9f330c5 | 2022-05-17 05:03:42 -0700 | [diff] [blame] | 269 | QueuedInputListener mQueuedListener; |
Siarhei Vishniakou | 1652397 | 2020-03-04 17:48:39 -0800 | [diff] [blame] | 270 | |
| 271 | std::unique_ptr<MotionClassifierInterface> mMotionClassifier GUARDED_BY(mLock); |
Siarhei Vishniakou | 34d6fef | 2022-02-01 19:03:45 -0800 | [diff] [blame] | 272 | std::future<void> mInitializeMotionClassifier GUARDED_BY(mLock); |
| 273 | |
Siarhei Vishniakou | 1652397 | 2020-03-04 17:48:39 -0800 | [diff] [blame] | 274 | /** |
| 275 | * Set the value of mMotionClassifier. |
| 276 | * This is called from 2 different threads: |
| 277 | * 1) mInitializeMotionClassifierThread, when we have constructed a MotionClassifier |
| 278 | * 2) A binder thread of the HalDeathRecipient, which is created when HAL dies. This would cause |
| 279 | * mMotionClassifier to become nullptr. |
| 280 | */ |
Siarhei Vishniakou | 34d6fef | 2022-02-01 19:03:45 -0800 | [diff] [blame] | 281 | void setMotionClassifierLocked(std::unique_ptr<MotionClassifierInterface> motionClassifier) |
| 282 | REQUIRES(mLock); |
Siarhei Vishniakou | 1652397 | 2020-03-04 17:48:39 -0800 | [diff] [blame] | 283 | |
Siarhei Vishniakou | 34d6fef | 2022-02-01 19:03:45 -0800 | [diff] [blame] | 284 | static void onBinderDied(void* cookie); |
Siarhei Vishniakou | 1652397 | 2020-03-04 17:48:39 -0800 | [diff] [blame] | 285 | |
Siarhei Vishniakou | 34d6fef | 2022-02-01 19:03:45 -0800 | [diff] [blame] | 286 | std::unique_ptr<ScopedDeathRecipient> mHalDeathRecipient GUARDED_BY(mLock); |
Siarhei Vishniakou | 473174e | 2017-12-27 16:44:42 -0800 | [diff] [blame] | 287 | }; |
| 288 | |
| 289 | } // namespace android |