Dianne Hackborn | f56e102 | 2011-02-22 10:47:13 -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. |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 15 | */ |
Dianne Hackborn | f56e102 | 2011-02-22 10:47:13 -0800 | [diff] [blame] | 16 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 17 | package com.android.server.wm; |
| 18 | |
Andrii Kulian | 5406e7a | 2016-10-21 11:55:23 -0700 | [diff] [blame] | 19 | import static android.view.Display.DEFAULT_DISPLAY; |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 20 | import static android.view.WindowManager.INPUT_CONSUMER_PIP; |
| 21 | import static android.view.WindowManager.INPUT_CONSUMER_WALLPAPER; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 22 | import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 23 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DRAG; |
| 24 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS_LIGHT; |
| 25 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_INPUT; |
| 26 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TASK_POSITIONING; |
| 27 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
Filip Gruszczynski | 9cac3b4 | 2015-10-30 14:20:37 -0700 | [diff] [blame] | 28 | |
Dianne Hackborn | 5fe7e2a | 2012-10-04 11:58:16 -0700 | [diff] [blame] | 29 | import android.app.ActivityManagerNative; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 30 | import android.graphics.Rect; |
Wale Ogunwale | e89eeac | 2016-03-12 11:07:58 -0800 | [diff] [blame] | 31 | import android.os.Debug; |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 32 | import android.os.Looper; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 33 | import android.os.RemoteException; |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 34 | import android.util.ArrayMap; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 35 | import android.util.Log; |
| 36 | import android.util.Slog; |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 37 | import android.view.InputChannel; |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 38 | import android.view.InputEventReceiver; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 39 | import android.view.KeyEvent; |
| 40 | import android.view.WindowManager; |
| 41 | |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 42 | import android.view.WindowManagerPolicy; |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 43 | import com.android.server.input.InputApplicationHandle; |
| 44 | import com.android.server.input.InputManagerService; |
| 45 | import com.android.server.input.InputWindowHandle; |
| 46 | |
Wale Ogunwale | e89eeac | 2016-03-12 11:07:58 -0800 | [diff] [blame] | 47 | import java.io.PrintWriter; |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 48 | import java.util.Arrays; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 49 | |
Jeff Brown | a9d131c | 2012-09-20 16:48:17 -0700 | [diff] [blame] | 50 | final class InputMonitor implements InputManagerService.WindowManagerCallbacks { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 51 | private final WindowManagerService mService; |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 52 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 53 | // Current window with input focus for keys and other non-touch events. May be null. |
| 54 | private WindowState mInputFocus; |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 55 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 56 | // When true, prevents input dispatch from proceeding until set to false again. |
| 57 | private boolean mInputDispatchFrozen; |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 58 | |
Wale Ogunwale | e89eeac | 2016-03-12 11:07:58 -0800 | [diff] [blame] | 59 | // The reason the input is currently frozen or null if the input isn't frozen. |
| 60 | private String mInputFreezeReason = null; |
| 61 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 62 | // When true, input dispatch proceeds normally. Otherwise all events are dropped. |
Jeff Brown | c042ee2 | 2012-05-08 13:03:42 -0700 | [diff] [blame] | 63 | // Initially false, so that input does not get dispatched until boot is finished at |
| 64 | // which point the ActivityManager will enable dispatching. |
| 65 | private boolean mInputDispatchEnabled; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 66 | |
| 67 | // When true, need to call updateInputWindowsLw(). |
| 68 | private boolean mUpdateInputWindowsNeeded = true; |
| 69 | |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 70 | // Array of window handles to provide to the input dispatcher. |
| 71 | private InputWindowHandle[] mInputWindowHandles; |
| 72 | private int mInputWindowHandleCount; |
| 73 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 74 | // Set to true when the first input device configuration change notification |
| 75 | // is received to indicate that the input devices are ready. |
| 76 | private final Object mInputDevicesReadyMonitor = new Object(); |
| 77 | private boolean mInputDevicesReady; |
| 78 | |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 79 | /** |
| 80 | * The set of input consumer added to the window manager by name, which consumes input events |
| 81 | * for the windows below it. |
| 82 | */ |
| 83 | private final ArrayMap<String, InputConsumerImpl> mInputConsumers = new ArrayMap(); |
| 84 | |
| 85 | private static final class EventReceiverInputConsumer extends InputConsumerImpl |
| 86 | implements WindowManagerPolicy.InputConsumer { |
| 87 | private InputMonitor mInputMonitor; |
| 88 | private final InputEventReceiver mInputEventReceiver; |
| 89 | |
| 90 | EventReceiverInputConsumer(WindowManagerService service, InputMonitor monitor, |
| 91 | Looper looper, String name, |
| 92 | InputEventReceiver.Factory inputEventReceiverFactory) { |
| 93 | super(service, name, null); |
| 94 | mInputMonitor = monitor; |
| 95 | mInputEventReceiver = inputEventReceiverFactory.createInputEventReceiver( |
| 96 | mClientChannel, looper); |
| 97 | } |
| 98 | |
| 99 | @Override |
| 100 | public void dismiss() { |
| 101 | synchronized (mService.mWindowMap) { |
| 102 | if (mInputMonitor.destroyInputConsumer(mWindowHandle.name)) { |
| 103 | mInputEventReceiver.dispose(); |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 109 | public InputMonitor(WindowManagerService service) { |
| 110 | mService = service; |
| 111 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 112 | |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 113 | private void addInputConsumer(String name, InputConsumerImpl consumer) { |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 114 | mInputConsumers.put(name, consumer); |
| 115 | updateInputWindowsLw(true /* force */); |
| 116 | } |
| 117 | |
| 118 | boolean destroyInputConsumer(String name) { |
| 119 | if (disposeInputConsumer(mInputConsumers.remove(name))) { |
| 120 | updateInputWindowsLw(true /* force */); |
| 121 | return true; |
| 122 | } |
| 123 | return false; |
| 124 | } |
| 125 | |
| 126 | private boolean disposeInputConsumer(InputConsumerImpl consumer) { |
| 127 | if (consumer != null) { |
| 128 | consumer.disposeChannelsLw(); |
| 129 | return true; |
| 130 | } |
| 131 | return false; |
| 132 | } |
| 133 | |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 134 | InputConsumerImpl getInputConsumer(String name, int displayId) { |
| 135 | // TODO(multi-display): Allow input consumers on non-default displays? |
| 136 | return (displayId == DEFAULT_DISPLAY) ? mInputConsumers.get(name) : null; |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | void layoutInputConsumers(int dw, int dh) { |
| 140 | for (int i = mInputConsumers.size() - 1; i >= 0; i--) { |
| 141 | mInputConsumers.valueAt(i).layout(dw, dh); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | WindowManagerPolicy.InputConsumer createInputConsumer(Looper looper, String name, |
| 146 | InputEventReceiver.Factory inputEventReceiverFactory) { |
| 147 | if (mInputConsumers.containsKey(name)) { |
| 148 | throw new IllegalStateException("Existing input consumer found with name: " + name); |
| 149 | } |
| 150 | |
| 151 | final EventReceiverInputConsumer consumer = new EventReceiverInputConsumer(mService, |
| 152 | this, looper, name, inputEventReceiverFactory); |
| 153 | addInputConsumer(name, consumer); |
| 154 | return consumer; |
| 155 | } |
| 156 | |
| 157 | void createInputConsumer(String name, InputChannel inputChannel) { |
| 158 | if (mInputConsumers.containsKey(name)) { |
| 159 | throw new IllegalStateException("Existing input consumer found with name: " + name); |
| 160 | } |
| 161 | |
| 162 | final InputConsumerImpl consumer = new InputConsumerImpl(mService, name, inputChannel); |
| 163 | switch (name) { |
| 164 | case INPUT_CONSUMER_WALLPAPER: |
| 165 | consumer.mWindowHandle.hasWallpaper = true; |
| 166 | break; |
| 167 | case INPUT_CONSUMER_PIP: |
| 168 | // The touchable region of the Pip input window is cropped to the bounds of the |
| 169 | // stack, and we need FLAG_NOT_TOUCH_MODAL to ensure other events fall through |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 170 | consumer.mWindowHandle.layoutParamsFlags |= FLAG_NOT_TOUCH_MODAL; |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 171 | break; |
| 172 | } |
| 173 | addInputConsumer(name, consumer); |
| 174 | } |
| 175 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 176 | /* Notifies the window manager about a broken input channel. |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 177 | * |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 178 | * Called by the InputManager. |
| 179 | */ |
Craig Mautner | 4cd0c13f | 2013-04-16 15:55:52 -0700 | [diff] [blame] | 180 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 181 | public void notifyInputChannelBroken(InputWindowHandle inputWindowHandle) { |
| 182 | if (inputWindowHandle == null) { |
| 183 | return; |
| 184 | } |
| 185 | |
| 186 | synchronized (mService.mWindowMap) { |
| 187 | WindowState windowState = (WindowState) inputWindowHandle.windowState; |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 188 | if (windowState != null) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 189 | Slog.i(TAG_WM, "WINDOW DIED " + windowState); |
Wale Ogunwale | 92fc372 | 2016-08-05 12:19:08 -0700 | [diff] [blame] | 190 | windowState.removeIfPossible(); |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 191 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 192 | } |
| 193 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 194 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 195 | /* Notifies the window manager about an application that is not responding. |
| 196 | * Returns a new timeout to continue waiting in nanoseconds, or 0 to abort dispatch. |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 197 | * |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 198 | * Called by the InputManager. |
| 199 | */ |
Craig Mautner | 4cd0c13f | 2013-04-16 15:55:52 -0700 | [diff] [blame] | 200 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 201 | public long notifyANR(InputApplicationHandle inputApplicationHandle, |
Jeff Brown | bd181bb | 2013-09-10 16:44:24 -0700 | [diff] [blame] | 202 | InputWindowHandle inputWindowHandle, String reason) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 203 | AppWindowToken appWindowToken = null; |
Dianne Hackborn | 5fe7e2a | 2012-10-04 11:58:16 -0700 | [diff] [blame] | 204 | WindowState windowState = null; |
| 205 | boolean aboveSystem = false; |
Jeff Brown | ee17241 | 2012-06-18 12:58:03 -0700 | [diff] [blame] | 206 | synchronized (mService.mWindowMap) { |
Jeff Brown | ee17241 | 2012-06-18 12:58:03 -0700 | [diff] [blame] | 207 | if (inputWindowHandle != null) { |
| 208 | windowState = (WindowState) inputWindowHandle.windowState; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 209 | if (windowState != null) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 210 | appWindowToken = windowState.mAppToken; |
| 211 | } |
| 212 | } |
Jeff Brown | ee17241 | 2012-06-18 12:58:03 -0700 | [diff] [blame] | 213 | if (appWindowToken == null && inputApplicationHandle != null) { |
| 214 | appWindowToken = (AppWindowToken)inputApplicationHandle.appWindowToken; |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 215 | } |
Jeff Brown | ee17241 | 2012-06-18 12:58:03 -0700 | [diff] [blame] | 216 | |
| 217 | if (windowState != null) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 218 | Slog.i(TAG_WM, "Input event dispatching timed out " |
Jeff Brown | bd181bb | 2013-09-10 16:44:24 -0700 | [diff] [blame] | 219 | + "sending to " + windowState.mAttrs.getTitle() |
| 220 | + ". Reason: " + reason); |
Dianne Hackborn | 5fe7e2a | 2012-10-04 11:58:16 -0700 | [diff] [blame] | 221 | // Figure out whether this window is layered above system windows. |
| 222 | // We need to do this here to help the activity manager know how to |
| 223 | // layer its ANR dialog. |
| 224 | int systemAlertLayer = mService.mPolicy.windowTypeToLayerLw( |
| 225 | WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); |
| 226 | aboveSystem = windowState.mBaseLayer > systemAlertLayer; |
Jeff Brown | ee17241 | 2012-06-18 12:58:03 -0700 | [diff] [blame] | 227 | } else if (appWindowToken != null) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 228 | Slog.i(TAG_WM, "Input event dispatching timed out " |
Jeff Brown | bd181bb | 2013-09-10 16:44:24 -0700 | [diff] [blame] | 229 | + "sending to application " + appWindowToken.stringName |
| 230 | + ". Reason: " + reason); |
Jeff Brown | ee17241 | 2012-06-18 12:58:03 -0700 | [diff] [blame] | 231 | } else { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 232 | Slog.i(TAG_WM, "Input event dispatching timed out " |
Jeff Brown | bd181bb | 2013-09-10 16:44:24 -0700 | [diff] [blame] | 233 | + ". Reason: " + reason); |
Jeff Brown | ee17241 | 2012-06-18 12:58:03 -0700 | [diff] [blame] | 234 | } |
| 235 | |
Jeff Brown | bd181bb | 2013-09-10 16:44:24 -0700 | [diff] [blame] | 236 | mService.saveANRStateLocked(appWindowToken, windowState, reason); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | if (appWindowToken != null && appWindowToken.appToken != null) { |
| 240 | try { |
| 241 | // Notify the activity manager about the timeout and let it decide whether |
| 242 | // to abort dispatching or keep waiting. |
Jeff Brown | bd181bb | 2013-09-10 16:44:24 -0700 | [diff] [blame] | 243 | boolean abort = appWindowToken.appToken.keyDispatchingTimedOut(reason); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 244 | if (! abort) { |
| 245 | // The activity manager declined to abort dispatching. |
| 246 | // Wait a bit longer and timeout again later. |
| 247 | return appWindowToken.inputDispatchingTimeoutNanos; |
| 248 | } |
| 249 | } catch (RemoteException ex) { |
| 250 | } |
Dianne Hackborn | 5fe7e2a | 2012-10-04 11:58:16 -0700 | [diff] [blame] | 251 | } else if (windowState != null) { |
| 252 | try { |
| 253 | // Notify the activity manager about the timeout and let it decide whether |
| 254 | // to abort dispatching or keep waiting. |
| 255 | long timeout = ActivityManagerNative.getDefault().inputDispatchingTimedOut( |
Jeff Brown | bd181bb | 2013-09-10 16:44:24 -0700 | [diff] [blame] | 256 | windowState.mSession.mPid, aboveSystem, reason); |
Dianne Hackborn | 5fe7e2a | 2012-10-04 11:58:16 -0700 | [diff] [blame] | 257 | if (timeout >= 0) { |
| 258 | // The activity manager declined to abort dispatching. |
| 259 | // Wait a bit longer and timeout again later. |
baik.han | def340d | 2015-04-15 10:21:05 +0900 | [diff] [blame] | 260 | return timeout * 1000000L; // nanoseconds |
Dianne Hackborn | 5fe7e2a | 2012-10-04 11:58:16 -0700 | [diff] [blame] | 261 | } |
| 262 | } catch (RemoteException ex) { |
| 263 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 264 | } |
| 265 | return 0; // abort dispatching |
| 266 | } |
| 267 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 268 | void addInputWindowHandle(final InputWindowHandle windowHandle) { |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 269 | if (mInputWindowHandles == null) { |
| 270 | mInputWindowHandles = new InputWindowHandle[16]; |
| 271 | } |
| 272 | if (mInputWindowHandleCount >= mInputWindowHandles.length) { |
| 273 | mInputWindowHandles = Arrays.copyOf(mInputWindowHandles, |
| 274 | mInputWindowHandleCount * 2); |
| 275 | } |
| 276 | mInputWindowHandles[mInputWindowHandleCount++] = windowHandle; |
| 277 | } |
| 278 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 279 | void addInputWindowHandle(final InputWindowHandle inputWindowHandle, |
Craig Mautner | c08eab8 | 2014-11-11 09:03:59 -0800 | [diff] [blame] | 280 | final WindowState child, int flags, final int type, final boolean isVisible, |
Wale Ogunwale | 053c8e4 | 2015-11-16 14:27:21 -0800 | [diff] [blame] | 281 | final boolean hasFocus, final boolean hasWallpaper) { |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 282 | // Add a window to our list of input windows. |
| 283 | inputWindowHandle.name = child.toString(); |
Wale Ogunwale | 053c8e4 | 2015-11-16 14:27:21 -0800 | [diff] [blame] | 284 | flags = child.getTouchableRegion(inputWindowHandle.touchableRegion, flags); |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 285 | inputWindowHandle.layoutParamsFlags = flags; |
| 286 | inputWindowHandle.layoutParamsType = type; |
| 287 | inputWindowHandle.dispatchingTimeoutNanos = child.getInputDispatchingTimeoutNanos(); |
| 288 | inputWindowHandle.visible = isVisible; |
| 289 | inputWindowHandle.canReceiveKeys = child.canReceiveKeys(); |
| 290 | inputWindowHandle.hasFocus = hasFocus; |
| 291 | inputWindowHandle.hasWallpaper = hasWallpaper; |
| 292 | inputWindowHandle.paused = child.mAppToken != null ? child.mAppToken.paused : false; |
| 293 | inputWindowHandle.layer = child.mLayer; |
| 294 | inputWindowHandle.ownerPid = child.mSession.mPid; |
| 295 | inputWindowHandle.ownerUid = child.mSession.mUid; |
| 296 | inputWindowHandle.inputFeatures = child.mAttrs.inputFeatures; |
| 297 | |
| 298 | final Rect frame = child.mFrame; |
| 299 | inputWindowHandle.frameLeft = frame.left; |
| 300 | inputWindowHandle.frameTop = frame.top; |
| 301 | inputWindowHandle.frameRight = frame.right; |
| 302 | inputWindowHandle.frameBottom = frame.bottom; |
| 303 | |
| 304 | if (child.mGlobalScale != 1) { |
| 305 | // If we are scaling the window, input coordinates need |
| 306 | // to be inversely scaled to map from what is on screen |
| 307 | // to what is actually being touched in the UI. |
| 308 | inputWindowHandle.scaleFactor = 1.0f/child.mGlobalScale; |
| 309 | } else { |
| 310 | inputWindowHandle.scaleFactor = 1; |
| 311 | } |
| 312 | |
Filip Gruszczynski | f8a2a63 | 2015-10-28 11:18:02 -0700 | [diff] [blame] | 313 | if (DEBUG_INPUT) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 314 | Slog.d(TAG_WM, "addInputWindowHandle: " |
Chong Zhang | b15758a | 2015-11-17 12:12:03 -0800 | [diff] [blame] | 315 | + child + ", " + inputWindowHandle); |
Filip Gruszczynski | f8a2a63 | 2015-10-28 11:18:02 -0700 | [diff] [blame] | 316 | } |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 317 | addInputWindowHandle(inputWindowHandle); |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 318 | } |
| 319 | |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 320 | private void clearInputWindowHandlesLw() { |
| 321 | while (mInputWindowHandleCount != 0) { |
| 322 | mInputWindowHandles[--mInputWindowHandleCount] = null; |
| 323 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | public void setUpdateInputWindowsNeededLw() { |
| 327 | mUpdateInputWindowsNeeded = true; |
| 328 | } |
| 329 | |
| 330 | /* Updates the cached window information provided to the input dispatcher. */ |
| 331 | public void updateInputWindowsLw(boolean force) { |
| 332 | if (!force && !mUpdateInputWindowsNeeded) { |
| 333 | return; |
| 334 | } |
| 335 | mUpdateInputWindowsNeeded = false; |
| 336 | |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 337 | if (false) Slog.d(TAG_WM, ">>>>>> ENTERED updateInputWindowsLw"); |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 338 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 339 | // Populate the input window list with information about all of the windows that |
| 340 | // could potentially receive input. |
| 341 | // As an optimization, we could try to prune the list of windows but this turns |
| 342 | // out to be difficult because only the native code knows for sure which window |
| 343 | // currently has touch focus. |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 344 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 345 | // If there's a drag in flight, provide a pseudo-window to catch drag input |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 346 | final boolean inDrag = (mService.mDragState != null); |
| 347 | if (inDrag) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 348 | if (DEBUG_DRAG) { |
| 349 | Log.d(TAG_WM, "Inserting drag window"); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 350 | } |
Vladislav Kaznacheev | 64b103a | 2016-08-10 11:49:08 -0700 | [diff] [blame] | 351 | final InputWindowHandle dragWindowHandle = mService.mDragState.getInputWindowHandle(); |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 352 | if (dragWindowHandle != null) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 353 | addInputWindowHandle(dragWindowHandle); |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 354 | } else { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 355 | Slog.w(TAG_WM, "Drag is in progress but there is no " |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 356 | + "drag window handle."); |
| 357 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 358 | } |
| 359 | |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 360 | final boolean inPositioning = (mService.mTaskPositioner != null); |
| 361 | if (inPositioning) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 362 | if (DEBUG_TASK_POSITIONING) { |
| 363 | Log.d(TAG_WM, "Inserting window handle for repositioning"); |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 364 | } |
| 365 | final InputWindowHandle dragWindowHandle = mService.mTaskPositioner.mDragWindowHandle; |
| 366 | if (dragWindowHandle != null) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 367 | addInputWindowHandle(dragWindowHandle); |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 368 | } else { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 369 | Slog.e(TAG_WM, |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 370 | "Repositioning is in progress but there is no drag window handle."); |
| 371 | } |
| 372 | } |
| 373 | |
Jeff Brown | 83d616a | 2012-09-09 20:33:43 -0700 | [diff] [blame] | 374 | // Add all windows on the default display. |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 375 | mService.mRoot.updateInputWindows(this, mInputFocus, inDrag); |
Vladislav Kaznacheev | 0d50d86 | 2016-03-29 15:43:28 -0700 | [diff] [blame] | 376 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 377 | // Send windows to native code. |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 378 | mService.mInputManager.setInputWindows(mInputWindowHandles); |
| 379 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 380 | // Clear the list in preparation for the next round. |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 381 | clearInputWindowHandlesLw(); |
| 382 | |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 383 | if (false) Slog.d(TAG_WM, "<<<<<<< EXITED updateInputWindowsLw"); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | /* Notifies that the input device configuration has changed. */ |
Jeff Brown | 0b31d81 | 2013-08-22 19:41:29 -0700 | [diff] [blame] | 387 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 388 | public void notifyConfigurationChanged() { |
Andrii Kulian | 5406e7a | 2016-10-21 11:55:23 -0700 | [diff] [blame] | 389 | // TODO(multi-display): Notify proper displays that are associated with this input device. |
| 390 | mService.sendNewConfiguration(DEFAULT_DISPLAY); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 391 | |
| 392 | synchronized (mInputDevicesReadyMonitor) { |
| 393 | if (!mInputDevicesReady) { |
| 394 | mInputDevicesReady = true; |
| 395 | mInputDevicesReadyMonitor.notifyAll(); |
| 396 | } |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | /* Waits until the built-in input devices have been configured. */ |
| 401 | public boolean waitForInputDevicesReady(long timeoutMillis) { |
| 402 | synchronized (mInputDevicesReadyMonitor) { |
| 403 | if (!mInputDevicesReady) { |
| 404 | try { |
| 405 | mInputDevicesReadyMonitor.wait(timeoutMillis); |
| 406 | } catch (InterruptedException ex) { |
| 407 | } |
| 408 | } |
| 409 | return mInputDevicesReady; |
| 410 | } |
| 411 | } |
| 412 | |
| 413 | /* Notifies that the lid switch changed state. */ |
Jeff Brown | 0b31d81 | 2013-08-22 19:41:29 -0700 | [diff] [blame] | 414 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 415 | public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) { |
| 416 | mService.mPolicy.notifyLidSwitchChanged(whenNanos, lidOpen); |
| 417 | } |
Craig Mautner | 5845812 | 2013-09-14 14:59:50 -0700 | [diff] [blame] | 418 | |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 419 | /* Notifies that the camera lens cover state has changed. */ |
| 420 | @Override |
| 421 | public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered) { |
| 422 | mService.mPolicy.notifyCameraLensCoverSwitchChanged(whenNanos, lensCovered); |
| 423 | } |
| 424 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 425 | /* Provides an opportunity for the window manager policy to intercept early key |
| 426 | * processing as soon as the key has been read from the device. */ |
Jeff Brown | 0b31d81 | 2013-08-22 19:41:29 -0700 | [diff] [blame] | 427 | @Override |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 428 | public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) { |
| 429 | return mService.mPolicy.interceptKeyBeforeQueueing(event, policyFlags); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 430 | } |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 431 | |
Michael Wright | 70af00a | 2014-09-03 19:30:20 -0700 | [diff] [blame] | 432 | /* Provides an opportunity for the window manager policy to intercept early motion event |
| 433 | * processing when the device is in a non-interactive state since these events are normally |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 434 | * dropped. */ |
Jeff Brown | 0b31d81 | 2013-08-22 19:41:29 -0700 | [diff] [blame] | 435 | @Override |
Michael Wright | 70af00a | 2014-09-03 19:30:20 -0700 | [diff] [blame] | 436 | public int interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags) { |
| 437 | return mService.mPolicy.interceptMotionBeforeQueueingNonInteractive( |
| 438 | whenNanos, policyFlags); |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 439 | } |
| 440 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 441 | /* Provides an opportunity for the window manager policy to process a key before |
| 442 | * ordinary dispatch. */ |
Jeff Brown | 0b31d81 | 2013-08-22 19:41:29 -0700 | [diff] [blame] | 443 | @Override |
Jeff Brown | 905805a | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 444 | public long interceptKeyBeforeDispatching( |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 445 | InputWindowHandle focus, KeyEvent event, int policyFlags) { |
| 446 | WindowState windowState = focus != null ? (WindowState) focus.windowState : null; |
| 447 | return mService.mPolicy.interceptKeyBeforeDispatching(windowState, event, policyFlags); |
| 448 | } |
Craig Mautner | 5845812 | 2013-09-14 14:59:50 -0700 | [diff] [blame] | 449 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 450 | /* Provides an opportunity for the window manager policy to process a key that |
| 451 | * the application did not handle. */ |
Jeff Brown | 0b31d81 | 2013-08-22 19:41:29 -0700 | [diff] [blame] | 452 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 453 | public KeyEvent dispatchUnhandledKey( |
| 454 | InputWindowHandle focus, KeyEvent event, int policyFlags) { |
| 455 | WindowState windowState = focus != null ? (WindowState) focus.windowState : null; |
| 456 | return mService.mPolicy.dispatchUnhandledKey(windowState, event, policyFlags); |
| 457 | } |
Jeff Brown | 4532e61 | 2012-04-05 14:27:12 -0700 | [diff] [blame] | 458 | |
| 459 | /* Callback to get pointer layer. */ |
Jeff Brown | 0b31d81 | 2013-08-22 19:41:29 -0700 | [diff] [blame] | 460 | @Override |
Jeff Brown | 4532e61 | 2012-04-05 14:27:12 -0700 | [diff] [blame] | 461 | public int getPointerLayer() { |
| 462 | return mService.mPolicy.windowTypeToLayerLw(WindowManager.LayoutParams.TYPE_POINTER) |
| 463 | * WindowManagerService.TYPE_LAYER_MULTIPLIER |
| 464 | + WindowManagerService.TYPE_LAYER_OFFSET; |
| 465 | } |
| 466 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 467 | /* Called when the current input focus changes. |
| 468 | * Layer assignment is assumed to be complete by the time this is called. |
| 469 | */ |
| 470 | public void setInputFocusLw(WindowState newWindow, boolean updateInputWindows) { |
Filip Gruszczynski | f8a2a63 | 2015-10-28 11:18:02 -0700 | [diff] [blame] | 471 | if (DEBUG_FOCUS_LIGHT || DEBUG_INPUT) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 472 | Slog.d(TAG_WM, "Input focus has changed to " + newWindow); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 473 | } |
| 474 | |
| 475 | if (newWindow != mInputFocus) { |
| 476 | if (newWindow != null && newWindow.canReceiveKeys()) { |
| 477 | // Displaying a window implicitly causes dispatching to be unpaused. |
| 478 | // This is to protect against bugs if someone pauses dispatching but |
| 479 | // forgets to resume. |
| 480 | newWindow.mToken.paused = false; |
| 481 | } |
| 482 | |
| 483 | mInputFocus = newWindow; |
| 484 | setUpdateInputWindowsNeededLw(); |
| 485 | |
| 486 | if (updateInputWindows) { |
| 487 | updateInputWindowsLw(false /*force*/); |
| 488 | } |
| 489 | } |
| 490 | } |
Craig Mautner | 5845812 | 2013-09-14 14:59:50 -0700 | [diff] [blame] | 491 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 492 | public void setFocusedAppLw(AppWindowToken newApp) { |
| 493 | // Focused app has changed. |
| 494 | if (newApp == null) { |
| 495 | mService.mInputManager.setFocusedApplication(null); |
| 496 | } else { |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 497 | final InputApplicationHandle handle = newApp.mInputApplicationHandle; |
| 498 | handle.name = newApp.toString(); |
| 499 | handle.dispatchingTimeoutNanos = newApp.inputDispatchingTimeoutNanos; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 500 | |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 501 | mService.mInputManager.setFocusedApplication(handle); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 502 | } |
| 503 | } |
Craig Mautner | 5845812 | 2013-09-14 14:59:50 -0700 | [diff] [blame] | 504 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 505 | public void pauseDispatchingLw(WindowToken window) { |
| 506 | if (! window.paused) { |
Filip Gruszczynski | f8a2a63 | 2015-10-28 11:18:02 -0700 | [diff] [blame] | 507 | if (DEBUG_INPUT) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 508 | Slog.v(TAG_WM, "Pausing WindowToken " + window); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 509 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 510 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 511 | window.paused = true; |
| 512 | updateInputWindowsLw(true /*force*/); |
| 513 | } |
| 514 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 515 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 516 | public void resumeDispatchingLw(WindowToken window) { |
| 517 | if (window.paused) { |
Filip Gruszczynski | f8a2a63 | 2015-10-28 11:18:02 -0700 | [diff] [blame] | 518 | if (DEBUG_INPUT) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 519 | Slog.v(TAG_WM, "Resuming WindowToken " + window); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 520 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 521 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 522 | window.paused = false; |
| 523 | updateInputWindowsLw(true /*force*/); |
| 524 | } |
| 525 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 526 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 527 | public void freezeInputDispatchingLw() { |
Wale Ogunwale | e89eeac | 2016-03-12 11:07:58 -0800 | [diff] [blame] | 528 | if (!mInputDispatchFrozen) { |
Filip Gruszczynski | f8a2a63 | 2015-10-28 11:18:02 -0700 | [diff] [blame] | 529 | if (DEBUG_INPUT) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 530 | Slog.v(TAG_WM, "Freezing input dispatching"); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 531 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 532 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 533 | mInputDispatchFrozen = true; |
Wale Ogunwale | e89eeac | 2016-03-12 11:07:58 -0800 | [diff] [blame] | 534 | |
| 535 | if (DEBUG_INPUT || true) { |
| 536 | mInputFreezeReason = Debug.getCallers(6); |
| 537 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 538 | updateInputDispatchModeLw(); |
| 539 | } |
| 540 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 541 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 542 | public void thawInputDispatchingLw() { |
| 543 | if (mInputDispatchFrozen) { |
Filip Gruszczynski | f8a2a63 | 2015-10-28 11:18:02 -0700 | [diff] [blame] | 544 | if (DEBUG_INPUT) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 545 | Slog.v(TAG_WM, "Thawing input dispatching"); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 546 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 547 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 548 | mInputDispatchFrozen = false; |
Wale Ogunwale | e89eeac | 2016-03-12 11:07:58 -0800 | [diff] [blame] | 549 | mInputFreezeReason = null; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 550 | updateInputDispatchModeLw(); |
| 551 | } |
| 552 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 553 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 554 | public void setEventDispatchingLw(boolean enabled) { |
| 555 | if (mInputDispatchEnabled != enabled) { |
Filip Gruszczynski | f8a2a63 | 2015-10-28 11:18:02 -0700 | [diff] [blame] | 556 | if (DEBUG_INPUT) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 557 | Slog.v(TAG_WM, "Setting event dispatching to " + enabled); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 558 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 559 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 560 | mInputDispatchEnabled = enabled; |
| 561 | updateInputDispatchModeLw(); |
| 562 | } |
| 563 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 564 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 565 | private void updateInputDispatchModeLw() { |
| 566 | mService.mInputManager.setInputDispatchMode(mInputDispatchEnabled, mInputDispatchFrozen); |
| 567 | } |
Wale Ogunwale | e89eeac | 2016-03-12 11:07:58 -0800 | [diff] [blame] | 568 | |
| 569 | void dump(PrintWriter pw, String prefix) { |
| 570 | if (mInputFreezeReason != null) { |
| 571 | pw.println(prefix + "mInputFreezeReason=" + mInputFreezeReason); |
| 572 | } |
| 573 | } |
Jeff Brown | ea42655 | 2011-07-18 16:53:48 -0700 | [diff] [blame] | 574 | } |