Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.server.wm; |
| 18 | |
Wale Ogunwale | 6cae765 | 2015-12-26 07:36:26 -0800 | [diff] [blame] | 19 | import static android.app.ActivityManager.StackId; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 20 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 21 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM; |
| 22 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS; |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 23 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE; |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 24 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STARTING_WINDOW; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 25 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY; |
| 26 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_MOVEMENT; |
| 27 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; |
| 28 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
Chong Zhang | f596cd5 | 2016-01-05 13:42:44 -0800 | [diff] [blame] | 29 | import static com.android.server.wm.WindowManagerService.WINDOW_REPLACEMENT_TIMEOUT_DURATION; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 30 | |
Jeff Brown | 4532e61 | 2012-04-05 14:27:12 -0700 | [diff] [blame] | 31 | import com.android.server.input.InputApplicationHandle; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 32 | import com.android.server.wm.WindowManagerService.H; |
| 33 | |
Filip Gruszczynski | a590c99 | 2015-11-25 16:45:26 -0800 | [diff] [blame] | 34 | import android.annotation.NonNull; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 35 | import android.content.pm.ActivityInfo; |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 36 | import android.graphics.Rect; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 37 | import android.os.Message; |
| 38 | import android.os.RemoteException; |
| 39 | import android.util.Slog; |
| 40 | import android.view.IApplicationToken; |
| 41 | import android.view.View; |
| 42 | import android.view.WindowManager; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 43 | |
| 44 | import java.io.PrintWriter; |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 45 | import java.util.ArrayDeque; |
Craig Mautner | b1fd65c0 | 2013-02-05 13:34:57 -0800 | [diff] [blame] | 46 | import java.util.ArrayList; |
| 47 | |
| 48 | class AppTokenList extends ArrayList<AppWindowToken> { |
| 49 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 50 | |
| 51 | /** |
| 52 | * Version of WindowToken that is specifically for a particular application (or |
| 53 | * really activity) that is displaying windows. |
| 54 | */ |
Craig Mautner | e32c307 | 2012-03-12 15:25:35 -0700 | [diff] [blame] | 55 | class AppWindowToken extends WindowToken { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 56 | private static final String TAG = TAG_WITH_CLASS_NAME ? "AppWindowToken" : TAG_WM; |
| 57 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 58 | // Non-null only for application tokens. |
| 59 | final IApplicationToken appToken; |
| 60 | |
| 61 | // All of the windows and child windows that are included in this |
| 62 | // application token. Note this list is NOT sorted! |
Craig Mautner | 9686833 | 2012-12-04 14:29:11 -0800 | [diff] [blame] | 63 | final WindowList allAppWindows = new WindowList(); |
Filip Gruszczynski | a590c99 | 2015-11-25 16:45:26 -0800 | [diff] [blame] | 64 | @NonNull final AppWindowAnimator mAppAnimator; |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 65 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 66 | final boolean voiceInteraction; |
| 67 | |
Chong Zhang | db20b5f | 2015-10-23 14:01:43 -0700 | [diff] [blame] | 68 | // Whether we're performing an entering animation with a saved surface. |
| 69 | boolean mAnimatingWithSavedSurface; |
| 70 | |
Jorim Jaggi | 4846ee3 | 2016-01-07 17:39:12 +0100 | [diff] [blame] | 71 | |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 72 | Task mTask; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 73 | boolean appFullscreen; |
| 74 | int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
Craig Mautner | 4c5eb22 | 2013-11-18 12:59:05 -0800 | [diff] [blame] | 75 | boolean layoutConfigChanges; |
Wale Ogunwale | 6dfdfd6 | 2015-04-15 12:01:38 -0700 | [diff] [blame] | 76 | boolean showForAllUsers; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 77 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 78 | // The input dispatching timeout for this application token in nanoseconds. |
| 79 | long inputDispatchingTimeoutNanos; |
| 80 | |
| 81 | // These are used for determining when all windows associated with |
| 82 | // an activity have been drawn, so they can be made visible together |
| 83 | // at the same time. |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 84 | // initialize so that it doesn't match mTransactionSequence which is an int. |
| 85 | long lastTransactionSequence = Long.MIN_VALUE; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 86 | int numInterestingWindows; |
| 87 | int numDrawnWindows; |
| 88 | boolean inPendingTransaction; |
| 89 | boolean allDrawn; |
Craig Mautner | 7636dfb | 2012-11-16 15:24:11 -0800 | [diff] [blame] | 90 | // Set to true when this app creates a surface while in the middle of an animation. In that |
| 91 | // case do not clear allDrawn until the animation completes. |
| 92 | boolean deferClearAllDrawn; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 93 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 94 | // Is this window's surface needed? This is almost like hidden, except |
| 95 | // it will sometimes be true a little earlier: when the token has |
| 96 | // been shown, but is still waiting for its app transition to execute |
| 97 | // before making its windows shown. |
| 98 | boolean hiddenRequested; |
| 99 | |
| 100 | // Have we told the window clients to hide themselves? |
| 101 | boolean clientHidden; |
| 102 | |
| 103 | // Last visibility state we reported to the app token. |
| 104 | boolean reportedVisible; |
| 105 | |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 106 | // Last drawn state we reported to the app token. |
| 107 | boolean reportedDrawn; |
| 108 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 109 | // Set to true when the token has been removed from the window mgr. |
| 110 | boolean removed; |
| 111 | |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 112 | boolean appDied; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 113 | // Information about an application starting window if displayed. |
| 114 | StartingData startingData; |
| 115 | WindowState startingWindow; |
| 116 | View startingView; |
| 117 | boolean startingDisplayed; |
| 118 | boolean startingMoved; |
| 119 | boolean firstWindowDrawn; |
| 120 | |
| 121 | // Input application handle used by the input dispatcher. |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 122 | final InputApplicationHandle mInputApplicationHandle; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 123 | |
Craig Mautner | 799bc1d | 2015-01-14 10:33:48 -0800 | [diff] [blame] | 124 | boolean mIsExiting; |
Craig Mautner | 9ef471f | 2014-02-07 13:11:47 -0800 | [diff] [blame] | 125 | |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 126 | boolean mLaunchTaskBehind; |
Craig Mautner | 8746a47 | 2014-07-24 15:12:54 -0700 | [diff] [blame] | 127 | boolean mEnteringAnimation; |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 128 | |
Wale Ogunwale | 6cae765 | 2015-12-26 07:36:26 -0800 | [diff] [blame] | 129 | boolean mAlwaysFocusable; |
| 130 | |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 131 | boolean mAppStopped; |
| 132 | |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 133 | ArrayDeque<Rect> mFrozenBounds = new ArrayDeque<>(); |
| 134 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 135 | AppWindowToken(WindowManagerService _service, IApplicationToken _token, |
| 136 | boolean _voiceInteraction) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 137 | super(_service, _token.asBinder(), |
| 138 | WindowManager.LayoutParams.TYPE_APPLICATION, true); |
| 139 | appWindowToken = this; |
| 140 | appToken = _token; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 141 | voiceInteraction = _voiceInteraction; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 142 | mInputApplicationHandle = new InputApplicationHandle(this); |
Craig Mautner | 322e403 | 2012-07-13 13:35:20 -0700 | [diff] [blame] | 143 | mAppAnimator = new AppWindowAnimator(this); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | void sendAppVisibilityToClients() { |
| 147 | final int N = allAppWindows.size(); |
| 148 | for (int i=0; i<N; i++) { |
| 149 | WindowState win = allAppWindows.get(i); |
| 150 | if (win == startingWindow && clientHidden) { |
| 151 | // Don't hide the starting window. |
| 152 | continue; |
| 153 | } |
| 154 | try { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 155 | if (DEBUG_VISIBILITY) Slog.v(TAG, |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 156 | "Setting visibility of " + win + ": " + (!clientHidden)); |
| 157 | win.mClient.dispatchAppVisibility(!clientHidden); |
| 158 | } catch (RemoteException e) { |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 163 | void onFirstWindowDrawn(WindowState win, WindowStateAnimator winAnimator) { |
| 164 | firstWindowDrawn = true; |
| 165 | |
| 166 | // We now have a good window to show, remove dead placeholders |
| 167 | removeAllDeadWindows(); |
| 168 | |
| 169 | if (startingData != null) { |
| 170 | if (DEBUG_STARTING_WINDOW || DEBUG_ANIM) Slog.v(TAG, "Finish starting " |
| 171 | + win.mToken + ": first real window is shown, no animation"); |
| 172 | // If this initial window is animating, stop it -- we will do an animation to reveal |
| 173 | // it from behind the starting window, so there is no need for it to also be doing its |
| 174 | // own stuff. |
| 175 | winAnimator.clearAnimation(); |
| 176 | winAnimator.mService.mFinishedStarting.add(this); |
| 177 | winAnimator.mService.mH.sendEmptyMessage(H.FINISHED_STARTING); |
| 178 | } |
| 179 | updateReportedVisibilityLocked(); |
| 180 | } |
| 181 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 182 | void updateReportedVisibilityLocked() { |
| 183 | if (appToken == null) { |
| 184 | return; |
| 185 | } |
| 186 | |
| 187 | int numInteresting = 0; |
| 188 | int numVisible = 0; |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 189 | int numDrawn = 0; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 190 | boolean nowGone = true; |
| 191 | |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 192 | if (DEBUG_VISIBILITY) Slog.v(TAG, |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 193 | "Update reported visibility: " + this); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 194 | final int N = allAppWindows.size(); |
| 195 | for (int i=0; i<N; i++) { |
| 196 | WindowState win = allAppWindows.get(i); |
| 197 | if (win == startingWindow || win.mAppFreezing |
| 198 | || win.mViewVisibility != View.VISIBLE |
| 199 | || win.mAttrs.type == TYPE_APPLICATION_STARTING |
| 200 | || win.mDestroying) { |
| 201 | continue; |
| 202 | } |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 203 | if (DEBUG_VISIBILITY) { |
| 204 | Slog.v(TAG, "Win " + win + ": isDrawn=" |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 205 | + win.isDrawnLw() |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 206 | + ", isAnimating=" + win.mWinAnimator.isAnimating()); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 207 | if (!win.isDrawnLw()) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 208 | Slog.v(TAG, "Not displayed: s=" + |
Robert Carr | e6a8351 | 2015-11-03 16:09:21 -0800 | [diff] [blame] | 209 | win.mWinAnimator.mSurfaceController |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 210 | + " pv=" + win.mPolicyVisibility |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 211 | + " mDrawState=" + win.mWinAnimator.mDrawState |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 212 | + " ah=" + win.mAttachedHidden |
| 213 | + " th=" |
| 214 | + (win.mAppToken != null |
| 215 | ? win.mAppToken.hiddenRequested : false) |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 216 | + " a=" + win.mWinAnimator.mAnimating); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 217 | } |
| 218 | } |
| 219 | numInteresting++; |
| 220 | if (win.isDrawnLw()) { |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 221 | numDrawn++; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 222 | if (!win.mWinAnimator.isAnimating()) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 223 | numVisible++; |
| 224 | } |
| 225 | nowGone = false; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 226 | } else if (win.mWinAnimator.isAnimating()) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 227 | nowGone = false; |
| 228 | } |
| 229 | } |
| 230 | |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 231 | boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 232 | boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting; |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 233 | if (!nowGone) { |
| 234 | // If the app is not yet gone, then it can only become visible/drawn. |
| 235 | if (!nowDrawn) { |
| 236 | nowDrawn = reportedDrawn; |
| 237 | } |
| 238 | if (!nowVisible) { |
| 239 | nowVisible = reportedVisible; |
| 240 | } |
| 241 | } |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 242 | if (DEBUG_VISIBILITY) Slog.v(TAG, "VIS " + this + ": interesting=" |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 243 | + numInteresting + " visible=" + numVisible); |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 244 | if (nowDrawn != reportedDrawn) { |
| 245 | if (nowDrawn) { |
| 246 | Message m = service.mH.obtainMessage( |
| 247 | H.REPORT_APPLICATION_TOKEN_DRAWN, this); |
| 248 | service.mH.sendMessage(m); |
| 249 | } |
| 250 | reportedDrawn = nowDrawn; |
| 251 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 252 | if (nowVisible != reportedVisible) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 253 | if (DEBUG_VISIBILITY) Slog.v( |
| 254 | TAG, "Visibility changed in " + this |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 255 | + ": vis=" + nowVisible); |
| 256 | reportedVisible = nowVisible; |
| 257 | Message m = service.mH.obtainMessage( |
| 258 | H.REPORT_APPLICATION_TOKEN_WINDOWS, |
| 259 | nowVisible ? 1 : 0, |
| 260 | nowGone ? 1 : 0, |
| 261 | this); |
| 262 | service.mH.sendMessage(m); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | WindowState findMainWindow() { |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 267 | WindowState candidate = null; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 268 | int j = windows.size(); |
| 269 | while (j > 0) { |
| 270 | j--; |
| 271 | WindowState win = windows.get(j); |
| 272 | if (win.mAttrs.type == WindowManager.LayoutParams.TYPE_BASE_APPLICATION |
| 273 | || win.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) { |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 274 | // In cases where there are multiple windows, we prefer the non-exiting window. This |
Sungsoo Lim | 0d3d1f8 | 2015-12-02 14:47:59 +0900 | [diff] [blame] | 275 | // happens for example when replacing windows during an activity relaunch. When |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 276 | // constructing the animation, we want the new window, not the exiting one. |
Wale Ogunwale | c48a354 | 2016-02-19 15:18:45 -0800 | [diff] [blame] | 277 | if (win.mAnimatingExit) { |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 278 | candidate = win; |
| 279 | } else { |
| 280 | return win; |
| 281 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 282 | } |
| 283 | } |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 284 | return candidate; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 285 | } |
| 286 | |
Wale Ogunwale | 6cae765 | 2015-12-26 07:36:26 -0800 | [diff] [blame] | 287 | boolean windowsAreFocusable() { |
| 288 | return StackId.canReceiveKeys(mTask.mStack.mStackId) || mAlwaysFocusable; |
Wale Ogunwale | d045c82 | 2015-12-02 09:14:28 -0800 | [diff] [blame] | 289 | } |
| 290 | |
Craig Mautner | 72669d1 | 2012-12-18 17:23:54 -0800 | [diff] [blame] | 291 | boolean isVisible() { |
| 292 | final int N = allAppWindows.size(); |
Craig Mautner | 72669d1 | 2012-12-18 17:23:54 -0800 | [diff] [blame] | 293 | for (int i=0; i<N; i++) { |
| 294 | WindowState win = allAppWindows.get(i); |
Chong Zhang | db20b5f | 2015-10-23 14:01:43 -0700 | [diff] [blame] | 295 | // If we're animating with a saved surface, we're already visible. |
| 296 | // Return true so that the alpha doesn't get cleared. |
Craig Mautner | 72669d1 | 2012-12-18 17:23:54 -0800 | [diff] [blame] | 297 | if (!win.mAppFreezing |
Filip Gruszczynski | 57f76f1 | 2015-11-04 16:10:54 -0800 | [diff] [blame] | 298 | && (win.mViewVisibility == View.VISIBLE || mAnimatingWithSavedSurface |
| 299 | || (win.mWinAnimator.isAnimating() |
| 300 | && !service.mAppTransition.isTransitionSet())) |
| 301 | && !win.mDestroying |
| 302 | && win.isDrawnLw()) { |
Craig Mautner | 72669d1 | 2012-12-18 17:23:54 -0800 | [diff] [blame] | 303 | return true; |
| 304 | } |
| 305 | } |
| 306 | return false; |
| 307 | } |
| 308 | |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 309 | void removeAppFromTaskLocked() { |
| 310 | mIsExiting = false; |
| 311 | removeAllWindows(); |
| 312 | |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 313 | // Use local variable because removeAppToken will null out mTask. |
| 314 | final Task task = mTask; |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 315 | if (task != null) { |
| 316 | if (!task.removeAppToken(this)) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 317 | Slog.e(TAG, "removeAppFromTaskLocked: token=" + this |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 318 | + " not found."); |
| 319 | } |
| 320 | task.mStack.mExitingAppTokens.remove(this); |
| 321 | } |
| 322 | } |
| 323 | |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 324 | void setWindowsExiting(boolean exiting) { |
Chong Zhang | eb22e8e | 2016-01-20 19:52:22 -0800 | [diff] [blame] | 325 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 326 | WindowState win = allAppWindows.get(i); |
Chong Zhang | 6bb8250 | 2016-02-02 14:13:48 -0800 | [diff] [blame] | 327 | // If the app already requested to remove its window, we don't modify |
| 328 | // its exiting state. Otherwise the stale window won't get removed on |
| 329 | // exit and could cause focus to be given to the wrong window. |
Wale Ogunwale | c48a354 | 2016-02-19 15:18:45 -0800 | [diff] [blame] | 330 | if (!(win.mRemoveOnExit && win.mAnimatingExit)) { |
| 331 | win.mAnimatingExit = exiting; |
Chong Zhang | 6bb8250 | 2016-02-02 14:13:48 -0800 | [diff] [blame] | 332 | } |
Chong Zhang | 5471e90 | 2016-02-12 15:34:10 -0800 | [diff] [blame] | 333 | // If we're no longer exiting, remove the window from destroying list |
Wale Ogunwale | c48a354 | 2016-02-19 15:18:45 -0800 | [diff] [blame] | 334 | if (!win.mAnimatingExit && win.mDestroying) { |
Chong Zhang | 5471e90 | 2016-02-12 15:34:10 -0800 | [diff] [blame] | 335 | win.mDestroying = false; |
| 336 | service.mDestroySurface.remove(win); |
| 337 | } |
Chong Zhang | eb22e8e | 2016-01-20 19:52:22 -0800 | [diff] [blame] | 338 | } |
| 339 | } |
| 340 | |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 341 | // Here we destroy surfaces which have been marked as eligible by the animator, taking care |
| 342 | // to ensure the client has finished with them. If the client could still be using them |
| 343 | // we will skip destruction and try again when the client has stopped. |
| 344 | void destroySurfaces() { |
| 345 | final ArrayList<WindowState> allWindows = (ArrayList<WindowState>) allAppWindows.clone(); |
| 346 | final DisplayContentList displayList = new DisplayContentList(); |
| 347 | for (int i = allWindows.size() - 1; i >= 0; i--) { |
| 348 | final WindowState win = allWindows.get(i); |
| 349 | if (!win.mDestroying) { |
| 350 | continue; |
| 351 | } |
| 352 | |
Wale Ogunwale | c48a354 | 2016-02-19 15:18:45 -0800 | [diff] [blame] | 353 | if (!(mAppStopped || win.mWindowRemovalAllowed)) { |
Chong Zhang | 5471e90 | 2016-02-12 15:34:10 -0800 | [diff] [blame] | 354 | continue; |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 355 | } |
| 356 | |
Wale Ogunwale | 8d5a542 | 2016-03-03 18:28:21 -0800 | [diff] [blame] | 357 | if (DEBUG_ADD_REMOVE) Slog.e(TAG_WM, "win=" + win |
| 358 | + " destroySurfaces: mAppStopped=" + mAppStopped |
| 359 | + " win.mWindowRemovalAllowed=" + win.mWindowRemovalAllowed |
| 360 | + " win.mRemoveOnExit=" + win.mRemoveOnExit); |
| 361 | |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 362 | win.destroyOrSaveSurface(); |
| 363 | if (win.mRemoveOnExit) { |
Wale Ogunwale | c48a354 | 2016-02-19 15:18:45 -0800 | [diff] [blame] | 364 | win.mAnimatingExit = false; |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 365 | service.removeWindowInnerLocked(win); |
| 366 | } |
| 367 | final DisplayContent displayContent = win.getDisplayContent(); |
| 368 | if (displayContent != null && !displayList.contains(displayContent)) { |
| 369 | displayList.add(displayContent); |
| 370 | } |
| 371 | win.mDestroying = false; |
| 372 | } |
| 373 | for (int i = 0; i < displayList.size(); i++) { |
| 374 | final DisplayContent displayContent = displayList.get(i); |
| 375 | service.mLayersController.assignLayersLocked(displayContent.getWindowList()); |
| 376 | displayContent.layoutNeeded = true; |
| 377 | } |
| 378 | } |
| 379 | |
Wale Ogunwale | 8d5a542 | 2016-03-03 18:28:21 -0800 | [diff] [blame] | 380 | /** |
| 381 | * If the application has stopped it is okay to destroy any surfaces which were keeping alive |
| 382 | * in case they were still being used. |
| 383 | */ |
| 384 | void notifyAppStopped(boolean stopped) { |
| 385 | if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppStopped: stopped=" + stopped + " " + this); |
| 386 | mAppStopped = stopped; |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 387 | |
Wale Ogunwale | 8d5a542 | 2016-03-03 18:28:21 -0800 | [diff] [blame] | 388 | if (stopped) { |
| 389 | destroySurfaces(); |
| 390 | // Remove any starting window that was added for this app if they are still around. |
| 391 | mTask.mService.scheduleRemoveStartingWindowLocked(this); |
| 392 | } |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 393 | } |
| 394 | |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 395 | /** |
| 396 | * Checks whether we should save surfaces for this app. |
| 397 | * |
| 398 | * @return true if the surfaces should be saved, false otherwise. |
| 399 | */ |
| 400 | boolean shouldSaveSurface() { |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 401 | // We want to save surface if the app's windows are "allDrawn". |
| 402 | // (If we started entering animation early with saved surfaces, allDrawn |
| 403 | // should have been restored to true. So we'll save again in that case |
| 404 | // even if app didn't actually finish drawing.) |
| 405 | return allDrawn; |
Robert Carr | 13f7be9e | 2015-12-02 18:39:45 -0800 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | boolean hasSavedSurface() { |
| 409 | for (int i = windows.size() -1; i >= 0; i--) { |
| 410 | final WindowState ws = windows.get(i); |
| 411 | if (ws.hasSavedSurface()) { |
| 412 | return true; |
| 413 | } |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 414 | } |
| 415 | return false; |
| 416 | } |
| 417 | |
| 418 | void restoreSavedSurfaces() { |
Robert Carr | 13f7be9e | 2015-12-02 18:39:45 -0800 | [diff] [blame] | 419 | if (!hasSavedSurface()) { |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 420 | return; |
| 421 | } |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 422 | mAnimatingWithSavedSurface = true; |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 423 | |
| 424 | // Check if we have enough drawn windows to mark allDrawn= true. |
| 425 | int numInteresting = 0; |
| 426 | int numDrawn = 0; |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 427 | for (int i = windows.size() - 1; i >= 0; i--) { |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 428 | WindowState w = windows.get(i); |
Chong Zhang | 4113ffa | 2016-02-18 12:39:13 -0800 | [diff] [blame] | 429 | if (w.hasSavedSurface()) { |
| 430 | w.restoreSavedSurface(); |
| 431 | } |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 432 | if (w != startingWindow && !w.mAppDied |
| 433 | && (!mAppAnimator.freezingScreen || !w.mAppFreezing)) { |
| 434 | numInteresting++; |
| 435 | if (w.isDrawnLw()) { |
| 436 | numDrawn++; |
| 437 | } |
| 438 | } |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 439 | } |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 440 | |
Chong Zhang | 4113ffa | 2016-02-18 12:39:13 -0800 | [diff] [blame] | 441 | allDrawn |= (numInteresting > 0) && (numInteresting == numDrawn); |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 442 | |
| 443 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG, |
| 444 | "restoreSavedSurfaces: " + appWindowToken + " allDrawn=" + allDrawn); |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | void destroySavedSurfaces() { |
Robert Carr | 13f7be9e | 2015-12-02 18:39:45 -0800 | [diff] [blame] | 448 | for (int i = windows.size() - 1; i >= 0; i--) { |
| 449 | WindowState win = windows.get(i); |
| 450 | win.destroySavedSurface(); |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 451 | } |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 452 | mAnimatingWithSavedSurface = false; |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 453 | } |
| 454 | |
Wale Ogunwale | 98e70d0 | 2014-11-10 12:12:27 -0800 | [diff] [blame] | 455 | @Override |
Craig Mautner | 7c9ee19 | 2014-08-14 16:08:26 -0700 | [diff] [blame] | 456 | void removeAllWindows() { |
Craig Mautner | 7b4655d | 2014-11-20 12:13:22 -0800 | [diff] [blame] | 457 | for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; |
| 458 | // removeWindowLocked at bottom of loop may remove multiple entries from |
| 459 | // allAppWindows if the window to be removed has child windows. It also may |
| 460 | // not remove any windows from allAppWindows at all if win is exiting and |
| 461 | // currently animating away. This ensures that winNdx is monotonically decreasing |
| 462 | // and never beyond allAppWindows bounds. |
| 463 | winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) { |
| 464 | WindowState win = allAppWindows.get(winNdx); |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 465 | if (DEBUG_WINDOW_MOVEMENT) { |
| 466 | Slog.w(TAG, "removeAllWindows: removing win=" + win); |
Wale Ogunwale | 98e70d0 | 2014-11-10 12:12:27 -0800 | [diff] [blame] | 467 | } |
| 468 | |
Wale Ogunwale | a6ab5c4 | 2015-04-24 09:00:25 -0700 | [diff] [blame] | 469 | service.removeWindowLocked(win); |
Craig Mautner | 7c9ee19 | 2014-08-14 16:08:26 -0700 | [diff] [blame] | 470 | } |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 471 | allAppWindows.clear(); |
| 472 | windows.clear(); |
Craig Mautner | 7c9ee19 | 2014-08-14 16:08:26 -0700 | [diff] [blame] | 473 | } |
| 474 | |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 475 | void removeAllDeadWindows() { |
| 476 | for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; |
| 477 | // removeWindowLocked at bottom of loop may remove multiple entries from |
| 478 | // allAppWindows if the window to be removed has child windows. It also may |
| 479 | // not remove any windows from allAppWindows at all if win is exiting and |
| 480 | // currently animating away. This ensures that winNdx is monotonically decreasing |
| 481 | // and never beyond allAppWindows bounds. |
| 482 | winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) { |
| 483 | WindowState win = allAppWindows.get(winNdx); |
| 484 | if (win.mAppDied) { |
Wale Ogunwale | 2728bf4 | 2016-03-03 11:03:26 -0800 | [diff] [blame] | 485 | if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 486 | Slog.w(TAG, "removeAllDeadWindows: " + win); |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 487 | } |
| 488 | // Set mDestroying, we don't want any animation or delayed removal here. |
| 489 | win.mDestroying = true; |
| 490 | service.removeWindowLocked(win); |
| 491 | } |
| 492 | } |
| 493 | } |
| 494 | |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 495 | void setReplacingWindows(boolean animate) { |
| 496 | if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + appWindowToken |
| 497 | + " with replacing windows."); |
| 498 | |
| 499 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 500 | final WindowState w = allAppWindows.get(i); |
| 501 | w.setReplacing(animate); |
| 502 | } |
| 503 | if (animate) { |
| 504 | // Set-up dummy animation so we can start treating windows associated with this |
| 505 | // token like they are in transition before the new app window is ready for us to |
| 506 | // run the real transition animation. |
| 507 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, |
| 508 | "setReplacingWindow() Setting dummy animation on: " + this); |
| 509 | mAppAnimator.setDummyAnimation(); |
| 510 | } |
| 511 | } |
| 512 | |
Robert Carr | 23fa16b | 2016-01-13 13:19:58 -0800 | [diff] [blame] | 513 | void setReplacingChildren() { |
| 514 | if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + appWindowToken |
| 515 | + " with replacing child windows."); |
| 516 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 517 | final WindowState w = allAppWindows.get(i); |
| 518 | if (w.isChildWindow()) { |
| 519 | w.setReplacing(false /* animate */); |
| 520 | } |
| 521 | } |
| 522 | } |
| 523 | |
Chong Zhang | f596cd5 | 2016-01-05 13:42:44 -0800 | [diff] [blame] | 524 | void resetReplacingWindows() { |
| 525 | if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Resetting app token " + appWindowToken |
| 526 | + " of replacing window marks."); |
| 527 | |
| 528 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 529 | final WindowState w = allAppWindows.get(i); |
| 530 | w.resetReplacing(); |
| 531 | } |
| 532 | } |
| 533 | |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 534 | void addWindow(WindowState w) { |
| 535 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 536 | WindowState candidate = allAppWindows.get(i); |
| 537 | if (candidate.mWillReplaceWindow && candidate.mReplacingWindow == null && |
| 538 | candidate.getWindowTag().equals(w.getWindowTag().toString())) { |
| 539 | candidate.mReplacingWindow = w; |
Chong Zhang | f596cd5 | 2016-01-05 13:42:44 -0800 | [diff] [blame] | 540 | |
| 541 | // if we got a replacement window, reset the timeout to give drawing more time |
| 542 | service.mH.removeMessages(H.WINDOW_REPLACEMENT_TIMEOUT); |
| 543 | service.mH.sendMessageDelayed( |
| 544 | service.mH.obtainMessage(H.WINDOW_REPLACEMENT_TIMEOUT, this), |
| 545 | WINDOW_REPLACEMENT_TIMEOUT_DURATION); |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 546 | } |
| 547 | } |
| 548 | allAppWindows.add(w); |
| 549 | } |
| 550 | |
| 551 | boolean waitingForReplacement() { |
| 552 | for (int i = allAppWindows.size() -1; i >= 0; i--) { |
| 553 | WindowState candidate = allAppWindows.get(i); |
| 554 | if (candidate.mWillReplaceWindow) { |
| 555 | return true; |
| 556 | } |
| 557 | } |
| 558 | return false; |
| 559 | } |
| 560 | |
Chong Zhang | f596cd5 | 2016-01-05 13:42:44 -0800 | [diff] [blame] | 561 | void clearTimedoutReplacesLocked() { |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 562 | for (int i = allAppWindows.size() - 1; i >= 0; |
| 563 | // removeWindowLocked at bottom of loop may remove multiple entries from |
| 564 | // allAppWindows if the window to be removed has child windows. It also may |
| 565 | // not remove any windows from allAppWindows at all if win is exiting and |
| 566 | // currently animating away. This ensures that winNdx is monotonically decreasing |
| 567 | // and never beyond allAppWindows bounds. |
| 568 | i = Math.min(i - 1, allAppWindows.size() - 1)) { |
| 569 | WindowState candidate = allAppWindows.get(i); |
| 570 | if (candidate.mWillReplaceWindow == false) { |
| 571 | continue; |
| 572 | } |
| 573 | candidate.mWillReplaceWindow = false; |
Chong Zhang | f596cd5 | 2016-01-05 13:42:44 -0800 | [diff] [blame] | 574 | // Since the window already timed out, remove it immediately now. |
| 575 | // Use removeWindowInnerLocked() instead of removeWindowLocked(), as the latter |
| 576 | // delays removal on certain conditions, which will leave the stale window in the |
| 577 | // stack and marked mWillReplaceWindow=false, so the window will never be removed. |
| 578 | service.removeWindowInnerLocked(candidate); |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 579 | } |
| 580 | } |
| 581 | |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 582 | /** |
| 583 | * Freezes the task bounds. The size of this task reported the app will be fixed to the bounds |
| 584 | * freezed by {@link Task#prepareFreezingBounds} until {@link #unfreezeBounds} gets called, even |
| 585 | * if they change in the meantime. If the bounds are already frozen, the bounds will be frozen |
| 586 | * with a queue. |
| 587 | */ |
| 588 | void freezeBounds() { |
| 589 | mFrozenBounds.offer(new Rect(mTask.mPreparedFrozenBounds)); |
| 590 | } |
| 591 | |
| 592 | /** |
| 593 | * Unfreezes the previously frozen bounds. See {@link #freezeBounds}. |
| 594 | */ |
| 595 | void unfreezeBounds() { |
| 596 | mFrozenBounds.remove(); |
Jorim Jaggi | 4846ee3 | 2016-01-07 17:39:12 +0100 | [diff] [blame] | 597 | for (int i = windows.size() - 1; i >= 0; i--) { |
| 598 | final WindowState win = windows.get(i); |
Jorim Jaggi | 69abc19 | 2016-02-04 19:34:00 -0800 | [diff] [blame] | 599 | if (!win.mHasSurface) { |
| 600 | continue; |
| 601 | } |
Jorim Jaggi | 4846ee3 | 2016-01-07 17:39:12 +0100 | [diff] [blame] | 602 | win.mLayoutNeeded = true; |
| 603 | win.setDisplayLayoutNeeded(); |
| 604 | if (!service.mResizingWindows.contains(win)) { |
| 605 | service.mResizingWindows.add(win); |
| 606 | } |
| 607 | } |
| 608 | service.mWindowPlacerLocked.performSurfacePlacement(); |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 609 | } |
| 610 | |
Craig Mautner | dbb7991 | 2012-03-01 18:59:14 -0800 | [diff] [blame] | 611 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 612 | void dump(PrintWriter pw, String prefix) { |
| 613 | super.dump(pw, prefix); |
| 614 | if (appToken != null) { |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 615 | pw.print(prefix); pw.print("app=true voiceInteraction="); pw.println(voiceInteraction); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 616 | } |
| 617 | if (allAppWindows.size() > 0) { |
| 618 | pw.print(prefix); pw.print("allAppWindows="); pw.println(allAppWindows); |
| 619 | } |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 620 | pw.print(prefix); pw.print("task="); pw.println(mTask); |
| 621 | pw.print(prefix); pw.print(" appFullscreen="); pw.print(appFullscreen); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 622 | pw.print(" requestedOrientation="); pw.println(requestedOrientation); |
| 623 | pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested); |
| 624 | pw.print(" clientHidden="); pw.print(clientHidden); |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 625 | pw.print(" reportedDrawn="); pw.print(reportedDrawn); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 626 | pw.print(" reportedVisible="); pw.println(reportedVisible); |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 627 | if (paused) { |
| 628 | pw.print(prefix); pw.print("paused="); pw.println(paused); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 629 | } |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 630 | if (mAppStopped) { |
| 631 | pw.print(prefix); pw.print("mAppStopped="); pw.println(mAppStopped); |
| 632 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 633 | if (numInterestingWindows != 0 || numDrawnWindows != 0 |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 634 | || allDrawn || mAppAnimator.allDrawn) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 635 | pw.print(prefix); pw.print("numInterestingWindows="); |
| 636 | pw.print(numInterestingWindows); |
| 637 | pw.print(" numDrawnWindows="); pw.print(numDrawnWindows); |
| 638 | pw.print(" inPendingTransaction="); pw.print(inPendingTransaction); |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 639 | pw.print(" allDrawn="); pw.print(allDrawn); |
| 640 | pw.print(" (animator="); pw.print(mAppAnimator.allDrawn); |
| 641 | pw.println(")"); |
| 642 | } |
| 643 | if (inPendingTransaction) { |
| 644 | pw.print(prefix); pw.print("inPendingTransaction="); |
| 645 | pw.println(inPendingTransaction); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 646 | } |
Craig Mautner | 799bc1d | 2015-01-14 10:33:48 -0800 | [diff] [blame] | 647 | if (startingData != null || removed || firstWindowDrawn || mIsExiting) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 648 | pw.print(prefix); pw.print("startingData="); pw.print(startingData); |
| 649 | pw.print(" removed="); pw.print(removed); |
Craig Mautner | 3d7ca31 | 2015-01-08 10:56:00 -0800 | [diff] [blame] | 650 | pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn); |
Craig Mautner | 799bc1d | 2015-01-14 10:33:48 -0800 | [diff] [blame] | 651 | pw.print(" mIsExiting="); pw.println(mIsExiting); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 652 | } |
| 653 | if (startingWindow != null || startingView != null |
| 654 | || startingDisplayed || startingMoved) { |
| 655 | pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow); |
| 656 | pw.print(" startingView="); pw.print(startingView); |
| 657 | pw.print(" startingDisplayed="); pw.print(startingDisplayed); |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 658 | pw.print(" startingMoved="); pw.println(startingMoved); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 659 | } |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 660 | if (!mFrozenBounds.isEmpty()) { |
| 661 | pw.print(prefix); pw.print("mFrozenBounds="); pw.print(mFrozenBounds); |
| 662 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 663 | } |
| 664 | |
| 665 | @Override |
| 666 | public String toString() { |
| 667 | if (stringName == null) { |
| 668 | StringBuilder sb = new StringBuilder(); |
| 669 | sb.append("AppWindowToken{"); |
| 670 | sb.append(Integer.toHexString(System.identityHashCode(this))); |
| 671 | sb.append(" token="); sb.append(token); sb.append('}'); |
| 672 | stringName = sb.toString(); |
| 673 | } |
| 674 | return stringName; |
| 675 | } |
Jeff Brown | e9bdb31 | 2012-04-05 15:30:10 -0700 | [diff] [blame] | 676 | } |