blob: 8ab46518ed4dc344495f1974c5599605d75c5161 [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;
Jorim Jaggi60640512018-06-29 01:14:31 +020043import android.os.Trace;
Winson Chung6463c362017-09-25 16:23:26 -070044import android.os.UserHandle;
Winson41275482016-10-10 15:17:45 -070045import android.util.ArrayMap;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080046import android.util.Log;
47import android.util.Slog;
Jeff Browncc4f7db2011-08-30 20:34:48 -070048import android.view.InputChannel;
Winson41275482016-10-10 15:17:45 -070049import android.view.InputEventReceiver;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080050import android.view.KeyEvent;
51import android.view.WindowManager;
Wale Ogunwale1e129a42016-11-21 13:03:47 -080052
Selim Cinekf83e8242015-05-19 18:08:14 -070053import com.android.server.input.InputApplicationHandle;
54import com.android.server.input.InputManagerService;
55import com.android.server.input.InputWindowHandle;
Adrian Roose99bc052017-11-20 17:55:31 +010056import com.android.server.policy.WindowManagerPolicy;
Selim Cinekf83e8242015-05-19 18:08:14 -070057
Wale Ogunwalee89eeac2016-03-12 11:07:58 -080058import java.io.PrintWriter;
Jeff Brown9302c872011-07-13 22:51:29 -070059import java.util.Arrays;
Winson Chung853c99a2017-03-21 22:16:42 -070060import java.util.Set;
Wale Ogunwale1e129a42016-11-21 13:03:47 -080061import java.util.function.Consumer;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080062
Jeff Browna9d131c2012-09-20 16:48:17 -070063final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080064 private final WindowManagerService mService;
Selim Cinekf83e8242015-05-19 18:08:14 -070065
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080066 // Current window with input focus for keys and other non-touch events. May be null.
67 private WindowState mInputFocus;
Selim Cinekf83e8242015-05-19 18:08:14 -070068
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080069 // When true, prevents input dispatch from proceeding until set to false again.
70 private boolean mInputDispatchFrozen;
Selim Cinekf83e8242015-05-19 18:08:14 -070071
Wale Ogunwalee89eeac2016-03-12 11:07:58 -080072 // The reason the input is currently frozen or null if the input isn't frozen.
73 private String mInputFreezeReason = null;
74
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080075 // When true, input dispatch proceeds normally. Otherwise all events are dropped.
Jeff Brownc042ee22012-05-08 13:03:42 -070076 // Initially false, so that input does not get dispatched until boot is finished at
77 // which point the ActivityManager will enable dispatching.
78 private boolean mInputDispatchEnabled;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080079
80 // When true, need to call updateInputWindowsLw().
81 private boolean mUpdateInputWindowsNeeded = true;
82
Jeff Brown9302c872011-07-13 22:51:29 -070083 // Array of window handles to provide to the input dispatcher.
84 private InputWindowHandle[] mInputWindowHandles;
85 private int mInputWindowHandleCount;
Vladislav Kaznacheev3787de12016-12-21 10:36:35 -080086 private InputWindowHandle mFocusedInputWindowHandle;
87
Wale Ogunwale6213caa2016-12-02 16:47:15 +000088 private boolean mAddInputConsumerHandle;
89 private boolean mAddPipInputConsumerHandle;
90 private boolean mAddWallpaperInputConsumerHandle;
Winson Chunga89ffed2018-01-25 17:46:11 +000091 private boolean mAddRecentsAnimationInputConsumerHandle;
Wale Ogunwale6213caa2016-12-02 16:47:15 +000092 private boolean mDisableWallpaperTouchEvents;
Wale Ogunwale1e129a42016-11-21 13:03:47 -080093 private final Rect mTmpRect = new Rect();
94 private final UpdateInputForAllWindowsConsumer mUpdateInputForAllWindowsConsumer =
95 new UpdateInputForAllWindowsConsumer();
Jeff Brown9302c872011-07-13 22:51:29 -070096
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080097 // Set to true when the first input device configuration change notification
98 // is received to indicate that the input devices are ready.
99 private final Object mInputDevicesReadyMonitor = new Object();
100 private boolean mInputDevicesReady;
101
Winson41275482016-10-10 15:17:45 -0700102 /**
103 * The set of input consumer added to the window manager by name, which consumes input events
104 * for the windows below it.
105 */
106 private final ArrayMap<String, InputConsumerImpl> mInputConsumers = new ArrayMap();
107
108 private static final class EventReceiverInputConsumer extends InputConsumerImpl
109 implements WindowManagerPolicy.InputConsumer {
110 private InputMonitor mInputMonitor;
111 private final InputEventReceiver mInputEventReceiver;
112
113 EventReceiverInputConsumer(WindowManagerService service, InputMonitor monitor,
114 Looper looper, String name,
Winson Chung6463c362017-09-25 16:23:26 -0700115 InputEventReceiver.Factory inputEventReceiverFactory,
116 int clientPid, UserHandle clientUser) {
117 super(service, null /* token */, name, null /* inputChannel */, clientPid, clientUser);
Winson41275482016-10-10 15:17:45 -0700118 mInputMonitor = monitor;
119 mInputEventReceiver = inputEventReceiverFactory.createInputEventReceiver(
120 mClientChannel, looper);
121 }
122
123 @Override
124 public void dismiss() {
125 synchronized (mService.mWindowMap) {
126 if (mInputMonitor.destroyInputConsumer(mWindowHandle.name)) {
127 mInputEventReceiver.dispose();
128 }
129 }
130 }
131 }
132
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800133 public InputMonitor(WindowManagerService service) {
134 mService = service;
135 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700136
Wale Ogunwalef7cab102016-10-25 15:25:14 -0700137 private void addInputConsumer(String name, InputConsumerImpl consumer) {
Winson41275482016-10-10 15:17:45 -0700138 mInputConsumers.put(name, consumer);
Winson Chung6463c362017-09-25 16:23:26 -0700139 consumer.linkToDeathRecipient();
Winson41275482016-10-10 15:17:45 -0700140 updateInputWindowsLw(true /* force */);
141 }
142
143 boolean destroyInputConsumer(String name) {
144 if (disposeInputConsumer(mInputConsumers.remove(name))) {
145 updateInputWindowsLw(true /* force */);
146 return true;
147 }
148 return false;
149 }
150
151 private boolean disposeInputConsumer(InputConsumerImpl consumer) {
152 if (consumer != null) {
153 consumer.disposeChannelsLw();
154 return true;
155 }
156 return false;
157 }
158
Wale Ogunwalef7cab102016-10-25 15:25:14 -0700159 InputConsumerImpl getInputConsumer(String name, int displayId) {
160 // TODO(multi-display): Allow input consumers on non-default displays?
161 return (displayId == DEFAULT_DISPLAY) ? mInputConsumers.get(name) : null;
Winson41275482016-10-10 15:17:45 -0700162 }
163
164 void layoutInputConsumers(int dw, int dh) {
165 for (int i = mInputConsumers.size() - 1; i >= 0; i--) {
166 mInputConsumers.valueAt(i).layout(dw, dh);
167 }
168 }
169
170 WindowManagerPolicy.InputConsumer createInputConsumer(Looper looper, String name,
171 InputEventReceiver.Factory inputEventReceiverFactory) {
172 if (mInputConsumers.containsKey(name)) {
173 throw new IllegalStateException("Existing input consumer found with name: " + name);
174 }
175
176 final EventReceiverInputConsumer consumer = new EventReceiverInputConsumer(mService,
Winson Chung6463c362017-09-25 16:23:26 -0700177 this, looper, name, inputEventReceiverFactory, Process.myPid(),
178 UserHandle.SYSTEM);
Winson41275482016-10-10 15:17:45 -0700179 addInputConsumer(name, consumer);
180 return consumer;
181 }
182
Winson Chung6463c362017-09-25 16:23:26 -0700183 void createInputConsumer(IBinder token, String name, InputChannel inputChannel, int clientPid,
184 UserHandle clientUser) {
Winson41275482016-10-10 15:17:45 -0700185 if (mInputConsumers.containsKey(name)) {
186 throw new IllegalStateException("Existing input consumer found with name: " + name);
187 }
188
Winson Chung6463c362017-09-25 16:23:26 -0700189 final InputConsumerImpl consumer = new InputConsumerImpl(mService, token, name,
190 inputChannel, clientPid, clientUser);
Winson41275482016-10-10 15:17:45 -0700191 switch (name) {
192 case INPUT_CONSUMER_WALLPAPER:
193 consumer.mWindowHandle.hasWallpaper = true;
194 break;
195 case INPUT_CONSUMER_PIP:
196 // The touchable region of the Pip input window is cropped to the bounds of the
197 // stack, and we need FLAG_NOT_TOUCH_MODAL to ensure other events fall through
Wale Ogunwalef7cab102016-10-25 15:25:14 -0700198 consumer.mWindowHandle.layoutParamsFlags |= FLAG_NOT_TOUCH_MODAL;
Winson41275482016-10-10 15:17:45 -0700199 break;
200 }
201 addInputConsumer(name, consumer);
202 }
203
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800204 /* Notifies the window manager about a broken input channel.
Chong Zhang8e89b312015-09-09 15:09:30 -0700205 *
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800206 * Called by the InputManager.
207 */
Craig Mautner4cd0c13f2013-04-16 15:55:52 -0700208 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800209 public void notifyInputChannelBroken(InputWindowHandle inputWindowHandle) {
210 if (inputWindowHandle == null) {
211 return;
212 }
213
214 synchronized (mService.mWindowMap) {
215 WindowState windowState = (WindowState) inputWindowHandle.windowState;
Jeff Brown9302c872011-07-13 22:51:29 -0700216 if (windowState != null) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800217 Slog.i(TAG_WM, "WINDOW DIED " + windowState);
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700218 windowState.removeIfPossible();
Jeff Brown9302c872011-07-13 22:51:29 -0700219 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800220 }
221 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700222
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800223 /* Notifies the window manager about an application that is not responding.
224 * Returns a new timeout to continue waiting in nanoseconds, or 0 to abort dispatch.
Chong Zhang8e89b312015-09-09 15:09:30 -0700225 *
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800226 * Called by the InputManager.
227 */
Craig Mautner4cd0c13f2013-04-16 15:55:52 -0700228 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800229 public long notifyANR(InputApplicationHandle inputApplicationHandle,
Jeff Brownbd181bb2013-09-10 16:44:24 -0700230 InputWindowHandle inputWindowHandle, String reason) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800231 AppWindowToken appWindowToken = null;
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -0700232 WindowState windowState = null;
233 boolean aboveSystem = false;
Jeff Brownee172412012-06-18 12:58:03 -0700234 synchronized (mService.mWindowMap) {
Jeff Brownee172412012-06-18 12:58:03 -0700235 if (inputWindowHandle != null) {
236 windowState = (WindowState) inputWindowHandle.windowState;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800237 if (windowState != null) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800238 appWindowToken = windowState.mAppToken;
239 }
240 }
Jeff Brownee172412012-06-18 12:58:03 -0700241 if (appWindowToken == null && inputApplicationHandle != null) {
242 appWindowToken = (AppWindowToken)inputApplicationHandle.appWindowToken;
Jeff Brown9302c872011-07-13 22:51:29 -0700243 }
Jeff Brownee172412012-06-18 12:58:03 -0700244
245 if (windowState != null) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800246 Slog.i(TAG_WM, "Input event dispatching timed out "
Jeff Brownbd181bb2013-09-10 16:44:24 -0700247 + "sending to " + windowState.mAttrs.getTitle()
248 + ". Reason: " + reason);
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -0700249 // Figure out whether this window is layered above system windows.
250 // We need to do this here to help the activity manager know how to
251 // layer its ANR dialog.
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800252 int systemAlertLayer = mService.mPolicy.getWindowLayerFromTypeLw(
253 TYPE_APPLICATION_OVERLAY, windowState.mOwnerCanAddInternalSystemWindow);
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -0700254 aboveSystem = windowState.mBaseLayer > systemAlertLayer;
Jeff Brownee172412012-06-18 12:58:03 -0700255 } else if (appWindowToken != null) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800256 Slog.i(TAG_WM, "Input event dispatching timed out "
Jeff Brownbd181bb2013-09-10 16:44:24 -0700257 + "sending to application " + appWindowToken.stringName
258 + ". Reason: " + reason);
Jeff Brownee172412012-06-18 12:58:03 -0700259 } else {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800260 Slog.i(TAG_WM, "Input event dispatching timed out "
Jeff Brownbd181bb2013-09-10 16:44:24 -0700261 + ". Reason: " + reason);
Jeff Brownee172412012-06-18 12:58:03 -0700262 }
263
Jeff Brownbd181bb2013-09-10 16:44:24 -0700264 mService.saveANRStateLocked(appWindowToken, windowState, reason);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800265 }
266
Wale Ogunwalef1285912017-06-09 15:20:29 -0700267 // All the calls below need to happen without the WM lock held since they call into AM.
268 mService.mAmInternal.saveANRState(reason);
269
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800270 if (appWindowToken != null && appWindowToken.appToken != null) {
Wale Ogunwale26c0dfe2016-12-14 14:42:30 -0800271 // Notify the activity manager about the timeout and let it decide whether
272 // to abort dispatching or keep waiting.
273 final AppWindowContainerController controller = appWindowToken.getController();
Wale Ogunwale7402ddf2017-03-29 12:58:24 -0700274 final boolean abort = controller != null
Brian Carlstrom7b0f2e82017-03-31 00:24:18 -0700275 && controller.keyDispatchingTimedOut(reason,
276 (windowState != null) ? windowState.mSession.mPid : -1);
Wale Ogunwale26c0dfe2016-12-14 14:42:30 -0800277 if (!abort) {
278 // The activity manager declined to abort dispatching.
279 // Wait a bit longer and timeout again later.
280 return appWindowToken.mInputDispatchingTimeoutNanos;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800281 }
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -0700282 } else if (windowState != null) {
283 try {
284 // Notify the activity manager about the timeout and let it decide whether
285 // to abort dispatching or keep waiting.
Sudheer Shankadc589ac2016-11-10 15:30:17 -0800286 long timeout = ActivityManager.getService().inputDispatchingTimedOut(
Jeff Brownbd181bb2013-09-10 16:44:24 -0700287 windowState.mSession.mPid, aboveSystem, reason);
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -0700288 if (timeout >= 0) {
289 // The activity manager declined to abort dispatching.
290 // Wait a bit longer and timeout again later.
baik.handef340d2015-04-15 10:21:05 +0900291 return timeout * 1000000L; // nanoseconds
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -0700292 }
293 } catch (RemoteException ex) {
294 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800295 }
296 return 0; // abort dispatching
297 }
298
Wale Ogunwale7402ddf2017-03-29 12:58:24 -0700299 private void addInputWindowHandle(final InputWindowHandle windowHandle) {
Jeff Brown9302c872011-07-13 22:51:29 -0700300 if (mInputWindowHandles == null) {
301 mInputWindowHandles = new InputWindowHandle[16];
302 }
303 if (mInputWindowHandleCount >= mInputWindowHandles.length) {
304 mInputWindowHandles = Arrays.copyOf(mInputWindowHandles,
305 mInputWindowHandleCount * 2);
306 }
307 mInputWindowHandles[mInputWindowHandleCount++] = windowHandle;
308 }
309
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700310 void addInputWindowHandle(final InputWindowHandle inputWindowHandle,
Craig Mautnerc08eab82014-11-11 09:03:59 -0800311 final WindowState child, int flags, final int type, final boolean isVisible,
Wale Ogunwale053c8e42015-11-16 14:27:21 -0800312 final boolean hasFocus, final boolean hasWallpaper) {
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700313 // Add a window to our list of input windows.
314 inputWindowHandle.name = child.toString();
Wale Ogunwale053c8e42015-11-16 14:27:21 -0800315 flags = child.getTouchableRegion(inputWindowHandle.touchableRegion, flags);
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700316 inputWindowHandle.layoutParamsFlags = flags;
317 inputWindowHandle.layoutParamsType = type;
318 inputWindowHandle.dispatchingTimeoutNanos = child.getInputDispatchingTimeoutNanos();
319 inputWindowHandle.visible = isVisible;
320 inputWindowHandle.canReceiveKeys = child.canReceiveKeys();
321 inputWindowHandle.hasFocus = hasFocus;
322 inputWindowHandle.hasWallpaper = hasWallpaper;
323 inputWindowHandle.paused = child.mAppToken != null ? child.mAppToken.paused : false;
324 inputWindowHandle.layer = child.mLayer;
325 inputWindowHandle.ownerPid = child.mSession.mPid;
326 inputWindowHandle.ownerUid = child.mSession.mUid;
327 inputWindowHandle.inputFeatures = child.mAttrs.inputFeatures;
328
chaviw492139a2018-07-16 16:07:35 -0700329 final Rect frame = child.getFrameLw();
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700330 inputWindowHandle.frameLeft = frame.left;
331 inputWindowHandle.frameTop = frame.top;
332 inputWindowHandle.frameRight = frame.right;
333 inputWindowHandle.frameBottom = frame.bottom;
334
335 if (child.mGlobalScale != 1) {
336 // If we are scaling the window, input coordinates need
337 // to be inversely scaled to map from what is on screen
338 // to what is actually being touched in the UI.
339 inputWindowHandle.scaleFactor = 1.0f/child.mGlobalScale;
340 } else {
341 inputWindowHandle.scaleFactor = 1;
342 }
343
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700344 if (DEBUG_INPUT) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800345 Slog.d(TAG_WM, "addInputWindowHandle: "
Chong Zhangb15758a2015-11-17 12:12:03 -0800346 + child + ", " + inputWindowHandle);
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700347 }
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700348 addInputWindowHandle(inputWindowHandle);
Vladislav Kaznacheev3787de12016-12-21 10:36:35 -0800349 if (hasFocus) {
350 mFocusedInputWindowHandle = inputWindowHandle;
351 }
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700352 }
353
Jeff Brown9302c872011-07-13 22:51:29 -0700354 private void clearInputWindowHandlesLw() {
355 while (mInputWindowHandleCount != 0) {
356 mInputWindowHandles[--mInputWindowHandleCount] = null;
357 }
Vladislav Kaznacheev3787de12016-12-21 10:36:35 -0800358 mFocusedInputWindowHandle = null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800359 }
360
Wale Ogunwale6213caa2016-12-02 16:47:15 +0000361 void setUpdateInputWindowsNeededLw() {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800362 mUpdateInputWindowsNeeded = true;
363 }
364
365 /* Updates the cached window information provided to the input dispatcher. */
Wale Ogunwale6213caa2016-12-02 16:47:15 +0000366 void updateInputWindowsLw(boolean force) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800367 if (!force && !mUpdateInputWindowsNeeded) {
368 return;
369 }
370 mUpdateInputWindowsNeeded = false;
371
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800372 if (false) Slog.d(TAG_WM, ">>>>>> ENTERED updateInputWindowsLw");
Jeff Brown9302c872011-07-13 22:51:29 -0700373
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800374 // Populate the input window list with information about all of the windows that
375 // could potentially receive input.
376 // As an optimization, we could try to prune the list of windows but this turns
377 // out to be difficult because only the native code knows for sure which window
378 // currently has touch focus.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800379
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700380 // If there's a drag in flight, provide a pseudo-window to catch drag input
Daichi Hirono76a26aa2017-09-11 15:13:38 +0900381 final boolean inDrag = mService.mDragDropController.dragDropActiveLocked();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800382 if (inDrag) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800383 if (DEBUG_DRAG) {
384 Log.d(TAG_WM, "Inserting drag window");
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800385 }
Daichi Hirono76a26aa2017-09-11 15:13:38 +0900386 final InputWindowHandle dragWindowHandle =
Daichi Hirono768012e2017-10-30 10:05:37 +0900387 mService.mDragDropController.getInputWindowHandleLocked();
Jeff Browncc4f7db2011-08-30 20:34:48 -0700388 if (dragWindowHandle != null) {
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700389 addInputWindowHandle(dragWindowHandle);
Jeff Browncc4f7db2011-08-30 20:34:48 -0700390 } else {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800391 Slog.w(TAG_WM, "Drag is in progress but there is no "
Jeff Browncc4f7db2011-08-30 20:34:48 -0700392 + "drag window handle.");
393 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800394 }
395
Daichi Hirono34fb7312017-12-04 10:00:24 +0900396 final boolean inPositioning = mService.mTaskPositioningController.isPositioningLocked();
Chong Zhang8e89b312015-09-09 15:09:30 -0700397 if (inPositioning) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800398 if (DEBUG_TASK_POSITIONING) {
399 Log.d(TAG_WM, "Inserting window handle for repositioning");
Chong Zhang8e89b312015-09-09 15:09:30 -0700400 }
Daichi Hirono34fb7312017-12-04 10:00:24 +0900401 final InputWindowHandle dragWindowHandle =
402 mService.mTaskPositioningController.getDragWindowHandleLocked();
Chong Zhang8e89b312015-09-09 15:09:30 -0700403 if (dragWindowHandle != null) {
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700404 addInputWindowHandle(dragWindowHandle);
Chong Zhang8e89b312015-09-09 15:09:30 -0700405 } else {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800406 Slog.e(TAG_WM,
Chong Zhang8e89b312015-09-09 15:09:30 -0700407 "Repositioning is in progress but there is no drag window handle.");
408 }
409 }
410
Jeff Brown83d616a2012-09-09 20:33:43 -0700411 // Add all windows on the default display.
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800412 mUpdateInputForAllWindowsConsumer.updateInputWindows(inDrag);
Wale Ogunwale6213caa2016-12-02 16:47:15 +0000413
414 if (false) Slog.d(TAG_WM, "<<<<<<< EXITED updateInputWindowsLw");
415 }
416
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800417 /* Notifies that the input device configuration has changed. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700418 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800419 public void notifyConfigurationChanged() {
Andrii Kulian5406e7a2016-10-21 11:55:23 -0700420 // TODO(multi-display): Notify proper displays that are associated with this input device.
421 mService.sendNewConfiguration(DEFAULT_DISPLAY);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800422
423 synchronized (mInputDevicesReadyMonitor) {
424 if (!mInputDevicesReady) {
425 mInputDevicesReady = true;
426 mInputDevicesReadyMonitor.notifyAll();
427 }
428 }
429 }
430
431 /* Waits until the built-in input devices have been configured. */
432 public boolean waitForInputDevicesReady(long timeoutMillis) {
433 synchronized (mInputDevicesReadyMonitor) {
434 if (!mInputDevicesReady) {
435 try {
436 mInputDevicesReadyMonitor.wait(timeoutMillis);
437 } catch (InterruptedException ex) {
438 }
439 }
440 return mInputDevicesReady;
441 }
442 }
443
444 /* Notifies that the lid switch changed state. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700445 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800446 public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) {
447 mService.mPolicy.notifyLidSwitchChanged(whenNanos, lidOpen);
448 }
Craig Mautner58458122013-09-14 14:59:50 -0700449
Michael Wright3818c922014-09-02 13:59:07 -0700450 /* Notifies that the camera lens cover state has changed. */
451 @Override
452 public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered) {
453 mService.mPolicy.notifyCameraLensCoverSwitchChanged(whenNanos, lensCovered);
454 }
455
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800456 /* Provides an opportunity for the window manager policy to intercept early key
457 * processing as soon as the key has been read from the device. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700458 @Override
Jeff Brown037c33e2014-04-09 00:31:55 -0700459 public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) {
460 return mService.mPolicy.interceptKeyBeforeQueueing(event, policyFlags);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800461 }
Jeff Brown56194eb2011-03-02 19:23:13 -0800462
Michael Wright70af00a2014-09-03 19:30:20 -0700463 /* Provides an opportunity for the window manager policy to intercept early motion event
464 * processing when the device is in a non-interactive state since these events are normally
Jeff Brown56194eb2011-03-02 19:23:13 -0800465 * dropped. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700466 @Override
Michael Wright70af00a2014-09-03 19:30:20 -0700467 public int interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags) {
468 return mService.mPolicy.interceptMotionBeforeQueueingNonInteractive(
469 whenNanos, policyFlags);
Jeff Brown56194eb2011-03-02 19:23:13 -0800470 }
471
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800472 /* Provides an opportunity for the window manager policy to process a key before
473 * ordinary dispatch. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700474 @Override
Jeff Brown905805a2011-10-12 13:57:59 -0700475 public long interceptKeyBeforeDispatching(
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800476 InputWindowHandle focus, KeyEvent event, int policyFlags) {
477 WindowState windowState = focus != null ? (WindowState) focus.windowState : null;
478 return mService.mPolicy.interceptKeyBeforeDispatching(windowState, event, policyFlags);
479 }
Craig Mautner58458122013-09-14 14:59:50 -0700480
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800481 /* Provides an opportunity for the window manager policy to process a key that
482 * the application did not handle. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700483 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800484 public KeyEvent dispatchUnhandledKey(
485 InputWindowHandle focus, KeyEvent event, int policyFlags) {
486 WindowState windowState = focus != null ? (WindowState) focus.windowState : null;
487 return mService.mPolicy.dispatchUnhandledKey(windowState, event, policyFlags);
488 }
Jeff Brown4532e612012-04-05 14:27:12 -0700489
490 /* Callback to get pointer layer. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700491 @Override
Jeff Brown4532e612012-04-05 14:27:12 -0700492 public int getPointerLayer() {
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800493 return mService.mPolicy.getWindowLayerFromTypeLw(WindowManager.LayoutParams.TYPE_POINTER)
Jeff Brown4532e612012-04-05 14:27:12 -0700494 * WindowManagerService.TYPE_LAYER_MULTIPLIER
495 + WindowManagerService.TYPE_LAYER_OFFSET;
496 }
497
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800498 /* Called when the current input focus changes.
499 * Layer assignment is assumed to be complete by the time this is called.
500 */
501 public void setInputFocusLw(WindowState newWindow, boolean updateInputWindows) {
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700502 if (DEBUG_FOCUS_LIGHT || DEBUG_INPUT) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800503 Slog.d(TAG_WM, "Input focus has changed to " + newWindow);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800504 }
505
506 if (newWindow != mInputFocus) {
507 if (newWindow != null && newWindow.canReceiveKeys()) {
508 // Displaying a window implicitly causes dispatching to be unpaused.
509 // This is to protect against bugs if someone pauses dispatching but
510 // forgets to resume.
511 newWindow.mToken.paused = false;
512 }
513
514 mInputFocus = newWindow;
515 setUpdateInputWindowsNeededLw();
516
517 if (updateInputWindows) {
518 updateInputWindowsLw(false /*force*/);
519 }
520 }
521 }
Craig Mautner58458122013-09-14 14:59:50 -0700522
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800523 public void setFocusedAppLw(AppWindowToken newApp) {
524 // Focused app has changed.
525 if (newApp == null) {
526 mService.mInputManager.setFocusedApplication(null);
527 } else {
Jeff Brown9302c872011-07-13 22:51:29 -0700528 final InputApplicationHandle handle = newApp.mInputApplicationHandle;
529 handle.name = newApp.toString();
Wale Ogunwale72919d22016-12-08 18:58:50 -0800530 handle.dispatchingTimeoutNanos = newApp.mInputDispatchingTimeoutNanos;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800531
Jeff Brown9302c872011-07-13 22:51:29 -0700532 mService.mInputManager.setFocusedApplication(handle);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800533 }
534 }
Craig Mautner58458122013-09-14 14:59:50 -0700535
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800536 public void pauseDispatchingLw(WindowToken window) {
537 if (! window.paused) {
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700538 if (DEBUG_INPUT) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800539 Slog.v(TAG_WM, "Pausing WindowToken " + window);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800540 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700541
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800542 window.paused = true;
543 updateInputWindowsLw(true /*force*/);
544 }
545 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700546
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800547 public void resumeDispatchingLw(WindowToken window) {
548 if (window.paused) {
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700549 if (DEBUG_INPUT) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800550 Slog.v(TAG_WM, "Resuming WindowToken " + window);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800551 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700552
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800553 window.paused = false;
554 updateInputWindowsLw(true /*force*/);
555 }
556 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700557
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800558 public void freezeInputDispatchingLw() {
Wale Ogunwalee89eeac2016-03-12 11:07:58 -0800559 if (!mInputDispatchFrozen) {
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700560 if (DEBUG_INPUT) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800561 Slog.v(TAG_WM, "Freezing input dispatching");
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800562 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700563
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800564 mInputDispatchFrozen = true;
Wale Ogunwalee89eeac2016-03-12 11:07:58 -0800565
566 if (DEBUG_INPUT || true) {
567 mInputFreezeReason = Debug.getCallers(6);
568 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800569 updateInputDispatchModeLw();
570 }
571 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700572
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800573 public void thawInputDispatchingLw() {
574 if (mInputDispatchFrozen) {
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700575 if (DEBUG_INPUT) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800576 Slog.v(TAG_WM, "Thawing input dispatching");
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800577 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700578
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800579 mInputDispatchFrozen = false;
Wale Ogunwalee89eeac2016-03-12 11:07:58 -0800580 mInputFreezeReason = null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800581 updateInputDispatchModeLw();
582 }
583 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700584
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800585 public void setEventDispatchingLw(boolean enabled) {
586 if (mInputDispatchEnabled != enabled) {
Filip Gruszczynskif8a2a632015-10-28 11:18:02 -0700587 if (DEBUG_INPUT) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800588 Slog.v(TAG_WM, "Setting event dispatching to " + enabled);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800589 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700590
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800591 mInputDispatchEnabled = enabled;
592 updateInputDispatchModeLw();
593 }
594 }
Chong Zhang8e89b312015-09-09 15:09:30 -0700595
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800596 private void updateInputDispatchModeLw() {
597 mService.mInputManager.setInputDispatchMode(mInputDispatchEnabled, mInputDispatchFrozen);
598 }
Wale Ogunwalee89eeac2016-03-12 11:07:58 -0800599
600 void dump(PrintWriter pw, String prefix) {
601 if (mInputFreezeReason != null) {
602 pw.println(prefix + "mInputFreezeReason=" + mInputFreezeReason);
603 }
Winson Chung853c99a2017-03-21 22:16:42 -0700604 final Set<String> inputConsumerKeys = mInputConsumers.keySet();
605 if (!inputConsumerKeys.isEmpty()) {
606 pw.println(prefix + "InputConsumers:");
607 for (String key : inputConsumerKeys) {
Winson Chung6463c362017-09-25 16:23:26 -0700608 mInputConsumers.get(key).dump(pw, key, prefix);
Winson Chung853c99a2017-03-21 22:16:42 -0700609 }
610 }
Wale Ogunwalee89eeac2016-03-12 11:07:58 -0800611 }
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800612
613 private final class UpdateInputForAllWindowsConsumer implements Consumer<WindowState> {
614
615 InputConsumerImpl navInputConsumer;
616 InputConsumerImpl pipInputConsumer;
617 InputConsumerImpl wallpaperInputConsumer;
Winson Chunga89ffed2018-01-25 17:46:11 +0000618 InputConsumerImpl recentsAnimationInputConsumer;
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800619 boolean inDrag;
620 WallpaperController wallpaperController;
621
622 private void updateInputWindows(boolean inDrag) {
623
Jorim Jaggi60640512018-06-29 01:14:31 +0200624 Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "updateInputWindows");
625
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800626 // TODO: multi-display
627 navInputConsumer = getInputConsumer(INPUT_CONSUMER_NAVIGATION, DEFAULT_DISPLAY);
628 pipInputConsumer = getInputConsumer(INPUT_CONSUMER_PIP, DEFAULT_DISPLAY);
629 wallpaperInputConsumer = getInputConsumer(INPUT_CONSUMER_WALLPAPER, DEFAULT_DISPLAY);
Winson Chunga89ffed2018-01-25 17:46:11 +0000630 recentsAnimationInputConsumer = getInputConsumer(INPUT_CONSUMER_RECENTS_ANIMATION,
631 DEFAULT_DISPLAY);
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800632 mAddInputConsumerHandle = navInputConsumer != null;
633 mAddPipInputConsumerHandle = pipInputConsumer != null;
634 mAddWallpaperInputConsumerHandle = wallpaperInputConsumer != null;
Winson Chunga89ffed2018-01-25 17:46:11 +0000635 mAddRecentsAnimationInputConsumerHandle = recentsAnimationInputConsumer != null;
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800636 mTmpRect.setEmpty();
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800637 mDisableWallpaperTouchEvents = false;
638 this.inDrag = inDrag;
639 wallpaperController = mService.mRoot.mWallpaperController;
640
641 mService.mRoot.forAllWindows(this, true /* traverseTopToBottom */);
642 if (mAddWallpaperInputConsumerHandle) {
643 // No visible wallpaper found, add the wallpaper input consumer at the end.
644 addInputWindowHandle(wallpaperInputConsumer.mWindowHandle);
645 }
646
647 // Send windows to native code.
Vladislav Kaznacheev3787de12016-12-21 10:36:35 -0800648 mService.mInputManager.setInputWindows(mInputWindowHandles, mFocusedInputWindowHandle);
Vladislav Kaznacheev2e96c632016-12-13 14:31:24 -0800649
650 clearInputWindowHandlesLw();
Jorim Jaggi60640512018-06-29 01:14:31 +0200651
652 Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800653 }
654
655 @Override
656 public void accept(WindowState w) {
657 final InputChannel inputChannel = w.mInputChannel;
658 final InputWindowHandle inputWindowHandle = w.mInputWindowHandle;
659 if (inputChannel == null || inputWindowHandle == null || w.mRemoved
Matthew Nge15352e2016-12-20 15:36:29 -0800660 || w.canReceiveTouchInput()) {
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800661 // Skip this window because it cannot possibly receive input.
662 return;
663 }
664
Winson Chung61ecc1b2017-02-17 10:46:17 -0800665 final int flags = w.mAttrs.flags;
666 final int privateFlags = w.mAttrs.privateFlags;
667 final int type = w.mAttrs.type;
668 final boolean hasFocus = w == mInputFocus;
669 final boolean isVisible = w.isVisibleLw();
670
Winson Chunga89ffed2018-01-25 17:46:11 +0000671 if (mAddRecentsAnimationInputConsumerHandle) {
672 final RecentsAnimationController recentsAnimationController =
673 mService.getRecentsAnimationController();
674 if (recentsAnimationController != null
675 && recentsAnimationController.hasInputConsumerForApp(w.mAppToken)) {
676 if (recentsAnimationController.updateInputConsumerForApp(
677 recentsAnimationInputConsumer, hasFocus)) {
678 addInputWindowHandle(recentsAnimationInputConsumer.mWindowHandle);
679 mAddRecentsAnimationInputConsumerHandle = false;
680 }
681 // Skip adding the window below regardless of whether there is an input consumer
682 // to handle it
683 return;
684 }
685 }
686
Wale Ogunwale44f036f2017-09-29 05:09:09 -0700687 if (w.inPinnedWindowingMode()) {
Winson Chung61ecc1b2017-02-17 10:46:17 -0800688 if (mAddPipInputConsumerHandle
689 && (inputWindowHandle.layer <= pipInputConsumer.mWindowHandle.layer)) {
Bryce Leef3c6a472017-11-14 14:53:06 -0800690 // Update the bounds of the Pip input consumer to match the window bounds.
Winson Chunga89ffed2018-01-25 17:46:11 +0000691 w.getBounds(mTmpRect);
692 pipInputConsumer.mWindowHandle.touchableRegion.set(mTmpRect);
Winson Chung61ecc1b2017-02-17 10:46:17 -0800693 addInputWindowHandle(pipInputConsumer.mWindowHandle);
694 mAddPipInputConsumerHandle = false;
695 }
696 // TODO: Fix w.canReceiveTouchInput() to handle this case
697 if (!hasFocus) {
698 // Skip this pinned stack window if it does not have focus
699 return;
700 }
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800701 }
702
703 if (mAddInputConsumerHandle
704 && inputWindowHandle.layer <= navInputConsumer.mWindowHandle.layer) {
705 addInputWindowHandle(navInputConsumer.mWindowHandle);
706 mAddInputConsumerHandle = false;
707 }
708
709 if (mAddWallpaperInputConsumerHandle) {
710 if (w.mAttrs.type == TYPE_WALLPAPER && w.isVisibleLw()) {
711 // Add the wallpaper input consumer above the first visible wallpaper.
712 addInputWindowHandle(wallpaperInputConsumer.mWindowHandle);
713 mAddWallpaperInputConsumerHandle = false;
714 }
715 }
716
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800717 if ((privateFlags & PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS) != 0) {
718 mDisableWallpaperTouchEvents = true;
719 }
720 final boolean hasWallpaper = wallpaperController.isWallpaperTarget(w)
721 && (privateFlags & PRIVATE_FLAG_KEYGUARD) == 0
722 && !mDisableWallpaperTouchEvents;
723
724 // If there's a drag in progress and 'child' is a potential drop target,
725 // make sure it's been told about the drag
726 if (inDrag && isVisible && w.getDisplayContent().isDefaultDisplay) {
Daichi Hirono768012e2017-10-30 10:05:37 +0900727 mService.mDragDropController.sendDragStartedIfNeededLocked(w);
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800728 }
729
730 addInputWindowHandle(
731 inputWindowHandle, w, flags, type, isVisible, hasFocus, hasWallpaper);
732 }
733 }
Jeff Brownea426552011-07-18 16:53:48 -0700734}