blob: 281e0a8441e24f682fd6ab77d957e43447414e07 [file] [log] [blame]
Dianne Hackbornf56e1022011-02-22 10:47:13 -08001/*
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 Hackborn6e1eb762011-02-17 16:07:28 -080015 */
Dianne Hackbornf56e1022011-02-22 10:47:13 -080016
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080017package com.android.server.wm;
18
Andrii Kulian5406e7a2016-10-21 11:55:23 -070019import static android.view.Display.DEFAULT_DISPLAY;
Wale Ogunwale6213caa2016-12-02 16:47:15 +000020import static android.view.WindowManager.INPUT_CONSUMER_NAVIGATION;
Winson41275482016-10-10 15:17:45 -070021import static android.view.WindowManager.INPUT_CONSUMER_PIP;
Winson Chunga89ffed2018-01-25 17:46:11 +000022import static android.view.WindowManager.INPUT_CONSUMER_RECENTS_ANIMATION;
Winson41275482016-10-10 15:17:45 -070023import static android.view.WindowManager.INPUT_CONSUMER_WALLPAPER;
Wale Ogunwalef7cab102016-10-25 15:25:14 -070024import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
Wale Ogunwale6213caa2016-12-02 16:47:15 +000025import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS;
26import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
Wale Ogunwale5cd907d2017-01-26 14:14:08 -080027import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
Wale Ogunwale6213caa2016-12-02 16:47:15 +000028import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
Winson Chung6463c362017-09-25 16:23:26 -070029
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080030import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DRAG;
31import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS_LIGHT;
32import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_INPUT;
33import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TASK_POSITIONING;
34import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
Filip Gruszczynski9cac3b42015-10-30 14:20:37 -070035
Sudheer Shankadc589ac2016-11-10 15:30:17 -080036import android.app.ActivityManager;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080037import android.graphics.Rect;
Wale Ogunwalee89eeac2016-03-12 11:07:58 -080038import android.os.Debug;
Winson Chung6463c362017-09-25 16:23:26 -070039import android.os.IBinder;
Winson41275482016-10-10 15:17:45 -070040import android.os.Looper;
Winson Chung6463c362017-09-25 16:23:26 -070041import android.os.Process;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080042import android.os.RemoteException;
Winson Chung6463c362017-09-25 16:23:26 -070043import android.os.UserHandle;
Winson41275482016-10-10 15:17:45 -070044import android.util.ArrayMap;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080045import android.util.Log;
46import android.util.Slog;
Jeff Browncc4f7db2011-08-30 20:34:48 -070047import android.view.InputChannel;
Winson41275482016-10-10 15:17:45 -070048import android.view.InputEventReceiver;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080049import android.view.KeyEvent;
50import android.view.WindowManager;
Wale Ogunwale1e129a42016-11-21 13:03:47 -080051
Selim Cinekf83e8242015-05-19 18:08:14 -070052import com.android.server.input.InputApplicationHandle;
53import com.android.server.input.InputManagerService;
54import com.android.server.input.InputWindowHandle;
Adrian Roose99bc052017-11-20 17:55:31 +010055import com.android.server.policy.WindowManagerPolicy;
Selim Cinekf83e8242015-05-19 18:08:14 -070056
Wale Ogunwalee89eeac2016-03-12 11:07:58 -080057import java.io.PrintWriter;
Jeff Brown9302c872011-07-13 22:51:29 -070058import java.util.Arrays;
Winson Chung853c99a2017-03-21 22:16:42 -070059import java.util.Set;
Wale Ogunwale1e129a42016-11-21 13:03:47 -080060import java.util.function.Consumer;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080061
Jeff Browna9d131c2012-09-20 16:48:17 -070062final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080063 private final WindowManagerService mService;
Selim Cinekf83e8242015-05-19 18:08:14 -070064
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080065 // Current window with input focus for keys and other non-touch events. May be null.
66 private WindowState mInputFocus;
Selim Cinekf83e8242015-05-19 18:08:14 -070067
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080068 // When true, prevents input dispatch from proceeding until set to false again.
69 private boolean mInputDispatchFrozen;
Selim Cinekf83e8242015-05-19 18:08:14 -070070
Wale Ogunwalee89eeac2016-03-12 11:07:58 -080071 // The reason the input is currently frozen or null if the input isn't frozen.
72 private String mInputFreezeReason = null;
73
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080074 // When true, input dispatch proceeds normally. Otherwise all events are dropped.
Jeff Brownc042ee22012-05-08 13:03:42 -070075 // Initially false, so that input does not get dispatched until boot is finished at
76 // which point the ActivityManager will enable dispatching.
77 private boolean mInputDispatchEnabled;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080078
79 // When true, need to call updateInputWindowsLw().
80 private boolean mUpdateInputWindowsNeeded = true;
81
Jeff Brown9302c872011-07-13 22:51:29 -070082 // Array of window handles to provide to the input dispatcher.
83 private InputWindowHandle[] mInputWindowHandles;
84 private int mInputWindowHandleCount;
Vladislav Kaznacheev3787de12016-12-21 10:36:35 -080085 private InputWindowHandle mFocusedInputWindowHandle;
86
Wale Ogunwale6213caa2016-12-02 16:47:15 +000087 private boolean mAddInputConsumerHandle;
88 private boolean mAddPipInputConsumerHandle;
89 private boolean mAddWallpaperInputConsumerHandle;
Winson Chunga89ffed2018-01-25 17:46:11 +000090 private boolean mAddRecentsAnimationInputConsumerHandle;
Wale Ogunwale6213caa2016-12-02 16:47:15 +000091 private boolean mDisableWallpaperTouchEvents;
Wale Ogunwale1e129a42016-11-21 13:03:47 -080092 private final Rect mTmpRect = new Rect();
93 private final UpdateInputForAllWindowsConsumer mUpdateInputForAllWindowsConsumer =
94 new UpdateInputForAllWindowsConsumer();
Jeff Brown9302c872011-07-13 22:51:29 -070095
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080096 // Set to true when the first input device configuration change notification
97 // is received to indicate that the input devices are ready.
98 private final Object mInputDevicesReadyMonitor = new Object();
99 private boolean mInputDevicesReady;
100
Winson41275482016-10-10 15:17:45 -0700101 /**
102 * The set of input consumer added to the window manager by name, which consumes input events
103 * for the windows below it.
104 */
105 private final ArrayMap<String, InputConsumerImpl> mInputConsumers = new ArrayMap();
106
107 private static final class EventReceiverInputConsumer extends InputConsumerImpl
108 implements WindowManagerPolicy.InputConsumer {
109 private InputMonitor mInputMonitor;
110 private final InputEventReceiver mInputEventReceiver;
111
112 EventReceiverInputConsumer(WindowManagerService service, InputMonitor monitor,
113 Looper looper, String name,
Winson Chung6463c362017-09-25 16:23:26 -0700114 InputEventReceiver.Factory inputEventReceiverFactory,
115 int clientPid, UserHandle clientUser) {
116 super(service, null /* token */, name, null /* inputChannel */, clientPid, clientUser);
Winson41275482016-10-10 15:17:45 -0700117 mInputMonitor = monitor;
118 mInputEventReceiver = inputEventReceiverFactory.createInputEventReceiver(
119 mClientChannel, looper);
120 }
121
122 @Override
123 public void dismiss() {
124 synchronized (mService.mWindowMap) {
125 if (mInputMonitor.destroyInputConsumer(mWindowHandle.name)) {
126 mInputEventReceiver.dispose();
127 }
128 }
129 }
130 }
131
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800132 public InputMonitor(WindowManagerService service) {
133 mService = service;
134 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700135
Wale Ogunwalef7cab102016-10-25 15:25:14 -0700136 private void addInputConsumer(String name, InputConsumerImpl consumer) {
Winson41275482016-10-10 15:17:45 -0700137 mInputConsumers.put(name, consumer);
Winson Chung6463c362017-09-25 16:23:26 -0700138 consumer.linkToDeathRecipient();
Winson41275482016-10-10 15:17:45 -0700139 updateInputWindowsLw(true /* force */);
140 }
141
142 boolean destroyInputConsumer(String name) {
143 if (disposeInputConsumer(mInputConsumers.remove(name))) {
144 updateInputWindowsLw(true /* force */);
145 return true;
146 }
147 return false;
148 }
149
150 private boolean disposeInputConsumer(InputConsumerImpl consumer) {
151 if (consumer != null) {
152 consumer.disposeChannelsLw();
153 return true;
154 }
155 return false;
156 }
157
Wale Ogunwalef7cab102016-10-25 15:25:14 -0700158 InputConsumerImpl getInputConsumer(String name, int displayId) {
159 // TODO(multi-display): Allow input consumers on non-default displays?
160 return (displayId == DEFAULT_DISPLAY) ? mInputConsumers.get(name) : null;
Winson41275482016-10-10 15:17:45 -0700161 }
162
163 void layoutInputConsumers(int dw, int dh) {
164 for (int i = mInputConsumers.size() - 1; i >= 0; i--) {
165 mInputConsumers.valueAt(i).layout(dw, dh);
166 }
167 }
168
169 WindowManagerPolicy.InputConsumer createInputConsumer(Looper looper, String name,
170 InputEventReceiver.Factory inputEventReceiverFactory) {
171 if (mInputConsumers.containsKey(name)) {
172 throw new IllegalStateException("Existing input consumer found with name: " + name);
173 }
174
175 final EventReceiverInputConsumer consumer = new EventReceiverInputConsumer(mService,
Winson Chung6463c362017-09-25 16:23:26 -0700176 this, looper, name, inputEventReceiverFactory, Process.myPid(),
177 UserHandle.SYSTEM);
Winson41275482016-10-10 15:17:45 -0700178 addInputConsumer(name, consumer);
179 return consumer;
180 }
181
Winson Chung6463c362017-09-25 16:23:26 -0700182 void createInputConsumer(IBinder token, String name, InputChannel inputChannel, int clientPid,
183 UserHandle clientUser) {
Winson41275482016-10-10 15:17:45 -0700184 if (mInputConsumers.containsKey(name)) {
185 throw new IllegalStateException("Existing input consumer found with name: " + name);
186 }
187
Winson Chung6463c362017-09-25 16:23:26 -0700188 final InputConsumerImpl consumer = new InputConsumerImpl(mService, token, name,
189 inputChannel, clientPid, clientUser);
Winson41275482016-10-10 15:17:45 -0700190 switch (name) {
191 case INPUT_CONSUMER_WALLPAPER:
192 consumer.mWindowHandle.hasWallpaper = true;
193 break;
194 case INPUT_CONSUMER_PIP:
195 // The touchable region of the Pip input window is cropped to the bounds of the
196 // stack, and we need FLAG_NOT_TOUCH_MODAL to ensure other events fall through
Wale Ogunwalef7cab102016-10-25 15:25:14 -0700197 consumer.mWindowHandle.layoutParamsFlags |= FLAG_NOT_TOUCH_MODAL;
Winson41275482016-10-10 15:17:45 -0700198 break;
199 }
200 addInputConsumer(name, consumer);
201 }
202
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800203 /* Notifies the window manager about a broken input channel.
Chong Zhang8e89b312015-09-09 15:09:30 -0700204 *
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800205 * Called by the InputManager.
206 */
Craig Mautner4cd0c13f2013-04-16 15:55:52 -0700207 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800208 public void notifyInputChannelBroken(InputWindowHandle inputWindowHandle) {
209 if (inputWindowHandle == null) {
210 return;
211 }
212
213 synchronized (mService.mWindowMap) {
214 WindowState windowState = (WindowState) inputWindowHandle.windowState;
Jeff Brown9302c872011-07-13 22:51:29 -0700215 if (windowState != null) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800216 Slog.i(TAG_WM, "WINDOW DIED " + windowState);
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700217 windowState.removeIfPossible();
Jeff Brown9302c872011-07-13 22:51:29 -0700218 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800219 }
220 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700221
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800222 /* Notifies the window manager about an application that is not responding.
223 * Returns a new timeout to continue waiting in nanoseconds, or 0 to abort dispatch.
Chong Zhang8e89b312015-09-09 15:09:30 -0700224 *
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800225 * Called by the InputManager.
226 */
Craig Mautner4cd0c13f2013-04-16 15:55:52 -0700227 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800228 public long notifyANR(InputApplicationHandle inputApplicationHandle,
Jeff Brownbd181bb2013-09-10 16:44:24 -0700229 InputWindowHandle inputWindowHandle, String reason) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800230 AppWindowToken appWindowToken = null;
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -0700231 WindowState windowState = null;
232 boolean aboveSystem = false;
Jeff Brownee172412012-06-18 12:58:03 -0700233 synchronized (mService.mWindowMap) {
Jeff Brownee172412012-06-18 12:58:03 -0700234 if (inputWindowHandle != null) {
235 windowState = (WindowState) inputWindowHandle.windowState;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800236 if (windowState != null) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800237 appWindowToken = windowState.mAppToken;
238 }
239 }
Jeff Brownee172412012-06-18 12:58:03 -0700240 if (appWindowToken == null && inputApplicationHandle != null) {
241 appWindowToken = (AppWindowToken)inputApplicationHandle.appWindowToken;
Jeff Brown9302c872011-07-13 22:51:29 -0700242 }
Jeff Brownee172412012-06-18 12:58:03 -0700243
244 if (windowState != null) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800245 Slog.i(TAG_WM, "Input event dispatching timed out "
Jeff Brownbd181bb2013-09-10 16:44:24 -0700246 + "sending to " + windowState.mAttrs.getTitle()
247 + ". Reason: " + reason);
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -0700248 // Figure out whether this window is layered above system windows.
249 // We need to do this here to help the activity manager know how to
250 // layer its ANR dialog.
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800251 int systemAlertLayer = mService.mPolicy.getWindowLayerFromTypeLw(
252 TYPE_APPLICATION_OVERLAY, windowState.mOwnerCanAddInternalSystemWindow);
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -0700253 aboveSystem = windowState.mBaseLayer > systemAlertLayer;
Jeff Brownee172412012-06-18 12:58:03 -0700254 } else if (appWindowToken != null) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800255 Slog.i(TAG_WM, "Input event dispatching timed out "
Jeff Brownbd181bb2013-09-10 16:44:24 -0700256 + "sending to application " + appWindowToken.stringName
257 + ". Reason: " + reason);
Jeff Brownee172412012-06-18 12:58:03 -0700258 } else {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800259 Slog.i(TAG_WM, "Input event dispatching timed out "
Jeff Brownbd181bb2013-09-10 16:44:24 -0700260 + ". Reason: " + reason);
Jeff Brownee172412012-06-18 12:58:03 -0700261 }
262
Jeff Brownbd181bb2013-09-10 16:44:24 -0700263 mService.saveANRStateLocked(appWindowToken, windowState, reason);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800264 }
265
Wale Ogunwalef1285912017-06-09 15:20:29 -0700266 // All the calls below need to happen without the WM lock held since they call into AM.
267 mService.mAmInternal.saveANRState(reason);
268
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800269 if (appWindowToken != null && appWindowToken.appToken != null) {
Wale Ogunwale26c0dfe2016-12-14 14:42:30 -0800270 // Notify the activity manager about the timeout and let it decide whether
271 // to abort dispatching or keep waiting.
272 final AppWindowContainerController controller = appWindowToken.getController();
Wale Ogunwale7402ddf2017-03-29 12:58:24 -0700273 final boolean abort = controller != null
Brian Carlstrom7b0f2e82017-03-31 00:24:18 -0700274 && controller.keyDispatchingTimedOut(reason,
275 (windowState != null) ? windowState.mSession.mPid : -1);
Wale Ogunwale26c0dfe2016-12-14 14:42:30 -0800276 if (!abort) {
277 // The activity manager declined to abort dispatching.
278 // Wait a bit longer and timeout again later.
279 return appWindowToken.mInputDispatchingTimeoutNanos;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800280 }
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -0700281 } else if (windowState != null) {
282 try {
283 // Notify the activity manager about the timeout and let it decide whether
284 // to abort dispatching or keep waiting.
Sudheer Shankadc589ac2016-11-10 15:30:17 -0800285 long timeout = ActivityManager.getService().inputDispatchingTimedOut(
Jeff Brownbd181bb2013-09-10 16:44:24 -0700286 windowState.mSession.mPid, aboveSystem, reason);
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -0700287 if (timeout >= 0) {
288 // The activity manager declined to abort dispatching.
289 // Wait a bit longer and timeout again later.
baik.handef340d2015-04-15 10:21:05 +0900290 return timeout * 1000000L; // nanoseconds
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -0700291 }
292 } catch (RemoteException ex) {
293 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800294 }
295 return 0; // abort dispatching
296 }
297
Wale Ogunwale7402ddf2017-03-29 12:58:24 -0700298 private void addInputWindowHandle(final InputWindowHandle windowHandle) {
Jeff Brown9302c872011-07-13 22:51:29 -0700299 if (mInputWindowHandles == null) {
300 mInputWindowHandles = new InputWindowHandle[16];
301 }
302 if (mInputWindowHandleCount >= mInputWindowHandles.length) {
303 mInputWindowHandles = Arrays.copyOf(mInputWindowHandles,
304 mInputWindowHandleCount * 2);
305 }
306 mInputWindowHandles[mInputWindowHandleCount++] = windowHandle;
307 }
308
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700309 void addInputWindowHandle(final InputWindowHandle inputWindowHandle,
Craig Mautnerc08eab82014-11-11 09:03:59 -0800310 final WindowState child, int flags, final int type, final boolean isVisible,
Wale Ogunwale053c8e42015-11-16 14:27:21 -0800311 final boolean hasFocus, final boolean hasWallpaper) {
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700312 // Add a window to our list of input windows.
313 inputWindowHandle.name = child.toString();
Wale Ogunwale053c8e42015-11-16 14:27:21 -0800314 flags = child.getTouchableRegion(inputWindowHandle.touchableRegion, flags);
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700315 inputWindowHandle.layoutParamsFlags = flags;
316 inputWindowHandle.layoutParamsType = type;
317 inputWindowHandle.dispatchingTimeoutNanos = child.getInputDispatchingTimeoutNanos();
318 inputWindowHandle.visible = isVisible;
319 inputWindowHandle.canReceiveKeys = child.canReceiveKeys();
320 inputWindowHandle.hasFocus = hasFocus;
321 inputWindowHandle.hasWallpaper = hasWallpaper;
322 inputWindowHandle.paused = child.mAppToken != null ? child.mAppToken.paused : false;
323 inputWindowHandle.layer = child.mLayer;
324 inputWindowHandle.ownerPid = child.mSession.mPid;
325 inputWindowHandle.ownerUid = child.mSession.mUid;
326 inputWindowHandle.inputFeatures = child.mAttrs.inputFeatures;
327
328 final Rect frame = child.mFrame;
329 inputWindowHandle.frameLeft = frame.left;
330 inputWindowHandle.frameTop = frame.top;
331 inputWindowHandle.frameRight = frame.right;
332 inputWindowHandle.frameBottom = frame.bottom;
333
334 if (child.mGlobalScale != 1) {
335 // If we are scaling the window, input coordinates need
336 // to be inversely scaled to map from what is on screen
337 // to what is actually being touched in the UI.
338 inputWindowHandle.scaleFactor = 1.0f/child.mGlobalScale;
339 } else {
340 inputWindowHandle.scaleFactor = 1;
341 }
342
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700343 if (DEBUG_INPUT) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800344 Slog.d(TAG_WM, "addInputWindowHandle: "
Chong Zhangb15758a2015-11-17 12:12:03 -0800345 + child + ", " + inputWindowHandle);
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700346 }
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700347 addInputWindowHandle(inputWindowHandle);
Vladislav Kaznacheev3787de12016-12-21 10:36:35 -0800348 if (hasFocus) {
349 mFocusedInputWindowHandle = inputWindowHandle;
350 }
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700351 }
352
Jeff Brown9302c872011-07-13 22:51:29 -0700353 private void clearInputWindowHandlesLw() {
354 while (mInputWindowHandleCount != 0) {
355 mInputWindowHandles[--mInputWindowHandleCount] = null;
356 }
Vladislav Kaznacheev3787de12016-12-21 10:36:35 -0800357 mFocusedInputWindowHandle = null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800358 }
359
Wale Ogunwale6213caa2016-12-02 16:47:15 +0000360 void setUpdateInputWindowsNeededLw() {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800361 mUpdateInputWindowsNeeded = true;
362 }
363
364 /* Updates the cached window information provided to the input dispatcher. */
Wale Ogunwale6213caa2016-12-02 16:47:15 +0000365 void updateInputWindowsLw(boolean force) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800366 if (!force && !mUpdateInputWindowsNeeded) {
367 return;
368 }
369 mUpdateInputWindowsNeeded = false;
370
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800371 if (false) Slog.d(TAG_WM, ">>>>>> ENTERED updateInputWindowsLw");
Jeff Brown9302c872011-07-13 22:51:29 -0700372
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800373 // Populate the input window list with information about all of the windows that
374 // could potentially receive input.
375 // As an optimization, we could try to prune the list of windows but this turns
376 // out to be difficult because only the native code knows for sure which window
377 // currently has touch focus.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800378
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700379 // If there's a drag in flight, provide a pseudo-window to catch drag input
Daichi Hirono76a26aa2017-09-11 15:13:38 +0900380 final boolean inDrag = mService.mDragDropController.dragDropActiveLocked();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800381 if (inDrag) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800382 if (DEBUG_DRAG) {
383 Log.d(TAG_WM, "Inserting drag window");
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800384 }
Daichi Hirono76a26aa2017-09-11 15:13:38 +0900385 final InputWindowHandle dragWindowHandle =
Daichi Hirono768012e2017-10-30 10:05:37 +0900386 mService.mDragDropController.getInputWindowHandleLocked();
Jeff Browncc4f7db2011-08-30 20:34:48 -0700387 if (dragWindowHandle != null) {
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700388 addInputWindowHandle(dragWindowHandle);
Jeff Browncc4f7db2011-08-30 20:34:48 -0700389 } else {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800390 Slog.w(TAG_WM, "Drag is in progress but there is no "
Jeff Browncc4f7db2011-08-30 20:34:48 -0700391 + "drag window handle.");
392 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800393 }
394
Daichi Hirono34fb7312017-12-04 10:00:24 +0900395 final boolean inPositioning = mService.mTaskPositioningController.isPositioningLocked();
Chong Zhang8e89b312015-09-09 15:09:30 -0700396 if (inPositioning) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800397 if (DEBUG_TASK_POSITIONING) {
398 Log.d(TAG_WM, "Inserting window handle for repositioning");
Chong Zhang8e89b312015-09-09 15:09:30 -0700399 }
Daichi Hirono34fb7312017-12-04 10:00:24 +0900400 final InputWindowHandle dragWindowHandle =
401 mService.mTaskPositioningController.getDragWindowHandleLocked();
Chong Zhang8e89b312015-09-09 15:09:30 -0700402 if (dragWindowHandle != null) {
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700403 addInputWindowHandle(dragWindowHandle);
Chong Zhang8e89b312015-09-09 15:09:30 -0700404 } else {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800405 Slog.e(TAG_WM,
Chong Zhang8e89b312015-09-09 15:09:30 -0700406 "Repositioning is in progress but there is no drag window handle.");
407 }
408 }
409
Jeff Brown83d616a2012-09-09 20:33:43 -0700410 // Add all windows on the default display.
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800411 mUpdateInputForAllWindowsConsumer.updateInputWindows(inDrag);
Wale Ogunwale6213caa2016-12-02 16:47:15 +0000412
413 if (false) Slog.d(TAG_WM, "<<<<<<< EXITED updateInputWindowsLw");
414 }
415
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800416 /* Notifies that the input device configuration has changed. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700417 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800418 public void notifyConfigurationChanged() {
Andrii Kulian5406e7a2016-10-21 11:55:23 -0700419 // TODO(multi-display): Notify proper displays that are associated with this input device.
420 mService.sendNewConfiguration(DEFAULT_DISPLAY);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800421
422 synchronized (mInputDevicesReadyMonitor) {
423 if (!mInputDevicesReady) {
424 mInputDevicesReady = true;
425 mInputDevicesReadyMonitor.notifyAll();
426 }
427 }
428 }
429
430 /* Waits until the built-in input devices have been configured. */
431 public boolean waitForInputDevicesReady(long timeoutMillis) {
432 synchronized (mInputDevicesReadyMonitor) {
433 if (!mInputDevicesReady) {
434 try {
435 mInputDevicesReadyMonitor.wait(timeoutMillis);
436 } catch (InterruptedException ex) {
437 }
438 }
439 return mInputDevicesReady;
440 }
441 }
442
443 /* Notifies that the lid switch changed state. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700444 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800445 public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) {
446 mService.mPolicy.notifyLidSwitchChanged(whenNanos, lidOpen);
447 }
Craig Mautner58458122013-09-14 14:59:50 -0700448
Michael Wright3818c922014-09-02 13:59:07 -0700449 /* Notifies that the camera lens cover state has changed. */
450 @Override
451 public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered) {
452 mService.mPolicy.notifyCameraLensCoverSwitchChanged(whenNanos, lensCovered);
453 }
454
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800455 /* Provides an opportunity for the window manager policy to intercept early key
456 * processing as soon as the key has been read from the device. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700457 @Override
Jeff Brown037c33e2014-04-09 00:31:55 -0700458 public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) {
459 return mService.mPolicy.interceptKeyBeforeQueueing(event, policyFlags);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800460 }
Jeff Brown56194eb2011-03-02 19:23:13 -0800461
Michael Wright70af00a2014-09-03 19:30:20 -0700462 /* Provides an opportunity for the window manager policy to intercept early motion event
463 * processing when the device is in a non-interactive state since these events are normally
Jeff Brown56194eb2011-03-02 19:23:13 -0800464 * dropped. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700465 @Override
Michael Wright70af00a2014-09-03 19:30:20 -0700466 public int interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags) {
467 return mService.mPolicy.interceptMotionBeforeQueueingNonInteractive(
468 whenNanos, policyFlags);
Jeff Brown56194eb2011-03-02 19:23:13 -0800469 }
470
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800471 /* Provides an opportunity for the window manager policy to process a key before
472 * ordinary dispatch. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700473 @Override
Jeff Brown905805a2011-10-12 13:57:59 -0700474 public long interceptKeyBeforeDispatching(
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800475 InputWindowHandle focus, KeyEvent event, int policyFlags) {
476 WindowState windowState = focus != null ? (WindowState) focus.windowState : null;
477 return mService.mPolicy.interceptKeyBeforeDispatching(windowState, event, policyFlags);
478 }
Craig Mautner58458122013-09-14 14:59:50 -0700479
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800480 /* Provides an opportunity for the window manager policy to process a key that
481 * the application did not handle. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700482 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800483 public KeyEvent dispatchUnhandledKey(
484 InputWindowHandle focus, KeyEvent event, int policyFlags) {
485 WindowState windowState = focus != null ? (WindowState) focus.windowState : null;
486 return mService.mPolicy.dispatchUnhandledKey(windowState, event, policyFlags);
487 }
Jeff Brown4532e612012-04-05 14:27:12 -0700488
489 /* Callback to get pointer layer. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700490 @Override
Jeff Brown4532e612012-04-05 14:27:12 -0700491 public int getPointerLayer() {
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800492 return mService.mPolicy.getWindowLayerFromTypeLw(WindowManager.LayoutParams.TYPE_POINTER)
Jeff Brown4532e612012-04-05 14:27:12 -0700493 * WindowManagerService.TYPE_LAYER_MULTIPLIER
494 + WindowManagerService.TYPE_LAYER_OFFSET;
495 }
496
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800497 /* Called when the current input focus changes.
498 * Layer assignment is assumed to be complete by the time this is called.
499 */
500 public void setInputFocusLw(WindowState newWindow, boolean updateInputWindows) {
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700501 if (DEBUG_FOCUS_LIGHT || DEBUG_INPUT) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800502 Slog.d(TAG_WM, "Input focus has changed to " + newWindow);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800503 }
504
505 if (newWindow != mInputFocus) {
506 if (newWindow != null && newWindow.canReceiveKeys()) {
507 // Displaying a window implicitly causes dispatching to be unpaused.
508 // This is to protect against bugs if someone pauses dispatching but
509 // forgets to resume.
510 newWindow.mToken.paused = false;
511 }
512
513 mInputFocus = newWindow;
514 setUpdateInputWindowsNeededLw();
515
516 if (updateInputWindows) {
517 updateInputWindowsLw(false /*force*/);
518 }
519 }
520 }
Craig Mautner58458122013-09-14 14:59:50 -0700521
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800522 public void setFocusedAppLw(AppWindowToken newApp) {
523 // Focused app has changed.
524 if (newApp == null) {
525 mService.mInputManager.setFocusedApplication(null);
526 } else {
Jeff Brown9302c872011-07-13 22:51:29 -0700527 final InputApplicationHandle handle = newApp.mInputApplicationHandle;
528 handle.name = newApp.toString();
Wale Ogunwale72919d22016-12-08 18:58:50 -0800529 handle.dispatchingTimeoutNanos = newApp.mInputDispatchingTimeoutNanos;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800530
Jeff Brown9302c872011-07-13 22:51:29 -0700531 mService.mInputManager.setFocusedApplication(handle);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800532 }
533 }
Craig Mautner58458122013-09-14 14:59:50 -0700534
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800535 public void pauseDispatchingLw(WindowToken window) {
536 if (! window.paused) {
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700537 if (DEBUG_INPUT) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800538 Slog.v(TAG_WM, "Pausing WindowToken " + window);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800539 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700540
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800541 window.paused = true;
542 updateInputWindowsLw(true /*force*/);
543 }
544 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700545
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800546 public void resumeDispatchingLw(WindowToken window) {
547 if (window.paused) {
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700548 if (DEBUG_INPUT) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800549 Slog.v(TAG_WM, "Resuming WindowToken " + window);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800550 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700551
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800552 window.paused = false;
553 updateInputWindowsLw(true /*force*/);
554 }
555 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700556
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800557 public void freezeInputDispatchingLw() {
Wale Ogunwalee89eeac2016-03-12 11:07:58 -0800558 if (!mInputDispatchFrozen) {
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700559 if (DEBUG_INPUT) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800560 Slog.v(TAG_WM, "Freezing input dispatching");
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800561 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700562
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800563 mInputDispatchFrozen = true;
Wale Ogunwalee89eeac2016-03-12 11:07:58 -0800564
565 if (DEBUG_INPUT || true) {
566 mInputFreezeReason = Debug.getCallers(6);
567 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800568 updateInputDispatchModeLw();
569 }
570 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700571
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800572 public void thawInputDispatchingLw() {
573 if (mInputDispatchFrozen) {
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700574 if (DEBUG_INPUT) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800575 Slog.v(TAG_WM, "Thawing input dispatching");
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800576 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700577
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800578 mInputDispatchFrozen = false;
Wale Ogunwalee89eeac2016-03-12 11:07:58 -0800579 mInputFreezeReason = null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800580 updateInputDispatchModeLw();
581 }
582 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700583
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800584 public void setEventDispatchingLw(boolean enabled) {
585 if (mInputDispatchEnabled != enabled) {
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700586 if (DEBUG_INPUT) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800587 Slog.v(TAG_WM, "Setting event dispatching to " + enabled);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800588 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700589
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800590 mInputDispatchEnabled = enabled;
591 updateInputDispatchModeLw();
592 }
593 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700594
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800595 private void updateInputDispatchModeLw() {
596 mService.mInputManager.setInputDispatchMode(mInputDispatchEnabled, mInputDispatchFrozen);
597 }
Wale Ogunwalee89eeac2016-03-12 11:07:58 -0800598
599 void dump(PrintWriter pw, String prefix) {
600 if (mInputFreezeReason != null) {
601 pw.println(prefix + "mInputFreezeReason=" + mInputFreezeReason);
602 }
Winson Chung853c99a2017-03-21 22:16:42 -0700603 final Set<String> inputConsumerKeys = mInputConsumers.keySet();
604 if (!inputConsumerKeys.isEmpty()) {
605 pw.println(prefix + "InputConsumers:");
606 for (String key : inputConsumerKeys) {
Winson Chung6463c362017-09-25 16:23:26 -0700607 mInputConsumers.get(key).dump(pw, key, prefix);
Winson Chung853c99a2017-03-21 22:16:42 -0700608 }
609 }
Wale Ogunwalee89eeac2016-03-12 11:07:58 -0800610 }
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800611
612 private final class UpdateInputForAllWindowsConsumer implements Consumer<WindowState> {
613
614 InputConsumerImpl navInputConsumer;
615 InputConsumerImpl pipInputConsumer;
616 InputConsumerImpl wallpaperInputConsumer;
Winson Chunga89ffed2018-01-25 17:46:11 +0000617 InputConsumerImpl recentsAnimationInputConsumer;
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800618 boolean inDrag;
619 WallpaperController wallpaperController;
620
621 private void updateInputWindows(boolean inDrag) {
622
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800623 // TODO: multi-display
624 navInputConsumer = getInputConsumer(INPUT_CONSUMER_NAVIGATION, DEFAULT_DISPLAY);
625 pipInputConsumer = getInputConsumer(INPUT_CONSUMER_PIP, DEFAULT_DISPLAY);
626 wallpaperInputConsumer = getInputConsumer(INPUT_CONSUMER_WALLPAPER, DEFAULT_DISPLAY);
Winson Chunga89ffed2018-01-25 17:46:11 +0000627 recentsAnimationInputConsumer = getInputConsumer(INPUT_CONSUMER_RECENTS_ANIMATION,
628 DEFAULT_DISPLAY);
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800629 mAddInputConsumerHandle = navInputConsumer != null;
630 mAddPipInputConsumerHandle = pipInputConsumer != null;
631 mAddWallpaperInputConsumerHandle = wallpaperInputConsumer != null;
Winson Chunga89ffed2018-01-25 17:46:11 +0000632 mAddRecentsAnimationInputConsumerHandle = recentsAnimationInputConsumer != null;
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800633 mTmpRect.setEmpty();
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800634 mDisableWallpaperTouchEvents = false;
635 this.inDrag = inDrag;
636 wallpaperController = mService.mRoot.mWallpaperController;
637
638 mService.mRoot.forAllWindows(this, true /* traverseTopToBottom */);
639 if (mAddWallpaperInputConsumerHandle) {
640 // No visible wallpaper found, add the wallpaper input consumer at the end.
641 addInputWindowHandle(wallpaperInputConsumer.mWindowHandle);
642 }
643
644 // Send windows to native code.
Vladislav Kaznacheev3787de12016-12-21 10:36:35 -0800645 mService.mInputManager.setInputWindows(mInputWindowHandles, mFocusedInputWindowHandle);
Vladislav Kaznacheev2e96c632016-12-13 14:31:24 -0800646
647 clearInputWindowHandlesLw();
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800648 }
649
650 @Override
651 public void accept(WindowState w) {
652 final InputChannel inputChannel = w.mInputChannel;
653 final InputWindowHandle inputWindowHandle = w.mInputWindowHandle;
654 if (inputChannel == null || inputWindowHandle == null || w.mRemoved
Matthew Nge15352e2016-12-20 15:36:29 -0800655 || w.canReceiveTouchInput()) {
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800656 // Skip this window because it cannot possibly receive input.
657 return;
658 }
659
Winson Chung61ecc1b2017-02-17 10:46:17 -0800660 final int flags = w.mAttrs.flags;
661 final int privateFlags = w.mAttrs.privateFlags;
662 final int type = w.mAttrs.type;
663 final boolean hasFocus = w == mInputFocus;
664 final boolean isVisible = w.isVisibleLw();
665
Winson Chunga89ffed2018-01-25 17:46:11 +0000666 if (mAddRecentsAnimationInputConsumerHandle) {
667 final RecentsAnimationController recentsAnimationController =
668 mService.getRecentsAnimationController();
669 if (recentsAnimationController != null
670 && recentsAnimationController.hasInputConsumerForApp(w.mAppToken)) {
671 if (recentsAnimationController.updateInputConsumerForApp(
672 recentsAnimationInputConsumer, hasFocus)) {
673 addInputWindowHandle(recentsAnimationInputConsumer.mWindowHandle);
674 mAddRecentsAnimationInputConsumerHandle = false;
675 }
676 // Skip adding the window below regardless of whether there is an input consumer
677 // to handle it
678 return;
679 }
680 }
681
Wale Ogunwale44f036f2017-09-29 05:09:09 -0700682 if (w.inPinnedWindowingMode()) {
Winson Chung61ecc1b2017-02-17 10:46:17 -0800683 if (mAddPipInputConsumerHandle
684 && (inputWindowHandle.layer <= pipInputConsumer.mWindowHandle.layer)) {
Bryce Leef3c6a472017-11-14 14:53:06 -0800685 // Update the bounds of the Pip input consumer to match the window bounds.
Winson Chunga89ffed2018-01-25 17:46:11 +0000686 w.getBounds(mTmpRect);
687 pipInputConsumer.mWindowHandle.touchableRegion.set(mTmpRect);
Winson Chung61ecc1b2017-02-17 10:46:17 -0800688 addInputWindowHandle(pipInputConsumer.mWindowHandle);
689 mAddPipInputConsumerHandle = false;
690 }
691 // TODO: Fix w.canReceiveTouchInput() to handle this case
692 if (!hasFocus) {
693 // Skip this pinned stack window if it does not have focus
694 return;
695 }
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800696 }
697
698 if (mAddInputConsumerHandle
699 && inputWindowHandle.layer <= navInputConsumer.mWindowHandle.layer) {
700 addInputWindowHandle(navInputConsumer.mWindowHandle);
701 mAddInputConsumerHandle = false;
702 }
703
704 if (mAddWallpaperInputConsumerHandle) {
705 if (w.mAttrs.type == TYPE_WALLPAPER && w.isVisibleLw()) {
706 // Add the wallpaper input consumer above the first visible wallpaper.
707 addInputWindowHandle(wallpaperInputConsumer.mWindowHandle);
708 mAddWallpaperInputConsumerHandle = false;
709 }
710 }
711
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800712 if ((privateFlags & PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS) != 0) {
713 mDisableWallpaperTouchEvents = true;
714 }
715 final boolean hasWallpaper = wallpaperController.isWallpaperTarget(w)
716 && (privateFlags & PRIVATE_FLAG_KEYGUARD) == 0
717 && !mDisableWallpaperTouchEvents;
718
719 // If there's a drag in progress and 'child' is a potential drop target,
720 // make sure it's been told about the drag
721 if (inDrag && isVisible && w.getDisplayContent().isDefaultDisplay) {
Daichi Hirono768012e2017-10-30 10:05:37 +0900722 mService.mDragDropController.sendDragStartedIfNeededLocked(w);
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800723 }
724
725 addInputWindowHandle(
726 inputWindowHandle, w, flags, type, isVisible, hasFocus, hasWallpaper);
727 }
728 }
Jeff Brownea426552011-07-18 16:53:48 -0700729}