blob: 55d571dde0a4ca56430f22af5d65cc166915d2af [file] [log] [blame]
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001/*
2 * Copyright (C) 2011 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
19import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
20
Jeff Brown4532e612012-04-05 14:27:12 -070021import com.android.server.input.InputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080022import com.android.server.wm.WindowManagerService.H;
23
24import android.content.pm.ActivityInfo;
Dianne Hackborn8078d8c2012-03-20 11:11:26 -070025import android.graphics.Matrix;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080026import android.os.Message;
27import android.os.RemoteException;
28import android.util.Slog;
29import android.view.IApplicationToken;
Dianne Hackborn8078d8c2012-03-20 11:11:26 -070030import android.view.Surface;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080031import android.view.View;
32import android.view.WindowManager;
Craig Mautnere32c3072012-03-12 15:25:35 -070033import android.view.WindowManagerPolicy;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080034import android.view.animation.Animation;
35import android.view.animation.Transformation;
36
37import java.io.PrintWriter;
38import java.util.ArrayList;
39
40/**
41 * Version of WindowToken that is specifically for a particular application (or
42 * really activity) that is displaying windows.
43 */
Craig Mautnere32c3072012-03-12 15:25:35 -070044class AppWindowToken extends WindowToken {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080045 // Non-null only for application tokens.
46 final IApplicationToken appToken;
47
48 // All of the windows and child windows that are included in this
49 // application token. Note this list is NOT sorted!
50 final ArrayList<WindowState> allAppWindows = new ArrayList<WindowState>();
51
52 int groupId = -1;
53 boolean appFullscreen;
54 int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
Craig Mautnera2c77052012-03-26 12:14:43 -070055
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080056 // The input dispatching timeout for this application token in nanoseconds.
57 long inputDispatchingTimeoutNanos;
58
59 // These are used for determining when all windows associated with
60 // an activity have been drawn, so they can be made visible together
61 // at the same time.
Craig Mautner764983d2012-03-22 11:37:36 -070062 // initialize so that it doesn't match mTransactionSequence which is an int.
63 long lastTransactionSequence = Long.MIN_VALUE;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080064 int numInterestingWindows;
65 int numDrawnWindows;
66 boolean inPendingTransaction;
67 boolean allDrawn;
68
69 // Is this token going to be hidden in a little while? If so, it
70 // won't be taken into account for setting the screen orientation.
71 boolean willBeHidden;
72
73 // Is this window's surface needed? This is almost like hidden, except
74 // it will sometimes be true a little earlier: when the token has
75 // been shown, but is still waiting for its app transition to execute
76 // before making its windows shown.
77 boolean hiddenRequested;
78
79 // Have we told the window clients to hide themselves?
80 boolean clientHidden;
81
82 // Last visibility state we reported to the app token.
83 boolean reportedVisible;
84
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -070085 // Last drawn state we reported to the app token.
86 boolean reportedDrawn;
87
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080088 // Set to true when the token has been removed from the window mgr.
89 boolean removed;
90
91 // Have we been asked to have this token keep the screen frozen?
92 boolean freezingScreen;
93
94 boolean animating;
95 Animation animation;
Dianne Hackborn8078d8c2012-03-20 11:11:26 -070096 boolean animInitialized;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080097 boolean hasTransformation;
98 final Transformation transformation = new Transformation();
99
100 // Offset to the window of all layers in the token, for use by
101 // AppWindowToken animations.
102 int animLayerAdjustment;
103
104 // Information about an application starting window if displayed.
105 StartingData startingData;
106 WindowState startingWindow;
107 View startingView;
108 boolean startingDisplayed;
109 boolean startingMoved;
110 boolean firstWindowDrawn;
111
Dianne Hackborn8078d8c2012-03-20 11:11:26 -0700112 // Special surface for thumbnail animation.
113 Surface thumbnail;
114 int thumbnailTransactionSeq;
115 int thumbnailX;
116 int thumbnailY;
117 int thumbnailLayer;
118 Animation thumbnailAnimation;
119 final Transformation thumbnailTransformation = new Transformation();
120
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800121 // Input application handle used by the input dispatcher.
Jeff Brown9302c872011-07-13 22:51:29 -0700122 final InputApplicationHandle mInputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800123
124 AppWindowToken(WindowManagerService _service, IApplicationToken _token) {
125 super(_service, _token.asBinder(),
126 WindowManager.LayoutParams.TYPE_APPLICATION, true);
127 appWindowToken = this;
128 appToken = _token;
129 mInputApplicationHandle = new InputApplicationHandle(this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800130 }
131
Dianne Hackborn8078d8c2012-03-20 11:11:26 -0700132 public void setAnimation(Animation anim, boolean initialized) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800133 if (WindowManagerService.localLOGV) Slog.v(
134 WindowManagerService.TAG, "Setting animation in " + this + ": " + anim);
135 animation = anim;
136 animating = false;
Dianne Hackborn8078d8c2012-03-20 11:11:26 -0700137 animInitialized = initialized;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800138 anim.restrictDuration(WindowManagerService.MAX_ANIMATION_DURATION);
139 anim.scaleCurrentDuration(service.mTransitionAnimationScale);
140 int zorder = anim.getZAdjustment();
141 int adj = 0;
142 if (zorder == Animation.ZORDER_TOP) {
143 adj = WindowManagerService.TYPE_LAYER_OFFSET;
144 } else if (zorder == Animation.ZORDER_BOTTOM) {
145 adj = -WindowManagerService.TYPE_LAYER_OFFSET;
146 }
147
148 if (animLayerAdjustment != adj) {
149 animLayerAdjustment = adj;
150 updateLayers();
151 }
Craig Mautner22ce1412012-03-20 10:16:26 -0700152 // Start out animation gone if window is gone, or visible if window is visible.
153 transformation.clear();
154 transformation.setAlpha(reportedVisible ? 1 : 0);
155 hasTransformation = true;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800156 }
157
158 public void setDummyAnimation() {
159 if (animation == null) {
160 if (WindowManagerService.localLOGV) Slog.v(
161 WindowManagerService.TAG, "Setting dummy animation in " + this);
162 animation = WindowManagerService.sDummyAnimation;
Dianne Hackborn8078d8c2012-03-20 11:11:26 -0700163 animInitialized = false;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800164 }
165 }
166
167 public void clearAnimation() {
168 if (animation != null) {
169 animation = null;
170 animating = true;
Dianne Hackborn8078d8c2012-03-20 11:11:26 -0700171 animInitialized = false;
172 }
173 clearThumbnail();
174 }
175
176 public void clearThumbnail() {
177 if (thumbnail != null) {
178 thumbnail.destroy();
179 thumbnail = null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800180 }
181 }
182
183 void updateLayers() {
184 final int N = allAppWindows.size();
185 final int adj = animLayerAdjustment;
Dianne Hackborn8078d8c2012-03-20 11:11:26 -0700186 thumbnailLayer = -1;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800187 for (int i=0; i<N; i++) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700188 final WindowState w = allAppWindows.get(i);
189 final WindowStateAnimator winAnimator = w.mWinAnimator;
190 winAnimator.mAnimLayer = w.mLayer + adj;
191 if (winAnimator.mAnimLayer > thumbnailLayer) {
192 thumbnailLayer = winAnimator.mAnimLayer;
Dianne Hackborn8078d8c2012-03-20 11:11:26 -0700193 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800194 if (WindowManagerService.DEBUG_LAYERS) Slog.v(WindowManagerService.TAG, "Updating layer " + w + ": "
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700195 + winAnimator.mAnimLayer);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800196 if (w == service.mInputMethodTarget && !service.mInputMethodTargetWaitingAnim) {
197 service.setInputMethodAnimLayerAdjustment(adj);
198 }
199 if (w == service.mWallpaperTarget && service.mLowerWallpaperTarget == null) {
200 service.setWallpaperAnimLayerAdjustmentLocked(adj);
201 }
202 }
203 }
204
205 void sendAppVisibilityToClients() {
206 final int N = allAppWindows.size();
207 for (int i=0; i<N; i++) {
208 WindowState win = allAppWindows.get(i);
209 if (win == startingWindow && clientHidden) {
210 // Don't hide the starting window.
211 continue;
212 }
213 try {
214 if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG,
215 "Setting visibility of " + win + ": " + (!clientHidden));
216 win.mClient.dispatchAppVisibility(!clientHidden);
217 } catch (RemoteException e) {
218 }
219 }
220 }
221
Craig Mautner03273d02012-03-21 11:52:40 -0700222 boolean showAllWindowsLocked() {
223 boolean isAnimating = false;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800224 final int NW = allAppWindows.size();
225 for (int i=0; i<NW; i++) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700226 WindowStateAnimator winAnimator = allAppWindows.get(i).mWinAnimator;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800227 if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG,
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700228 "performing show on: " + winAnimator);
229 winAnimator.performShowLocked();
230 isAnimating |= winAnimator.isAnimating();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800231 }
Craig Mautner03273d02012-03-21 11:52:40 -0700232 return isAnimating;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800233 }
234
Dianne Hackborn8078d8c2012-03-20 11:11:26 -0700235 private void stepThumbnailAnimation(long currentTime) {
236 thumbnailTransformation.clear();
237 thumbnailAnimation.getTransformation(currentTime, thumbnailTransformation);
238 thumbnailTransformation.getMatrix().preTranslate(thumbnailX, thumbnailY);
239 final boolean screenAnimation = service.mAnimator.mScreenRotationAnimation != null
240 && service.mAnimator.mScreenRotationAnimation.isAnimating();
241 if (screenAnimation) {
242 thumbnailTransformation.postCompose(
243 service.mAnimator.mScreenRotationAnimation.getEnterTransformation());
244 }
245 // cache often used attributes locally
246 final float tmpFloats[] = service.mTmpFloats;
247 thumbnailTransformation.getMatrix().getValues(tmpFloats);
Craig Mautnera2c77052012-03-26 12:14:43 -0700248 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(thumbnail,
Dianne Hackborn8078d8c2012-03-20 11:11:26 -0700249 "thumbnail", "POS " + tmpFloats[Matrix.MTRANS_X]
250 + ", " + tmpFloats[Matrix.MTRANS_Y], null);
251 thumbnail.setPosition(tmpFloats[Matrix.MTRANS_X], tmpFloats[Matrix.MTRANS_Y]);
Craig Mautnera2c77052012-03-26 12:14:43 -0700252 if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(thumbnail,
Dianne Hackborn8078d8c2012-03-20 11:11:26 -0700253 "thumbnail", "alpha=" + thumbnailTransformation.getAlpha()
254 + " layer=" + thumbnailLayer
255 + " matrix=[" + tmpFloats[Matrix.MSCALE_X]
256 + "," + tmpFloats[Matrix.MSKEW_Y]
257 + "][" + tmpFloats[Matrix.MSKEW_X]
258 + "," + tmpFloats[Matrix.MSCALE_Y] + "]", null);
259 thumbnail.setAlpha(thumbnailTransformation.getAlpha());
260 // The thumbnail is layered below the window immediately above this
261 // token's anim layer.
262 thumbnail.setLayer(thumbnailLayer + WindowManagerService.WINDOW_LAYER_MULTIPLIER
263 - WindowManagerService.LAYER_OFFSET_THUMBNAIL);
264 thumbnail.setMatrix(tmpFloats[Matrix.MSCALE_X], tmpFloats[Matrix.MSKEW_Y],
265 tmpFloats[Matrix.MSKEW_X], tmpFloats[Matrix.MSCALE_Y]);
266 }
Craig Mautnere32c3072012-03-12 15:25:35 -0700267
268 private boolean stepAnimation(long currentTime) {
Craig Mautnerdbb79912012-03-01 18:59:14 -0800269 if (animation == null) {
270 return false;
271 }
272 transformation.clear();
273 final boolean more = animation.getTransformation(currentTime, transformation);
274 if (WindowManagerService.DEBUG_ANIM) Slog.v(
275 WindowManagerService.TAG, "Stepped animation in " + this +
276 ": more=" + more + ", xform=" + transformation);
277 if (!more) {
278 animation = null;
Dianne Hackborn8078d8c2012-03-20 11:11:26 -0700279 clearThumbnail();
Craig Mautnerdbb79912012-03-01 18:59:14 -0800280 if (WindowManagerService.DEBUG_ANIM) Slog.v(
281 WindowManagerService.TAG, "Finished animation in " + this +
282 " @ " + currentTime);
283 }
284 hasTransformation = more;
285 return more;
286 }
287
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800288 // This must be called while inside a transaction.
Craig Mautnere32c3072012-03-12 15:25:35 -0700289 boolean stepAnimationLocked(long currentTime, int dw, int dh) {
Craig Mautner2fb98b12012-03-20 17:24:00 -0700290 if (service.okToDisplay()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800291 // We will run animations as long as the display isn't frozen.
292
293 if (animation == WindowManagerService.sDummyAnimation) {
294 // This guy is going to animate, but not yet. For now count
295 // it as not animating for purposes of scheduling transactions;
296 // when it is really time to animate, this will be set to
297 // a real animation and the next call will execute normally.
298 return false;
299 }
300
301 if ((allDrawn || animating || startingDisplayed) && animation != null) {
302 if (!animating) {
303 if (WindowManagerService.DEBUG_ANIM) Slog.v(
304 WindowManagerService.TAG, "Starting animation in " + this +
305 " @ " + currentTime + ": dw=" + dw + " dh=" + dh
306 + " scale=" + service.mTransitionAnimationScale
307 + " allDrawn=" + allDrawn + " animating=" + animating);
Dianne Hackborn8078d8c2012-03-20 11:11:26 -0700308 if (!animInitialized) {
309 animation.initialize(dw, dh, dw, dh);
310 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800311 animation.setStartTime(currentTime);
312 animating = true;
Dianne Hackborn8078d8c2012-03-20 11:11:26 -0700313 if (thumbnail != null) {
314 thumbnail.show();
315 thumbnailAnimation.setStartTime(currentTime);
316 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800317 }
Craig Mautner1dd3ed02012-03-16 14:01:16 -0700318 if (stepAnimation(currentTime)) {
Dianne Hackborn8078d8c2012-03-20 11:11:26 -0700319 // animation isn't over, step any thumbnail and that's
320 // it for now.
321 if (thumbnail != null) {
322 stepThumbnailAnimation(currentTime);
323 }
Craig Mautner1dd3ed02012-03-16 14:01:16 -0700324 return true;
325 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800326 }
327 } else if (animation != null) {
328 // If the display is frozen, and there is a pending animation,
329 // clear it and make sure we run the cleanup code.
330 animating = true;
331 animation = null;
332 }
333
334 hasTransformation = false;
335
336 if (!animating) {
337 return false;
338 }
339
Craig Mautnere32c3072012-03-12 15:25:35 -0700340 service.mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
Craig Mautnercf8cbbe2012-03-25 21:54:36 -0700341 if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
342 service.debugLayoutRepeats("AppWindowToken");
343 }
344
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800345 clearAnimation();
346 animating = false;
347 if (animLayerAdjustment != 0) {
348 animLayerAdjustment = 0;
349 updateLayers();
350 }
351 if (service.mInputMethodTarget != null && service.mInputMethodTarget.mAppToken == this) {
352 service.moveInputMethodWindowsIfNeededLocked(true);
353 }
354
355 if (WindowManagerService.DEBUG_ANIM) Slog.v(
356 WindowManagerService.TAG, "Animation done in " + this
357 + ": reportedVisible=" + reportedVisible);
358
359 transformation.clear();
360
361 final int N = windows.size();
362 for (int i=0; i<N; i++) {
Craig Mautnera2c77052012-03-26 12:14:43 -0700363 windows.get(i).mWinAnimator.finishExit();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800364 }
365 updateReportedVisibilityLocked();
366
367 return false;
368 }
369
370 void updateReportedVisibilityLocked() {
371 if (appToken == null) {
372 return;
373 }
374
375 int numInteresting = 0;
376 int numVisible = 0;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700377 int numDrawn = 0;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800378 boolean nowGone = true;
379
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700380 if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG,
381 "Update reported visibility: " + this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800382 final int N = allAppWindows.size();
383 for (int i=0; i<N; i++) {
384 WindowState win = allAppWindows.get(i);
385 if (win == startingWindow || win.mAppFreezing
386 || win.mViewVisibility != View.VISIBLE
387 || win.mAttrs.type == TYPE_APPLICATION_STARTING
388 || win.mDestroying) {
389 continue;
390 }
391 if (WindowManagerService.DEBUG_VISIBILITY) {
392 Slog.v(WindowManagerService.TAG, "Win " + win + ": isDrawn="
393 + win.isDrawnLw()
Craig Mautnera2c77052012-03-26 12:14:43 -0700394 + ", isAnimating=" + win.mWinAnimator.isAnimating());
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800395 if (!win.isDrawnLw()) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700396 Slog.v(WindowManagerService.TAG, "Not displayed: s=" + win.mWinAnimator.mSurface
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800397 + " pv=" + win.mPolicyVisibility
Craig Mautner749a7bb2012-04-02 13:49:53 -0700398 + " mDrawState=" + win.mWinAnimator.mDrawState
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800399 + " ah=" + win.mAttachedHidden
400 + " th="
401 + (win.mAppToken != null
402 ? win.mAppToken.hiddenRequested : false)
Craig Mautnera2c77052012-03-26 12:14:43 -0700403 + " a=" + win.mWinAnimator.mAnimating);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800404 }
405 }
406 numInteresting++;
407 if (win.isDrawnLw()) {
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700408 numDrawn++;
Craig Mautnera2c77052012-03-26 12:14:43 -0700409 if (!win.mWinAnimator.isAnimating()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800410 numVisible++;
411 }
412 nowGone = false;
Craig Mautnera2c77052012-03-26 12:14:43 -0700413 } else if (win.mWinAnimator.isAnimating()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800414 nowGone = false;
415 }
416 }
417
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700418 boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800419 boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700420 if (!nowGone) {
421 // If the app is not yet gone, then it can only become visible/drawn.
422 if (!nowDrawn) {
423 nowDrawn = reportedDrawn;
424 }
425 if (!nowVisible) {
426 nowVisible = reportedVisible;
427 }
428 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800429 if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "VIS " + this + ": interesting="
430 + numInteresting + " visible=" + numVisible);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700431 if (nowDrawn != reportedDrawn) {
432 if (nowDrawn) {
433 Message m = service.mH.obtainMessage(
434 H.REPORT_APPLICATION_TOKEN_DRAWN, this);
435 service.mH.sendMessage(m);
436 }
437 reportedDrawn = nowDrawn;
438 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800439 if (nowVisible != reportedVisible) {
440 if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(
441 WindowManagerService.TAG, "Visibility changed in " + this
442 + ": vis=" + nowVisible);
443 reportedVisible = nowVisible;
444 Message m = service.mH.obtainMessage(
445 H.REPORT_APPLICATION_TOKEN_WINDOWS,
446 nowVisible ? 1 : 0,
447 nowGone ? 1 : 0,
448 this);
449 service.mH.sendMessage(m);
450 }
451 }
452
453 WindowState findMainWindow() {
454 int j = windows.size();
455 while (j > 0) {
456 j--;
457 WindowState win = windows.get(j);
458 if (win.mAttrs.type == WindowManager.LayoutParams.TYPE_BASE_APPLICATION
459 || win.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) {
460 return win;
461 }
462 }
463 return null;
464 }
465
Craig Mautnerdbb79912012-03-01 18:59:14 -0800466 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800467 void dump(PrintWriter pw, String prefix) {
468 super.dump(pw, prefix);
469 if (appToken != null) {
470 pw.print(prefix); pw.println("app=true");
471 }
472 if (allAppWindows.size() > 0) {
473 pw.print(prefix); pw.print("allAppWindows="); pw.println(allAppWindows);
474 }
475 pw.print(prefix); pw.print("groupId="); pw.print(groupId);
476 pw.print(" appFullscreen="); pw.print(appFullscreen);
477 pw.print(" requestedOrientation="); pw.println(requestedOrientation);
478 pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested);
479 pw.print(" clientHidden="); pw.print(clientHidden);
480 pw.print(" willBeHidden="); pw.print(willBeHidden);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700481 pw.print(" reportedDrawn="); pw.print(reportedDrawn);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800482 pw.print(" reportedVisible="); pw.println(reportedVisible);
483 if (paused || freezingScreen) {
484 pw.print(prefix); pw.print("paused="); pw.print(paused);
485 pw.print(" freezingScreen="); pw.println(freezingScreen);
486 }
487 if (numInterestingWindows != 0 || numDrawnWindows != 0
488 || inPendingTransaction || allDrawn) {
489 pw.print(prefix); pw.print("numInterestingWindows=");
490 pw.print(numInterestingWindows);
491 pw.print(" numDrawnWindows="); pw.print(numDrawnWindows);
492 pw.print(" inPendingTransaction="); pw.print(inPendingTransaction);
493 pw.print(" allDrawn="); pw.println(allDrawn);
494 }
495 if (animating || animation != null) {
496 pw.print(prefix); pw.print("animating="); pw.print(animating);
497 pw.print(" animation="); pw.println(animation);
498 }
499 if (hasTransformation) {
500 pw.print(prefix); pw.print("XForm: ");
501 transformation.printShortString(pw);
502 pw.println();
503 }
504 if (animLayerAdjustment != 0) {
505 pw.print(prefix); pw.print("animLayerAdjustment="); pw.println(animLayerAdjustment);
506 }
507 if (startingData != null || removed || firstWindowDrawn) {
508 pw.print(prefix); pw.print("startingData="); pw.print(startingData);
509 pw.print(" removed="); pw.print(removed);
510 pw.print(" firstWindowDrawn="); pw.println(firstWindowDrawn);
511 }
512 if (startingWindow != null || startingView != null
513 || startingDisplayed || startingMoved) {
514 pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow);
515 pw.print(" startingView="); pw.print(startingView);
516 pw.print(" startingDisplayed="); pw.print(startingDisplayed);
517 pw.print(" startingMoved"); pw.println(startingMoved);
518 }
Dianne Hackborn8078d8c2012-03-20 11:11:26 -0700519 if (thumbnail != null) {
520 pw.print(prefix); pw.print("thumbnail="); pw.print(thumbnail);
521 pw.print(" x="); pw.print(thumbnailX);
522 pw.print(" y="); pw.print(thumbnailY);
523 pw.print(" layer="); pw.println(thumbnailLayer);
524 pw.print(prefix); pw.print("thumbnailAnimation="); pw.println(thumbnailAnimation);
525 pw.print(prefix); pw.print("thumbnailTransformation=");
526 pw.println(thumbnailTransformation.toShortString());
527 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800528 }
529
530 @Override
531 public String toString() {
532 if (stringName == null) {
533 StringBuilder sb = new StringBuilder();
534 sb.append("AppWindowToken{");
535 sb.append(Integer.toHexString(System.identityHashCode(this)));
536 sb.append(" token="); sb.append(token); sb.append('}');
537 stringName = sb.toString();
538 }
539 return stringName;
540 }
541}