• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 #pragma once
18 
19 #include <android/os/IInputConstants.h>
20 #include <input/DisplayViewport.h>
21 #include <input/Input.h>
22 #include <input/InputDevice.h>
23 #include <input/VelocityControl.h>
24 #include <input/VelocityTracker.h>
25 #include <stddef.h>
26 #include <ui/Rotation.h>
27 #include <unistd.h>
28 #include <utils/Errors.h>
29 #include <utils/RefBase.h>
30 
31 #include <optional>
32 #include <set>
33 #include <unordered_map>
34 #include <vector>
35 
36 #include "PointerControllerInterface.h"
37 #include "TouchpadHardwareState.h"
38 #include "VibrationElement.h"
39 #include "include/gestures.h"
40 
41 // Maximum supported size of a vibration pattern.
42 // Must be at least 2.
43 #define MAX_VIBRATE_PATTERN_SIZE 100
44 
45 namespace android {
46 
47 // --- InputReaderConfiguration ---
48 
49 /*
50  * Input reader configuration.
51  *
52  * Specifies various options that modify the behavior of the input reader.
53  */
54 struct InputReaderConfiguration {
55     // Describes changes that have occurred.
56     enum class Change : uint32_t {
57         // The mouse pointer speed changed.
58         POINTER_SPEED = 1u << 0,
59 
60         // The pointer gesture control changed.
61         POINTER_GESTURE_ENABLEMENT = 1u << 1,
62 
63         // The display size or orientation changed.
64         DISPLAY_INFO = 1u << 2,
65 
66         // The keyboard layouts must be reloaded.
67         KEYBOARD_LAYOUTS = 1u << 4,
68 
69         // The device name alias supplied by the may have changed for some devices.
70         DEVICE_ALIAS = 1u << 5,
71 
72         // The location calibration matrix changed.
73         TOUCH_AFFINE_TRANSFORMATION = 1u << 6,
74 
75         // The presence of an external stylus has changed.
76         EXTERNAL_STYLUS_PRESENCE = 1u << 7,
77 
78         // The pointer capture mode has changed.
79         POINTER_CAPTURE = 1u << 8,
80 
81         // The set of disabled input devices (disabledDevices) has changed.
82         ENABLED_STATE = 1u << 9,
83 
84         // The device type has been updated.
85         DEVICE_TYPE = 1u << 10,
86 
87         // The keyboard layout association has changed.
88         KEYBOARD_LAYOUT_ASSOCIATION = 1u << 11,
89 
90         // The stylus button reporting configurations has changed.
91         STYLUS_BUTTON_REPORTING = 1u << 12,
92 
93         // The touchpad settings changed.
94         TOUCHPAD_SETTINGS = 1u << 13,
95 
96         // The key remapping has changed.
97         KEY_REMAPPING = 1u << 14,
98 
99         // The mouse settings changed, this includes mouse reverse vertical scrolling and swap
100         // primary button.
101         MOUSE_SETTINGS = 1u << 15,
102 
103         // All devices must be reopened.
104         MUST_REOPEN = 1u << 31,
105     };
106 
107     // Gets the amount of time to disable virtual keys after the screen is touched
108     // in order to filter out accidental virtual key presses due to swiping gestures
109     // or taps near the edge of the display.  May be 0 to disable the feature.
110     nsecs_t virtualKeyQuietTime;
111 
112     // The excluded device names for the platform.
113     // Devices with these names will be ignored.
114     std::vector<std::string> excludedDeviceNames;
115 
116     // The associations between input ports and display ports.
117     // Used to determine which DisplayViewport should be tied to which InputDevice.
118     std::unordered_map<std::string, uint8_t> inputPortToDisplayPortAssociations;
119 
120     // The associations between input device ports and display unique ids.
121     // Used to determine which DisplayViewport should be tied to which InputDevice.
122     std::unordered_map<std::string, std::string> inputPortToDisplayUniqueIdAssociations;
123 
124     // The associations between input device descriptor and display unique ids.
125     // Used to determine which DisplayViewport should be tied to which InputDevice.
126     std::unordered_map<std::string, std::string> inputDeviceDescriptorToDisplayUniqueIdAssociations;
127 
128     // The associations between input device ports device types.
129     // This is used to determine which device type and source should be tied to which InputDevice.
130     std::unordered_map<std::string, std::string> deviceTypeAssociations;
131 
132     // The map from the input device physical port location to the input device layout info.
133     // Can be used to determine the layout of the keyboard device.
134     std::unordered_map<std::string, KeyboardLayoutInfo> keyboardLayoutAssociations;
135 
136     // The suggested display ID to show the cursor.
137     ui::LogicalDisplayId defaultPointerDisplayId;
138 
139     // The mouse pointer speed, as a number from -7 (slowest) to 7 (fastest).
140     int32_t mousePointerSpeed;
141 
142     // Displays on which all pointer scaling, including linear scaling based on the
143     // user's pointer speed setting, should be disabled for mice. This differs from
144     // disabling acceleration via the 'mousePointerAccelerationEnabled' setting, where
145     // the pointer speed setting still influences the scaling factor.
146     std::set<ui::LogicalDisplayId> displaysWithMouseScalingDisabled;
147 
148     // True if the connected mouse should exhibit pointer acceleration. If false,
149     // a flat acceleration curve (linear scaling) is used, but the user's pointer
150     // speed setting still affects the scaling factor.
151     bool mousePointerAccelerationEnabled;
152 
153     // True if the touchpad should exhibit pointer acceleration. If false,
154     // a flat acceleration curve (linear scaling) is used, but the user's pointer
155     // speed setting still affects the scaling factor.
156     bool touchpadAccelerationEnabled;
157 
158     // Velocity control parameters for touchpad pointer movements on the old touchpad stack (based
159     // on TouchInputMapper).
160     //
161     // For mice, these are ignored and the values of mousePointerSpeed and
162     // mousePointerAccelerationEnabled used instead.
163     //
164     // TODO(b/281840344): remove this.
165     VelocityControlParameters pointerVelocityControlParameters;
166 
167     // Velocity control parameters for mouse wheel movements.
168     VelocityControlParameters wheelVelocityControlParameters;
169 
170     // True if pointer gestures are enabled.
171     bool pointerGesturesEnabled;
172 
173     // Quiet time between certain pointer gesture transitions.
174     // Time to allow for all fingers or buttons to settle into a stable state before
175     // starting a new gesture.
176     nsecs_t pointerGestureQuietInterval;
177 
178     // The minimum speed that a pointer must travel for us to consider switching the active
179     // touch pointer to it during a drag.  This threshold is set to avoid switching due
180     // to noise from a finger resting on the touch pad (perhaps just pressing it down).
181     float pointerGestureDragMinSwitchSpeed; // in pixels per second
182 
183     // Tap gesture delay time.
184     // The time between down and up must be less than this to be considered a tap.
185     nsecs_t pointerGestureTapInterval;
186 
187     // Tap drag gesture delay time.
188     // The time between the previous tap's up and the next down must be less than
189     // this to be considered a drag.  Otherwise, the previous tap is finished and a
190     // new tap begins.
191     //
192     // Note that the previous tap will be held down for this entire duration so this
193     // interval must be shorter than the long press timeout.
194     nsecs_t pointerGestureTapDragInterval;
195 
196     // The distance in pixels that the pointer is allowed to move from initial down
197     // to up and still be called a tap.
198     float pointerGestureTapSlop; // in pixels
199 
200     // Time after the first touch points go down to settle on an initial centroid.
201     // This is intended to be enough time to handle cases where the user puts down two
202     // fingers at almost but not quite exactly the same time.
203     nsecs_t pointerGestureMultitouchSettleInterval;
204 
205     // The transition from PRESS to SWIPE or FREEFORM gesture mode is made when
206     // at least two pointers have moved at least this far from their starting place.
207     float pointerGestureMultitouchMinDistance; // in pixels
208 
209     // The transition from PRESS to SWIPE gesture mode can only occur when the
210     // cosine of the angle between the two vectors is greater than or equal to than this value
211     // which indicates that the vectors are oriented in the same direction.
212     // When the vectors are oriented in the exactly same direction, the cosine is 1.0.
213     // (In exactly opposite directions, the cosine is -1.0.)
214     float pointerGestureSwipeTransitionAngleCosine;
215 
216     // The transition from PRESS to SWIPE gesture mode can only occur when the
217     // fingers are no more than this far apart relative to the diagonal size of
218     // the touch pad.  For example, a ratio of 0.5 means that the fingers must be
219     // no more than half the diagonal size of the touch pad apart.
220     float pointerGestureSwipeMaxWidthRatio;
221 
222     // The gesture movement speed factor relative to the size of the display.
223     // Movement speed applies when the fingers are moving in the same direction.
224     // Without acceleration, a full swipe of the touch pad diagonal in movement mode
225     // will cover this portion of the display diagonal.
226     float pointerGestureMovementSpeedRatio;
227 
228     // The gesture zoom speed factor relative to the size of the display.
229     // Zoom speed applies when the fingers are mostly moving relative to each other
230     // to execute a scale gesture or similar.
231     // Without acceleration, a full swipe of the touch pad diagonal in zoom mode
232     // will cover this portion of the display diagonal.
233     float pointerGestureZoomSpeedRatio;
234 
235     // The latest request to enable or disable Pointer Capture.
236     PointerCaptureRequest pointerCaptureRequest;
237 
238     // The touchpad pointer speed, as a number from -7 (slowest) to 7 (fastest).
239     int32_t touchpadPointerSpeed;
240 
241     // True to invert the touchpad scrolling direction, so that moving two fingers downwards on the
242     // touchpad scrolls the content upwards.
243     bool touchpadNaturalScrollingEnabled;
244 
245     // True to enable tap-to-click on touchpads.
246     bool touchpadTapToClickEnabled;
247 
248     // True to enable tap dragging on touchpads.
249     bool touchpadTapDraggingEnabled;
250 
251     // True if hardware state update notifications should be sent to the policy.
252     bool shouldNotifyTouchpadHardwareState;
253 
254     // True to enable a zone on the right-hand side of touchpads where clicks will be turned into
255     // context (a.k.a. "right") clicks.
256     bool touchpadRightClickZoneEnabled;
257 
258     // True to use three-finger tap as a customizable shortcut; false to use it as a middle-click.
259     bool touchpadThreeFingerTapShortcutEnabled;
260 
261     // True to enable system gestures (three- and four-finger swipes) on touchpads.
262     bool touchpadSystemGesturesEnabled;
263 
264     // The set of currently disabled input devices.
265     std::set<int32_t> disabledDevices;
266 
267     // True if stylus button reporting through motion events should be enabled, in which case
268     // stylus button state changes are reported through motion events.
269     bool stylusButtonMotionEventsEnabled;
270 
271     // True if a pointer icon should be shown for direct stylus pointers.
272     bool stylusPointerIconEnabled;
273 
274     // Keycodes to be remapped.
275     std::map<int32_t /* fromKeyCode */, int32_t /* toKeyCode */> keyRemapping;
276 
277     // True if the external mouse should have its vertical scrolling reversed, so that rotating the
278     // wheel downwards scrolls the content upwards.
279     bool mouseReverseVerticalScrollingEnabled;
280 
281     // True if the connected mouse should have its primary button (default: left click) swapped,
282     // so that the right click will be the primary action button and the left click will be the
283     // secondary action.
284     bool mouseSwapPrimaryButtonEnabled;
285 
InputReaderConfigurationInputReaderConfiguration286     InputReaderConfiguration()
287           : virtualKeyQuietTime(0),
288             defaultPointerDisplayId(ui::LogicalDisplayId::DEFAULT),
289             mousePointerSpeed(0),
290             displaysWithMouseScalingDisabled(),
291             mousePointerAccelerationEnabled(true),
292             touchpadAccelerationEnabled(true),
293             pointerVelocityControlParameters(1.0f, 500.0f, 3000.0f,
294                                              static_cast<float>(
295                                                      android::os::IInputConstants::
296                                                              DEFAULT_POINTER_ACCELERATION)),
297             wheelVelocityControlParameters(1.0f, 15.0f, 50.0f,
298                                            static_cast<float>(
299                                                    android::os::IInputConstants::
300                                                            DEFAULT_MOUSE_WHEEL_ACCELERATION)),
301             pointerGesturesEnabled(true),
302             pointerGestureQuietInterval(100 * 1000000LL),            // 100 ms
303             pointerGestureDragMinSwitchSpeed(50),                    // 50 pixels per second
304             pointerGestureTapInterval(150 * 1000000LL),              // 150 ms
305             pointerGestureTapDragInterval(150 * 1000000LL),          // 150 ms
306             pointerGestureTapSlop(10.0f),                            // 10 pixels
307             pointerGestureMultitouchSettleInterval(100 * 1000000LL), // 100 ms
308             pointerGestureMultitouchMinDistance(15),                 // 15 pixels
309             pointerGestureSwipeTransitionAngleCosine(0.2588f),       // cosine of 75 degrees
310             pointerGestureSwipeMaxWidthRatio(0.25f),
311             pointerGestureMovementSpeedRatio(0.8f),
312             pointerGestureZoomSpeedRatio(0.3f),
313             pointerCaptureRequest(),
314             touchpadPointerSpeed(0),
315             touchpadNaturalScrollingEnabled(true),
316             touchpadTapToClickEnabled(true),
317             touchpadTapDraggingEnabled(false),
318             shouldNotifyTouchpadHardwareState(false),
319             touchpadRightClickZoneEnabled(false),
320             touchpadThreeFingerTapShortcutEnabled(false),
321             touchpadSystemGesturesEnabled(true),
322             stylusButtonMotionEventsEnabled(true),
323             stylusPointerIconEnabled(false),
324             mouseReverseVerticalScrollingEnabled(false),
325             mouseSwapPrimaryButtonEnabled(false) {}
326 
327     std::optional<DisplayViewport> getDisplayViewportByType(ViewportType type) const;
328     std::optional<DisplayViewport> getDisplayViewportByUniqueId(const std::string& uniqueDisplayId)
329             const;
330     std::optional<DisplayViewport> getDisplayViewportByPort(uint8_t physicalPort) const;
331     std::optional<DisplayViewport> getDisplayViewportById(ui::LogicalDisplayId displayId) const;
332     void setDisplayViewports(const std::vector<DisplayViewport>& viewports);
333 
334     void dump(std::string& dump) const;
335     void dumpViewport(std::string& dump, const DisplayViewport& viewport) const;
336 
337 private:
338     std::vector<DisplayViewport> mDisplays;
339 };
340 
341 using ConfigurationChanges = ftl::Flags<InputReaderConfiguration::Change>;
342 
343 // --- InputReaderInterface ---
344 
345 /* The interface for the InputReader shared library.
346  *
347  * Manages one or more threads that process raw input events and sends cooked event data to an
348  * input listener.
349  *
350  * The implementation must guarantee thread safety for this interface. However, since the input
351  * listener is NOT thread safe, all calls to the listener must happen from the same thread.
352  */
353 class InputReaderInterface {
354 public:
InputReaderInterface()355     InputReaderInterface() {}
~InputReaderInterface()356     virtual ~InputReaderInterface() {}
357     /* Dumps the state of the input reader.
358      *
359      * This method may be called on any thread (usually by the input manager). */
360     virtual void dump(std::string& dump) = 0;
361 
362     /* Called by the heartbeat to ensures that the reader has not deadlocked. */
363     virtual void monitor() = 0;
364 
365     /* Makes the reader start processing events from the kernel. */
366     virtual status_t start() = 0;
367 
368     /* Makes the reader stop processing any more events. */
369     virtual status_t stop() = 0;
370 
371     /* Gets information about all input devices.
372      *
373      * This method may be called on any thread (usually by the input manager).
374      */
375     virtual std::vector<InputDeviceInfo> getInputDevices() const = 0;
376 
377     /* Query current input state. */
378     virtual int32_t getScanCodeState(int32_t deviceId, uint32_t sourceMask, int32_t scanCode) = 0;
379     virtual int32_t getKeyCodeState(int32_t deviceId, uint32_t sourceMask, int32_t keyCode) = 0;
380     virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask, int32_t sw) = 0;
381 
382     virtual int32_t getKeyCodeForKeyLocation(int32_t deviceId, int32_t locationKeyCode) const = 0;
383 
384     /* Toggle Caps Lock */
385     virtual void toggleCapsLockState(int32_t deviceId) = 0;
386 
387     /* Resets locked modifier state */
388     virtual void resetLockedModifierState() = 0;
389 
390     /* Determine whether physical keys exist for the given framework-domain key codes. */
391     virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask,
392                          const std::vector<int32_t>& keyCodes, uint8_t* outFlags) = 0;
393 
394     /* Requests that a reconfiguration of all input devices.
395      * The changes flag is a bitfield that indicates what has changed and whether
396      * the input devices must all be reopened. */
397     virtual void requestRefreshConfiguration(ConfigurationChanges changes) = 0;
398 
399     /* Controls the vibrator of a particular input device. */
400     virtual void vibrate(int32_t deviceId, const VibrationSequence& sequence, ssize_t repeat,
401                          int32_t token) = 0;
402     virtual void cancelVibrate(int32_t deviceId, int32_t token) = 0;
403 
404     virtual bool isVibrating(int32_t deviceId) = 0;
405 
406     virtual std::vector<int32_t> getVibratorIds(int32_t deviceId) = 0;
407     /* Get battery level of a particular input device. */
408     virtual std::optional<int32_t> getBatteryCapacity(int32_t deviceId) = 0;
409     /* Get battery status of a particular input device. */
410     virtual std::optional<int32_t> getBatteryStatus(int32_t deviceId) = 0;
411     /* Get the device path for the battery of an input device. */
412     virtual std::optional<std::string> getBatteryDevicePath(int32_t deviceId) = 0;
413 
414     virtual std::vector<InputDeviceLightInfo> getLights(int32_t deviceId) = 0;
415 
416     virtual std::vector<InputDeviceSensorInfo> getSensors(int32_t deviceId) = 0;
417 
418     virtual std::optional<HardwareProperties> getTouchpadHardwareProperties(int32_t deviceId) = 0;
419 
420     /* Return true if the device can send input events to the specified display. */
421     virtual bool canDispatchToDisplay(int32_t deviceId, ui::LogicalDisplayId displayId) = 0;
422 
423     /* Enable sensor in input reader mapper. */
424     virtual bool enableSensor(int32_t deviceId, InputDeviceSensorType sensorType,
425                               std::chrono::microseconds samplingPeriod,
426                               std::chrono::microseconds maxBatchReportLatency) = 0;
427 
428     /* Disable sensor in input reader mapper. */
429     virtual void disableSensor(int32_t deviceId, InputDeviceSensorType sensorType) = 0;
430 
431     /* Flush sensor data in input reader mapper. */
432     virtual void flushSensor(int32_t deviceId, InputDeviceSensorType sensorType) = 0;
433 
434     /* Set color for the light */
435     virtual bool setLightColor(int32_t deviceId, int32_t lightId, int32_t color) = 0;
436     /* Set player ID for the light */
437     virtual bool setLightPlayerId(int32_t deviceId, int32_t lightId, int32_t playerId) = 0;
438     /* Get light color */
439     virtual std::optional<int32_t> getLightColor(int32_t deviceId, int32_t lightId) = 0;
440     /* Get light player ID */
441     virtual std::optional<int32_t> getLightPlayerId(int32_t deviceId, int32_t lightId) = 0;
442 
443     /* Get the Bluetooth address of an input device, if known. */
444     virtual std::optional<std::string> getBluetoothAddress(int32_t deviceId) const = 0;
445 
446     /* Gets the sysfs root path for this device. Returns an empty path if there is none. */
447     virtual std::filesystem::path getSysfsRootPath(int32_t deviceId) const = 0;
448 
449     /* Sysfs node change reported. Recreate device if required to incorporate the new sysfs nodes */
450     virtual void sysfsNodeChanged(const std::string& sysfsNodePath) = 0;
451 
452     /* Get the ID of the InputDevice that was used most recently.
453      *
454      * Returns ReservedInputDeviceId::INVALID_INPUT_DEVICE_ID if no device has been used since boot.
455      */
456     virtual DeviceId getLastUsedInputDeviceId() = 0;
457 
458     /* Notifies that mouse cursor faded due to typing. */
459     virtual void notifyMouseCursorFadedOnTyping() = 0;
460 
461     /* Set whether the given input device can wake up the kernel from sleep
462      * when it generates input events. By default, usually only internal (built-in)
463      * input devices can wake the kernel from sleep. For an external input device
464      * that supports remote wakeup to be able to wake the kernel, this must be called
465      * after each time the device is connected/added.
466      *
467      * Returns true if setting power wakeup was successful.
468      */
469     virtual bool setKernelWakeEnabled(int32_t deviceId, bool enabled) = 0;
470 };
471 
472 // --- TouchAffineTransformation ---
473 
474 struct TouchAffineTransformation {
475     float x_scale;
476     float x_ymix;
477     float x_offset;
478     float y_xmix;
479     float y_scale;
480     float y_offset;
481 
TouchAffineTransformationTouchAffineTransformation482     TouchAffineTransformation() :
483         x_scale(1.0f), x_ymix(0.0f), x_offset(0.0f),
484         y_xmix(0.0f), y_scale(1.0f), y_offset(0.0f) {
485     }
486 
TouchAffineTransformationTouchAffineTransformation487     TouchAffineTransformation(float xscale, float xymix, float xoffset,
488             float yxmix, float yscale, float yoffset) :
489         x_scale(xscale), x_ymix(xymix), x_offset(xoffset),
490         y_xmix(yxmix), y_scale(yscale), y_offset(yoffset) {
491     }
492 
493     void applyTo(float& x, float& y) const;
494 };
495 
496 // --- InputReaderPolicyInterface ---
497 
498 /*
499  * Input reader policy interface.
500  *
501  * The input reader policy is used by the input reader to interact with the Window Manager
502  * and other system components.
503  *
504  * The actual implementation is partially supported by callbacks into the DVM
505  * via JNI.  This interface is also mocked in the unit tests.
506  *
507  * These methods will NOT re-enter the input reader interface, so they may be called from
508  * any method in the input reader interface.
509  */
510 class InputReaderPolicyInterface : public virtual RefBase {
511 protected:
InputReaderPolicyInterface()512     InputReaderPolicyInterface() { }
~InputReaderPolicyInterface()513     virtual ~InputReaderPolicyInterface() { }
514 
515 public:
516     /* Gets the input reader configuration. */
517     virtual void getReaderConfiguration(InputReaderConfiguration* outConfig) = 0;
518 
519     /* Notifies the input reader policy that some input devices have changed
520      * and provides information about all current input devices.
521      */
522     virtual void notifyInputDevicesChanged(const std::vector<InputDeviceInfo>& inputDevices) = 0;
523 
524     /* Sends the hardware state of a connected touchpad */
525     virtual void notifyTouchpadHardwareState(const SelfContainedHardwareState& schs,
526                                              int32_t deviceId) = 0;
527 
528     /* Sends the Info of gestures that happen on the touchpad. */
529     virtual void notifyTouchpadGestureInfo(GestureType type, int32_t deviceId) = 0;
530 
531     /* Notifies the policy that the user has performed a three-finger touchpad tap. */
532     virtual void notifyTouchpadThreeFingerTap() = 0;
533 
534     /* Gets the keyboard layout for a particular input device. */
535     virtual std::shared_ptr<KeyCharacterMap> getKeyboardLayoutOverlay(
536             const InputDeviceIdentifier& identifier,
537             const std::optional<KeyboardLayoutInfo> keyboardLayoutInfo) = 0;
538 
539     /* Gets a user-supplied alias for a particular input device, or an empty string if none. */
540     virtual std::string getDeviceAlias(const InputDeviceIdentifier& identifier) = 0;
541 
542     /* Gets the affine calibration associated with the specified device. */
543     virtual TouchAffineTransformation getTouchAffineTransformation(
544             const std::string& inputDeviceDescriptor, ui::Rotation surfaceRotation) = 0;
545     /* Notifies the input reader policy that a stylus gesture has started. */
546     virtual void notifyStylusGestureStarted(int32_t deviceId, nsecs_t eventTime) = 0;
547 
548     /* Returns true if any InputConnection is currently active. */
549     virtual bool isInputMethodConnectionActive() = 0;
550 
551     /* Gets the viewport of a particular display that the pointer device is associated with. If
552      * the pointer device is not associated with any display, it should ADISPLAY_IS_NONE to get
553      * the viewport that should be used. The device should get a new viewport using this method
554      * every time there is a display configuration change. The logical bounds of the viewport should
555      * be used as the range of possible values for pointing devices, like mice and touchpads.
556      */
557     virtual std::optional<DisplayViewport> getPointerViewportForAssociatedDisplay(
558             ui::LogicalDisplayId associatedDisplayId = ui::LogicalDisplayId::INVALID) = 0;
559 };
560 
561 } // namespace android
562