blob: ea3af26349edd974320ecdde51b827023b69a5ff [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
Jeff Brown4532e612012-04-05 14:27:12 -070019import com.android.server.input.InputManagerService;
20import com.android.server.input.InputApplicationHandle;
21import com.android.server.input.InputWindowHandle;
22
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -070023import android.app.ActivityManagerNative;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080024import android.graphics.Rect;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080025import android.os.RemoteException;
26import android.util.Log;
27import android.util.Slog;
Jeff Brown83d616a2012-09-09 20:33:43 -070028import android.view.Display;
Jeff Browncc4f7db2011-08-30 20:34:48 -070029import android.view.InputChannel;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080030import android.view.KeyEvent;
31import android.view.WindowManager;
32
Jeff Brown9302c872011-07-13 22:51:29 -070033import java.util.Arrays;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080034
Jeff Browna9d131c2012-09-20 16:48:17 -070035final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080036 private final WindowManagerService mService;
37
38 // Current window with input focus for keys and other non-touch events. May be null.
39 private WindowState mInputFocus;
40
41 // When true, prevents input dispatch from proceeding until set to false again.
42 private boolean mInputDispatchFrozen;
43
44 // When true, input dispatch proceeds normally. Otherwise all events are dropped.
Jeff Brownc042ee22012-05-08 13:03:42 -070045 // Initially false, so that input does not get dispatched until boot is finished at
46 // which point the ActivityManager will enable dispatching.
47 private boolean mInputDispatchEnabled;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080048
49 // When true, need to call updateInputWindowsLw().
50 private boolean mUpdateInputWindowsNeeded = true;
51
Jeff Brown9302c872011-07-13 22:51:29 -070052 // Array of window handles to provide to the input dispatcher.
53 private InputWindowHandle[] mInputWindowHandles;
54 private int mInputWindowHandleCount;
55
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080056 // Set to true when the first input device configuration change notification
57 // is received to indicate that the input devices are ready.
58 private final Object mInputDevicesReadyMonitor = new Object();
59 private boolean mInputDevicesReady;
60
61 public InputMonitor(WindowManagerService service) {
62 mService = service;
63 }
64
65 /* Notifies the window manager about a broken input channel.
66 *
67 * Called by the InputManager.
68 */
Craig Mautner4cd0c13f2013-04-16 15:55:52 -070069 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080070 public void notifyInputChannelBroken(InputWindowHandle inputWindowHandle) {
71 if (inputWindowHandle == null) {
72 return;
73 }
74
75 synchronized (mService.mWindowMap) {
76 WindowState windowState = (WindowState) inputWindowHandle.windowState;
Jeff Brown9302c872011-07-13 22:51:29 -070077 if (windowState != null) {
78 Slog.i(WindowManagerService.TAG, "WINDOW DIED " + windowState);
79 mService.removeWindowLocked(windowState.mSession, windowState);
80 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080081 }
82 }
83
84 /* Notifies the window manager about an application that is not responding.
85 * Returns a new timeout to continue waiting in nanoseconds, or 0 to abort dispatch.
86 *
87 * Called by the InputManager.
88 */
Craig Mautner4cd0c13f2013-04-16 15:55:52 -070089 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080090 public long notifyANR(InputApplicationHandle inputApplicationHandle,
Jeff Brownbd181bb2013-09-10 16:44:24 -070091 InputWindowHandle inputWindowHandle, String reason) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080092 AppWindowToken appWindowToken = null;
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -070093 WindowState windowState = null;
94 boolean aboveSystem = false;
Jeff Brownee172412012-06-18 12:58:03 -070095 synchronized (mService.mWindowMap) {
Jeff Brownee172412012-06-18 12:58:03 -070096 if (inputWindowHandle != null) {
97 windowState = (WindowState) inputWindowHandle.windowState;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080098 if (windowState != null) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080099 appWindowToken = windowState.mAppToken;
100 }
101 }
Jeff Brownee172412012-06-18 12:58:03 -0700102 if (appWindowToken == null && inputApplicationHandle != null) {
103 appWindowToken = (AppWindowToken)inputApplicationHandle.appWindowToken;
Jeff Brown9302c872011-07-13 22:51:29 -0700104 }
Jeff Brownee172412012-06-18 12:58:03 -0700105
106 if (windowState != null) {
107 Slog.i(WindowManagerService.TAG, "Input event dispatching timed out "
Jeff Brownbd181bb2013-09-10 16:44:24 -0700108 + "sending to " + windowState.mAttrs.getTitle()
109 + ". Reason: " + reason);
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -0700110 // Figure out whether this window is layered above system windows.
111 // We need to do this here to help the activity manager know how to
112 // layer its ANR dialog.
113 int systemAlertLayer = mService.mPolicy.windowTypeToLayerLw(
114 WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
115 aboveSystem = windowState.mBaseLayer > systemAlertLayer;
Jeff Brownee172412012-06-18 12:58:03 -0700116 } else if (appWindowToken != null) {
117 Slog.i(WindowManagerService.TAG, "Input event dispatching timed out "
Jeff Brownbd181bb2013-09-10 16:44:24 -0700118 + "sending to application " + appWindowToken.stringName
119 + ". Reason: " + reason);
Jeff Brownee172412012-06-18 12:58:03 -0700120 } else {
Jeff Brownbd181bb2013-09-10 16:44:24 -0700121 Slog.i(WindowManagerService.TAG, "Input event dispatching timed out "
122 + ". Reason: " + reason);
Jeff Brownee172412012-06-18 12:58:03 -0700123 }
124
Jeff Brownbd181bb2013-09-10 16:44:24 -0700125 mService.saveANRStateLocked(appWindowToken, windowState, reason);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800126 }
127
128 if (appWindowToken != null && appWindowToken.appToken != null) {
129 try {
130 // Notify the activity manager about the timeout and let it decide whether
131 // to abort dispatching or keep waiting.
Jeff Brownbd181bb2013-09-10 16:44:24 -0700132 boolean abort = appWindowToken.appToken.keyDispatchingTimedOut(reason);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800133 if (! abort) {
134 // The activity manager declined to abort dispatching.
135 // Wait a bit longer and timeout again later.
136 return appWindowToken.inputDispatchingTimeoutNanos;
137 }
138 } catch (RemoteException ex) {
139 }
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -0700140 } else if (windowState != null) {
141 try {
142 // Notify the activity manager about the timeout and let it decide whether
143 // to abort dispatching or keep waiting.
144 long timeout = ActivityManagerNative.getDefault().inputDispatchingTimedOut(
Jeff Brownbd181bb2013-09-10 16:44:24 -0700145 windowState.mSession.mPid, aboveSystem, reason);
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -0700146 if (timeout >= 0) {
147 // The activity manager declined to abort dispatching.
148 // Wait a bit longer and timeout again later.
149 return timeout;
150 }
151 } catch (RemoteException ex) {
152 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800153 }
154 return 0; // abort dispatching
155 }
156
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700157 private void addInputWindowHandleLw(final InputWindowHandle windowHandle) {
Jeff Brown9302c872011-07-13 22:51:29 -0700158 if (mInputWindowHandles == null) {
159 mInputWindowHandles = new InputWindowHandle[16];
160 }
161 if (mInputWindowHandleCount >= mInputWindowHandles.length) {
162 mInputWindowHandles = Arrays.copyOf(mInputWindowHandles,
163 mInputWindowHandleCount * 2);
164 }
165 mInputWindowHandles[mInputWindowHandleCount++] = windowHandle;
166 }
167
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700168 private void addInputWindowHandleLw(final InputWindowHandle inputWindowHandle,
Craig Mautner4cd0c13f2013-04-16 15:55:52 -0700169 final WindowState child, int flags, final int type,
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700170 final boolean isVisible, final boolean hasFocus, final boolean hasWallpaper) {
171 // Add a window to our list of input windows.
172 inputWindowHandle.name = child.toString();
Craig Mautner4cd0c13f2013-04-16 15:55:52 -0700173 final boolean modal = (flags & (WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
174 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)) == 0;
175 if (modal && child.mAppToken != null) {
176 // Limit the outer touch to the activity stack region.
177 flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
178 inputWindowHandle.touchableRegion.set(child.getStackBounds());
179 } else {
180 // Not modal or full screen modal
181 child.getTouchableRegion(inputWindowHandle.touchableRegion);
182 }
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700183 inputWindowHandle.layoutParamsFlags = flags;
184 inputWindowHandle.layoutParamsType = type;
185 inputWindowHandle.dispatchingTimeoutNanos = child.getInputDispatchingTimeoutNanos();
186 inputWindowHandle.visible = isVisible;
187 inputWindowHandle.canReceiveKeys = child.canReceiveKeys();
188 inputWindowHandle.hasFocus = hasFocus;
189 inputWindowHandle.hasWallpaper = hasWallpaper;
190 inputWindowHandle.paused = child.mAppToken != null ? child.mAppToken.paused : false;
191 inputWindowHandle.layer = child.mLayer;
192 inputWindowHandle.ownerPid = child.mSession.mPid;
193 inputWindowHandle.ownerUid = child.mSession.mUid;
194 inputWindowHandle.inputFeatures = child.mAttrs.inputFeatures;
195
196 final Rect frame = child.mFrame;
197 inputWindowHandle.frameLeft = frame.left;
198 inputWindowHandle.frameTop = frame.top;
199 inputWindowHandle.frameRight = frame.right;
200 inputWindowHandle.frameBottom = frame.bottom;
201
202 if (child.mGlobalScale != 1) {
203 // If we are scaling the window, input coordinates need
204 // to be inversely scaled to map from what is on screen
205 // to what is actually being touched in the UI.
206 inputWindowHandle.scaleFactor = 1.0f/child.mGlobalScale;
207 } else {
208 inputWindowHandle.scaleFactor = 1;
209 }
210
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700211
212 addInputWindowHandleLw(inputWindowHandle);
213 }
214
Jeff Brown9302c872011-07-13 22:51:29 -0700215 private void clearInputWindowHandlesLw() {
216 while (mInputWindowHandleCount != 0) {
217 mInputWindowHandles[--mInputWindowHandleCount] = null;
218 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800219 }
220
221 public void setUpdateInputWindowsNeededLw() {
222 mUpdateInputWindowsNeeded = true;
223 }
224
225 /* Updates the cached window information provided to the input dispatcher. */
226 public void updateInputWindowsLw(boolean force) {
227 if (!force && !mUpdateInputWindowsNeeded) {
228 return;
229 }
230 mUpdateInputWindowsNeeded = false;
231
Dianne Hackbornb961cd22011-06-21 12:13:37 -0700232 if (false) Slog.d(WindowManagerService.TAG, ">>>>>> ENTERED updateInputWindowsLw");
Jeff Brown9302c872011-07-13 22:51:29 -0700233
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800234 // Populate the input window list with information about all of the windows that
235 // could potentially receive input.
236 // As an optimization, we could try to prune the list of windows but this turns
237 // out to be difficult because only the native code knows for sure which window
238 // currently has touch focus.
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700239 final WindowStateAnimator universeBackground = mService.mAnimator.mUniverseBackground;
240 final int aboveUniverseLayer = mService.mAnimator.mAboveUniverseLayer;
241 boolean addedUniverse = false;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800242
243 // If there's a drag in flight, provide a pseudowindow to catch drag input
244 final boolean inDrag = (mService.mDragState != null);
245 if (inDrag) {
246 if (WindowManagerService.DEBUG_DRAG) {
247 Log.d(WindowManagerService.TAG, "Inserting drag window");
248 }
Jeff Browncc4f7db2011-08-30 20:34:48 -0700249 final InputWindowHandle dragWindowHandle = mService.mDragState.mDragWindowHandle;
250 if (dragWindowHandle != null) {
251 addInputWindowHandleLw(dragWindowHandle);
252 } else {
253 Slog.w(WindowManagerService.TAG, "Drag is in progress but there is no "
254 + "drag window handle.");
255 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800256 }
257
Dianne Hackborndf89e652011-10-06 22:35:11 -0700258 final int NFW = mService.mFakeWindows.size();
259 for (int i = 0; i < NFW; i++) {
260 addInputWindowHandleLw(mService.mFakeWindows.get(i).mWindowHandle);
261 }
262
Jeff Brown83d616a2012-09-09 20:33:43 -0700263 // Add all windows on the default display.
Craig Mautnerf8924152013-07-16 09:10:55 -0700264 final int numDisplays = mService.mDisplayContents.size();
265 for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
266 WindowList windows = mService.mDisplayContents.valueAt(displayNdx).getWindowList();
267 for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
268 final WindowState child = windows.get(winNdx);
269 final InputChannel inputChannel = child.mInputChannel;
270 final InputWindowHandle inputWindowHandle = child.mInputWindowHandle;
271 if (inputChannel == null || inputWindowHandle == null || child.mRemoved) {
272 // Skip this window because it cannot possibly receive input.
273 continue;
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700274 }
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400275
Craig Mautnerf8924152013-07-16 09:10:55 -0700276 final int flags = child.mAttrs.flags;
277 final int type = child.mAttrs.type;
278
279 final boolean hasFocus = (child == mInputFocus);
280 final boolean isVisible = child.isVisibleLw();
281 final boolean hasWallpaper = (child == mService.mWallpaperTarget)
282 && (type != WindowManager.LayoutParams.TYPE_KEYGUARD);
283 final boolean onDefaultDisplay = (child.getDisplayId() == Display.DEFAULT_DISPLAY);
284
285 // If there's a drag in progress and 'child' is a potential drop target,
286 // make sure it's been told about the drag
287 if (inDrag && isVisible && onDefaultDisplay) {
288 mService.mDragState.sendDragStartedIfNeededLw(child);
289 }
290
291 if (universeBackground != null && !addedUniverse
292 && child.mBaseLayer < aboveUniverseLayer && onDefaultDisplay) {
293 final WindowState u = universeBackground.mWin;
294 if (u.mInputChannel != null && u.mInputWindowHandle != null) {
295 addInputWindowHandleLw(u.mInputWindowHandle, u, u.mAttrs.flags,
296 u.mAttrs.type, true, u == mInputFocus, false);
297 }
298 addedUniverse = true;
299 }
300
301 if (child.mWinAnimator != universeBackground) {
302 addInputWindowHandleLw(inputWindowHandle, child, flags, type,
303 isVisible, hasFocus, hasWallpaper);
304 }
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700305 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800306 }
307
308 // Send windows to native code.
Jeff Brown9302c872011-07-13 22:51:29 -0700309 mService.mInputManager.setInputWindows(mInputWindowHandles);
310
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800311 // Clear the list in preparation for the next round.
Jeff Brown9302c872011-07-13 22:51:29 -0700312 clearInputWindowHandlesLw();
313
Dianne Hackbornb961cd22011-06-21 12:13:37 -0700314 if (false) Slog.d(WindowManagerService.TAG, "<<<<<<< EXITED updateInputWindowsLw");
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800315 }
316
317 /* Notifies that the input device configuration has changed. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700318 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800319 public void notifyConfigurationChanged() {
320 mService.sendNewConfiguration();
321
322 synchronized (mInputDevicesReadyMonitor) {
323 if (!mInputDevicesReady) {
324 mInputDevicesReady = true;
325 mInputDevicesReadyMonitor.notifyAll();
326 }
327 }
328 }
329
330 /* Waits until the built-in input devices have been configured. */
331 public boolean waitForInputDevicesReady(long timeoutMillis) {
332 synchronized (mInputDevicesReadyMonitor) {
333 if (!mInputDevicesReady) {
334 try {
335 mInputDevicesReadyMonitor.wait(timeoutMillis);
336 } catch (InterruptedException ex) {
337 }
338 }
339 return mInputDevicesReady;
340 }
341 }
342
343 /* Notifies that the lid switch changed state. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700344 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800345 public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) {
346 mService.mPolicy.notifyLidSwitchChanged(whenNanos, lidOpen);
347 }
348
349 /* Provides an opportunity for the window manager policy to intercept early key
350 * processing as soon as the key has been read from the device. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700351 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800352 public int interceptKeyBeforeQueueing(
353 KeyEvent event, int policyFlags, boolean isScreenOn) {
354 return mService.mPolicy.interceptKeyBeforeQueueing(event, policyFlags, isScreenOn);
355 }
Jeff Brown56194eb2011-03-02 19:23:13 -0800356
357 /* Provides an opportunity for the window manager policy to intercept early
358 * motion event processing when the screen is off since these events are normally
359 * dropped. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700360 @Override
Jeff Brown56194eb2011-03-02 19:23:13 -0800361 public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags) {
362 return mService.mPolicy.interceptMotionBeforeQueueingWhenScreenOff(policyFlags);
363 }
364
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800365 /* Provides an opportunity for the window manager policy to process a key before
366 * ordinary dispatch. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700367 @Override
Jeff Brown905805a2011-10-12 13:57:59 -0700368 public long interceptKeyBeforeDispatching(
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800369 InputWindowHandle focus, KeyEvent event, int policyFlags) {
370 WindowState windowState = focus != null ? (WindowState) focus.windowState : null;
371 return mService.mPolicy.interceptKeyBeforeDispatching(windowState, event, policyFlags);
372 }
373
374 /* Provides an opportunity for the window manager policy to process a key that
375 * the application did not handle. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700376 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800377 public KeyEvent dispatchUnhandledKey(
378 InputWindowHandle focus, KeyEvent event, int policyFlags) {
379 WindowState windowState = focus != null ? (WindowState) focus.windowState : null;
380 return mService.mPolicy.dispatchUnhandledKey(windowState, event, policyFlags);
381 }
Jeff Brown4532e612012-04-05 14:27:12 -0700382
383 /* Callback to get pointer layer. */
Jeff Brown0b31d812013-08-22 19:41:29 -0700384 @Override
Jeff Brown4532e612012-04-05 14:27:12 -0700385 public int getPointerLayer() {
386 return mService.mPolicy.windowTypeToLayerLw(WindowManager.LayoutParams.TYPE_POINTER)
387 * WindowManagerService.TYPE_LAYER_MULTIPLIER
388 + WindowManagerService.TYPE_LAYER_OFFSET;
389 }
390
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800391 /* Called when the current input focus changes.
392 * Layer assignment is assumed to be complete by the time this is called.
393 */
394 public void setInputFocusLw(WindowState newWindow, boolean updateInputWindows) {
395 if (WindowManagerService.DEBUG_INPUT) {
396 Slog.d(WindowManagerService.TAG, "Input focus has changed to " + newWindow);
397 }
398
399 if (newWindow != mInputFocus) {
400 if (newWindow != null && newWindow.canReceiveKeys()) {
401 // Displaying a window implicitly causes dispatching to be unpaused.
402 // This is to protect against bugs if someone pauses dispatching but
403 // forgets to resume.
404 newWindow.mToken.paused = false;
405 }
406
407 mInputFocus = newWindow;
408 setUpdateInputWindowsNeededLw();
409
410 if (updateInputWindows) {
411 updateInputWindowsLw(false /*force*/);
412 }
413 }
414 }
415
416 public void setFocusedAppLw(AppWindowToken newApp) {
417 // Focused app has changed.
418 if (newApp == null) {
419 mService.mInputManager.setFocusedApplication(null);
420 } else {
Jeff Brown9302c872011-07-13 22:51:29 -0700421 final InputApplicationHandle handle = newApp.mInputApplicationHandle;
422 handle.name = newApp.toString();
423 handle.dispatchingTimeoutNanos = newApp.inputDispatchingTimeoutNanos;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800424
Jeff Brown9302c872011-07-13 22:51:29 -0700425 mService.mInputManager.setFocusedApplication(handle);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800426 }
427 }
428
429 public void pauseDispatchingLw(WindowToken window) {
430 if (! window.paused) {
431 if (WindowManagerService.DEBUG_INPUT) {
432 Slog.v(WindowManagerService.TAG, "Pausing WindowToken " + window);
433 }
434
435 window.paused = true;
436 updateInputWindowsLw(true /*force*/);
437 }
438 }
439
440 public void resumeDispatchingLw(WindowToken window) {
441 if (window.paused) {
442 if (WindowManagerService.DEBUG_INPUT) {
443 Slog.v(WindowManagerService.TAG, "Resuming WindowToken " + window);
444 }
445
446 window.paused = false;
447 updateInputWindowsLw(true /*force*/);
448 }
449 }
450
451 public void freezeInputDispatchingLw() {
452 if (! mInputDispatchFrozen) {
453 if (WindowManagerService.DEBUG_INPUT) {
454 Slog.v(WindowManagerService.TAG, "Freezing input dispatching");
455 }
456
457 mInputDispatchFrozen = true;
458 updateInputDispatchModeLw();
459 }
460 }
461
462 public void thawInputDispatchingLw() {
463 if (mInputDispatchFrozen) {
464 if (WindowManagerService.DEBUG_INPUT) {
465 Slog.v(WindowManagerService.TAG, "Thawing input dispatching");
466 }
467
468 mInputDispatchFrozen = false;
469 updateInputDispatchModeLw();
470 }
471 }
472
473 public void setEventDispatchingLw(boolean enabled) {
474 if (mInputDispatchEnabled != enabled) {
475 if (WindowManagerService.DEBUG_INPUT) {
476 Slog.v(WindowManagerService.TAG, "Setting event dispatching to " + enabled);
477 }
478
479 mInputDispatchEnabled = enabled;
480 updateInputDispatchModeLw();
481 }
482 }
483
484 private void updateInputDispatchModeLw() {
485 mService.mInputManager.setInputDispatchMode(mInputDispatchEnabled, mInputDispatchFrozen);
486 }
Jeff Brownea426552011-07-18 16:53:48 -0700487}