blob: 3ca4598a9cc56977bf13ec37ffd9a337e3a83a47 [file] [log] [blame]
Wale Ogunwalee8069dc2015-08-18 09:52:01 -07001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
15 */
16
17package com.android.server.wm;
18
Wale Ogunwale3797c222015-10-27 14:21:58 -070019import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -070020import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
21import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
22import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
23import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_SCRIM;
24import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
25import static com.android.server.wm.WindowManagerService.DEBUG_ADD_REMOVE;
26import static com.android.server.wm.WindowManagerService.DEBUG_APP_TRANSITIONS;
27import static com.android.server.wm.WindowManagerService.DEBUG_LAYERS;
28import static com.android.server.wm.WindowManagerService.DEBUG_WINDOW_MOVEMENT;
29import static com.android.server.wm.WindowManagerService.DEBUG_VISIBILITY;
30import static com.android.server.wm.WindowManagerService.DEBUG_WALLPAPER;
31import static com.android.server.wm.WindowManagerService.DEBUG_WALLPAPER_LIGHT;
32import static com.android.server.wm.WindowManagerService.H.WALLPAPER_DRAW_PENDING_TIMEOUT;
33import static com.android.server.wm.WindowManagerService.TYPE_LAYER_MULTIPLIER;
34import static com.android.server.wm.WindowManagerService.TYPE_LAYER_OFFSET;
35
36import android.os.Bundle;
37import android.os.Debug;
38import android.os.IBinder;
39import android.os.RemoteException;
40import android.os.SystemClock;
41import android.util.Slog;
42import android.view.DisplayInfo;
43import android.view.WindowManager;
44import android.view.WindowManagerPolicy;
45
46import java.io.PrintWriter;
47import java.util.ArrayList;
48
49/**
50 * Controls wallpaper windows visibility, ordering, and so on.
51 * NOTE: All methods in this class must be called with the window manager service lock held.
52 */
53class WallpaperController {
54 private static final String TAG = com.android.server.wm.WindowManagerService.TAG;
55 final private WindowManagerService mService;
56
57 private final ArrayList<WindowToken> mWallpaperTokens = new ArrayList<>();
58
59 // If non-null, this is the currently visible window that is associated
60 // with the wallpaper.
61 private WindowState mWallpaperTarget = null;
62 // If non-null, we are in the middle of animating from one wallpaper target
63 // to another, and this is the lower one in Z-order.
64 private WindowState mLowerWallpaperTarget = null;
65 // If non-null, we are in the middle of animating from one wallpaper target
66 // to another, and this is the higher one in Z-order.
67 private WindowState mUpperWallpaperTarget = null;
68
69 private int mWallpaperAnimLayerAdjustment;
70
71 private float mLastWallpaperX = -1;
72 private float mLastWallpaperY = -1;
73 private float mLastWallpaperXStep = -1;
74 private float mLastWallpaperYStep = -1;
75 private int mLastWallpaperDisplayOffsetX = Integer.MIN_VALUE;
76 private int mLastWallpaperDisplayOffsetY = Integer.MIN_VALUE;
77
78 // This is set when we are waiting for a wallpaper to tell us it is done
79 // changing its scroll position.
80 WindowState mWaitingOnWallpaper;
81
82 // The last time we had a timeout when waiting for a wallpaper.
83 private long mLastWallpaperTimeoutTime;
84 // We give a wallpaper up to 150ms to finish scrolling.
85 private static final long WALLPAPER_TIMEOUT = 150;
86 // Time we wait after a timeout before trying to wait again.
87 private static final long WALLPAPER_TIMEOUT_RECOVERY = 10000;
88
89 // Set to the wallpaper window we would like to hide once the transition animations are done.
90 // This is useful in cases where we don't want the wallpaper to be hidden when the close app
91 // is a wallpaper target and is done animating out, but the opening app isn't a wallpaper
92 // target and isn't done animating in.
93 private WindowState mDeferredHideWallpaper = null;
94
95 // We give a wallpaper up to 500ms to finish drawing before playing app transitions.
96 private static final long WALLPAPER_DRAW_PENDING_TIMEOUT_DURATION = 500;
97 private static final int WALLPAPER_DRAW_NORMAL = 0;
98 private static final int WALLPAPER_DRAW_PENDING = 1;
99 private static final int WALLPAPER_DRAW_TIMEOUT = 2;
100 private int mWallpaperDrawState = WALLPAPER_DRAW_NORMAL;
101
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700102 private final FindWallpaperTargetResult mFindResults = new FindWallpaperTargetResult();
103
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700104 public WallpaperController(WindowManagerService service) {
105 mService = service;
106 }
107
108 WindowState getWallpaperTarget() {
109 return mWallpaperTarget;
110 }
111
112 WindowState getLowerWallpaperTarget() {
113 return mLowerWallpaperTarget;
114 }
115
116 WindowState getUpperWallpaperTarget() {
117 return mUpperWallpaperTarget;
118 }
119
120 boolean isWallpaperTarget(WindowState win) {
121 return win == mWallpaperTarget;
122 }
123
124 boolean isBelowWallpaperTarget(WindowState win) {
125 return mWallpaperTarget != null && mWallpaperTarget.mLayer >= win.mBaseLayer;
126 }
127
128 boolean isWallpaperVisible() {
129 return isWallpaperVisible(mWallpaperTarget);
130 }
131
132 private boolean isWallpaperVisible(WindowState wallpaperTarget) {
133 if (DEBUG_WALLPAPER) Slog.v(TAG, "Wallpaper vis: target " + wallpaperTarget + ", obscured="
134 + (wallpaperTarget != null ? Boolean.toString(wallpaperTarget.mObscured) : "??")
135 + " anim=" + ((wallpaperTarget != null && wallpaperTarget.mAppToken != null)
136 ? wallpaperTarget.mAppToken.mAppAnimator.animation : null)
137 + " upper=" + mUpperWallpaperTarget
138 + " lower=" + mLowerWallpaperTarget);
139 return (wallpaperTarget != null
140 && (!wallpaperTarget.mObscured || (wallpaperTarget.mAppToken != null
141 && wallpaperTarget.mAppToken.mAppAnimator.animation != null)))
142 || mUpperWallpaperTarget != null
143 || mLowerWallpaperTarget != null;
144 }
145
146 boolean isWallpaperTargetAnimating() {
147 return mWallpaperTarget != null && mWallpaperTarget.mWinAnimator.isAnimating()
148 && !mWallpaperTarget.mWinAnimator.isDummyAnimation();
149 }
150
151 void updateWallpaperVisibility() {
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700152 final DisplayContent displayContent = mWallpaperTarget.getDisplayContent();
153 if (displayContent == null) {
154 return;
155 }
Filip Gruszczynski63a35e22015-11-05 15:38:59 -0800156 final boolean visible = isWallpaperVisible(mWallpaperTarget);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700157 final DisplayInfo displayInfo = displayContent.getDisplayInfo();
158 final int dw = displayInfo.logicalWidth;
159 final int dh = displayInfo.logicalHeight;
160
161 for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
162 WindowToken token = mWallpaperTokens.get(curTokenNdx);
163 if (token.hidden == visible) {
164 token.hidden = !visible;
165 // Need to do a layout to ensure the wallpaper now has the
166 // correct size.
167 displayContent.layoutNeeded = true;
168 }
169
170 final WindowList windows = token.windows;
171 for (int wallpaperNdx = windows.size() - 1; wallpaperNdx >= 0; wallpaperNdx--) {
172 WindowState wallpaper = windows.get(wallpaperNdx);
173 if (visible) {
174 updateWallpaperOffset(wallpaper, dw, dh, false);
175 }
176
177 dispatchWallpaperVisibility(wallpaper, visible);
178 }
179 }
180 }
181
182 void hideDeferredWallpapersIfNeeded() {
183 if (mDeferredHideWallpaper != null) {
184 hideWallpapers(mDeferredHideWallpaper);
185 mDeferredHideWallpaper = null;
186 }
187 }
188
189 void hideWallpapers(final WindowState winGoingAway) {
190 if (mWallpaperTarget != null
191 && (mWallpaperTarget != winGoingAway || mLowerWallpaperTarget != null)) {
192 return;
193 }
194 if (mService.mAppTransition.isRunning()) {
195 // Defer hiding the wallpaper when app transition is running until the animations
196 // are done.
197 mDeferredHideWallpaper = winGoingAway;
198 return;
199 }
200
201 final boolean wasDeferred = (mDeferredHideWallpaper == winGoingAway);
202 for (int i = mWallpaperTokens.size() - 1; i >= 0; i--) {
203 final WindowToken token = mWallpaperTokens.get(i);
204 for (int j = token.windows.size() - 1; j >= 0; j--) {
205 final WindowState wallpaper = token.windows.get(j);
206 final WindowStateAnimator winAnimator = wallpaper.mWinAnimator;
207 if (!winAnimator.mLastHidden || wasDeferred) {
Filip Gruszczynski63a35e22015-11-05 15:38:59 -0800208 winAnimator.hide("hideWallpapers");
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700209 dispatchWallpaperVisibility(wallpaper, false);
210 final DisplayContent displayContent = wallpaper.getDisplayContent();
211 if (displayContent != null) {
212 displayContent.pendingLayoutChanges |=
213 WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
214 }
215 }
216 }
217 if (DEBUG_WALLPAPER_LIGHT && !token.hidden) Slog.d(TAG, "Hiding wallpaper " + token
218 + " from " + winGoingAway + " target=" + mWallpaperTarget + " lower="
219 + mLowerWallpaperTarget + "\n" + Debug.getCallers(5, " "));
220 token.hidden = true;
221 }
222 }
223
224 /**
225 * Check wallpaper for visibility change and notify window if so.
226 * @param wallpaper The wallpaper to test and notify.
227 * @param visible Current visibility.
228 */
229 void dispatchWallpaperVisibility(final WindowState wallpaper, final boolean visible) {
230 // Only send notification if the visibility actually changed and we are not trying to hide
231 // the wallpaper when we are deferring hiding of the wallpaper.
232 if (wallpaper.mWallpaperVisible != visible
233 && (mDeferredHideWallpaper == null || visible)) {
234 wallpaper.mWallpaperVisible = visible;
235 try {
236 if (DEBUG_VISIBILITY || DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
237 "Updating vis of wallpaper " + wallpaper
238 + ": " + visible + " from:\n" + Debug.getCallers(4, " "));
239 wallpaper.mClient.dispatchAppVisibility(visible);
240 } catch (RemoteException e) {
241 }
242 }
243 }
244
245 boolean updateWallpaperOffset(WindowState wallpaperWin, int dw, int dh, boolean sync) {
246 boolean rawChanged = false;
247 float wpx = mLastWallpaperX >= 0 ? mLastWallpaperX : 0.5f;
248 float wpxs = mLastWallpaperXStep >= 0 ? mLastWallpaperXStep : -1.0f;
249 int availw = wallpaperWin.mFrame.right - wallpaperWin.mFrame.left - dw;
250 int offset = availw > 0 ? -(int)(availw * wpx + .5f) : 0;
251 if (mLastWallpaperDisplayOffsetX != Integer.MIN_VALUE) {
252 offset += mLastWallpaperDisplayOffsetX;
253 }
254 boolean changed = wallpaperWin.mXOffset != offset;
255 if (changed) {
256 if (DEBUG_WALLPAPER) Slog.v(TAG, "Update wallpaper " + wallpaperWin + " x: " + offset);
257 wallpaperWin.mXOffset = offset;
258 }
259 if (wallpaperWin.mWallpaperX != wpx || wallpaperWin.mWallpaperXStep != wpxs) {
260 wallpaperWin.mWallpaperX = wpx;
261 wallpaperWin.mWallpaperXStep = wpxs;
262 rawChanged = true;
263 }
264
265 float wpy = mLastWallpaperY >= 0 ? mLastWallpaperY : 0.5f;
266 float wpys = mLastWallpaperYStep >= 0 ? mLastWallpaperYStep : -1.0f;
267 int availh = wallpaperWin.mFrame.bottom - wallpaperWin.mFrame.top - dh;
268 offset = availh > 0 ? -(int)(availh * wpy + .5f) : 0;
269 if (mLastWallpaperDisplayOffsetY != Integer.MIN_VALUE) {
270 offset += mLastWallpaperDisplayOffsetY;
271 }
272 if (wallpaperWin.mYOffset != offset) {
273 if (DEBUG_WALLPAPER) Slog.v(TAG, "Update wallpaper " + wallpaperWin + " y: " + offset);
274 changed = true;
275 wallpaperWin.mYOffset = offset;
276 }
277 if (wallpaperWin.mWallpaperY != wpy || wallpaperWin.mWallpaperYStep != wpys) {
278 wallpaperWin.mWallpaperY = wpy;
279 wallpaperWin.mWallpaperYStep = wpys;
280 rawChanged = true;
281 }
282
283 if (rawChanged && (wallpaperWin.mAttrs.privateFlags &
284 WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS) != 0) {
285 try {
286 if (DEBUG_WALLPAPER) Slog.v(TAG, "Report new wp offset "
287 + wallpaperWin + " x=" + wallpaperWin.mWallpaperX
288 + " y=" + wallpaperWin.mWallpaperY);
289 if (sync) {
290 mWaitingOnWallpaper = wallpaperWin;
291 }
292 wallpaperWin.mClient.dispatchWallpaperOffsets(
293 wallpaperWin.mWallpaperX, wallpaperWin.mWallpaperY,
294 wallpaperWin.mWallpaperXStep, wallpaperWin.mWallpaperYStep, sync);
295 if (sync) {
296 if (mWaitingOnWallpaper != null) {
297 long start = SystemClock.uptimeMillis();
298 if ((mLastWallpaperTimeoutTime + WALLPAPER_TIMEOUT_RECOVERY)
299 < start) {
300 try {
301 if (DEBUG_WALLPAPER) Slog.v(TAG,
302 "Waiting for offset complete...");
303 mService.mWindowMap.wait(WALLPAPER_TIMEOUT);
304 } catch (InterruptedException e) {
305 }
306 if (DEBUG_WALLPAPER) Slog.v(TAG, "Offset complete!");
307 if ((start + WALLPAPER_TIMEOUT) < SystemClock.uptimeMillis()) {
308 Slog.i(TAG, "Timeout waiting for wallpaper to offset: "
309 + wallpaperWin);
310 mLastWallpaperTimeoutTime = start;
311 }
312 }
313 mWaitingOnWallpaper = null;
314 }
315 }
316 } catch (RemoteException e) {
317 }
318 }
319
320 return changed;
321 }
322
323 void setWindowWallpaperPosition(
324 WindowState window, float x, float y, float xStep, float yStep) {
325 if (window.mWallpaperX != x || window.mWallpaperY != y) {
326 window.mWallpaperX = x;
327 window.mWallpaperY = y;
328 window.mWallpaperXStep = xStep;
329 window.mWallpaperYStep = yStep;
330 updateWallpaperOffsetLocked(window, true);
331 }
332 }
333
334 void setWindowWallpaperDisplayOffset(WindowState window, int x, int y) {
335 if (window.mWallpaperDisplayOffsetX != x || window.mWallpaperDisplayOffsetY != y) {
336 window.mWallpaperDisplayOffsetX = x;
337 window.mWallpaperDisplayOffsetY = y;
338 updateWallpaperOffsetLocked(window, true);
339 }
340 }
341
342 Bundle sendWindowWallpaperCommand(
343 WindowState window, String action, int x, int y, int z, Bundle extras, boolean sync) {
344 if (window == mWallpaperTarget
345 || window == mLowerWallpaperTarget
346 || window == mUpperWallpaperTarget) {
347 boolean doWait = sync;
348 for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
349 final WindowList windows = mWallpaperTokens.get(curTokenNdx).windows;
350 for (int wallpaperNdx = windows.size() - 1; wallpaperNdx >= 0; wallpaperNdx--) {
351 WindowState wallpaper = windows.get(wallpaperNdx);
352 try {
353 wallpaper.mClient.dispatchWallpaperCommand(action,
354 x, y, z, extras, sync);
355 // We only want to be synchronous with one wallpaper.
356 sync = false;
357 } catch (RemoteException e) {
358 }
359 }
360 }
361
362 if (doWait) {
363 // TODO: Need to wait for result.
364 }
365 }
366
367 return null;
368 }
369
370 void updateWallpaperOffsetLocked(WindowState changingTarget, boolean sync) {
371 final DisplayContent displayContent = changingTarget.getDisplayContent();
372 if (displayContent == null) {
373 return;
374 }
375 final DisplayInfo displayInfo = displayContent.getDisplayInfo();
376 final int dw = displayInfo.logicalWidth;
377 final int dh = displayInfo.logicalHeight;
378
379 WindowState target = mWallpaperTarget;
380 if (target != null) {
381 if (target.mWallpaperX >= 0) {
382 mLastWallpaperX = target.mWallpaperX;
383 } else if (changingTarget.mWallpaperX >= 0) {
384 mLastWallpaperX = changingTarget.mWallpaperX;
385 }
386 if (target.mWallpaperY >= 0) {
387 mLastWallpaperY = target.mWallpaperY;
388 } else if (changingTarget.mWallpaperY >= 0) {
389 mLastWallpaperY = changingTarget.mWallpaperY;
390 }
391 if (target.mWallpaperDisplayOffsetX != Integer.MIN_VALUE) {
392 mLastWallpaperDisplayOffsetX = target.mWallpaperDisplayOffsetX;
393 } else if (changingTarget.mWallpaperDisplayOffsetX != Integer.MIN_VALUE) {
394 mLastWallpaperDisplayOffsetX = changingTarget.mWallpaperDisplayOffsetX;
395 }
396 if (target.mWallpaperDisplayOffsetY != Integer.MIN_VALUE) {
397 mLastWallpaperDisplayOffsetY = target.mWallpaperDisplayOffsetY;
398 } else if (changingTarget.mWallpaperDisplayOffsetY != Integer.MIN_VALUE) {
399 mLastWallpaperDisplayOffsetY = changingTarget.mWallpaperDisplayOffsetY;
400 }
401 if (target.mWallpaperXStep >= 0) {
402 mLastWallpaperXStep = target.mWallpaperXStep;
403 } else if (changingTarget.mWallpaperXStep >= 0) {
404 mLastWallpaperXStep = changingTarget.mWallpaperXStep;
405 }
406 if (target.mWallpaperYStep >= 0) {
407 mLastWallpaperYStep = target.mWallpaperYStep;
408 } else if (changingTarget.mWallpaperYStep >= 0) {
409 mLastWallpaperYStep = changingTarget.mWallpaperYStep;
410 }
411 }
412
413 for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
414 WindowList windows = mWallpaperTokens.get(curTokenNdx).windows;
415 for (int wallpaperNdx = windows.size() - 1; wallpaperNdx >= 0; wallpaperNdx--) {
416 WindowState wallpaper = windows.get(wallpaperNdx);
417 if (updateWallpaperOffset(wallpaper, dw, dh, sync)) {
418 WindowStateAnimator winAnimator = wallpaper.mWinAnimator;
419 winAnimator.computeShownFrameLocked();
420 // No need to lay out the windows - we can just set the wallpaper position
421 // directly.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700422 winAnimator.setWallpaperOffset(wallpaper.mShownPosition);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700423 // We only want to be synchronous with one wallpaper.
424 sync = false;
425 }
426 }
427 }
428 }
429
430 void clearLastWallpaperTimeoutTime() {
431 mLastWallpaperTimeoutTime = 0;
432 }
433
434 void wallpaperCommandComplete(IBinder window) {
435 if (mWaitingOnWallpaper != null &&
436 mWaitingOnWallpaper.mClient.asBinder() == window) {
437 mWaitingOnWallpaper = null;
438 mService.mWindowMap.notifyAll();
439 }
440 }
441
442 void wallpaperOffsetsComplete(IBinder window) {
443 if (mWaitingOnWallpaper != null &&
444 mWaitingOnWallpaper.mClient.asBinder() == window) {
445 mWaitingOnWallpaper = null;
446 mService.mWindowMap.notifyAll();
447 }
448 }
449
450 int getAnimLayerAdjustment() {
451 return mWallpaperAnimLayerAdjustment;
452 }
453
454 void setAnimLayerAdjustment(WindowState win, int adj) {
455 if (win != mWallpaperTarget || mLowerWallpaperTarget != null) {
456 return;
457 }
458
459 if (DEBUG_LAYERS || DEBUG_WALLPAPER) Slog.v(TAG, "Setting wallpaper layer adj to " + adj);
460 mWallpaperAnimLayerAdjustment = adj;
461 for (int i = mWallpaperTokens.size() - 1; i >= 0; i--) {
462 WindowList windows = mWallpaperTokens.get(i).windows;
463 for (int j = windows.size() - 1; j >= 0; j--) {
464 WindowState wallpaper = windows.get(j);
465 wallpaper.mWinAnimator.mAnimLayer = wallpaper.mLayer + adj;
466 if (DEBUG_LAYERS || DEBUG_WALLPAPER) Slog.v(TAG, "setWallpaper win "
467 + wallpaper + " anim layer: " + wallpaper.mWinAnimator.mAnimLayer);
468 }
469 }
470 }
471
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700472 private void findWallpaperTarget(WindowList windows, FindWallpaperTargetResult result) {
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700473
474 final WindowAnimator winAnimator = mService.mAnimator;
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700475 result.reset();
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700476 WindowState w = null;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700477 int windowDetachedI = -1;
Wale Ogunwale21fdd912015-08-20 12:34:57 -0700478 boolean resetTopWallpaper = false;
479 boolean inFreeformSpace = false;
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700480 for (int i = windows.size() - 1; i >= 0; i--) {
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700481 w = windows.get(i);
482 if ((w.mAttrs.type == TYPE_WALLPAPER)) {
Wale Ogunwale21fdd912015-08-20 12:34:57 -0700483 if (result.topWallpaper == null || resetTopWallpaper) {
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700484 result.setTopWallpaper(w, i);
Wale Ogunwale21fdd912015-08-20 12:34:57 -0700485 resetTopWallpaper = false;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700486 }
487 continue;
488 }
Wale Ogunwale21fdd912015-08-20 12:34:57 -0700489 resetTopWallpaper = true;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700490 if (w != winAnimator.mWindowDetachedWallpaper && w.mAppToken != null) {
491 // If this window's app token is hidden and not animating,
492 // it is of no interest to us.
493 if (w.mAppToken.hidden && w.mAppToken.mAppAnimator.animation == null) {
494 if (DEBUG_WALLPAPER) Slog.v(TAG,
495 "Skipping hidden and not animating token: " + w);
496 continue;
497 }
498 }
499 if (DEBUG_WALLPAPER) Slog.v(TAG, "Win #" + i + " " + w + ": isOnScreen="
500 + w.isOnScreen() + " mDrawState=" + w.mWinAnimator.mDrawState);
501
Wale Ogunwale21fdd912015-08-20 12:34:57 -0700502 if (!inFreeformSpace) {
503 TaskStack stack = w.getStack();
504 inFreeformSpace = stack != null && stack.mStackId == FREEFORM_WORKSPACE_STACK_ID;
505 }
506
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700507 // If the app is executing an animation because the keyguard is going away,
508 // keep the wallpaper during the animation so it doesn't flicker out.
509 final boolean hasWallpaper = (w.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0
510 || (w.mAppToken != null && w.mWinAnimator.mKeyguardGoingAwayAnimation);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700511 if (hasWallpaper && w.isOnScreen()
512 && (mWallpaperTarget == w || w.isDrawFinishedLw())) {
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700513 if (DEBUG_WALLPAPER) Slog.v(TAG, "Found wallpaper target: #" + i + "=" + w);
514 result.setWallpaperTarget(w, i);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700515 if (w == mWallpaperTarget && w.mWinAnimator.isAnimating()) {
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700516 // The current wallpaper target is animating, so we'll look behind it for
517 // another possible target and figure out what is going on later.
518 if (DEBUG_WALLPAPER) Slog.v(TAG,
519 "Win " + w + ": token animating, looking behind.");
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700520 continue;
521 }
522 break;
523 } else if (w == winAnimator.mWindowDetachedWallpaper) {
524 windowDetachedI = i;
525 }
526 }
527
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700528 if (result.wallpaperTarget == null && windowDetachedI >= 0) {
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700529 if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700530 "Found animating detached wallpaper activity: #" + windowDetachedI + "=" + w);
531 result.setWallpaperTarget(w, windowDetachedI);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700532 }
Wale Ogunwale21fdd912015-08-20 12:34:57 -0700533 if (result.wallpaperTarget == null && inFreeformSpace) {
534 // In freeform mode we set the wallpaper as its own target, so we don't need an
535 // additional window to make it visible.
536 result.setWallpaperTarget(result.topWallpaper, result.topWallpaperIndex);
537 }
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700538 }
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700539
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700540 private boolean updateWallpaperWindowsTarget(
541 WindowList windows, FindWallpaperTargetResult result) {
542
543 boolean targetChanged = false;
544 WindowState wallpaperTarget = result.wallpaperTarget;
545 int wallpaperTargetIndex = result.wallpaperTargetIndex;
546
547 if (mWallpaperTarget != wallpaperTarget
548 && (mLowerWallpaperTarget == null || mLowerWallpaperTarget != wallpaperTarget)) {
549 if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
550 "New wallpaper target: " + wallpaperTarget + " oldTarget: " + mWallpaperTarget);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700551
552 mLowerWallpaperTarget = null;
553 mUpperWallpaperTarget = null;
554
555 WindowState oldW = mWallpaperTarget;
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700556 mWallpaperTarget = wallpaperTarget;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700557 targetChanged = true;
558
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700559 // Now what is happening... if the current and new targets are animating,
560 // then we are in our super special mode!
561 if (wallpaperTarget != null && oldW != null) {
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700562 boolean oldAnim = oldW.isAnimatingLw();
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700563 boolean foundAnim = wallpaperTarget.isAnimatingLw();
564 if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
565 "New animation: " + foundAnim + " old animation: " + oldAnim);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700566 if (foundAnim && oldAnim) {
567 int oldI = windows.indexOf(oldW);
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700568 if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
569 "New i: " + wallpaperTargetIndex + " old i: " + oldI);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700570 if (oldI >= 0) {
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700571 if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
572 "Animating wallpapers: old#" + oldI + "=" + oldW + "; new#"
573 + wallpaperTargetIndex + "=" + wallpaperTarget);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700574
575 // Set the new target correctly.
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700576 if (wallpaperTarget.mAppToken != null
577 && wallpaperTarget.mAppToken.hiddenRequested) {
578 if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
579 "Old wallpaper still the target.");
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700580 mWallpaperTarget = oldW;
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700581 wallpaperTarget = oldW;
582 wallpaperTargetIndex = oldI;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700583 }
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700584 // Now set the upper and lower wallpaper targets correctly,
585 // and make sure that we are positioning the wallpaper below the lower.
586 else if (wallpaperTargetIndex > oldI) {
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700587 // The new target is on top of the old one.
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700588 if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
589 "Found target above old target.");
590 mUpperWallpaperTarget = wallpaperTarget;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700591 mLowerWallpaperTarget = oldW;
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700592 wallpaperTarget = oldW;
593 wallpaperTargetIndex = oldI;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700594 } else {
595 // The new target is below the old one.
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700596 if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
597 "Found target below old target.");
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700598 mUpperWallpaperTarget = oldW;
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700599 mLowerWallpaperTarget = wallpaperTarget;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700600 }
601 }
602 }
603 }
604
605 } else if (mLowerWallpaperTarget != null) {
606 // Is it time to stop animating?
607 if (!mLowerWallpaperTarget.isAnimatingLw() || !mUpperWallpaperTarget.isAnimatingLw()) {
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700608 if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG, "No longer animating wallpaper targets!");
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700609 mLowerWallpaperTarget = null;
610 mUpperWallpaperTarget = null;
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700611 mWallpaperTarget = wallpaperTarget;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700612 targetChanged = true;
613 }
614 }
615
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700616 result.setWallpaperTarget(wallpaperTarget, wallpaperTargetIndex);
617 return targetChanged;
618 }
619
620 boolean updateWallpaperWindowsTargetByLayer(
621 WindowList windows, FindWallpaperTargetResult result) {
622
623 WindowState wallpaperTarget = result.wallpaperTarget;
624 int wallpaperTargetIndex = result.wallpaperTargetIndex;
625 boolean visible = wallpaperTarget != null;
626
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700627 if (visible) {
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700628 // The window is visible to the compositor...but is it visible to the user?
629 // That is what the wallpaper cares about.
630 visible = isWallpaperVisible(wallpaperTarget);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700631 if (DEBUG_WALLPAPER) Slog.v(TAG, "Wallpaper visibility: " + visible);
632
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700633 // If the wallpaper target is animating, we may need to copy its layer adjustment.
634 // Only do this if we are not transferring between two wallpaper targets.
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700635 mWallpaperAnimLayerAdjustment =
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700636 (mLowerWallpaperTarget == null && wallpaperTarget.mAppToken != null)
637 ? wallpaperTarget.mAppToken.mAppAnimator.animLayerAdjustment : 0;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700638
639 final int maxLayer = (mService.mPolicy.getMaxWallpaperLayer() * TYPE_LAYER_MULTIPLIER)
640 + TYPE_LAYER_OFFSET;
641
642 // Now w is the window we are supposed to be behind... but we
643 // need to be sure to also be behind any of its attached windows,
644 // AND any starting window associated with it, AND below the
645 // maximum layer the policy allows for wallpapers.
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700646 while (wallpaperTargetIndex > 0) {
647 WindowState wb = windows.get(wallpaperTargetIndex - 1);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700648 if (wb.mBaseLayer < maxLayer &&
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700649 wb.mAttachedWindow != wallpaperTarget &&
650 (wallpaperTarget.mAttachedWindow == null ||
651 wb.mAttachedWindow != wallpaperTarget.mAttachedWindow) &&
652 (wb.mAttrs.type != TYPE_APPLICATION_STARTING
653 || wallpaperTarget.mToken == null
654 || wb.mToken != wallpaperTarget.mToken)) {
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700655 // This window is not related to the previous one in any
656 // interesting way, so stop here.
657 break;
658 }
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700659 wallpaperTarget = wb;
660 wallpaperTargetIndex--;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700661 }
662 } else {
663 if (DEBUG_WALLPAPER) Slog.v(TAG, "No wallpaper target");
664 }
665
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700666 result.setWallpaperTarget(wallpaperTarget, wallpaperTargetIndex);
667 return visible;
668 }
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700669
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700670 boolean updateWallpaperWindowsPlacement(WindowList windows,
671 WindowState wallpaperTarget, int wallpaperTargetIndex, boolean visible) {
672
673 // TODO(multidisplay): Wallpapers on main screen only.
674 final DisplayInfo displayInfo = mService.getDefaultDisplayContentLocked().getDisplayInfo();
675 final int dw = displayInfo.logicalWidth;
676 final int dh = displayInfo.logicalHeight;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700677
678 // Start stepping backwards from here, ensuring that our wallpaper windows
679 // are correctly placed.
680 boolean changed = false;
681 for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
682 WindowToken token = mWallpaperTokens.get(curTokenNdx);
683 if (token.hidden == visible) {
684 if (DEBUG_WALLPAPER_LIGHT) Slog.d(TAG,
685 "Wallpaper token " + token + " hidden=" + !visible);
686 token.hidden = !visible;
687 // Need to do a layout to ensure the wallpaper now has the correct size.
688 mService.getDefaultDisplayContentLocked().layoutNeeded = true;
689 }
690
691 final WindowList tokenWindows = token.windows;
692 for (int wallpaperNdx = tokenWindows.size() - 1; wallpaperNdx >= 0; wallpaperNdx--) {
693 WindowState wallpaper = tokenWindows.get(wallpaperNdx);
694
695 if (visible) {
696 updateWallpaperOffset(wallpaper, dw, dh, false);
697 }
698
699 // First, make sure the client has the current visibility state.
700 dispatchWallpaperVisibility(wallpaper, visible);
701
702 wallpaper.mWinAnimator.mAnimLayer =
703 wallpaper.mLayer + mWallpaperAnimLayerAdjustment;
704 if (DEBUG_LAYERS || DEBUG_WALLPAPER_LIGHT) Slog.v(TAG, "adjustWallpaper win "
705 + wallpaper + " anim layer: " + wallpaper.mWinAnimator.mAnimLayer);
706
707 // First, if this window is at the current index, then all is well.
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700708 if (wallpaper == wallpaperTarget) {
709 wallpaperTargetIndex--;
710 wallpaperTarget = wallpaperTargetIndex > 0
711 ? windows.get(wallpaperTargetIndex - 1) : null;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700712 continue;
713 }
714
715 // The window didn't match... the current wallpaper window,
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700716 // wherever it is, is in the wrong place, so make sure it is not in the list.
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700717 int oldIndex = windows.indexOf(wallpaper);
718 if (oldIndex >= 0) {
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700719 if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG,
720 "Wallpaper removing at " + oldIndex + ": " + wallpaper);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700721 windows.remove(oldIndex);
722 mService.mWindowsChanged = true;
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700723 if (oldIndex < wallpaperTargetIndex) {
724 wallpaperTargetIndex--;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700725 }
726 }
727
728 // Now stick it in. For apps over wallpaper keep the wallpaper at the bottommost
729 // layer. For keyguard over wallpaper put the wallpaper under the keyguard.
730 int insertionIndex = 0;
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700731 if (visible && wallpaperTarget != null) {
732 final int type = wallpaperTarget.mAttrs.type;
733 final int privateFlags = wallpaperTarget.mAttrs.privateFlags;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700734 if ((privateFlags & PRIVATE_FLAG_KEYGUARD) != 0
735 || type == TYPE_KEYGUARD_SCRIM) {
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700736 insertionIndex = windows.indexOf(wallpaperTarget);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700737 }
738 }
Filip Gruszczynskia59ac9c2015-09-10 18:28:48 -0700739 if (DEBUG_WALLPAPER_LIGHT || DEBUG_WINDOW_MOVEMENT
740 || (DEBUG_ADD_REMOVE && oldIndex != insertionIndex)) Slog.v(TAG,
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700741 "Moving wallpaper " + wallpaper
742 + " from " + oldIndex + " to " + insertionIndex);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700743
744 windows.add(insertionIndex, wallpaper);
745 mService.mWindowsChanged = true;
746 changed = true;
747 }
748 }
749
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700750 return changed;
751 }
752
753 boolean adjustWallpaperWindows() {
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700754 mService.mWindowPlacerLocked.mWallpaperMayChange = false;
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700755
756 final WindowList windows = mService.getDefaultWindowListLocked();
757 // First find top-most window that has asked to be on top of the wallpaper;
758 // all wallpapers go behind it.
759 findWallpaperTarget(windows, mFindResults);
760 final boolean targetChanged = updateWallpaperWindowsTarget(windows, mFindResults);
761 final boolean visible = updateWallpaperWindowsTargetByLayer(windows, mFindResults);
762 WindowState wallpaperTarget = mFindResults.wallpaperTarget;
763 int wallpaperTargetIndex = mFindResults.wallpaperTargetIndex;
764
765 if (wallpaperTarget == null && mFindResults.topWallpaper != null) {
766 // There is no wallpaper target, so it goes at the bottom.
767 // We will assume it is the same place as last time, if known.
768 wallpaperTarget = mFindResults.topWallpaper;
769 wallpaperTargetIndex = mFindResults.topWallpaperIndex + 1;
770 } else {
771 // Okay i is the position immediately above the wallpaper.
772 // Look at what is below it for later.
773 wallpaperTarget = wallpaperTargetIndex > 0
774 ? windows.get(wallpaperTargetIndex - 1) : null;
775 }
776
777 if (visible) {
778 if (mWallpaperTarget.mWallpaperX >= 0) {
779 mLastWallpaperX = mWallpaperTarget.mWallpaperX;
780 mLastWallpaperXStep = mWallpaperTarget.mWallpaperXStep;
781 }
782 if (mWallpaperTarget.mWallpaperY >= 0) {
783 mLastWallpaperY = mWallpaperTarget.mWallpaperY;
784 mLastWallpaperYStep = mWallpaperTarget.mWallpaperYStep;
785 }
786 if (mWallpaperTarget.mWallpaperDisplayOffsetX != Integer.MIN_VALUE) {
787 mLastWallpaperDisplayOffsetX = mWallpaperTarget.mWallpaperDisplayOffsetX;
788 }
789 if (mWallpaperTarget.mWallpaperDisplayOffsetY != Integer.MIN_VALUE) {
790 mLastWallpaperDisplayOffsetY = mWallpaperTarget.mWallpaperDisplayOffsetY;
791 }
792 }
793
794 final boolean changed = updateWallpaperWindowsPlacement(
795 windows, wallpaperTarget, wallpaperTargetIndex, visible);
796
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700797 if (targetChanged && DEBUG_WALLPAPER_LIGHT) Slog.d(TAG, "New wallpaper: target="
798 + mWallpaperTarget + " lower=" + mLowerWallpaperTarget + " upper="
799 + mUpperWallpaperTarget);
800
801 return changed;
802 }
803
804 boolean processWallpaperDrawPendingTimeout() {
805 if (mWallpaperDrawState == WALLPAPER_DRAW_PENDING) {
806 mWallpaperDrawState = WALLPAPER_DRAW_TIMEOUT;
807 if (DEBUG_APP_TRANSITIONS || DEBUG_WALLPAPER) Slog.v(TAG,
808 "*** WALLPAPER DRAW TIMEOUT");
809 return true;
810 }
811 return false;
812 }
813
814 boolean wallpaperTransitionReady() {
815 boolean transitionReady = true;
816 boolean wallpaperReady = true;
817 for (int curTokenIndex = mWallpaperTokens.size() - 1;
818 curTokenIndex >= 0 && wallpaperReady; curTokenIndex--) {
819 WindowToken token = mWallpaperTokens.get(curTokenIndex);
820 for (int curWallpaperIndex = token.windows.size() - 1; curWallpaperIndex >= 0;
821 curWallpaperIndex--) {
822 WindowState wallpaper = token.windows.get(curWallpaperIndex);
823 if (wallpaper.mWallpaperVisible && !wallpaper.isDrawnLw()) {
824 // We've told this wallpaper to be visible, but it is not drawn yet
825 wallpaperReady = false;
826 if (mWallpaperDrawState != WALLPAPER_DRAW_TIMEOUT) {
827 // wait for this wallpaper until it is drawn or timeout
828 transitionReady = false;
829 }
830 if (mWallpaperDrawState == WALLPAPER_DRAW_NORMAL) {
831 mWallpaperDrawState = WALLPAPER_DRAW_PENDING;
832 mService.mH.removeMessages(WALLPAPER_DRAW_PENDING_TIMEOUT);
833 mService.mH.sendEmptyMessageDelayed(WALLPAPER_DRAW_PENDING_TIMEOUT,
834 WALLPAPER_DRAW_PENDING_TIMEOUT_DURATION);
835 }
836 if (DEBUG_APP_TRANSITIONS || DEBUG_WALLPAPER) Slog.v(TAG,
837 "Wallpaper should be visible but has not been drawn yet. " +
838 "mWallpaperDrawState=" + mWallpaperDrawState);
839 break;
840 }
841 }
842 }
843 if (wallpaperReady) {
844 mWallpaperDrawState = WALLPAPER_DRAW_NORMAL;
845 mService.mH.removeMessages(WALLPAPER_DRAW_PENDING_TIMEOUT);
846 }
847
848 return transitionReady;
849 }
850
851 void addWallpaperToken(WindowToken token) {
852 mWallpaperTokens.add(token);
853 }
854
855 void removeWallpaperToken(WindowToken token) {
856 mWallpaperTokens.remove(token);
857 }
858
859 void dump(PrintWriter pw, String prefix) {
860 pw.print(prefix); pw.print("mWallpaperTarget="); pw.println(mWallpaperTarget);
861 if (mLowerWallpaperTarget != null || mUpperWallpaperTarget != null) {
862 pw.print(prefix); pw.print("mLowerWallpaperTarget="); pw.println(mLowerWallpaperTarget);
863 pw.print(prefix); pw.print("mUpperWallpaperTarget="); pw.println(mUpperWallpaperTarget);
864 }
865 pw.print(prefix); pw.print("mLastWallpaperX="); pw.print(mLastWallpaperX);
866 pw.print(" mLastWallpaperY="); pw.println(mLastWallpaperY);
867 if (mLastWallpaperDisplayOffsetX != Integer.MIN_VALUE
868 || mLastWallpaperDisplayOffsetY != Integer.MIN_VALUE) {
869 pw.print(prefix);
870 pw.print("mLastWallpaperDisplayOffsetX="); pw.print(mLastWallpaperDisplayOffsetX);
871 pw.print(" mLastWallpaperDisplayOffsetY="); pw.println(mLastWallpaperDisplayOffsetY);
872 }
873 }
874
875 void dumpTokens(PrintWriter pw, String prefix, boolean dumpAll) {
876 if (!mWallpaperTokens.isEmpty()) {
877 pw.println();
878 pw.print(prefix); pw.println("Wallpaper tokens:");
879 for (int i = mWallpaperTokens.size() - 1; i >= 0; i--) {
880 WindowToken token = mWallpaperTokens.get(i);
881 pw.print(prefix); pw.print("Wallpaper #"); pw.print(i);
882 pw.print(' '); pw.print(token);
883 if (dumpAll) {
884 pw.println(':');
885 token.dump(pw, " ");
886 } else {
887 pw.println();
888 }
889 }
890 }
891 }
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700892
893 /** Helper class for storing the results of a wallpaper target find operation. */
894 final private static class FindWallpaperTargetResult {
895 int topWallpaperIndex = 0;
896 WindowState topWallpaper = null;
897 int wallpaperTargetIndex = 0;
898 WindowState wallpaperTarget = null;
899
900 void setTopWallpaper(WindowState win, int index) {
901 topWallpaper = win;
902 topWallpaperIndex = index;
903 }
904
905 void setWallpaperTarget(WindowState win, int index) {
906 wallpaperTarget = win;
907 wallpaperTargetIndex = index;
908 }
909
910 void reset() {
911 topWallpaperIndex = 0;
912 topWallpaper = null;
913 wallpaperTargetIndex = 0;
914 wallpaperTarget = null;
915 }
916 }
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700917}