blob: c509980e1e9e2339157e469c05bd74359ca16df5 [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 Ogunwale1e129a42016-11-21 13:03:47 -080019import com.android.internal.util.ToBooleanFunction;
20
Wale Ogunwale44f036f2017-09-29 05:09:09 -070021import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -080022import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -070023import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
Jorim Jaggife762342016-10-13 14:33:27 +020024import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -070025import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
Jorim Jaggife762342016-10-13 14:33:27 +020026
Adrian Roose99bc052017-11-20 17:55:31 +010027import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
Jorim Jaggif84e2f62018-01-16 14:17:59 +010028import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080029import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS;
chaviw0315a1a2018-03-05 15:28:35 -080030import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_SCREENSHOT;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080031import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WALLPAPER;
32import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WALLPAPER_LIGHT;
33import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
34import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -070035import static com.android.server.wm.WindowManagerService.H.WALLPAPER_DRAW_PENDING_TIMEOUT;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -070036
chaviw0315a1a2018-03-05 15:28:35 -080037import android.graphics.Bitmap;
38import android.graphics.GraphicBuffer;
39import android.graphics.Rect;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -070040import android.os.Bundle;
41import android.os.Debug;
42import android.os.IBinder;
43import android.os.RemoteException;
44import android.os.SystemClock;
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -070045import android.util.ArraySet;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -070046import android.util.Slog;
47import android.view.DisplayInfo;
chaviw0315a1a2018-03-05 15:28:35 -080048import android.view.SurfaceControl;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -070049import android.view.WindowManager;
Jorim Jaggife762342016-10-13 14:33:27 +020050import android.view.animation.Animation;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -070051
52import java.io.PrintWriter;
53import java.util.ArrayList;
54
55/**
56 * Controls wallpaper windows visibility, ordering, and so on.
57 * NOTE: All methods in this class must be called with the window manager service lock held.
58 */
59class WallpaperController {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080060 private static final String TAG = TAG_WITH_CLASS_NAME ? "WallpaperController" : TAG_WM;
Wale Ogunwale1e129a42016-11-21 13:03:47 -080061 private WindowManagerService mService;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -070062
Jorim Jaggi879ff722016-11-04 18:08:17 -070063 private final ArrayList<WallpaperWindowToken> mWallpaperTokens = new ArrayList<>();
Wale Ogunwalee8069dc2015-08-18 09:52:01 -070064
65 // If non-null, this is the currently visible window that is associated
66 // with the wallpaper.
67 private WindowState mWallpaperTarget = null;
68 // If non-null, we are in the middle of animating from one wallpaper target
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -080069 // to another, and this is the previous wallpaper target.
70 private WindowState mPrevWallpaperTarget = null;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -070071
Wale Ogunwalee8069dc2015-08-18 09:52:01 -070072 private float mLastWallpaperX = -1;
73 private float mLastWallpaperY = -1;
74 private float mLastWallpaperXStep = -1;
75 private float mLastWallpaperYStep = -1;
76 private int mLastWallpaperDisplayOffsetX = Integer.MIN_VALUE;
77 private int mLastWallpaperDisplayOffsetY = Integer.MIN_VALUE;
78
79 // This is set when we are waiting for a wallpaper to tell us it is done
80 // changing its scroll position.
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -080081 private WindowState mWaitingOnWallpaper;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -070082
83 // The last time we had a timeout when waiting for a wallpaper.
84 private long mLastWallpaperTimeoutTime;
85 // We give a wallpaper up to 150ms to finish scrolling.
86 private static final long WALLPAPER_TIMEOUT = 150;
87 // Time we wait after a timeout before trying to wait again.
88 private static final long WALLPAPER_TIMEOUT_RECOVERY = 10000;
89
90 // Set to the wallpaper window we would like to hide once the transition animations are done.
91 // This is useful in cases where we don't want the wallpaper to be hidden when the close app
92 // is a wallpaper target and is done animating out, but the opening app isn't a wallpaper
93 // target and isn't done animating in.
Wale Ogunwalee4da0c12016-07-29 12:47:02 -070094 WindowState mDeferredHideWallpaper = null;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -070095
96 // We give a wallpaper up to 500ms to finish drawing before playing app transitions.
97 private static final long WALLPAPER_DRAW_PENDING_TIMEOUT_DURATION = 500;
98 private static final int WALLPAPER_DRAW_NORMAL = 0;
99 private static final int WALLPAPER_DRAW_PENDING = 1;
100 private static final int WALLPAPER_DRAW_TIMEOUT = 2;
101 private int mWallpaperDrawState = WALLPAPER_DRAW_NORMAL;
102
chaviw0315a1a2018-03-05 15:28:35 -0800103 /**
104 * Temporary storage for taking a screenshot of the wallpaper.
105 * @see #screenshotWallpaperLocked()
106 */
107 private WindowState mTmpTopWallpaper;
108
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700109 private final FindWallpaperTargetResult mFindResults = new FindWallpaperTargetResult();
110
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800111 private final ToBooleanFunction<WindowState> mFindWallpaperTargetFunction = w -> {
112 final WindowAnimator winAnimator = mService.mAnimator;
113 if ((w.mAttrs.type == TYPE_WALLPAPER)) {
114 if (mFindResults.topWallpaper == null || mFindResults.resetTopWallpaper) {
115 mFindResults.setTopWallpaper(w);
116 mFindResults.resetTopWallpaper = false;
117 }
118 return false;
119 }
120
121 mFindResults.resetTopWallpaper = true;
122 if (w != winAnimator.mWindowDetachedWallpaper && w.mAppToken != null) {
123 // If this window's app token is hidden and not animating, it is of no interest to us.
Jorim Jaggif5f9e122017-10-24 18:21:09 +0200124 if (w.mAppToken.isHidden() && !w.mAppToken.isSelfAnimating()) {
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800125 if (DEBUG_WALLPAPER) Slog.v(TAG,
126 "Skipping hidden and not animating token: " + w);
127 return false;
128 }
129 }
130 if (DEBUG_WALLPAPER) Slog.v(TAG, "Win " + w + ": isOnScreen=" + w.isOnScreen()
131 + " mDrawState=" + w.mWinAnimator.mDrawState);
132
133 if (w.mWillReplaceWindow && mWallpaperTarget == null
134 && !mFindResults.useTopWallpaperAsTarget) {
135 // When we are replacing a window and there was wallpaper before replacement, we want to
136 // keep the window until the new windows fully appear and can determine the visibility,
137 // to avoid flickering.
138 mFindResults.setUseTopWallpaperAsTarget(true);
139 }
140
141 final boolean keyguardGoingAwayWithWallpaper = (w.mAppToken != null
Jorim Jaggif5f9e122017-10-24 18:21:09 +0200142 && w.mAppToken.isSelfAnimating()
143 && AppTransition.isKeyguardGoingAwayTransit(w.mAppToken.getTransit())
144 && (w.mAppToken.getTransitFlags()
145 & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER) != 0);
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800146
147 boolean needsShowWhenLockedWallpaper = false;
148 if ((w.mAttrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0
149 && mService.mPolicy.isKeyguardLocked()
150 && mService.mPolicy.isKeyguardOccluded()) {
151 // The lowest show when locked window decides whether we need to put the wallpaper
152 // behind.
153 needsShowWhenLockedWallpaper = !isFullscreen(w.mAttrs)
154 || (w.mAppToken != null && !w.mAppToken.fillsParent());
155 }
156
157 if (keyguardGoingAwayWithWallpaper || needsShowWhenLockedWallpaper) {
158 // Keep the wallpaper during Keyguard exit but also when it's needed for a
159 // non-fullscreen show when locked activity.
160 mFindResults.setUseTopWallpaperAsTarget(true);
161 }
162
Winson Chunge2d72172018-01-25 17:46:20 +0000163 final RecentsAnimationController recentsAnimationController =
164 mService.getRecentsAnimationController();
Jorim Jaggi82c17862018-02-21 17:50:18 +0100165 final boolean animationWallpaper = w.mAppToken != null && w.mAppToken.getAnimation() != null
166 && w.mAppToken.getAnimation().getShowWallpaper();
167 final boolean hasWallpaper = (w.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0
168 || animationWallpaper;
Winson Chunge2d72172018-01-25 17:46:20 +0000169 final boolean isRecentsTransitionTarget = (recentsAnimationController != null
170 && recentsAnimationController.isWallpaperVisible(w));
171 if (isRecentsTransitionTarget) {
172 if (DEBUG_WALLPAPER) Slog.v(TAG, "Found recents animation wallpaper target: " + w);
173 mFindResults.setWallpaperTarget(w);
174 return true;
175 } else if (hasWallpaper && w.isOnScreen()
176 && (mWallpaperTarget == w || w.isDrawFinishedLw())) {
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800177 if (DEBUG_WALLPAPER) Slog.v(TAG, "Found wallpaper target: " + w);
178 mFindResults.setWallpaperTarget(w);
179 if (w == mWallpaperTarget && w.mWinAnimator.isAnimationSet()) {
180 // The current wallpaper target is animating, so we'll look behind it for
181 // another possible target and figure out what is going on later.
182 if (DEBUG_WALLPAPER) Slog.v(TAG,
183 "Win " + w + ": token animating, looking behind.");
184 }
185 // Found a target! End search.
186 return true;
187 } else if (w == winAnimator.mWindowDetachedWallpaper) {
188 if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
189 "Found animating detached wallpaper target win: " + w);
190 mFindResults.setUseTopWallpaperAsTarget(true);
191 }
192 return false;
193 };
194
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700195 public WallpaperController(WindowManagerService service) {
196 mService = service;
197 }
198
199 WindowState getWallpaperTarget() {
200 return mWallpaperTarget;
201 }
202
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700203 boolean isWallpaperTarget(WindowState win) {
204 return win == mWallpaperTarget;
205 }
206
207 boolean isBelowWallpaperTarget(WindowState win) {
208 return mWallpaperTarget != null && mWallpaperTarget.mLayer >= win.mBaseLayer;
209 }
210
211 boolean isWallpaperVisible() {
212 return isWallpaperVisible(mWallpaperTarget);
213 }
214
Jorim Jaggife762342016-10-13 14:33:27 +0200215 /**
216 * Starts {@param a} on all wallpaper windows.
217 */
218 void startWallpaperAnimation(Animation a) {
219 for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
Jorim Jaggi879ff722016-11-04 18:08:17 -0700220 final WallpaperWindowToken token = mWallpaperTokens.get(curTokenNdx);
Jorim Jaggife762342016-10-13 14:33:27 +0200221 token.startAnimation(a);
222 }
223 }
224
Winson Chunge2d72172018-01-25 17:46:20 +0000225 private final boolean isWallpaperVisible(WindowState wallpaperTarget) {
226 final RecentsAnimationController recentsAnimationController =
227 mService.getRecentsAnimationController();
228 boolean isAnimatingWithRecentsComponent = recentsAnimationController != null
229 && recentsAnimationController.isWallpaperVisible(wallpaperTarget);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700230 if (DEBUG_WALLPAPER) Slog.v(TAG, "Wallpaper vis: target " + wallpaperTarget + ", obscured="
231 + (wallpaperTarget != null ? Boolean.toString(wallpaperTarget.mObscured) : "??")
Jorim Jaggif5f9e122017-10-24 18:21:09 +0200232 + " animating=" + ((wallpaperTarget != null && wallpaperTarget.mAppToken != null)
233 ? wallpaperTarget.mAppToken.isSelfAnimating() : null)
Winson Chunge2d72172018-01-25 17:46:20 +0000234 + " prev=" + mPrevWallpaperTarget
235 + " recentsAnimationWallpaperVisible=" + isAnimatingWithRecentsComponent);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700236 return (wallpaperTarget != null
Winson Chunge2d72172018-01-25 17:46:20 +0000237 && (!wallpaperTarget.mObscured
238 || isAnimatingWithRecentsComponent
239 || (wallpaperTarget.mAppToken != null
240 && wallpaperTarget.mAppToken.isSelfAnimating())))
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800241 || mPrevWallpaperTarget != null;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700242 }
243
244 boolean isWallpaperTargetAnimating() {
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700245 return mWallpaperTarget != null && mWallpaperTarget.mWinAnimator.isAnimationSet()
Jorim Jaggif5f9e122017-10-24 18:21:09 +0200246 && (mWallpaperTarget.mAppToken == null
247 || !mWallpaperTarget.mAppToken.isWaitingForTransitionStart());
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700248 }
249
250 void updateWallpaperVisibility() {
Filip Gruszczynski63a35e22015-11-05 15:38:59 -0800251 final boolean visible = isWallpaperVisible(mWallpaperTarget);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700252
253 for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
Jorim Jaggi879ff722016-11-04 18:08:17 -0700254 final WallpaperWindowToken token = mWallpaperTokens.get(curTokenNdx);
Wale Ogunwaleb0f3b832016-10-17 10:13:07 -0700255 token.updateWallpaperVisibility(visible);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700256 }
257 }
258
259 void hideDeferredWallpapersIfNeeded() {
260 if (mDeferredHideWallpaper != null) {
261 hideWallpapers(mDeferredHideWallpaper);
262 mDeferredHideWallpaper = null;
263 }
264 }
265
266 void hideWallpapers(final WindowState winGoingAway) {
267 if (mWallpaperTarget != null
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800268 && (mWallpaperTarget != winGoingAway || mPrevWallpaperTarget != null)) {
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700269 return;
270 }
271 if (mService.mAppTransition.isRunning()) {
272 // Defer hiding the wallpaper when app transition is running until the animations
273 // are done.
274 mDeferredHideWallpaper = winGoingAway;
275 return;
276 }
277
278 final boolean wasDeferred = (mDeferredHideWallpaper == winGoingAway);
279 for (int i = mWallpaperTokens.size() - 1; i >= 0; i--) {
Jorim Jaggi879ff722016-11-04 18:08:17 -0700280 final WallpaperWindowToken token = mWallpaperTokens.get(i);
Wale Ogunwalee4da0c12016-07-29 12:47:02 -0700281 token.hideWallpaperToken(wasDeferred, "hideWallpapers");
Jorim Jaggif5f9e122017-10-24 18:21:09 +0200282 if (DEBUG_WALLPAPER_LIGHT && !token.isHidden()) Slog.d(TAG, "Hiding wallpaper " + token
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800283 + " from " + winGoingAway + " target=" + mWallpaperTarget + " prev="
284 + mPrevWallpaperTarget + "\n" + Debug.getCallers(5, " "));
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700285 }
286 }
287
288 boolean updateWallpaperOffset(WindowState wallpaperWin, int dw, int dh, boolean sync) {
Robert Carr217e7cc2018-01-31 18:08:39 -0800289 int xOffset = 0;
290 int yOffset = 0;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700291 boolean rawChanged = false;
Winson4b4ba902016-07-27 19:45:52 -0700292 // Set the default wallpaper x-offset to either edge of the screen (depending on RTL), to
293 // match the behavior of most Launchers
294 float defaultWallpaperX = wallpaperWin.isRtl() ? 1f : 0f;
295 float wpx = mLastWallpaperX >= 0 ? mLastWallpaperX : defaultWallpaperX;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700296 float wpxs = mLastWallpaperXStep >= 0 ? mLastWallpaperXStep : -1.0f;
297 int availw = wallpaperWin.mFrame.right - wallpaperWin.mFrame.left - dw;
298 int offset = availw > 0 ? -(int)(availw * wpx + .5f) : 0;
299 if (mLastWallpaperDisplayOffsetX != Integer.MIN_VALUE) {
300 offset += mLastWallpaperDisplayOffsetX;
301 }
Robert Carr217e7cc2018-01-31 18:08:39 -0800302 xOffset = offset;
303
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700304 if (wallpaperWin.mWallpaperX != wpx || wallpaperWin.mWallpaperXStep != wpxs) {
305 wallpaperWin.mWallpaperX = wpx;
306 wallpaperWin.mWallpaperXStep = wpxs;
307 rawChanged = true;
308 }
309
310 float wpy = mLastWallpaperY >= 0 ? mLastWallpaperY : 0.5f;
311 float wpys = mLastWallpaperYStep >= 0 ? mLastWallpaperYStep : -1.0f;
312 int availh = wallpaperWin.mFrame.bottom - wallpaperWin.mFrame.top - dh;
313 offset = availh > 0 ? -(int)(availh * wpy + .5f) : 0;
314 if (mLastWallpaperDisplayOffsetY != Integer.MIN_VALUE) {
315 offset += mLastWallpaperDisplayOffsetY;
316 }
Robert Carr217e7cc2018-01-31 18:08:39 -0800317 yOffset = offset;
318
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700319 if (wallpaperWin.mWallpaperY != wpy || wallpaperWin.mWallpaperYStep != wpys) {
320 wallpaperWin.mWallpaperY = wpy;
321 wallpaperWin.mWallpaperYStep = wpys;
322 rawChanged = true;
323 }
324
Robert Carr217e7cc2018-01-31 18:08:39 -0800325 boolean changed = wallpaperWin.mWinAnimator.setWallpaperOffset(xOffset, yOffset);
326
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700327 if (rawChanged && (wallpaperWin.mAttrs.privateFlags &
328 WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS) != 0) {
329 try {
330 if (DEBUG_WALLPAPER) Slog.v(TAG, "Report new wp offset "
331 + wallpaperWin + " x=" + wallpaperWin.mWallpaperX
332 + " y=" + wallpaperWin.mWallpaperY);
333 if (sync) {
334 mWaitingOnWallpaper = wallpaperWin;
335 }
336 wallpaperWin.mClient.dispatchWallpaperOffsets(
337 wallpaperWin.mWallpaperX, wallpaperWin.mWallpaperY,
338 wallpaperWin.mWallpaperXStep, wallpaperWin.mWallpaperYStep, sync);
339 if (sync) {
340 if (mWaitingOnWallpaper != null) {
341 long start = SystemClock.uptimeMillis();
342 if ((mLastWallpaperTimeoutTime + WALLPAPER_TIMEOUT_RECOVERY)
343 < start) {
344 try {
345 if (DEBUG_WALLPAPER) Slog.v(TAG,
346 "Waiting for offset complete...");
347 mService.mWindowMap.wait(WALLPAPER_TIMEOUT);
348 } catch (InterruptedException e) {
349 }
350 if (DEBUG_WALLPAPER) Slog.v(TAG, "Offset complete!");
351 if ((start + WALLPAPER_TIMEOUT) < SystemClock.uptimeMillis()) {
352 Slog.i(TAG, "Timeout waiting for wallpaper to offset: "
353 + wallpaperWin);
354 mLastWallpaperTimeoutTime = start;
355 }
356 }
357 mWaitingOnWallpaper = null;
358 }
359 }
360 } catch (RemoteException e) {
361 }
362 }
363
364 return changed;
365 }
366
367 void setWindowWallpaperPosition(
368 WindowState window, float x, float y, float xStep, float yStep) {
369 if (window.mWallpaperX != x || window.mWallpaperY != y) {
370 window.mWallpaperX = x;
371 window.mWallpaperY = y;
372 window.mWallpaperXStep = xStep;
373 window.mWallpaperYStep = yStep;
374 updateWallpaperOffsetLocked(window, true);
375 }
376 }
377
378 void setWindowWallpaperDisplayOffset(WindowState window, int x, int y) {
379 if (window.mWallpaperDisplayOffsetX != x || window.mWallpaperDisplayOffsetY != y) {
380 window.mWallpaperDisplayOffsetX = x;
381 window.mWallpaperDisplayOffsetY = y;
382 updateWallpaperOffsetLocked(window, true);
383 }
384 }
385
386 Bundle sendWindowWallpaperCommand(
387 WindowState window, String action, int x, int y, int z, Bundle extras, boolean sync) {
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800388 if (window == mWallpaperTarget || window == mPrevWallpaperTarget) {
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700389 boolean doWait = sync;
390 for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
Jorim Jaggi879ff722016-11-04 18:08:17 -0700391 final WallpaperWindowToken token = mWallpaperTokens.get(curTokenNdx);
Wale Ogunwalee4da0c12016-07-29 12:47:02 -0700392 token.sendWindowWallpaperCommand(action, x, y, z, extras, sync);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700393 }
394
395 if (doWait) {
396 // TODO: Need to wait for result.
397 }
398 }
399
400 return null;
401 }
402
Wale Ogunwaleb0f3b832016-10-17 10:13:07 -0700403 private void updateWallpaperOffsetLocked(WindowState changingTarget, boolean sync) {
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700404 final DisplayContent displayContent = changingTarget.getDisplayContent();
405 if (displayContent == null) {
406 return;
407 }
408 final DisplayInfo displayInfo = displayContent.getDisplayInfo();
409 final int dw = displayInfo.logicalWidth;
410 final int dh = displayInfo.logicalHeight;
411
412 WindowState target = mWallpaperTarget;
413 if (target != null) {
414 if (target.mWallpaperX >= 0) {
415 mLastWallpaperX = target.mWallpaperX;
416 } else if (changingTarget.mWallpaperX >= 0) {
417 mLastWallpaperX = changingTarget.mWallpaperX;
418 }
419 if (target.mWallpaperY >= 0) {
420 mLastWallpaperY = target.mWallpaperY;
421 } else if (changingTarget.mWallpaperY >= 0) {
422 mLastWallpaperY = changingTarget.mWallpaperY;
423 }
424 if (target.mWallpaperDisplayOffsetX != Integer.MIN_VALUE) {
425 mLastWallpaperDisplayOffsetX = target.mWallpaperDisplayOffsetX;
426 } else if (changingTarget.mWallpaperDisplayOffsetX != Integer.MIN_VALUE) {
427 mLastWallpaperDisplayOffsetX = changingTarget.mWallpaperDisplayOffsetX;
428 }
429 if (target.mWallpaperDisplayOffsetY != Integer.MIN_VALUE) {
430 mLastWallpaperDisplayOffsetY = target.mWallpaperDisplayOffsetY;
431 } else if (changingTarget.mWallpaperDisplayOffsetY != Integer.MIN_VALUE) {
432 mLastWallpaperDisplayOffsetY = changingTarget.mWallpaperDisplayOffsetY;
433 }
434 if (target.mWallpaperXStep >= 0) {
435 mLastWallpaperXStep = target.mWallpaperXStep;
436 } else if (changingTarget.mWallpaperXStep >= 0) {
437 mLastWallpaperXStep = changingTarget.mWallpaperXStep;
438 }
439 if (target.mWallpaperYStep >= 0) {
440 mLastWallpaperYStep = target.mWallpaperYStep;
441 } else if (changingTarget.mWallpaperYStep >= 0) {
442 mLastWallpaperYStep = changingTarget.mWallpaperYStep;
443 }
444 }
445
446 for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
Wale Ogunwalee4da0c12016-07-29 12:47:02 -0700447 mWallpaperTokens.get(curTokenNdx).updateWallpaperOffset(dw, dh, sync);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700448 }
449 }
450
451 void clearLastWallpaperTimeoutTime() {
452 mLastWallpaperTimeoutTime = 0;
453 }
454
455 void wallpaperCommandComplete(IBinder window) {
456 if (mWaitingOnWallpaper != null &&
457 mWaitingOnWallpaper.mClient.asBinder() == window) {
458 mWaitingOnWallpaper = null;
459 mService.mWindowMap.notifyAll();
460 }
461 }
462
463 void wallpaperOffsetsComplete(IBinder window) {
464 if (mWaitingOnWallpaper != null &&
465 mWaitingOnWallpaper.mClient.asBinder() == window) {
466 mWaitingOnWallpaper = null;
467 mService.mWindowMap.notifyAll();
468 }
469 }
470
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800471 private void findWallpaperTarget(DisplayContent dc) {
472 mFindResults.reset();
Wale Ogunwale44f036f2017-09-29 05:09:09 -0700473 if (dc.isStackVisible(WINDOWING_MODE_FREEFORM)) {
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800474 // In freeform mode we set the wallpaper as its own target, so we don't need an
475 // additional window to make it visible.
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800476 mFindResults.setUseTopWallpaperAsTarget(true);
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800477 }
Wale Ogunwale6cbba702016-06-28 16:27:31 -0700478
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800479 dc.forAllWindows(mFindWallpaperTargetFunction, true /* traverseTopToBottom */);
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800480
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800481 if (mFindResults.wallpaperTarget == null && mFindResults.useTopWallpaperAsTarget) {
482 mFindResults.setWallpaperTarget(mFindResults.topWallpaper);
Wale Ogunwale21fdd912015-08-20 12:34:57 -0700483 }
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700484 }
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700485
Jorim Jaggife762342016-10-13 14:33:27 +0200486 private boolean isFullscreen(WindowManager.LayoutParams attrs) {
487 return attrs.x == 0 && attrs.y == 0
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800488 && attrs.width == MATCH_PARENT && attrs.height == MATCH_PARENT;
Jorim Jaggife762342016-10-13 14:33:27 +0200489 }
490
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700491 /** Updates the target wallpaper if needed and returns true if an update happened. */
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800492 private void updateWallpaperWindowsTarget(DisplayContent dc,
493 FindWallpaperTargetResult result) {
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700494
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700495 WindowState wallpaperTarget = result.wallpaperTarget;
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700496
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700497 if (mWallpaperTarget == wallpaperTarget
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800498 || (mPrevWallpaperTarget != null && mPrevWallpaperTarget == wallpaperTarget)) {
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700499
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800500 if (mPrevWallpaperTarget == null) {
501 return;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700502 }
503
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800504 // Is it time to stop animating?
505 if (!mPrevWallpaperTarget.isAnimatingLw()) {
506 if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG, "No longer animating wallpaper targets!");
507 mPrevWallpaperTarget = null;
508 mWallpaperTarget = wallpaperTarget;
509 }
510 return;
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700511 }
512
513 if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800514 "New wallpaper target: " + wallpaperTarget + " prevTarget: " + mWallpaperTarget);
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700515
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800516 mPrevWallpaperTarget = null;
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700517
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800518 final WindowState prevWallpaperTarget = mWallpaperTarget;
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700519 mWallpaperTarget = wallpaperTarget;
520
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800521 if (wallpaperTarget == null || prevWallpaperTarget == null) {
522 return;
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700523 }
524
525 // Now what is happening... if the current and new targets are animating,
526 // then we are in our super special mode!
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800527 boolean oldAnim = prevWallpaperTarget.isAnimatingLw();
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700528 boolean foundAnim = wallpaperTarget.isAnimatingLw();
529 if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
530 "New animation: " + foundAnim + " old animation: " + oldAnim);
531
532 if (!foundAnim || !oldAnim) {
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800533 return;
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700534 }
535
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800536 if (dc.getWindow(w -> w == prevWallpaperTarget) == null) {
537 return;
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700538 }
539
540 final boolean newTargetHidden = wallpaperTarget.mAppToken != null
541 && wallpaperTarget.mAppToken.hiddenRequested;
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800542 final boolean oldTargetHidden = prevWallpaperTarget.mAppToken != null
543 && prevWallpaperTarget.mAppToken.hiddenRequested;
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700544
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800545 if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG, "Animating wallpapers:" + " old: "
546 + prevWallpaperTarget + " hidden=" + oldTargetHidden + " new: " + wallpaperTarget
547 + " hidden=" + newTargetHidden);
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700548
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800549 mPrevWallpaperTarget = prevWallpaperTarget;
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700550
551 if (newTargetHidden && !oldTargetHidden) {
552 if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG, "Old wallpaper still the target.");
553 // Use the old target if new target is hidden but old target
554 // is not. If they're both hidden, still use the new target.
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800555 mWallpaperTarget = prevWallpaperTarget;
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700556 } else if (newTargetHidden == oldTargetHidden
557 && !mService.mOpeningApps.contains(wallpaperTarget.mAppToken)
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800558 && (mService.mOpeningApps.contains(prevWallpaperTarget.mAppToken)
559 || mService.mClosingApps.contains(prevWallpaperTarget.mAppToken))) {
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700560 // If they're both hidden (or both not hidden), prefer the one that's currently in
561 // opening or closing app list, this allows transition selection logic to better
562 // determine the wallpaper status of opening/closing apps.
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800563 mWallpaperTarget = prevWallpaperTarget;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700564 }
565
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800566 result.setWallpaperTarget(wallpaperTarget);
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700567 }
568
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800569 private void updateWallpaperTokens(boolean visible) {
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700570 for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
Jorim Jaggi879ff722016-11-04 18:08:17 -0700571 final WallpaperWindowToken token = mWallpaperTokens.get(curTokenNdx);
Jorim Jaggib0fc8172017-11-23 17:04:08 +0000572 token.updateWallpaperWindows(visible);
Robert Carrdee1b3f2017-02-27 11:33:33 -0800573 token.getDisplayContent().assignWindowLayers(false);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700574 }
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700575 }
576
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800577 void adjustWallpaperWindows(DisplayContent dc) {
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700578 mService.mRoot.mWallpaperMayChange = false;
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700579
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700580 // First find top-most window that has asked to be on top of the wallpaper;
581 // all wallpapers go behind it.
Wale Ogunwale1e129a42016-11-21 13:03:47 -0800582 findWallpaperTarget(dc);
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800583 updateWallpaperWindowsTarget(dc, mFindResults);
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700584
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800585 // The window is visible to the compositor...but is it visible to the user?
586 // That is what the wallpaper cares about.
587 final boolean visible = mWallpaperTarget != null && isWallpaperVisible(mWallpaperTarget);
588 if (DEBUG_WALLPAPER) Slog.v(TAG, "Wallpaper visibility: " + visible);
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700589
590 if (visible) {
591 if (mWallpaperTarget.mWallpaperX >= 0) {
592 mLastWallpaperX = mWallpaperTarget.mWallpaperX;
593 mLastWallpaperXStep = mWallpaperTarget.mWallpaperXStep;
594 }
595 if (mWallpaperTarget.mWallpaperY >= 0) {
596 mLastWallpaperY = mWallpaperTarget.mWallpaperY;
597 mLastWallpaperYStep = mWallpaperTarget.mWallpaperYStep;
598 }
599 if (mWallpaperTarget.mWallpaperDisplayOffsetX != Integer.MIN_VALUE) {
600 mLastWallpaperDisplayOffsetX = mWallpaperTarget.mWallpaperDisplayOffsetX;
601 }
602 if (mWallpaperTarget.mWallpaperDisplayOffsetY != Integer.MIN_VALUE) {
603 mLastWallpaperDisplayOffsetY = mWallpaperTarget.mWallpaperDisplayOffsetY;
604 }
605 }
606
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800607 updateWallpaperTokens(visible);
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700608
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800609 if (DEBUG_WALLPAPER_LIGHT) Slog.d(TAG, "New wallpaper: target=" + mWallpaperTarget
610 + " prev=" + mPrevWallpaperTarget);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700611 }
612
613 boolean processWallpaperDrawPendingTimeout() {
614 if (mWallpaperDrawState == WALLPAPER_DRAW_PENDING) {
615 mWallpaperDrawState = WALLPAPER_DRAW_TIMEOUT;
616 if (DEBUG_APP_TRANSITIONS || DEBUG_WALLPAPER) Slog.v(TAG,
617 "*** WALLPAPER DRAW TIMEOUT");
Winson Chunge2d72172018-01-25 17:46:20 +0000618
619 // If there was a recents animation in progress, cancel that animation
620 if (mService.getRecentsAnimationController() != null) {
621 mService.getRecentsAnimationController().cancelAnimation();
622 }
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700623 return true;
624 }
625 return false;
626 }
627
628 boolean wallpaperTransitionReady() {
629 boolean transitionReady = true;
630 boolean wallpaperReady = true;
631 for (int curTokenIndex = mWallpaperTokens.size() - 1;
632 curTokenIndex >= 0 && wallpaperReady; curTokenIndex--) {
Jorim Jaggi879ff722016-11-04 18:08:17 -0700633 final WallpaperWindowToken token = mWallpaperTokens.get(curTokenIndex);
Wale Ogunwalee4da0c12016-07-29 12:47:02 -0700634 if (token.hasVisibleNotDrawnWallpaper()) {
635 // We've told this wallpaper to be visible, but it is not drawn yet
636 wallpaperReady = false;
637 if (mWallpaperDrawState != WALLPAPER_DRAW_TIMEOUT) {
638 // wait for this wallpaper until it is drawn or timeout
639 transitionReady = false;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700640 }
Wale Ogunwalee4da0c12016-07-29 12:47:02 -0700641 if (mWallpaperDrawState == WALLPAPER_DRAW_NORMAL) {
642 mWallpaperDrawState = WALLPAPER_DRAW_PENDING;
643 mService.mH.removeMessages(WALLPAPER_DRAW_PENDING_TIMEOUT);
644 mService.mH.sendEmptyMessageDelayed(WALLPAPER_DRAW_PENDING_TIMEOUT,
645 WALLPAPER_DRAW_PENDING_TIMEOUT_DURATION);
646 }
647 if (DEBUG_APP_TRANSITIONS || DEBUG_WALLPAPER) Slog.v(TAG,
648 "Wallpaper should be visible but has not been drawn yet. " +
649 "mWallpaperDrawState=" + mWallpaperDrawState);
650 break;
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700651 }
652 }
653 if (wallpaperReady) {
654 mWallpaperDrawState = WALLPAPER_DRAW_NORMAL;
655 mService.mH.removeMessages(WALLPAPER_DRAW_PENDING_TIMEOUT);
656 }
657
658 return transitionReady;
659 }
660
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700661 /**
662 * Adjusts the wallpaper windows if the input display has a pending wallpaper layout or one of
663 * the opening apps should be a wallpaper target.
664 */
Wale Ogunwale0303c572016-10-20 10:16:29 -0700665 void adjustWallpaperWindowsForAppTransitionIfNeeded(DisplayContent dc,
666 ArraySet<AppWindowToken> openingApps) {
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700667 boolean adjust = false;
668 if ((dc.pendingLayoutChanges & FINISH_LAYOUT_REDO_WALLPAPER) != 0) {
669 adjust = true;
670 } else {
671 for (int i = openingApps.size() - 1; i >= 0; --i) {
672 final AppWindowToken token = openingApps.valueAt(i);
673 if (token.windowsCanBeWallpaperTarget()) {
674 adjust = true;
675 break;
676 }
677 }
678 }
679
Wale Ogunwale0303c572016-10-20 10:16:29 -0700680 if (adjust) {
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800681 adjustWallpaperWindows(dc);
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700682 }
683 }
684
Jorim Jaggi879ff722016-11-04 18:08:17 -0700685 void addWallpaperToken(WallpaperWindowToken token) {
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700686 mWallpaperTokens.add(token);
687 }
688
Jorim Jaggi879ff722016-11-04 18:08:17 -0700689 void removeWallpaperToken(WallpaperWindowToken token) {
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700690 mWallpaperTokens.remove(token);
691 }
692
chaviw0315a1a2018-03-05 15:28:35 -0800693 /**
694 * Take a screenshot of the wallpaper if it's visible.
695 *
696 * @return Bitmap of the wallpaper
697 */
698 Bitmap screenshotWallpaperLocked() {
699 if (!mService.mPolicy.isScreenOn()) {
700 if (DEBUG_SCREENSHOT) {
701 Slog.i(TAG_WM, "Attempted to take screenshot while display was off.");
702 }
703 return null;
704 }
705
706 final WindowState wallpaperWindowState = getTopVisibleWallpaper();
707 if (wallpaperWindowState == null) {
708 if (DEBUG_SCREENSHOT) {
709 Slog.i(TAG_WM, "No visible wallpaper to screenshot");
710 }
711 return null;
712 }
713
714 final Rect bounds = wallpaperWindowState.getBounds();
715 bounds.offsetTo(0, 0);
716
717 GraphicBuffer wallpaperBuffer = SurfaceControl.captureLayers(
718 wallpaperWindowState.getSurfaceControl().getHandle(), bounds, 1 /* frameScale */);
719
720 if (wallpaperBuffer == null) {
721 Slog.w(TAG_WM, "Failed to screenshot wallpaper");
722 return null;
723 }
724 return Bitmap.createHardwareBitmap(wallpaperBuffer);
725 }
726
727 private WindowState getTopVisibleWallpaper() {
728 mTmpTopWallpaper = null;
729
730 for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
731 final WallpaperWindowToken token = mWallpaperTokens.get(curTokenNdx);
732 token.forAllWindows(w -> {
733 final WindowStateAnimator winAnim = w.mWinAnimator;
734 if (winAnim != null && winAnim.getShown() && winAnim.mLastAlpha > 0f) {
735 mTmpTopWallpaper = w;
736 return true;
737 }
738 return false;
739 }, true /* traverseTopToBottom */);
740 }
741
742 return mTmpTopWallpaper;
743 }
744
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700745 void dump(PrintWriter pw, String prefix) {
746 pw.print(prefix); pw.print("mWallpaperTarget="); pw.println(mWallpaperTarget);
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800747 if (mPrevWallpaperTarget != null) {
748 pw.print(prefix); pw.print("mPrevWallpaperTarget="); pw.println(mPrevWallpaperTarget);
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700749 }
750 pw.print(prefix); pw.print("mLastWallpaperX="); pw.print(mLastWallpaperX);
751 pw.print(" mLastWallpaperY="); pw.println(mLastWallpaperY);
752 if (mLastWallpaperDisplayOffsetX != Integer.MIN_VALUE
753 || mLastWallpaperDisplayOffsetY != Integer.MIN_VALUE) {
754 pw.print(prefix);
755 pw.print("mLastWallpaperDisplayOffsetX="); pw.print(mLastWallpaperDisplayOffsetX);
756 pw.print(" mLastWallpaperDisplayOffsetY="); pw.println(mLastWallpaperDisplayOffsetY);
757 }
758 }
759
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700760 /** Helper class for storing the results of a wallpaper target find operation. */
761 final private static class FindWallpaperTargetResult {
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700762 WindowState topWallpaper = null;
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800763 boolean useTopWallpaperAsTarget = false;
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700764 WindowState wallpaperTarget = null;
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800765 boolean resetTopWallpaper = false;
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700766
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800767 void setTopWallpaper(WindowState win) {
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700768 topWallpaper = win;
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700769 }
770
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800771 void setWallpaperTarget(WindowState win) {
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700772 wallpaperTarget = win;
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800773 }
774
775 void setUseTopWallpaperAsTarget(boolean topWallpaperAsTarget) {
776 useTopWallpaperAsTarget = topWallpaperAsTarget;
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700777 }
778
779 void reset() {
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700780 topWallpaper = null;
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700781 wallpaperTarget = null;
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800782 useTopWallpaperAsTarget = false;
783 resetTopWallpaper = false;
Wale Ogunwale5f61d042015-08-20 10:09:47 -0700784 }
785 }
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700786}