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