Siarhei Vishniakou | 7062295 | 2020-07-30 11:17:23 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (c) 2020, 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 | package android.os; |
| 18 | |
| 19 | |
| 20 | /** @hide */ |
| 21 | interface IInputConstants |
| 22 | { |
Peter Collingbourne | b04b9b8 | 2021-02-08 12:09:47 -0800 | [diff] [blame] | 23 | // This should be multiplied by the value of the system property ro.hw_timeout_multiplier before |
| 24 | // use. A pre-multiplied constant is available in Java in |
| 25 | // android.os.InputConstants.DEFAULT_DISPATCHING_TIMEOUT_MILLIS. |
| 26 | const int UNMULTIPLIED_DEFAULT_DISPATCHING_TIMEOUT_MILLIS = 5000; // 5 seconds |
Siarhei Vishniakou | 2508b87 | 2020-12-03 16:33:53 -1000 | [diff] [blame] | 27 | |
Siarhei Vishniakou | fc434ac | 2021-01-13 10:28:00 -1000 | [diff] [blame] | 28 | // Indicate invalid battery capacity |
| 29 | const int INVALID_BATTERY_CAPACITY = -1; |
| 30 | |
| 31 | /** |
| 32 | * Every input event has an id. This constant value is used when a valid input event id is not |
| 33 | * available. |
| 34 | */ |
| 35 | const int INVALID_INPUT_EVENT_ID = 0; |
Siarhei Vishniakou | 5d552c4 | 2021-05-21 05:02:22 +0000 | [diff] [blame] | 36 | |
| 37 | /** |
Sandro Meier | d3d4060 | 2022-10-19 16:18:26 +0000 | [diff] [blame] | 38 | * Every input device has an id. This constant value is used when a valid input device id is not |
| 39 | * available. |
| 40 | * The virtual keyboard uses -1 as the input device id. Therefore, we use -2 as the value for |
| 41 | * an invalid input device. |
| 42 | */ |
| 43 | const int INVALID_INPUT_DEVICE_ID = -2; |
| 44 | |
| 45 | /** |
Siarhei Vishniakou | f00a4ec | 2021-06-16 03:55:32 +0000 | [diff] [blame] | 46 | * The input event was injected from accessibility. Used in policyFlags for input event |
| 47 | * injection. |
Siarhei Vishniakou | 5d552c4 | 2021-05-21 05:02:22 +0000 | [diff] [blame] | 48 | */ |
| 49 | const int POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY = 0x20000; |
Siarhei Vishniakou | f00a4ec | 2021-06-16 03:55:32 +0000 | [diff] [blame] | 50 | |
| 51 | /** |
Siarhei Vishniakou | c40f6e0 | 2024-04-25 15:49:29 -0700 | [diff] [blame] | 52 | * This flag indicates that the window that received this motion event is partly |
| 53 | * or wholly obscured by another visible window above it and the event directly passed through |
| 54 | * the obscured area. |
| 55 | * |
| 56 | * A security sensitive application can check this flag to identify situations in which |
| 57 | * a malicious application may have covered up part of its content for the purpose |
| 58 | * of misleading the user or hijacking touches. An appropriate response might be |
| 59 | * to drop the suspect touches or to take additional precautions to confirm the user's |
| 60 | * actual intent. |
| 61 | */ |
| 62 | const int MOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1; |
| 63 | |
| 64 | /** |
| 65 | * This flag indicates that the window that received this motion event is partly |
| 66 | * or wholly obscured by another visible window above it and the event did not directly pass |
| 67 | * through the obscured area. |
| 68 | * |
| 69 | * A security sensitive application can check this flag to identify situations in which |
| 70 | * a malicious application may have covered up part of its content for the purpose |
| 71 | * of misleading the user or hijacking touches. An appropriate response might be |
| 72 | * to drop the suspect touches or to take additional precautions to confirm the user's |
| 73 | * actual intent. |
| 74 | * |
| 75 | * Unlike FLAG_WINDOW_IS_OBSCURED, this is only true if the window that received this event is |
| 76 | * obstructed in areas other than the touched location. |
| 77 | */ |
| 78 | const int MOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED = 0x2; |
| 79 | |
| 80 | /** |
| 81 | * This private flag is only set on {@link #ACTION_HOVER_MOVE} events and indicates that |
| 82 | * this event will be immediately followed by a {@link #ACTION_HOVER_EXIT}. It is used to |
| 83 | * prevent generating redundant {@link #ACTION_HOVER_ENTER} events. |
| 84 | * @hide |
| 85 | */ |
| 86 | const int MOTION_EVENT_FLAG_HOVER_EXIT_PENDING = 0x4; |
| 87 | |
| 88 | /** |
| 89 | * This flag indicates that the event has been generated by a gesture generator. It |
| 90 | * provides a hint to the GestureDetector to not apply any touch slop. |
| 91 | * |
| 92 | * @hide |
| 93 | */ |
| 94 | const int MOTION_EVENT_FLAG_IS_GENERATED_GESTURE = 0x8; |
| 95 | |
| 96 | /** |
| 97 | * This flag is only set for events with {@link #ACTION_POINTER_UP} and {@link #ACTION_CANCEL}. |
| 98 | * It indicates that the pointer going up was an unintentional user touch. When FLAG_CANCELED |
| 99 | * is set, the typical actions that occur in response for a pointer going up (such as click |
| 100 | * handlers, end of drawing) should be aborted. This flag is typically set when the user was |
| 101 | * accidentally touching the screen, such as by gripping the device, or placing the palm on the |
| 102 | * screen. |
| 103 | * |
| 104 | * @see #ACTION_POINTER_UP |
| 105 | * @see #ACTION_CANCEL |
| 106 | */ |
| 107 | const int INPUT_EVENT_FLAG_CANCELED = 0x20; |
| 108 | |
| 109 | /** |
| 110 | * This flag indicates that the event will not cause a focus change if it is directed to an |
| 111 | * unfocused window, even if it an {@link #ACTION_DOWN}. This is typically used with pointer |
| 112 | * gestures to allow the user to direct gestures to an unfocused window without bringing the |
| 113 | * window into focus. |
| 114 | * @hide |
| 115 | */ |
| 116 | const int MOTION_EVENT_FLAG_NO_FOCUS_CHANGE = 0x40; |
| 117 | |
| 118 | /** |
Prabir Pradhan | 9a53b55 | 2024-06-04 02:59:40 +0000 | [diff] [blame^] | 119 | * This flag indicates that the event has a valid value for AXIS_ORIENTATION. |
| 120 | * |
| 121 | * This is a private flag that is not used in Java. |
| 122 | * @hide |
| 123 | */ |
| 124 | const int MOTION_EVENT_PRIVATE_FLAG_SUPPORTS_ORIENTATION = 0x80; |
| 125 | |
| 126 | /** |
| 127 | * This flag indicates that the pointers' AXIS_ORIENTATION can be used to precisely determine |
| 128 | * the direction in which the tool is pointing. The value of the orientation axis will be in |
| 129 | * the range [-pi, pi], which represents a full circle. This is usually supported by devices |
| 130 | * like styluses. |
| 131 | * |
| 132 | * Conversely, AXIS_ORIENTATION cannot be used to tell which direction the tool is pointing |
| 133 | * when this flag is not set. In this case, the axis value will have a range of [-pi/2, pi/2], |
| 134 | * which represents half a circle. This is usually the case for devices like touchscreens and |
| 135 | * touchpads, for which it is difficult to tell which direction along the major axis of the |
| 136 | * touch ellipse the finger is pointing. |
| 137 | * |
| 138 | * This is a private flag that is not used in Java. |
| 139 | * @hide |
| 140 | */ |
| 141 | const int MOTION_EVENT_PRIVATE_FLAG_SUPPORTS_DIRECTIONAL_ORIENTATION = 0x100; |
| 142 | |
| 143 | /** |
Siarhei Vishniakou | f00a4ec | 2021-06-16 03:55:32 +0000 | [diff] [blame] | 144 | * The input event was generated or modified by accessibility service. |
| 145 | * Shared by both KeyEvent and MotionEvent flags, so this value should not overlap with either |
| 146 | * set of flags, including in input/Input.h and in android/input.h. |
| 147 | */ |
| 148 | const int INPUT_EVENT_FLAG_IS_ACCESSIBILITY_EVENT = 0x800; |
Prabir Pradhan | de78850 | 2021-12-22 00:26:07 -0800 | [diff] [blame] | 149 | |
Siarhei Vishniakou | c40f6e0 | 2024-04-25 15:49:29 -0700 | [diff] [blame] | 150 | /** |
| 151 | * Private flag that indicates when the system has detected that this motion event |
| 152 | * may be inconsistent with respect to the sequence of previously delivered motion events, |
| 153 | * such as when a pointer move event is sent but the pointer is not down. |
| 154 | * |
| 155 | * @hide |
| 156 | * @see #isTainted |
| 157 | * @see #setTainted |
| 158 | */ |
| 159 | const int INPUT_EVENT_FLAG_TAINTED = 0x80000000; |
| 160 | |
| 161 | /** |
| 162 | * Private flag indicating that this event was synthesized by the system and should be delivered |
| 163 | * to the accessibility focused view first. When being dispatched such an event is not handled |
| 164 | * by predecessors of the accessibility focused view and after the event reaches that view the |
| 165 | * flag is cleared and normal event dispatch is performed. This ensures that the platform can |
| 166 | * click on any view that has accessibility focus which is semantically equivalent to asking the |
| 167 | * view to perform a click accessibility action but more generic as views not implementing click |
| 168 | * action correctly can still be activated. |
| 169 | * |
| 170 | * @hide |
| 171 | * @see #isTargetAccessibilityFocus() |
| 172 | * @see #setTargetAccessibilityFocus(boolean) |
| 173 | */ |
| 174 | const int MOTION_EVENT_FLAG_TARGET_ACCESSIBILITY_FOCUS = 0x40000000; |
| 175 | |
Christine Franks | 46d8a1e | 2022-01-05 16:11:48 -0800 | [diff] [blame] | 176 | /* The default pointer acceleration value. */ |
| 177 | const int DEFAULT_POINTER_ACCELERATION = 3; |
Siarhei Vishniakou | f7436a1 | 2023-08-14 15:17:11 -0700 | [diff] [blame] | 178 | |
| 179 | /** |
| 180 | * Use the default Velocity Tracker Strategy. Different axes may use different default |
| 181 | * strategies. |
| 182 | */ |
| 183 | const int VELOCITY_TRACKER_STRATEGY_DEFAULT = -1; |
| 184 | |
| 185 | /** |
| 186 | * Velocity Tracker Strategy: Impulse. |
| 187 | * Physical model of pushing an object. Quality: VERY GOOD. |
| 188 | * Works with duplicate coordinates, unclean finger liftoff. |
| 189 | */ |
| 190 | const int VELOCITY_TRACKER_STRATEGY_IMPULSE = 0; |
| 191 | |
| 192 | /** |
| 193 | * Velocity Tracker Strategy: LSQ1. |
| 194 | * 1st order least squares. Quality: POOR. |
| 195 | * Frequently underfits the touch data especially when the finger accelerates |
| 196 | * or changes direction. Often underestimates velocity. The direction |
| 197 | * is overly influenced by historical touch points. |
| 198 | */ |
| 199 | const int VELOCITY_TRACKER_STRATEGY_LSQ1 = 1; |
| 200 | |
| 201 | /** |
| 202 | * Velocity Tracker Strategy: LSQ2. |
| 203 | * 2nd order least squares. Quality: VERY GOOD. |
| 204 | * Pretty much ideal, but can be confused by certain kinds of touch data, |
| 205 | * particularly if the panel has a tendency to generate delayed, |
| 206 | * duplicate or jittery touch coordinates when the finger is released. |
| 207 | */ |
| 208 | const int VELOCITY_TRACKER_STRATEGY_LSQ2 = 2; |
| 209 | |
| 210 | /** |
| 211 | * Velocity Tracker Strategy: LSQ3. |
| 212 | * 3rd order least squares. Quality: UNUSABLE. |
| 213 | * Frequently overfits the touch data yielding wildly divergent estimates |
| 214 | * of the velocity when the finger is released. |
| 215 | */ |
| 216 | const int VELOCITY_TRACKER_STRATEGY_LSQ3 = 3; |
| 217 | |
| 218 | /** |
| 219 | * Velocity Tracker Strategy: WLSQ2_DELTA. |
| 220 | * 2nd order weighted least squares, delta weighting. Quality: EXPERIMENTAL |
| 221 | */ |
| 222 | const int VELOCITY_TRACKER_STRATEGY_WLSQ2_DELTA = 4; |
| 223 | |
| 224 | /** |
| 225 | * Velocity Tracker Strategy: WLSQ2_CENTRAL. |
| 226 | * 2nd order weighted least squares, central weighting. Quality: EXPERIMENTALe |
| 227 | */ |
| 228 | const int VELOCITY_TRACKER_STRATEGY_WLSQ2_CENTRAL = 5; |
| 229 | |
| 230 | /** |
| 231 | * Velocity Tracker Strategy: WLSQ2_RECENT. |
| 232 | * 2nd order weighted least squares, recent weighting. Quality: EXPERIMENTAL |
| 233 | */ |
| 234 | const int VELOCITY_TRACKER_STRATEGY_WLSQ2_RECENT = 6; |
| 235 | |
| 236 | /** |
| 237 | * Velocity Tracker Strategy: INT1. |
| 238 | * 1st order integrating filter. Quality: GOOD. |
| 239 | * Not as good as 'lsq2' because it cannot estimate acceleration but it is |
| 240 | * more tolerant of errors. Like 'lsq1', this strategy tends to underestimate |
| 241 | * the velocity of a fling but this strategy tends to respond to changes in |
| 242 | * direction more quickly and accurately. |
| 243 | */ |
| 244 | const int VELOCITY_TRACKER_STRATEGY_INT1 = 7; |
| 245 | |
| 246 | /** |
| 247 | * Velocity Tracker Strategy: INT2. |
| 248 | * 2nd order integrating filter. Quality: EXPERIMENTAL. |
| 249 | * For comparison purposes only. Unlike 'int1' this strategy can compensate |
| 250 | * for acceleration but it typically overestimates the effect. |
| 251 | */ |
| 252 | const int VELOCITY_TRACKER_STRATEGY_INT2 = 8; |
| 253 | |
| 254 | /** |
| 255 | * Velocity Tracker Strategy: Legacy. |
| 256 | * Legacy velocity tracker algorithm. Quality: POOR. |
| 257 | * For comparison purposes only. This algorithm is strongly influenced by |
| 258 | * old data points, consistently underestimates velocity and takes a very long |
| 259 | * time to adjust to changes in direction. |
| 260 | */ |
| 261 | const int VELOCITY_TRACKER_STRATEGY_LEGACY = 9; |
Siarhei Vishniakou | 7062295 | 2020-07-30 11:17:23 -0500 | [diff] [blame] | 262 | } |