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 | |
| 19 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 20 | import static com.android.server.wm.WindowManagerService.DEBUG_ANIM; |
| 21 | import static com.android.server.wm.WindowManagerService.DEBUG_APP_TRANSITIONS; |
| 22 | import static com.android.server.wm.WindowManagerService.TAG; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 23 | |
Jeff Brown | 4532e61 | 2012-04-05 14:27:12 -0700 | [diff] [blame] | 24 | import com.android.server.input.InputApplicationHandle; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 25 | import com.android.server.wm.WindowManagerService.H; |
| 26 | |
Filip Gruszczynski | a590c99 | 2015-11-25 16:45:26 -0800 | [diff] [blame] | 27 | import android.annotation.NonNull; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 28 | import android.content.pm.ActivityInfo; |
| 29 | import android.os.Message; |
| 30 | import android.os.RemoteException; |
| 31 | import android.util.Slog; |
| 32 | import android.view.IApplicationToken; |
| 33 | import android.view.View; |
| 34 | import android.view.WindowManager; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 35 | |
| 36 | import java.io.PrintWriter; |
Craig Mautner | b1fd65c0 | 2013-02-05 13:34:57 -0800 | [diff] [blame] | 37 | import java.util.ArrayList; |
| 38 | |
| 39 | class AppTokenList extends ArrayList<AppWindowToken> { |
| 40 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 41 | |
| 42 | /** |
| 43 | * Version of WindowToken that is specifically for a particular application (or |
| 44 | * really activity) that is displaying windows. |
| 45 | */ |
Craig Mautner | e32c307 | 2012-03-12 15:25:35 -0700 | [diff] [blame] | 46 | class AppWindowToken extends WindowToken { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 47 | // Non-null only for application tokens. |
| 48 | final IApplicationToken appToken; |
| 49 | |
| 50 | // All of the windows and child windows that are included in this |
| 51 | // application token. Note this list is NOT sorted! |
Craig Mautner | 9686833 | 2012-12-04 14:29:11 -0800 | [diff] [blame] | 52 | final WindowList allAppWindows = new WindowList(); |
Filip Gruszczynski | a590c99 | 2015-11-25 16:45:26 -0800 | [diff] [blame] | 53 | @NonNull final AppWindowAnimator mAppAnimator; |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 54 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 55 | final boolean voiceInteraction; |
| 56 | |
Chong Zhang | db20b5f | 2015-10-23 14:01:43 -0700 | [diff] [blame] | 57 | // Whether the window has a saved surface from last pause, which can be |
| 58 | // used to start an entering animation earlier. |
| 59 | boolean mHasSavedSurface; |
| 60 | |
| 61 | // Whether we're performing an entering animation with a saved surface. |
| 62 | boolean mAnimatingWithSavedSurface; |
| 63 | |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 64 | Task mTask; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 65 | boolean appFullscreen; |
| 66 | int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
Craig Mautner | 4c5eb22 | 2013-11-18 12:59:05 -0800 | [diff] [blame] | 67 | boolean layoutConfigChanges; |
Wale Ogunwale | 6dfdfd6 | 2015-04-15 12:01:38 -0700 | [diff] [blame] | 68 | boolean showForAllUsers; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 69 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 70 | // The input dispatching timeout for this application token in nanoseconds. |
| 71 | long inputDispatchingTimeoutNanos; |
| 72 | |
| 73 | // These are used for determining when all windows associated with |
| 74 | // an activity have been drawn, so they can be made visible together |
| 75 | // at the same time. |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 76 | // initialize so that it doesn't match mTransactionSequence which is an int. |
| 77 | long lastTransactionSequence = Long.MIN_VALUE; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 78 | int numInterestingWindows; |
| 79 | int numDrawnWindows; |
| 80 | boolean inPendingTransaction; |
| 81 | boolean allDrawn; |
Craig Mautner | 7636dfb | 2012-11-16 15:24:11 -0800 | [diff] [blame] | 82 | // Set to true when this app creates a surface while in the middle of an animation. In that |
| 83 | // case do not clear allDrawn until the animation completes. |
| 84 | boolean deferClearAllDrawn; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 85 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 86 | // Is this window's surface needed? This is almost like hidden, except |
| 87 | // it will sometimes be true a little earlier: when the token has |
| 88 | // been shown, but is still waiting for its app transition to execute |
| 89 | // before making its windows shown. |
| 90 | boolean hiddenRequested; |
| 91 | |
| 92 | // Have we told the window clients to hide themselves? |
| 93 | boolean clientHidden; |
| 94 | |
| 95 | // Last visibility state we reported to the app token. |
| 96 | boolean reportedVisible; |
| 97 | |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 98 | // Last drawn state we reported to the app token. |
| 99 | boolean reportedDrawn; |
| 100 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 101 | // Set to true when the token has been removed from the window mgr. |
| 102 | boolean removed; |
| 103 | |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 104 | boolean appDied; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 105 | // Information about an application starting window if displayed. |
| 106 | StartingData startingData; |
| 107 | WindowState startingWindow; |
| 108 | View startingView; |
| 109 | boolean startingDisplayed; |
| 110 | boolean startingMoved; |
| 111 | boolean firstWindowDrawn; |
| 112 | |
| 113 | // Input application handle used by the input dispatcher. |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 114 | final InputApplicationHandle mInputApplicationHandle; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 115 | |
Craig Mautner | 799bc1d | 2015-01-14 10:33:48 -0800 | [diff] [blame] | 116 | boolean mIsExiting; |
Craig Mautner | 9ef471f | 2014-02-07 13:11:47 -0800 | [diff] [blame] | 117 | |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 118 | boolean mLaunchTaskBehind; |
Craig Mautner | 8746a47 | 2014-07-24 15:12:54 -0700 | [diff] [blame] | 119 | boolean mEnteringAnimation; |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 120 | |
Wale Ogunwale | 61b009e | 2015-09-16 15:43:05 -0700 | [diff] [blame] | 121 | // True if the windows associated with this token should be cropped to their stack bounds. |
| 122 | boolean mCropWindowsToStack; |
| 123 | |
Filip Gruszczynski | 76cc44f | 2015-09-03 16:03:10 -0700 | [diff] [blame] | 124 | // This application will have its window replaced due to relaunch. This allows window manager |
| 125 | // to differentiate between simple removal of a window and replacement. In the latter case it |
| 126 | // will preserve the old window until the new one is drawn. |
Filip Gruszczynski | b6e6662 | 2015-10-25 16:05:27 -0700 | [diff] [blame] | 127 | boolean mWillReplaceWindow; |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 128 | // If true, the replaced window was already requested to be removed. |
| 129 | boolean mReplacingRemoveRequested; |
Jorim Jaggi | 030979c | 2015-11-20 15:14:43 -0800 | [diff] [blame] | 130 | // Whether the replacement of the window should trigger app transition animation. |
| 131 | boolean mAnimateReplacingWindow; |
Filip Gruszczynski | b6e6662 | 2015-10-25 16:05:27 -0700 | [diff] [blame] | 132 | // If not null, the window that will be used to replace the old one. This is being set when |
| 133 | // the window is added and unset when this window reports its first draw. |
| 134 | WindowState mReplacingWindow; |
Filip Gruszczynski | 78a08ee | 2015-11-08 18:04:32 -0800 | [diff] [blame] | 135 | // Whether the new window has replaced the old one, so the old one can be removed without |
| 136 | // blinking. |
| 137 | boolean mHasReplacedWindow; |
Filip Gruszczynski | 76cc44f | 2015-09-03 16:03:10 -0700 | [diff] [blame] | 138 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 139 | AppWindowToken(WindowManagerService _service, IApplicationToken _token, |
| 140 | boolean _voiceInteraction) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 141 | super(_service, _token.asBinder(), |
| 142 | WindowManager.LayoutParams.TYPE_APPLICATION, true); |
| 143 | appWindowToken = this; |
| 144 | appToken = _token; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 145 | voiceInteraction = _voiceInteraction; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 146 | mInputApplicationHandle = new InputApplicationHandle(this); |
Craig Mautner | 322e403 | 2012-07-13 13:35:20 -0700 | [diff] [blame] | 147 | mAppAnimator = new AppWindowAnimator(this); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | void sendAppVisibilityToClients() { |
| 151 | final int N = allAppWindows.size(); |
| 152 | for (int i=0; i<N; i++) { |
| 153 | WindowState win = allAppWindows.get(i); |
| 154 | if (win == startingWindow && clientHidden) { |
| 155 | // Don't hide the starting window. |
| 156 | continue; |
| 157 | } |
| 158 | try { |
| 159 | if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, |
| 160 | "Setting visibility of " + win + ": " + (!clientHidden)); |
| 161 | win.mClient.dispatchAppVisibility(!clientHidden); |
| 162 | } catch (RemoteException e) { |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 167 | void updateReportedVisibilityLocked() { |
| 168 | if (appToken == null) { |
| 169 | return; |
| 170 | } |
| 171 | |
| 172 | int numInteresting = 0; |
| 173 | int numVisible = 0; |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 174 | int numDrawn = 0; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 175 | boolean nowGone = true; |
| 176 | |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 177 | if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, |
| 178 | "Update reported visibility: " + this); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 179 | final int N = allAppWindows.size(); |
| 180 | for (int i=0; i<N; i++) { |
| 181 | WindowState win = allAppWindows.get(i); |
| 182 | if (win == startingWindow || win.mAppFreezing |
| 183 | || win.mViewVisibility != View.VISIBLE |
| 184 | || win.mAttrs.type == TYPE_APPLICATION_STARTING |
| 185 | || win.mDestroying) { |
| 186 | continue; |
| 187 | } |
| 188 | if (WindowManagerService.DEBUG_VISIBILITY) { |
| 189 | Slog.v(WindowManagerService.TAG, "Win " + win + ": isDrawn=" |
| 190 | + win.isDrawnLw() |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 191 | + ", isAnimating=" + win.mWinAnimator.isAnimating()); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 192 | if (!win.isDrawnLw()) { |
Robert Carr | e6a8351 | 2015-11-03 16:09:21 -0800 | [diff] [blame] | 193 | Slog.v(WindowManagerService.TAG, "Not displayed: s=" + |
| 194 | win.mWinAnimator.mSurfaceController |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 195 | + " pv=" + win.mPolicyVisibility |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 196 | + " mDrawState=" + win.mWinAnimator.mDrawState |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 197 | + " ah=" + win.mAttachedHidden |
| 198 | + " th=" |
| 199 | + (win.mAppToken != null |
| 200 | ? win.mAppToken.hiddenRequested : false) |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 201 | + " a=" + win.mWinAnimator.mAnimating); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 202 | } |
| 203 | } |
| 204 | numInteresting++; |
| 205 | if (win.isDrawnLw()) { |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 206 | numDrawn++; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 207 | if (!win.mWinAnimator.isAnimating()) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 208 | numVisible++; |
| 209 | } |
| 210 | nowGone = false; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 211 | } else if (win.mWinAnimator.isAnimating()) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 212 | nowGone = false; |
| 213 | } |
| 214 | } |
| 215 | |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 216 | boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 217 | boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting; |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 218 | if (!nowGone) { |
| 219 | // If the app is not yet gone, then it can only become visible/drawn. |
| 220 | if (!nowDrawn) { |
| 221 | nowDrawn = reportedDrawn; |
| 222 | } |
| 223 | if (!nowVisible) { |
| 224 | nowVisible = reportedVisible; |
| 225 | } |
| 226 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 227 | if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(WindowManagerService.TAG, "VIS " + this + ": interesting=" |
| 228 | + numInteresting + " visible=" + numVisible); |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 229 | if (nowDrawn != reportedDrawn) { |
| 230 | if (nowDrawn) { |
| 231 | Message m = service.mH.obtainMessage( |
| 232 | H.REPORT_APPLICATION_TOKEN_DRAWN, this); |
| 233 | service.mH.sendMessage(m); |
| 234 | } |
| 235 | reportedDrawn = nowDrawn; |
| 236 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 237 | if (nowVisible != reportedVisible) { |
| 238 | if (WindowManagerService.DEBUG_VISIBILITY) Slog.v( |
| 239 | WindowManagerService.TAG, "Visibility changed in " + this |
| 240 | + ": vis=" + nowVisible); |
| 241 | reportedVisible = nowVisible; |
| 242 | Message m = service.mH.obtainMessage( |
| 243 | H.REPORT_APPLICATION_TOKEN_WINDOWS, |
| 244 | nowVisible ? 1 : 0, |
| 245 | nowGone ? 1 : 0, |
| 246 | this); |
| 247 | service.mH.sendMessage(m); |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | WindowState findMainWindow() { |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 252 | WindowState candidate = null; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 253 | int j = windows.size(); |
| 254 | while (j > 0) { |
| 255 | j--; |
| 256 | WindowState win = windows.get(j); |
| 257 | if (win.mAttrs.type == WindowManager.LayoutParams.TYPE_BASE_APPLICATION |
| 258 | || win.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) { |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 259 | // In cases where there are multiple windows, we prefer the non-exiting window. This |
| 260 | // happens for example when when replacing windows during an activity relaunch. When |
| 261 | // constructing the animation, we want the new window, not the exiting one. |
| 262 | if (win.mExiting) { |
| 263 | candidate = win; |
| 264 | } else { |
| 265 | return win; |
| 266 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 267 | } |
| 268 | } |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 269 | return candidate; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 270 | } |
| 271 | |
Craig Mautner | 72669d1 | 2012-12-18 17:23:54 -0800 | [diff] [blame] | 272 | boolean isVisible() { |
| 273 | final int N = allAppWindows.size(); |
Craig Mautner | 72669d1 | 2012-12-18 17:23:54 -0800 | [diff] [blame] | 274 | for (int i=0; i<N; i++) { |
| 275 | WindowState win = allAppWindows.get(i); |
Chong Zhang | db20b5f | 2015-10-23 14:01:43 -0700 | [diff] [blame] | 276 | // If we're animating with a saved surface, we're already visible. |
| 277 | // Return true so that the alpha doesn't get cleared. |
Craig Mautner | 72669d1 | 2012-12-18 17:23:54 -0800 | [diff] [blame] | 278 | if (!win.mAppFreezing |
Filip Gruszczynski | 57f76f1 | 2015-11-04 16:10:54 -0800 | [diff] [blame] | 279 | && (win.mViewVisibility == View.VISIBLE || mAnimatingWithSavedSurface |
| 280 | || (win.mWinAnimator.isAnimating() |
| 281 | && !service.mAppTransition.isTransitionSet())) |
| 282 | && !win.mDestroying |
| 283 | && win.isDrawnLw()) { |
Craig Mautner | 72669d1 | 2012-12-18 17:23:54 -0800 | [diff] [blame] | 284 | return true; |
| 285 | } |
| 286 | } |
| 287 | return false; |
| 288 | } |
| 289 | |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 290 | void removeAppFromTaskLocked() { |
| 291 | mIsExiting = false; |
| 292 | removeAllWindows(); |
| 293 | |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 294 | // Use local variable because removeAppToken will null out mTask. |
| 295 | final Task task = mTask; |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 296 | if (task != null) { |
| 297 | if (!task.removeAppToken(this)) { |
| 298 | Slog.e(WindowManagerService.TAG, "removeAppFromTaskLocked: token=" + this |
| 299 | + " not found."); |
| 300 | } |
| 301 | task.mStack.mExitingAppTokens.remove(this); |
| 302 | } |
| 303 | } |
| 304 | |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 305 | /** |
| 306 | * Checks whether we should save surfaces for this app. |
| 307 | * |
| 308 | * @return true if the surfaces should be saved, false otherwise. |
| 309 | */ |
| 310 | boolean shouldSaveSurface() { |
| 311 | // We want to save surface if the app's windows are "allDrawn", or if we're |
| 312 | // currently animating with save surfaces. (If the app didn't even finish |
| 313 | // drawing when the user exits, but we have a saved surface from last time, |
| 314 | // we still want to keep that surface.) |
| 315 | mHasSavedSurface = allDrawn || mAnimatingWithSavedSurface; |
| 316 | if (mHasSavedSurface) { |
| 317 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 318 | "Saving surface: " + this); |
| 319 | return true; |
| 320 | } |
| 321 | return false; |
| 322 | } |
| 323 | |
| 324 | void restoreSavedSurfaces() { |
| 325 | if (!mHasSavedSurface) { |
| 326 | return; |
| 327 | } |
| 328 | |
| 329 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 330 | "Restoring saved surfaces: " + this + ", allDrawn=" + allDrawn); |
| 331 | |
| 332 | mHasSavedSurface = false; |
| 333 | mAnimatingWithSavedSurface = true; |
| 334 | for (int i = windows.size() - 1; i >= 0; i--) { |
| 335 | WindowState ws = windows.get(i); |
| 336 | ws.mWinAnimator.mDrawState = WindowStateAnimator.READY_TO_SHOW; |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | void destroySavedSurfaces() { |
| 341 | if (mHasSavedSurface) { |
| 342 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 343 | "Destroying saved surface: " + this); |
| 344 | for (int i = windows.size() - 1; i >= 0; i--) { |
| 345 | final WindowState win = windows.get(i); |
| 346 | win.mWinAnimator.destroySurfaceLocked(); |
| 347 | } |
| 348 | } |
| 349 | } |
| 350 | |
Wale Ogunwale | 98e70d0 | 2014-11-10 12:12:27 -0800 | [diff] [blame] | 351 | @Override |
Craig Mautner | 7c9ee19 | 2014-08-14 16:08:26 -0700 | [diff] [blame] | 352 | void removeAllWindows() { |
Craig Mautner | 7b4655d | 2014-11-20 12:13:22 -0800 | [diff] [blame] | 353 | for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; |
| 354 | // removeWindowLocked at bottom of loop may remove multiple entries from |
| 355 | // allAppWindows if the window to be removed has child windows. It also may |
| 356 | // not remove any windows from allAppWindows at all if win is exiting and |
| 357 | // currently animating away. This ensures that winNdx is monotonically decreasing |
| 358 | // and never beyond allAppWindows bounds. |
| 359 | winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) { |
| 360 | WindowState win = allAppWindows.get(winNdx); |
Wale Ogunwale | 98e70d0 | 2014-11-10 12:12:27 -0800 | [diff] [blame] | 361 | if (WindowManagerService.DEBUG_WINDOW_MOVEMENT) { |
| 362 | Slog.w(WindowManagerService.TAG, "removeAllWindows: removing win=" + win); |
| 363 | } |
| 364 | |
Wale Ogunwale | a6ab5c4 | 2015-04-24 09:00:25 -0700 | [diff] [blame] | 365 | service.removeWindowLocked(win); |
Craig Mautner | 7c9ee19 | 2014-08-14 16:08:26 -0700 | [diff] [blame] | 366 | } |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 367 | allAppWindows.clear(); |
| 368 | windows.clear(); |
Craig Mautner | 7c9ee19 | 2014-08-14 16:08:26 -0700 | [diff] [blame] | 369 | } |
| 370 | |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 371 | void removeAllDeadWindows() { |
| 372 | for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; |
| 373 | // removeWindowLocked at bottom of loop may remove multiple entries from |
| 374 | // allAppWindows if the window to be removed has child windows. It also may |
| 375 | // not remove any windows from allAppWindows at all if win is exiting and |
| 376 | // currently animating away. This ensures that winNdx is monotonically decreasing |
| 377 | // and never beyond allAppWindows bounds. |
| 378 | winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) { |
| 379 | WindowState win = allAppWindows.get(winNdx); |
| 380 | if (win.mAppDied) { |
| 381 | if (WindowManagerService.DEBUG_WINDOW_MOVEMENT) { |
| 382 | Slog.w(WindowManagerService.TAG, "removeAllDeadWindows: " + win); |
| 383 | } |
| 384 | // Set mDestroying, we don't want any animation or delayed removal here. |
| 385 | win.mDestroying = true; |
| 386 | service.removeWindowLocked(win); |
| 387 | } |
| 388 | } |
| 389 | } |
| 390 | |
Craig Mautner | dbb7991 | 2012-03-01 18:59:14 -0800 | [diff] [blame] | 391 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 392 | void dump(PrintWriter pw, String prefix) { |
| 393 | super.dump(pw, prefix); |
| 394 | if (appToken != null) { |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 395 | pw.print(prefix); pw.print("app=true voiceInteraction="); pw.println(voiceInteraction); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 396 | } |
| 397 | if (allAppWindows.size() > 0) { |
| 398 | pw.print(prefix); pw.print("allAppWindows="); pw.println(allAppWindows); |
| 399 | } |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 400 | pw.print(prefix); pw.print("task="); pw.println(mTask); |
| 401 | pw.print(prefix); pw.print(" appFullscreen="); pw.print(appFullscreen); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 402 | pw.print(" requestedOrientation="); pw.println(requestedOrientation); |
| 403 | pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested); |
| 404 | pw.print(" clientHidden="); pw.print(clientHidden); |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 405 | pw.print(" reportedDrawn="); pw.print(reportedDrawn); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 406 | pw.print(" reportedVisible="); pw.println(reportedVisible); |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 407 | if (paused) { |
| 408 | pw.print(prefix); pw.print("paused="); pw.println(paused); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 409 | } |
| 410 | if (numInterestingWindows != 0 || numDrawnWindows != 0 |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 411 | || allDrawn || mAppAnimator.allDrawn) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 412 | pw.print(prefix); pw.print("numInterestingWindows="); |
| 413 | pw.print(numInterestingWindows); |
| 414 | pw.print(" numDrawnWindows="); pw.print(numDrawnWindows); |
| 415 | pw.print(" inPendingTransaction="); pw.print(inPendingTransaction); |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 416 | pw.print(" allDrawn="); pw.print(allDrawn); |
| 417 | pw.print(" (animator="); pw.print(mAppAnimator.allDrawn); |
| 418 | pw.println(")"); |
| 419 | } |
| 420 | if (inPendingTransaction) { |
| 421 | pw.print(prefix); pw.print("inPendingTransaction="); |
| 422 | pw.println(inPendingTransaction); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 423 | } |
Craig Mautner | 799bc1d | 2015-01-14 10:33:48 -0800 | [diff] [blame] | 424 | if (startingData != null || removed || firstWindowDrawn || mIsExiting) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 425 | pw.print(prefix); pw.print("startingData="); pw.print(startingData); |
| 426 | pw.print(" removed="); pw.print(removed); |
Craig Mautner | 3d7ca31 | 2015-01-08 10:56:00 -0800 | [diff] [blame] | 427 | pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn); |
Craig Mautner | 799bc1d | 2015-01-14 10:33:48 -0800 | [diff] [blame] | 428 | pw.print(" mIsExiting="); pw.println(mIsExiting); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 429 | } |
| 430 | if (startingWindow != null || startingView != null |
| 431 | || startingDisplayed || startingMoved) { |
| 432 | pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow); |
| 433 | pw.print(" startingView="); pw.print(startingView); |
| 434 | pw.print(" startingDisplayed="); pw.print(startingDisplayed); |
| 435 | pw.print(" startingMoved"); pw.println(startingMoved); |
| 436 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | @Override |
| 440 | public String toString() { |
| 441 | if (stringName == null) { |
| 442 | StringBuilder sb = new StringBuilder(); |
| 443 | sb.append("AppWindowToken{"); |
| 444 | sb.append(Integer.toHexString(System.identityHashCode(this))); |
| 445 | sb.append(" token="); sb.append(token); sb.append('}'); |
| 446 | stringName = sb.toString(); |
| 447 | } |
| 448 | return stringName; |
| 449 | } |
Jeff Brown | e9bdb31 | 2012-04-05 15:30:10 -0700 | [diff] [blame] | 450 | } |