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 | /** |
Siarhei Vishniakou | f00a4ec | 2021-06-16 03:55:32 +0000 | [diff] [blame] | 119 | * The input event was generated or modified by accessibility service. |
| 120 | * Shared by both KeyEvent and MotionEvent flags, so this value should not overlap with either |
| 121 | * set of flags, including in input/Input.h and in android/input.h. |
| 122 | */ |
| 123 | const int INPUT_EVENT_FLAG_IS_ACCESSIBILITY_EVENT = 0x800; |
Prabir Pradhan | de78850 | 2021-12-22 00:26:07 -0800 | [diff] [blame] | 124 | |
Siarhei Vishniakou | c40f6e0 | 2024-04-25 15:49:29 -0700 | [diff] [blame] | 125 | /** |
| 126 | * Private flag that indicates when the system has detected that this motion event |
| 127 | * may be inconsistent with respect to the sequence of previously delivered motion events, |
| 128 | * such as when a pointer move event is sent but the pointer is not down. |
| 129 | * |
| 130 | * @hide |
| 131 | * @see #isTainted |
| 132 | * @see #setTainted |
| 133 | */ |
| 134 | const int INPUT_EVENT_FLAG_TAINTED = 0x80000000; |
| 135 | |
| 136 | /** |
| 137 | * Private flag indicating that this event was synthesized by the system and should be delivered |
| 138 | * to the accessibility focused view first. When being dispatched such an event is not handled |
| 139 | * by predecessors of the accessibility focused view and after the event reaches that view the |
| 140 | * flag is cleared and normal event dispatch is performed. This ensures that the platform can |
| 141 | * click on any view that has accessibility focus which is semantically equivalent to asking the |
| 142 | * view to perform a click accessibility action but more generic as views not implementing click |
| 143 | * action correctly can still be activated. |
| 144 | * |
| 145 | * @hide |
| 146 | * @see #isTargetAccessibilityFocus() |
| 147 | * @see #setTargetAccessibilityFocus(boolean) |
| 148 | */ |
| 149 | const int MOTION_EVENT_FLAG_TARGET_ACCESSIBILITY_FOCUS = 0x40000000; |
| 150 | |
Christine Franks | 46d8a1e | 2022-01-05 16:11:48 -0800 | [diff] [blame] | 151 | /* The default pointer acceleration value. */ |
| 152 | const int DEFAULT_POINTER_ACCELERATION = 3; |
Siarhei Vishniakou | f7436a1 | 2023-08-14 15:17:11 -0700 | [diff] [blame] | 153 | |
| 154 | /** |
| 155 | * Use the default Velocity Tracker Strategy. Different axes may use different default |
| 156 | * strategies. |
| 157 | */ |
| 158 | const int VELOCITY_TRACKER_STRATEGY_DEFAULT = -1; |
| 159 | |
| 160 | /** |
| 161 | * Velocity Tracker Strategy: Impulse. |
| 162 | * Physical model of pushing an object. Quality: VERY GOOD. |
| 163 | * Works with duplicate coordinates, unclean finger liftoff. |
| 164 | */ |
| 165 | const int VELOCITY_TRACKER_STRATEGY_IMPULSE = 0; |
| 166 | |
| 167 | /** |
| 168 | * Velocity Tracker Strategy: LSQ1. |
| 169 | * 1st order least squares. Quality: POOR. |
| 170 | * Frequently underfits the touch data especially when the finger accelerates |
| 171 | * or changes direction. Often underestimates velocity. The direction |
| 172 | * is overly influenced by historical touch points. |
| 173 | */ |
| 174 | const int VELOCITY_TRACKER_STRATEGY_LSQ1 = 1; |
| 175 | |
| 176 | /** |
| 177 | * Velocity Tracker Strategy: LSQ2. |
| 178 | * 2nd order least squares. Quality: VERY GOOD. |
| 179 | * Pretty much ideal, but can be confused by certain kinds of touch data, |
| 180 | * particularly if the panel has a tendency to generate delayed, |
| 181 | * duplicate or jittery touch coordinates when the finger is released. |
| 182 | */ |
| 183 | const int VELOCITY_TRACKER_STRATEGY_LSQ2 = 2; |
| 184 | |
| 185 | /** |
| 186 | * Velocity Tracker Strategy: LSQ3. |
| 187 | * 3rd order least squares. Quality: UNUSABLE. |
| 188 | * Frequently overfits the touch data yielding wildly divergent estimates |
| 189 | * of the velocity when the finger is released. |
| 190 | */ |
| 191 | const int VELOCITY_TRACKER_STRATEGY_LSQ3 = 3; |
| 192 | |
| 193 | /** |
| 194 | * Velocity Tracker Strategy: WLSQ2_DELTA. |
| 195 | * 2nd order weighted least squares, delta weighting. Quality: EXPERIMENTAL |
| 196 | */ |
| 197 | const int VELOCITY_TRACKER_STRATEGY_WLSQ2_DELTA = 4; |
| 198 | |
| 199 | /** |
| 200 | * Velocity Tracker Strategy: WLSQ2_CENTRAL. |
| 201 | * 2nd order weighted least squares, central weighting. Quality: EXPERIMENTALe |
| 202 | */ |
| 203 | const int VELOCITY_TRACKER_STRATEGY_WLSQ2_CENTRAL = 5; |
| 204 | |
| 205 | /** |
| 206 | * Velocity Tracker Strategy: WLSQ2_RECENT. |
| 207 | * 2nd order weighted least squares, recent weighting. Quality: EXPERIMENTAL |
| 208 | */ |
| 209 | const int VELOCITY_TRACKER_STRATEGY_WLSQ2_RECENT = 6; |
| 210 | |
| 211 | /** |
| 212 | * Velocity Tracker Strategy: INT1. |
| 213 | * 1st order integrating filter. Quality: GOOD. |
| 214 | * Not as good as 'lsq2' because it cannot estimate acceleration but it is |
| 215 | * more tolerant of errors. Like 'lsq1', this strategy tends to underestimate |
| 216 | * the velocity of a fling but this strategy tends to respond to changes in |
| 217 | * direction more quickly and accurately. |
| 218 | */ |
| 219 | const int VELOCITY_TRACKER_STRATEGY_INT1 = 7; |
| 220 | |
| 221 | /** |
| 222 | * Velocity Tracker Strategy: INT2. |
| 223 | * 2nd order integrating filter. Quality: EXPERIMENTAL. |
| 224 | * For comparison purposes only. Unlike 'int1' this strategy can compensate |
| 225 | * for acceleration but it typically overestimates the effect. |
| 226 | */ |
| 227 | const int VELOCITY_TRACKER_STRATEGY_INT2 = 8; |
| 228 | |
| 229 | /** |
| 230 | * Velocity Tracker Strategy: Legacy. |
| 231 | * Legacy velocity tracker algorithm. Quality: POOR. |
| 232 | * For comparison purposes only. This algorithm is strongly influenced by |
| 233 | * old data points, consistently underestimates velocity and takes a very long |
| 234 | * time to adjust to changes in direction. |
| 235 | */ |
| 236 | const int VELOCITY_TRACKER_STRATEGY_LEGACY = 9; |
Siarhei Vishniakou | 7062295 | 2020-07-30 11:17:23 -0500 | [diff] [blame] | 237 | } |