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; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame^] | 20 | import static android.view.Display.DEFAULT_DISPLAY; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 21 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame^] | 22 | import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; |
| 23 | import static android.view.WindowManagerPolicy.TRANSIT_ENTER; |
| 24 | import static android.view.WindowManagerPolicy.TRANSIT_EXIT; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 25 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM; |
| 26 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS; |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 27 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame^] | 28 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYERS; |
| 29 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT_REPEATS; |
| 30 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION; |
| 31 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_RESIZE; |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 32 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STARTING_WINDOW; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 33 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY; |
| 34 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_MOVEMENT; |
| 35 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; |
| 36 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 37 | import static com.android.server.wm.WindowManagerService.H.NOTIFY_ACTIVITY_DRAWN; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame^] | 38 | import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE_SURFACES; |
| 39 | import static com.android.server.wm.WindowManagerService.WINDOWS_FREEZING_SCREENS_TIMEOUT; |
| 40 | import static com.android.server.wm.WindowManagerService.logWithStack; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 41 | |
Jeff Brown | 4532e61 | 2012-04-05 14:27:12 -0700 | [diff] [blame] | 42 | import com.android.server.input.InputApplicationHandle; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 43 | import com.android.server.wm.WindowManagerService.H; |
| 44 | |
Filip Gruszczynski | a590c99 | 2015-11-25 16:45:26 -0800 | [diff] [blame] | 45 | import android.annotation.NonNull; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 46 | import android.content.pm.ActivityInfo; |
Jorim Jaggi | 26c8c42 | 2016-05-09 19:57:25 -0700 | [diff] [blame] | 47 | import android.content.res.Configuration; |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 48 | import android.graphics.Rect; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame^] | 49 | import android.os.Binder; |
| 50 | import android.os.IBinder; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 51 | import android.os.Message; |
| 52 | import android.os.RemoteException; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame^] | 53 | import android.os.SystemClock; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 54 | import android.util.Slog; |
| 55 | import android.view.IApplicationToken; |
| 56 | import android.view.View; |
| 57 | import android.view.WindowManager; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 58 | |
| 59 | import java.io.PrintWriter; |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 60 | import java.util.ArrayDeque; |
Craig Mautner | b1fd65c0 | 2013-02-05 13:34:57 -0800 | [diff] [blame] | 61 | import java.util.ArrayList; |
| 62 | |
| 63 | class AppTokenList extends ArrayList<AppWindowToken> { |
| 64 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 65 | |
| 66 | /** |
| 67 | * Version of WindowToken that is specifically for a particular application (or |
| 68 | * really activity) that is displaying windows. |
| 69 | */ |
Craig Mautner | e32c307 | 2012-03-12 15:25:35 -0700 | [diff] [blame] | 70 | class AppWindowToken extends WindowToken { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 71 | private static final String TAG = TAG_WITH_CLASS_NAME ? "AppWindowToken" : TAG_WM; |
| 72 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 73 | // Non-null only for application tokens. |
| 74 | final IApplicationToken appToken; |
| 75 | |
| 76 | // All of the windows and child windows that are included in this |
| 77 | // application token. Note this list is NOT sorted! |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame^] | 78 | private final WindowList allAppWindows = new WindowList(); |
Filip Gruszczynski | a590c99 | 2015-11-25 16:45:26 -0800 | [diff] [blame] | 79 | @NonNull final AppWindowAnimator mAppAnimator; |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 80 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 81 | final boolean voiceInteraction; |
| 82 | |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 83 | Task mTask; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 84 | boolean appFullscreen; |
| 85 | int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
Craig Mautner | 4c5eb22 | 2013-11-18 12:59:05 -0800 | [diff] [blame] | 86 | boolean layoutConfigChanges; |
Wale Ogunwale | 6dfdfd6 | 2015-04-15 12:01:38 -0700 | [diff] [blame] | 87 | boolean showForAllUsers; |
Yorke Lee | 0e85247 | 2016-06-15 10:03:18 -0700 | [diff] [blame] | 88 | int targetSdk; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 89 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 90 | // The input dispatching timeout for this application token in nanoseconds. |
| 91 | long inputDispatchingTimeoutNanos; |
| 92 | |
| 93 | // These are used for determining when all windows associated with |
| 94 | // an activity have been drawn, so they can be made visible together |
| 95 | // at the same time. |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 96 | // initialize so that it doesn't match mTransactionSequence which is an int. |
| 97 | long lastTransactionSequence = Long.MIN_VALUE; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 98 | int numInterestingWindows; |
| 99 | int numDrawnWindows; |
| 100 | boolean inPendingTransaction; |
| 101 | boolean allDrawn; |
Craig Mautner | 7636dfb | 2012-11-16 15:24:11 -0800 | [diff] [blame] | 102 | // Set to true when this app creates a surface while in the middle of an animation. In that |
| 103 | // case do not clear allDrawn until the animation completes. |
| 104 | boolean deferClearAllDrawn; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 105 | |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 106 | // These are to track the app's real drawing status if there were no saved surfaces. |
| 107 | boolean allDrawnExcludingSaved; |
| 108 | int numInterestingWindowsExcludingSaved; |
| 109 | int numDrawnWindowsExclusingSaved; |
| 110 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 111 | // Is this window's surface needed? This is almost like hidden, except |
| 112 | // it will sometimes be true a little earlier: when the token has |
| 113 | // been shown, but is still waiting for its app transition to execute |
| 114 | // before making its windows shown. |
| 115 | boolean hiddenRequested; |
| 116 | |
| 117 | // Have we told the window clients to hide themselves? |
| 118 | boolean clientHidden; |
| 119 | |
| 120 | // Last visibility state we reported to the app token. |
| 121 | boolean reportedVisible; |
| 122 | |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 123 | // Last drawn state we reported to the app token. |
| 124 | boolean reportedDrawn; |
| 125 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 126 | // Set to true when the token has been removed from the window mgr. |
| 127 | boolean removed; |
| 128 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 129 | // Information about an application starting window if displayed. |
| 130 | StartingData startingData; |
| 131 | WindowState startingWindow; |
| 132 | View startingView; |
| 133 | boolean startingDisplayed; |
| 134 | boolean startingMoved; |
| 135 | boolean firstWindowDrawn; |
| 136 | |
| 137 | // Input application handle used by the input dispatcher. |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 138 | final InputApplicationHandle mInputApplicationHandle; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 139 | |
Craig Mautner | 799bc1d | 2015-01-14 10:33:48 -0800 | [diff] [blame] | 140 | boolean mIsExiting; |
Craig Mautner | 9ef471f | 2014-02-07 13:11:47 -0800 | [diff] [blame] | 141 | |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 142 | boolean mLaunchTaskBehind; |
Craig Mautner | 8746a47 | 2014-07-24 15:12:54 -0700 | [diff] [blame] | 143 | boolean mEnteringAnimation; |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 144 | |
Wale Ogunwale | 6cae765 | 2015-12-26 07:36:26 -0800 | [diff] [blame] | 145 | boolean mAlwaysFocusable; |
| 146 | |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 147 | boolean mAppStopped; |
Robert Carr | fd10cd1 | 2016-06-29 16:41:50 -0700 | [diff] [blame] | 148 | int mRotationAnimationHint; |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 149 | int mPendingRelaunchCount; |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 150 | |
Robert Carr | 91b22809 | 2016-06-28 17:32:37 -0700 | [diff] [blame] | 151 | private ArrayList<WindowSurfaceController.SurfaceControlWithBackground> mSurfaceViewBackgrounds = |
| 152 | new ArrayList<WindowSurfaceController.SurfaceControlWithBackground>(); |
| 153 | |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 154 | ArrayDeque<Rect> mFrozenBounds = new ArrayDeque<>(); |
Jorim Jaggi | 26c8c42 | 2016-05-09 19:57:25 -0700 | [diff] [blame] | 155 | ArrayDeque<Configuration> mFrozenMergedConfig = new ArrayDeque<>(); |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 156 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 157 | AppWindowToken(WindowManagerService _service, IApplicationToken _token, |
| 158 | boolean _voiceInteraction) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 159 | super(_service, _token.asBinder(), |
| 160 | WindowManager.LayoutParams.TYPE_APPLICATION, true); |
| 161 | appWindowToken = this; |
| 162 | appToken = _token; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 163 | voiceInteraction = _voiceInteraction; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 164 | mInputApplicationHandle = new InputApplicationHandle(this); |
Craig Mautner | 322e403 | 2012-07-13 13:35:20 -0700 | [diff] [blame] | 165 | mAppAnimator = new AppWindowAnimator(this); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | void sendAppVisibilityToClients() { |
| 169 | final int N = allAppWindows.size(); |
| 170 | for (int i=0; i<N; i++) { |
| 171 | WindowState win = allAppWindows.get(i); |
| 172 | if (win == startingWindow && clientHidden) { |
| 173 | // Don't hide the starting window. |
| 174 | continue; |
| 175 | } |
| 176 | try { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 177 | if (DEBUG_VISIBILITY) Slog.v(TAG, |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 178 | "Setting visibility of " + win + ": " + (!clientHidden)); |
| 179 | win.mClient.dispatchAppVisibility(!clientHidden); |
| 180 | } catch (RemoteException e) { |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 185 | void setVisibleBeforeClientHidden() { |
| 186 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 187 | final WindowState w = allAppWindows.get(i); |
| 188 | w.setVisibleBeforeClientHidden(); |
| 189 | } |
| 190 | } |
| 191 | |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 192 | void onFirstWindowDrawn(WindowState win, WindowStateAnimator winAnimator) { |
| 193 | firstWindowDrawn = true; |
| 194 | |
| 195 | // We now have a good window to show, remove dead placeholders |
| 196 | removeAllDeadWindows(); |
| 197 | |
| 198 | if (startingData != null) { |
| 199 | if (DEBUG_STARTING_WINDOW || DEBUG_ANIM) Slog.v(TAG, "Finish starting " |
| 200 | + win.mToken + ": first real window is shown, no animation"); |
| 201 | // If this initial window is animating, stop it -- we will do an animation to reveal |
| 202 | // it from behind the starting window, so there is no need for it to also be doing its |
| 203 | // own stuff. |
| 204 | winAnimator.clearAnimation(); |
| 205 | winAnimator.mService.mFinishedStarting.add(this); |
| 206 | winAnimator.mService.mH.sendEmptyMessage(H.FINISHED_STARTING); |
| 207 | } |
| 208 | updateReportedVisibilityLocked(); |
| 209 | } |
| 210 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 211 | void updateReportedVisibilityLocked() { |
| 212 | if (appToken == null) { |
| 213 | return; |
| 214 | } |
| 215 | |
| 216 | int numInteresting = 0; |
| 217 | int numVisible = 0; |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 218 | int numDrawn = 0; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 219 | boolean nowGone = true; |
| 220 | |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 221 | if (DEBUG_VISIBILITY) Slog.v(TAG, |
Craig Mautner | c8bc97e | 2012-04-02 12:54:54 -0700 | [diff] [blame] | 222 | "Update reported visibility: " + this); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 223 | final int N = allAppWindows.size(); |
| 224 | for (int i=0; i<N; i++) { |
| 225 | WindowState win = allAppWindows.get(i); |
| 226 | if (win == startingWindow || win.mAppFreezing |
| 227 | || win.mViewVisibility != View.VISIBLE |
| 228 | || win.mAttrs.type == TYPE_APPLICATION_STARTING |
| 229 | || win.mDestroying) { |
| 230 | continue; |
| 231 | } |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 232 | if (DEBUG_VISIBILITY) { |
| 233 | Slog.v(TAG, "Win " + win + ": isDrawn=" |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 234 | + win.isDrawnLw() |
Jorim Jaggi | 5c80c41 | 2016-04-19 20:03:47 -0700 | [diff] [blame] | 235 | + ", isAnimationSet=" + win.mWinAnimator.isAnimationSet()); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 236 | if (!win.isDrawnLw()) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 237 | Slog.v(TAG, "Not displayed: s=" + |
Robert Carr | e6a8351 | 2015-11-03 16:09:21 -0800 | [diff] [blame] | 238 | win.mWinAnimator.mSurfaceController |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 239 | + " pv=" + win.mPolicyVisibility |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 240 | + " mDrawState=" + win.mWinAnimator.mDrawState |
Wale Ogunwale | 9d14790 | 2016-07-16 11:58:55 -0700 | [diff] [blame] | 241 | + " ph=" + win.isParentWindowHidden() |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 242 | + " th=" |
| 243 | + (win.mAppToken != null |
| 244 | ? win.mAppToken.hiddenRequested : false) |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 245 | + " a=" + win.mWinAnimator.mAnimating); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 246 | } |
| 247 | } |
| 248 | numInteresting++; |
| 249 | if (win.isDrawnLw()) { |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 250 | numDrawn++; |
Jorim Jaggi | 5c80c41 | 2016-04-19 20:03:47 -0700 | [diff] [blame] | 251 | if (!win.mWinAnimator.isAnimationSet()) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 252 | numVisible++; |
| 253 | } |
| 254 | nowGone = false; |
Jorim Jaggi | 5c80c41 | 2016-04-19 20:03:47 -0700 | [diff] [blame] | 255 | } else if (win.mWinAnimator.isAnimationSet()) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 256 | nowGone = false; |
| 257 | } |
| 258 | } |
| 259 | |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 260 | boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 261 | boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting; |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 262 | if (!nowGone) { |
| 263 | // If the app is not yet gone, then it can only become visible/drawn. |
| 264 | if (!nowDrawn) { |
| 265 | nowDrawn = reportedDrawn; |
| 266 | } |
| 267 | if (!nowVisible) { |
| 268 | nowVisible = reportedVisible; |
| 269 | } |
| 270 | } |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 271 | if (DEBUG_VISIBILITY) Slog.v(TAG, "VIS " + this + ": interesting=" |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 272 | + numInteresting + " visible=" + numVisible); |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 273 | if (nowDrawn != reportedDrawn) { |
| 274 | if (nowDrawn) { |
| 275 | Message m = service.mH.obtainMessage( |
| 276 | H.REPORT_APPLICATION_TOKEN_DRAWN, this); |
| 277 | service.mH.sendMessage(m); |
| 278 | } |
| 279 | reportedDrawn = nowDrawn; |
| 280 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 281 | if (nowVisible != reportedVisible) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 282 | if (DEBUG_VISIBILITY) Slog.v( |
| 283 | TAG, "Visibility changed in " + this |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 284 | + ": vis=" + nowVisible); |
| 285 | reportedVisible = nowVisible; |
| 286 | Message m = service.mH.obtainMessage( |
| 287 | H.REPORT_APPLICATION_TOKEN_WINDOWS, |
| 288 | nowVisible ? 1 : 0, |
| 289 | nowGone ? 1 : 0, |
| 290 | this); |
| 291 | service.mH.sendMessage(m); |
| 292 | } |
| 293 | } |
| 294 | |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame^] | 295 | boolean setVisibility(WindowManager.LayoutParams lp, |
| 296 | boolean visible, int transit, boolean performLayout, boolean isVoiceInteraction) { |
| 297 | |
| 298 | boolean delayed = false; |
| 299 | inPendingTransaction = false; |
| 300 | |
| 301 | if (clientHidden == visible) { |
| 302 | clientHidden = !visible; |
| 303 | sendAppVisibilityToClients(); |
| 304 | } |
| 305 | |
| 306 | // Allow for state changes and animation to be applied if: |
| 307 | // * token is transitioning visibility state |
| 308 | // * or the token was marked as hidden and is exiting before we had a chance to play the |
| 309 | // transition animation |
| 310 | // * or this is an opening app and windows are being replaced. |
| 311 | boolean visibilityChanged = false; |
| 312 | if (hidden == visible || (hidden && mIsExiting) || (visible && waitingForReplacement())) { |
| 313 | final AccessibilityController accessibilityController = service.mAccessibilityController; |
| 314 | boolean changed = false; |
| 315 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, |
| 316 | "Changing app " + this + " hidden=" + hidden + " performLayout=" + performLayout); |
| 317 | |
| 318 | boolean runningAppAnimation = false; |
| 319 | |
| 320 | if (transit != AppTransition.TRANSIT_UNSET) { |
| 321 | if (mAppAnimator.animation == AppWindowAnimator.sDummyAnimation) { |
| 322 | mAppAnimator.setNullAnimation(); |
| 323 | } |
| 324 | if (service.applyAnimationLocked(this, lp, transit, visible, isVoiceInteraction)) { |
| 325 | delayed = runningAppAnimation = true; |
| 326 | } |
| 327 | final WindowState window = findMainWindow(); |
| 328 | //TODO (multidisplay): Magnification is supported only for the default display. |
| 329 | if (window != null && accessibilityController != null |
| 330 | && window.getDisplayId() == DEFAULT_DISPLAY) { |
| 331 | accessibilityController.onAppWindowTransitionLocked(window, transit); |
| 332 | } |
| 333 | changed = true; |
| 334 | } |
| 335 | |
| 336 | final int windowsCount = allAppWindows.size(); |
| 337 | for (int i = 0; i < windowsCount; i++) { |
| 338 | final WindowState win = allAppWindows.get(i); |
| 339 | if (win == startingWindow) { |
| 340 | // Starting window that's exiting will be removed when the animation finishes. |
| 341 | // Mark all relevant flags for that onExitAnimationDone will proceed all the way |
| 342 | // to actually remove it. |
| 343 | if (!visible && win.isVisibleNow() && mAppAnimator.isAnimating()) { |
| 344 | win.mAnimatingExit = true; |
| 345 | win.mRemoveOnExit = true; |
| 346 | win.mWindowRemovalAllowed = true; |
| 347 | } |
| 348 | continue; |
| 349 | } |
| 350 | |
| 351 | //Slog.i(TAG_WM, "Window " + win + ": vis=" + win.isVisible()); |
| 352 | //win.dump(" "); |
| 353 | if (visible) { |
| 354 | if (!win.isVisibleNow()) { |
| 355 | if (!runningAppAnimation) { |
| 356 | win.mWinAnimator.applyAnimationLocked(TRANSIT_ENTER, true); |
| 357 | //TODO (multidisplay): Magnification is supported only for the default |
| 358 | if (accessibilityController != null |
| 359 | && win.getDisplayId() == DEFAULT_DISPLAY) { |
| 360 | accessibilityController.onWindowTransitionLocked(win, TRANSIT_ENTER); |
| 361 | } |
| 362 | } |
| 363 | changed = true; |
| 364 | win.setDisplayLayoutNeeded(); |
| 365 | } |
| 366 | } else if (win.isVisibleNow()) { |
| 367 | if (!runningAppAnimation) { |
| 368 | win.mWinAnimator.applyAnimationLocked(TRANSIT_EXIT, false); |
| 369 | //TODO (multidisplay): Magnification is supported only for the default |
| 370 | if (accessibilityController != null |
| 371 | && win.getDisplayId() == DEFAULT_DISPLAY) { |
| 372 | accessibilityController.onWindowTransitionLocked(win,TRANSIT_EXIT); |
| 373 | } |
| 374 | } |
| 375 | changed = true; |
| 376 | win.setDisplayLayoutNeeded(); |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | hidden = hiddenRequested = !visible; |
| 381 | visibilityChanged = true; |
| 382 | if (!visible) { |
| 383 | stopFreezingScreen(true, true); |
| 384 | } else { |
| 385 | // If we are being set visible, and the starting window is |
| 386 | // not yet displayed, then make sure it doesn't get displayed. |
| 387 | WindowState swin = startingWindow; |
| 388 | if (swin != null && !swin.isDrawnLw()) { |
| 389 | swin.mPolicyVisibility = false; |
| 390 | swin.mPolicyVisibilityAfterAnim = false; |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "setVisibility: " + this |
| 395 | + ": hidden=" + hidden + " hiddenRequested=" + hiddenRequested); |
| 396 | |
| 397 | if (changed) { |
| 398 | service.mInputMonitor.setUpdateInputWindowsNeededLw(); |
| 399 | if (performLayout) { |
| 400 | service.updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES, |
| 401 | false /*updateInputWindows*/); |
| 402 | service.mWindowPlacerLocked.performSurfacePlacement(); |
| 403 | } |
| 404 | service.mInputMonitor.updateInputWindowsLw(false /*force*/); |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | if (mAppAnimator.animation != null) { |
| 409 | delayed = true; |
| 410 | } |
| 411 | |
| 412 | for (int i = allAppWindows.size() - 1; i >= 0 && !delayed; i--) { |
| 413 | if (allAppWindows.get(i).mWinAnimator.isWindowAnimationSet()) { |
| 414 | delayed = true; |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | if (visibilityChanged) { |
| 419 | if (visible && !delayed) { |
| 420 | // The token was made immediately visible, there will be no entrance animation. |
| 421 | // We need to inform the client the enter animation was finished. |
| 422 | mEnteringAnimation = true; |
| 423 | service.mActivityManagerAppTransitionNotifier.onAppTransitionFinishedLocked(token); |
| 424 | } |
| 425 | |
| 426 | if (!service.mClosingApps.contains(this) && !service.mOpeningApps.contains(this)) { |
| 427 | // The token is not closing nor opening, so even if there is an animation set, that |
| 428 | // doesn't mean that it goes through the normal app transition cycle so we have |
| 429 | // to inform the docked controller about visibility change. |
| 430 | service.getDefaultDisplayContentLocked().getDockedDividerController() |
| 431 | .notifyAppVisibilityChanged(); |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | return delayed; |
| 436 | } |
| 437 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 438 | WindowState findMainWindow() { |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 439 | WindowState candidate = null; |
Wale Ogunwale | 455fac5 | 2016-07-21 07:24:49 -0700 | [diff] [blame] | 440 | int j = allAppWindows.size(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 441 | while (j > 0) { |
| 442 | j--; |
Wale Ogunwale | 455fac5 | 2016-07-21 07:24:49 -0700 | [diff] [blame] | 443 | WindowState win = allAppWindows.get(j); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 444 | if (win.mAttrs.type == WindowManager.LayoutParams.TYPE_BASE_APPLICATION |
| 445 | || win.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) { |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 446 | // 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] | 447 | // happens for example when replacing windows during an activity relaunch. When |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 448 | // constructing the animation, we want the new window, not the exiting one. |
Wale Ogunwale | c48a354 | 2016-02-19 15:18:45 -0800 | [diff] [blame] | 449 | if (win.mAnimatingExit) { |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 450 | candidate = win; |
| 451 | } else { |
| 452 | return win; |
| 453 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 454 | } |
| 455 | } |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 456 | return candidate; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 457 | } |
| 458 | |
Wale Ogunwale | 6cae765 | 2015-12-26 07:36:26 -0800 | [diff] [blame] | 459 | boolean windowsAreFocusable() { |
| 460 | return StackId.canReceiveKeys(mTask.mStack.mStackId) || mAlwaysFocusable; |
Wale Ogunwale | d045c82 | 2015-12-02 09:14:28 -0800 | [diff] [blame] | 461 | } |
| 462 | |
Craig Mautner | 72669d1 | 2012-12-18 17:23:54 -0800 | [diff] [blame] | 463 | boolean isVisible() { |
| 464 | final int N = allAppWindows.size(); |
Craig Mautner | 72669d1 | 2012-12-18 17:23:54 -0800 | [diff] [blame] | 465 | for (int i=0; i<N; i++) { |
| 466 | WindowState win = allAppWindows.get(i); |
Chong Zhang | db20b5f | 2015-10-23 14:01:43 -0700 | [diff] [blame] | 467 | // If we're animating with a saved surface, we're already visible. |
| 468 | // Return true so that the alpha doesn't get cleared. |
Craig Mautner | 72669d1 | 2012-12-18 17:23:54 -0800 | [diff] [blame] | 469 | if (!win.mAppFreezing |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 470 | && (win.mViewVisibility == View.VISIBLE || win.isAnimatingWithSavedSurface() |
Jorim Jaggi | 5c80c41 | 2016-04-19 20:03:47 -0700 | [diff] [blame] | 471 | || (win.mWinAnimator.isAnimationSet() |
Filip Gruszczynski | 57f76f1 | 2015-11-04 16:10:54 -0800 | [diff] [blame] | 472 | && !service.mAppTransition.isTransitionSet())) |
| 473 | && !win.mDestroying |
| 474 | && win.isDrawnLw()) { |
Craig Mautner | 72669d1 | 2012-12-18 17:23:54 -0800 | [diff] [blame] | 475 | return true; |
| 476 | } |
| 477 | } |
| 478 | return false; |
| 479 | } |
| 480 | |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame^] | 481 | boolean isVisibleForUser() { |
| 482 | for (int j = allAppWindows.size() - 1; j >= 0; j--) { |
| 483 | final WindowState w = allAppWindows.get(j); |
| 484 | if (!w.isHiddenFromUserLocked()) { |
| 485 | return true; |
| 486 | } |
| 487 | } |
| 488 | return false; |
| 489 | } |
| 490 | |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 491 | void removeAppFromTaskLocked() { |
| 492 | mIsExiting = false; |
| 493 | removeAllWindows(); |
| 494 | |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 495 | // Use local variable because removeAppToken will null out mTask. |
| 496 | final Task task = mTask; |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 497 | if (task != null) { |
| 498 | if (!task.removeAppToken(this)) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 499 | Slog.e(TAG, "removeAppFromTaskLocked: token=" + this |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 500 | + " not found."); |
| 501 | } |
| 502 | task.mStack.mExitingAppTokens.remove(this); |
| 503 | } |
| 504 | } |
| 505 | |
Chong Zhang | e05bcb1 | 2016-07-26 17:47:29 -0700 | [diff] [blame] | 506 | void clearAnimatingFlags() { |
| 507 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 508 | final WindowState win = allAppWindows.get(i); |
| 509 | // We don't want to clear it out for windows that get replaced, because the |
| 510 | // animation depends on the flag to remove the replaced window. |
| 511 | // |
| 512 | // We also don't clear the mAnimatingExit flag for windows which have the |
| 513 | // mRemoveOnExit flag. This indicates an explicit remove request has been issued |
| 514 | // by the client. We should let animation proceed and not clear this flag or |
| 515 | // they won't eventually be removed by WindowStateAnimator#finishExit. |
| 516 | if (!win.mWillReplaceWindow && !win.mRemoveOnExit) { |
| 517 | win.mAnimatingExit = false; |
| 518 | // Clear mAnimating flag together with mAnimatingExit. When animation |
| 519 | // changes from exiting to entering, we need to clear this flag until the |
| 520 | // new animation gets applied, so that isAnimationStarting() becomes true |
| 521 | // until then. |
| 522 | // Otherwise applySurfaceChangesTransaction will faill to skip surface |
| 523 | // placement for this window during this period, one or more frame will |
| 524 | // show up with wrong position or scale. |
| 525 | win.mWinAnimator.mAnimating = false; |
| 526 | } |
| 527 | } |
Chong Zhang | ec8299c | 2016-07-29 13:09:40 -0700 | [diff] [blame] | 528 | requestUpdateWallpaperIfNeeded(); |
Chong Zhang | e05bcb1 | 2016-07-26 17:47:29 -0700 | [diff] [blame] | 529 | } |
| 530 | |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 531 | void destroySurfaces() { |
Chong Zhang | 45e6d2d | 2016-07-20 18:33:56 -0700 | [diff] [blame] | 532 | destroySurfaces(false /*cleanupOnResume*/); |
| 533 | } |
| 534 | |
| 535 | /** |
| 536 | * Destroy surfaces which have been marked as eligible by the animator, taking care to ensure |
| 537 | * the client has finished with them. |
| 538 | * |
| 539 | * @param cleanupOnResume whether this is done when app is resumed without fully stopped. If |
| 540 | * set to true, destroy only surfaces of removed windows, and clear relevant flags of the |
| 541 | * others so that they are ready to be reused. If set to false (common case), destroy all |
| 542 | * surfaces that's eligible, if the app is already stopped. |
| 543 | */ |
| 544 | |
| 545 | private void destroySurfaces(boolean cleanupOnResume) { |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 546 | final ArrayList<WindowState> allWindows = (ArrayList<WindowState>) allAppWindows.clone(); |
| 547 | final DisplayContentList displayList = new DisplayContentList(); |
| 548 | for (int i = allWindows.size() - 1; i >= 0; i--) { |
| 549 | final WindowState win = allWindows.get(i); |
Chong Zhang | eb66557 | 2016-05-09 18:28:27 -0700 | [diff] [blame] | 550 | |
Chong Zhang | 45e6d2d | 2016-07-20 18:33:56 -0700 | [diff] [blame] | 551 | if (!(mAppStopped || win.mWindowRemovalAllowed || cleanupOnResume)) { |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 552 | continue; |
| 553 | } |
| 554 | |
Chong Zhang | eb66557 | 2016-05-09 18:28:27 -0700 | [diff] [blame] | 555 | win.mWinAnimator.destroyPreservedSurfaceLocked(); |
| 556 | |
| 557 | if (!win.mDestroying) { |
Chong Zhang | 5471e90 | 2016-02-12 15:34:10 -0800 | [diff] [blame] | 558 | continue; |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 559 | } |
| 560 | |
Wale Ogunwale | 8d5a542 | 2016-03-03 18:28:21 -0800 | [diff] [blame] | 561 | if (DEBUG_ADD_REMOVE) Slog.e(TAG_WM, "win=" + win |
| 562 | + " destroySurfaces: mAppStopped=" + mAppStopped |
| 563 | + " win.mWindowRemovalAllowed=" + win.mWindowRemovalAllowed |
| 564 | + " win.mRemoveOnExit=" + win.mRemoveOnExit); |
| 565 | |
Chong Zhang | 45e6d2d | 2016-07-20 18:33:56 -0700 | [diff] [blame] | 566 | if (!cleanupOnResume || win.mRemoveOnExit) { |
| 567 | win.destroyOrSaveSurface(); |
| 568 | } |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 569 | if (win.mRemoveOnExit) { |
Wale Ogunwale | e4343ef | 2016-07-19 08:00:46 -0700 | [diff] [blame] | 570 | win.remove(); |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 571 | } |
| 572 | final DisplayContent displayContent = win.getDisplayContent(); |
| 573 | if (displayContent != null && !displayList.contains(displayContent)) { |
| 574 | displayList.add(displayContent); |
| 575 | } |
Chong Zhang | ec8299c | 2016-07-29 13:09:40 -0700 | [diff] [blame] | 576 | if (cleanupOnResume) { |
| 577 | win.requestUpdateWallpaperIfNeeded(); |
| 578 | } |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 579 | win.mDestroying = false; |
| 580 | } |
| 581 | for (int i = 0; i < displayList.size(); i++) { |
| 582 | final DisplayContent displayContent = displayList.get(i); |
| 583 | service.mLayersController.assignLayersLocked(displayContent.getWindowList()); |
| 584 | displayContent.layoutNeeded = true; |
| 585 | } |
| 586 | } |
| 587 | |
Wale Ogunwale | 8d5a542 | 2016-03-03 18:28:21 -0800 | [diff] [blame] | 588 | /** |
Chong Zhang | 45e6d2d | 2016-07-20 18:33:56 -0700 | [diff] [blame] | 589 | * Notify that the app is now resumed, and it was not stopped before, perform a clean |
| 590 | * up of the surfaces |
Wale Ogunwale | 8d5a542 | 2016-03-03 18:28:21 -0800 | [diff] [blame] | 591 | */ |
Chong Zhang | 45e6d2d | 2016-07-20 18:33:56 -0700 | [diff] [blame] | 592 | void notifyAppResumed(boolean wasStopped) { |
| 593 | if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppResumed: wasStopped=" + wasStopped + " " + this); |
| 594 | mAppStopped = false; |
| 595 | if (!wasStopped) { |
| 596 | destroySurfaces(true /*cleanupOnResume*/); |
Wale Ogunwale | 8d5a542 | 2016-03-03 18:28:21 -0800 | [diff] [blame] | 597 | } |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 598 | } |
| 599 | |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 600 | /** |
Chong Zhang | 45e6d2d | 2016-07-20 18:33:56 -0700 | [diff] [blame] | 601 | * Notify that the app has stopped, and it is okay to destroy any surfaces which were |
| 602 | * keeping alive in case they were still being used. |
| 603 | */ |
| 604 | void notifyAppStopped() { |
| 605 | if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppStopped: " + this); |
| 606 | mAppStopped = true; |
| 607 | destroySurfaces(); |
| 608 | // Remove any starting window that was added for this app if they are still around. |
| 609 | mTask.mService.scheduleRemoveStartingWindowLocked(this); |
| 610 | } |
| 611 | |
| 612 | /** |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 613 | * Checks whether we should save surfaces for this app. |
| 614 | * |
| 615 | * @return true if the surfaces should be saved, false otherwise. |
| 616 | */ |
| 617 | boolean shouldSaveSurface() { |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 618 | // We want to save surface if the app's windows are "allDrawn". |
| 619 | // (If we started entering animation early with saved surfaces, allDrawn |
| 620 | // should have been restored to true. So we'll save again in that case |
| 621 | // even if app didn't actually finish drawing.) |
| 622 | return allDrawn; |
Robert Carr | 13f7be9e | 2015-12-02 18:39:45 -0800 | [diff] [blame] | 623 | } |
| 624 | |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 625 | boolean canRestoreSurfaces() { |
Chong Zhang | b7b4a56 | 2016-04-28 15:30:33 -0700 | [diff] [blame] | 626 | for (int i = allAppWindows.size() -1; i >= 0; i--) { |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 627 | final WindowState w = allAppWindows.get(i); |
| 628 | if (w.canRestoreSurface()) { |
Robert Carr | 13f7be9e | 2015-12-02 18:39:45 -0800 | [diff] [blame] | 629 | return true; |
| 630 | } |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 631 | } |
| 632 | return false; |
| 633 | } |
| 634 | |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 635 | void clearVisibleBeforeClientHidden() { |
| 636 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 637 | final WindowState w = allAppWindows.get(i); |
| 638 | w.clearVisibleBeforeClientHidden(); |
| 639 | } |
| 640 | } |
| 641 | |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 642 | /** |
| 643 | * Whether the app has some window that is invisible in layout, but |
| 644 | * animating with saved surface. |
| 645 | */ |
| 646 | boolean isAnimatingInvisibleWithSavedSurface() { |
| 647 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 648 | final WindowState w = allAppWindows.get(i); |
| 649 | if (w.isAnimatingInvisibleWithSavedSurface()) { |
| 650 | return true; |
| 651 | } |
| 652 | } |
| 653 | return false; |
| 654 | } |
| 655 | |
| 656 | /** |
| 657 | * Hide all window surfaces that's still invisible in layout but animating |
| 658 | * with a saved surface, and mark them destroying. |
| 659 | */ |
| 660 | void stopUsingSavedSurfaceLocked() { |
| 661 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 662 | final WindowState w = allAppWindows.get(i); |
| 663 | if (w.isAnimatingInvisibleWithSavedSurface()) { |
| 664 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG, |
| 665 | "stopUsingSavedSurfaceLocked: " + w); |
| 666 | w.clearAnimatingWithSavedSurface(); |
| 667 | w.mDestroying = true; |
| 668 | w.mWinAnimator.hide("stopUsingSavedSurfaceLocked"); |
Wale Ogunwale | e4da0c1 | 2016-07-29 12:47:02 -0700 | [diff] [blame] | 669 | service.mWallpaperControllerLocked.hideWallpapers(w); |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 670 | } |
| 671 | } |
| 672 | destroySurfaces(); |
| 673 | } |
| 674 | |
Chong Zhang | f58631a | 2016-05-24 16:02:10 -0700 | [diff] [blame] | 675 | void markSavedSurfaceExiting() { |
| 676 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 677 | final WindowState w = allAppWindows.get(i); |
| 678 | if (w.isAnimatingInvisibleWithSavedSurface()) { |
| 679 | w.mAnimatingExit = true; |
| 680 | w.mWinAnimator.mAnimating = true; |
| 681 | } |
| 682 | } |
| 683 | } |
| 684 | |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 685 | void restoreSavedSurfaces() { |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 686 | if (!canRestoreSurfaces()) { |
| 687 | clearVisibleBeforeClientHidden(); |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 688 | return; |
| 689 | } |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 690 | // Check if we have enough drawn windows to mark allDrawn= true. |
| 691 | int numInteresting = 0; |
| 692 | int numDrawn = 0; |
Chong Zhang | b7b4a56 | 2016-04-28 15:30:33 -0700 | [diff] [blame] | 693 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 694 | WindowState w = allAppWindows.get(i); |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 695 | if (w != startingWindow && !w.mAppDied && w.wasVisibleBeforeClientHidden() |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 696 | && (!mAppAnimator.freezingScreen || !w.mAppFreezing)) { |
| 697 | numInteresting++; |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 698 | if (w.hasSavedSurface()) { |
| 699 | w.restoreSavedSurface(); |
| 700 | } |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 701 | if (w.isDrawnLw()) { |
| 702 | numDrawn++; |
| 703 | } |
| 704 | } |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 705 | } |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 706 | |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 707 | if (!allDrawn) { |
| 708 | allDrawn = (numInteresting > 0) && (numInteresting == numDrawn); |
| 709 | if (allDrawn) { |
| 710 | service.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget(); |
| 711 | } |
| 712 | } |
| 713 | clearVisibleBeforeClientHidden(); |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 714 | |
| 715 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG, |
Wale Ogunwale | 455fac5 | 2016-07-21 07:24:49 -0700 | [diff] [blame] | 716 | "restoreSavedSurfaces: " + this + " allDrawn=" + allDrawn |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 717 | + " numInteresting=" + numInteresting + " numDrawn=" + numDrawn); |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 718 | } |
| 719 | |
| 720 | void destroySavedSurfaces() { |
Chong Zhang | b7b4a56 | 2016-04-28 15:30:33 -0700 | [diff] [blame] | 721 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 722 | WindowState win = allAppWindows.get(i); |
Robert Carr | 13f7be9e | 2015-12-02 18:39:45 -0800 | [diff] [blame] | 723 | win.destroySavedSurface(); |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 724 | } |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | void clearAllDrawn() { |
| 728 | allDrawn = false; |
| 729 | deferClearAllDrawn = false; |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 730 | allDrawnExcludingSaved = false; |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 731 | } |
| 732 | |
Wale Ogunwale | 98e70d0 | 2014-11-10 12:12:27 -0800 | [diff] [blame] | 733 | @Override |
Craig Mautner | 7c9ee19 | 2014-08-14 16:08:26 -0700 | [diff] [blame] | 734 | void removeAllWindows() { |
Craig Mautner | 7b4655d | 2014-11-20 12:13:22 -0800 | [diff] [blame] | 735 | for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; |
| 736 | // removeWindowLocked at bottom of loop may remove multiple entries from |
| 737 | // allAppWindows if the window to be removed has child windows. It also may |
| 738 | // not remove any windows from allAppWindows at all if win is exiting and |
| 739 | // currently animating away. This ensures that winNdx is monotonically decreasing |
| 740 | // and never beyond allAppWindows bounds. |
| 741 | winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) { |
| 742 | WindowState win = allAppWindows.get(winNdx); |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 743 | if (DEBUG_WINDOW_MOVEMENT) { |
| 744 | Slog.w(TAG, "removeAllWindows: removing win=" + win); |
Wale Ogunwale | 98e70d0 | 2014-11-10 12:12:27 -0800 | [diff] [blame] | 745 | } |
| 746 | |
Wale Ogunwale | a6ab5c4 | 2015-04-24 09:00:25 -0700 | [diff] [blame] | 747 | service.removeWindowLocked(win); |
Craig Mautner | 7c9ee19 | 2014-08-14 16:08:26 -0700 | [diff] [blame] | 748 | } |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 749 | allAppWindows.clear(); |
| 750 | windows.clear(); |
Craig Mautner | 7c9ee19 | 2014-08-14 16:08:26 -0700 | [diff] [blame] | 751 | } |
| 752 | |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame^] | 753 | @Override |
| 754 | void removeWindow(WindowState win) { |
| 755 | super.removeWindow(win); |
| 756 | |
| 757 | allAppWindows.remove(win); |
| 758 | |
| 759 | if (startingWindow == win) { |
| 760 | if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Notify removed startingWindow " + win); |
| 761 | service.scheduleRemoveStartingWindowLocked(this); |
| 762 | } else if (allAppWindows.size() == 0 && startingData != null) { |
| 763 | // If this is the last window and we had requested a starting transition window, |
| 764 | // well there is no point now. |
| 765 | if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Nulling last startingWindow"); |
| 766 | startingData = null; |
| 767 | } else if (allAppWindows.size() == 1 && startingView != null) { |
| 768 | // If this is the last window except for a starting transition window, |
| 769 | // we need to get rid of the starting transition. |
| 770 | service.scheduleRemoveStartingWindowLocked(this); |
| 771 | } |
| 772 | } |
| 773 | |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 774 | void removeAllDeadWindows() { |
| 775 | for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; |
Wale Ogunwale | e42d0e1 | 2016-05-02 16:40:59 -0700 | [diff] [blame] | 776 | // removeWindowLocked at bottom of loop may remove multiple entries from |
| 777 | // allAppWindows if the window to be removed has child windows. It also may |
| 778 | // not remove any windows from allAppWindows at all if win is exiting and |
| 779 | // currently animating away. This ensures that winNdx is monotonically decreasing |
| 780 | // and never beyond allAppWindows bounds. |
| 781 | winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) { |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 782 | WindowState win = allAppWindows.get(winNdx); |
| 783 | if (win.mAppDied) { |
Wale Ogunwale | 2728bf4 | 2016-03-03 11:03:26 -0800 | [diff] [blame] | 784 | if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 785 | Slog.w(TAG, "removeAllDeadWindows: " + win); |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 786 | } |
| 787 | // Set mDestroying, we don't want any animation or delayed removal here. |
| 788 | win.mDestroying = true; |
| 789 | service.removeWindowLocked(win); |
| 790 | } |
| 791 | } |
| 792 | } |
| 793 | |
Wale Ogunwale | e42d0e1 | 2016-05-02 16:40:59 -0700 | [diff] [blame] | 794 | boolean hasWindowsAlive() { |
| 795 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 796 | if (!allAppWindows.get(i).mAppDied) { |
| 797 | return true; |
| 798 | } |
| 799 | } |
| 800 | return false; |
| 801 | } |
| 802 | |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 803 | void setReplacingWindows(boolean animate) { |
Wale Ogunwale | 455fac5 | 2016-07-21 07:24:49 -0700 | [diff] [blame] | 804 | if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, |
| 805 | "Marking app token " + this + " with replacing windows."); |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 806 | |
| 807 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 808 | final WindowState w = allAppWindows.get(i); |
| 809 | w.setReplacing(animate); |
| 810 | } |
| 811 | if (animate) { |
| 812 | // Set-up dummy animation so we can start treating windows associated with this |
| 813 | // token like they are in transition before the new app window is ready for us to |
| 814 | // run the real transition animation. |
| 815 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, |
| 816 | "setReplacingWindow() Setting dummy animation on: " + this); |
| 817 | mAppAnimator.setDummyAnimation(); |
| 818 | } |
| 819 | } |
| 820 | |
Robert Carr | 23fa16b | 2016-01-13 13:19:58 -0800 | [diff] [blame] | 821 | void setReplacingChildren() { |
Wale Ogunwale | 455fac5 | 2016-07-21 07:24:49 -0700 | [diff] [blame] | 822 | if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + this |
Robert Carr | 23fa16b | 2016-01-13 13:19:58 -0800 | [diff] [blame] | 823 | + " with replacing child windows."); |
| 824 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 825 | final WindowState w = allAppWindows.get(i); |
Robert Carr | d1a010f | 2016-04-07 22:36:22 -0700 | [diff] [blame] | 826 | if (w.shouldBeReplacedWithChildren()) { |
Robert Carr | 23fa16b | 2016-01-13 13:19:58 -0800 | [diff] [blame] | 827 | w.setReplacing(false /* animate */); |
| 828 | } |
| 829 | } |
| 830 | } |
| 831 | |
Chong Zhang | f596cd5 | 2016-01-05 13:42:44 -0800 | [diff] [blame] | 832 | void resetReplacingWindows() { |
Wale Ogunwale | 455fac5 | 2016-07-21 07:24:49 -0700 | [diff] [blame] | 833 | if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, |
| 834 | "Resetting app token " + this + " of replacing window marks."); |
Chong Zhang | f596cd5 | 2016-01-05 13:42:44 -0800 | [diff] [blame] | 835 | |
| 836 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 837 | final WindowState w = allAppWindows.get(i); |
| 838 | w.resetReplacing(); |
| 839 | } |
| 840 | } |
| 841 | |
Chong Zhang | 4d7369a | 2016-04-25 16:09:14 -0700 | [diff] [blame] | 842 | void requestUpdateWallpaperIfNeeded() { |
| 843 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 844 | final WindowState w = allAppWindows.get(i); |
| 845 | w.requestUpdateWallpaperIfNeeded(); |
| 846 | } |
| 847 | } |
| 848 | |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 849 | boolean isRelaunching() { |
| 850 | return mPendingRelaunchCount > 0; |
| 851 | } |
| 852 | |
| 853 | void startRelaunching() { |
| 854 | if (canFreezeBounds()) { |
| 855 | freezeBounds(); |
| 856 | } |
| 857 | mPendingRelaunchCount++; |
| 858 | } |
| 859 | |
| 860 | void finishRelaunching() { |
| 861 | if (canFreezeBounds()) { |
| 862 | unfreezeBounds(); |
| 863 | } |
| 864 | if (mPendingRelaunchCount > 0) { |
| 865 | mPendingRelaunchCount--; |
| 866 | } |
| 867 | } |
| 868 | |
Wale Ogunwale | 8fd7542 | 2016-06-24 14:20:37 -0700 | [diff] [blame] | 869 | void clearRelaunching() { |
Wale Ogunwale | 37dbafc | 2016-06-27 10:15:20 -0700 | [diff] [blame] | 870 | if (mPendingRelaunchCount == 0) { |
| 871 | return; |
| 872 | } |
Wale Ogunwale | 8fd7542 | 2016-06-24 14:20:37 -0700 | [diff] [blame] | 873 | if (canFreezeBounds()) { |
| 874 | unfreezeBounds(); |
| 875 | } |
| 876 | mPendingRelaunchCount = 0; |
| 877 | } |
| 878 | |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 879 | void addWindow(WindowState w) { |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame^] | 880 | if (allAppWindows.contains(w)) { |
| 881 | return; |
| 882 | } |
| 883 | |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 884 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 885 | WindowState candidate = allAppWindows.get(i); |
| 886 | if (candidate.mWillReplaceWindow && candidate.mReplacingWindow == null && |
Robert Carr | 8bc8907 | 2016-04-08 13:29:59 -0700 | [diff] [blame] | 887 | candidate.getWindowTag().toString().equals(w.getWindowTag().toString())) { |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 888 | candidate.mReplacingWindow = w; |
Robert Carr | b439a63 | 2016-04-07 22:52:10 -0700 | [diff] [blame] | 889 | w.mSkipEnterAnimationForSeamlessReplacement = !candidate.mAnimateReplacingWindow; |
Chong Zhang | f596cd5 | 2016-01-05 13:42:44 -0800 | [diff] [blame] | 890 | |
| 891 | // if we got a replacement window, reset the timeout to give drawing more time |
Chong Zhang | 32de365 | 2016-05-12 16:00:01 -0700 | [diff] [blame] | 892 | service.scheduleReplacingWindowTimeouts(this); |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 893 | } |
| 894 | } |
| 895 | allAppWindows.add(w); |
| 896 | } |
| 897 | |
| 898 | boolean waitingForReplacement() { |
| 899 | for (int i = allAppWindows.size() -1; i >= 0; i--) { |
| 900 | WindowState candidate = allAppWindows.get(i); |
| 901 | if (candidate.mWillReplaceWindow) { |
| 902 | return true; |
| 903 | } |
| 904 | } |
| 905 | return false; |
| 906 | } |
| 907 | |
Chong Zhang | f596cd5 | 2016-01-05 13:42:44 -0800 | [diff] [blame] | 908 | void clearTimedoutReplacesLocked() { |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 909 | for (int i = allAppWindows.size() - 1; i >= 0; |
| 910 | // removeWindowLocked at bottom of loop may remove multiple entries from |
| 911 | // allAppWindows if the window to be removed has child windows. It also may |
| 912 | // not remove any windows from allAppWindows at all if win is exiting and |
| 913 | // currently animating away. This ensures that winNdx is monotonically decreasing |
| 914 | // and never beyond allAppWindows bounds. |
| 915 | i = Math.min(i - 1, allAppWindows.size() - 1)) { |
| 916 | WindowState candidate = allAppWindows.get(i); |
| 917 | if (candidate.mWillReplaceWindow == false) { |
| 918 | continue; |
| 919 | } |
| 920 | candidate.mWillReplaceWindow = false; |
Robert Carr | b439a63 | 2016-04-07 22:52:10 -0700 | [diff] [blame] | 921 | if (candidate.mReplacingWindow != null) { |
| 922 | candidate.mReplacingWindow.mSkipEnterAnimationForSeamlessReplacement = false; |
| 923 | } |
Chong Zhang | f596cd5 | 2016-01-05 13:42:44 -0800 | [diff] [blame] | 924 | // Since the window already timed out, remove it immediately now. |
Wale Ogunwale | e4343ef | 2016-07-19 08:00:46 -0700 | [diff] [blame] | 925 | // Use WindowState#remove() instead of removeWindowLocked(), as the latter |
Chong Zhang | f596cd5 | 2016-01-05 13:42:44 -0800 | [diff] [blame] | 926 | // delays removal on certain conditions, which will leave the stale window in the |
| 927 | // stack and marked mWillReplaceWindow=false, so the window will never be removed. |
Wale Ogunwale | e4343ef | 2016-07-19 08:00:46 -0700 | [diff] [blame] | 928 | candidate.remove(); |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 929 | } |
| 930 | } |
| 931 | |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 932 | private boolean canFreezeBounds() { |
| 933 | // For freeform windows, we can't freeze the bounds at the moment because this would make |
| 934 | // the resizing unresponsive. |
| 935 | return mTask != null && !mTask.inFreeformWorkspace(); |
| 936 | } |
| 937 | |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 938 | /** |
| 939 | * Freezes the task bounds. The size of this task reported the app will be fixed to the bounds |
| 940 | * freezed by {@link Task#prepareFreezingBounds} until {@link #unfreezeBounds} gets called, even |
| 941 | * if they change in the meantime. If the bounds are already frozen, the bounds will be frozen |
| 942 | * with a queue. |
| 943 | */ |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 944 | private void freezeBounds() { |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 945 | mFrozenBounds.offer(new Rect(mTask.mPreparedFrozenBounds)); |
Jorim Jaggi | 26c8c42 | 2016-05-09 19:57:25 -0700 | [diff] [blame] | 946 | |
| 947 | if (mTask.mPreparedFrozenMergedConfig.equals(Configuration.EMPTY)) { |
| 948 | // We didn't call prepareFreezingBounds on the task, so use the current value. |
| 949 | final Configuration config = new Configuration(service.mCurConfiguration); |
| 950 | config.updateFrom(mTask.mOverrideConfig); |
| 951 | mFrozenMergedConfig.offer(config); |
| 952 | } else { |
| 953 | mFrozenMergedConfig.offer(new Configuration(mTask.mPreparedFrozenMergedConfig)); |
| 954 | } |
| 955 | mTask.mPreparedFrozenMergedConfig.setToDefaults(); |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 956 | } |
| 957 | |
| 958 | /** |
| 959 | * Unfreezes the previously frozen bounds. See {@link #freezeBounds}. |
| 960 | */ |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 961 | private void unfreezeBounds() { |
Wale Ogunwale | 37dbafc | 2016-06-27 10:15:20 -0700 | [diff] [blame] | 962 | if (!mFrozenBounds.isEmpty()) { |
| 963 | mFrozenBounds.remove(); |
| 964 | } |
| 965 | if (!mFrozenMergedConfig.isEmpty()) { |
| 966 | mFrozenMergedConfig.remove(); |
| 967 | } |
Wale Ogunwale | 455fac5 | 2016-07-21 07:24:49 -0700 | [diff] [blame] | 968 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 969 | final WindowState win = allAppWindows.get(i); |
Jorim Jaggi | 69abc19 | 2016-02-04 19:34:00 -0800 | [diff] [blame] | 970 | if (!win.mHasSurface) { |
| 971 | continue; |
| 972 | } |
Jorim Jaggi | 4846ee3 | 2016-01-07 17:39:12 +0100 | [diff] [blame] | 973 | win.mLayoutNeeded = true; |
| 974 | win.setDisplayLayoutNeeded(); |
| 975 | if (!service.mResizingWindows.contains(win)) { |
| 976 | service.mResizingWindows.add(win); |
| 977 | } |
| 978 | } |
| 979 | service.mWindowPlacerLocked.performSurfacePlacement(); |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 980 | } |
| 981 | |
Robert Carr | 91b22809 | 2016-06-28 17:32:37 -0700 | [diff] [blame] | 982 | void addSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) { |
| 983 | mSurfaceViewBackgrounds.add(background); |
| 984 | } |
| 985 | |
| 986 | void removeSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) { |
| 987 | mSurfaceViewBackgrounds.remove(background); |
| 988 | updateSurfaceViewBackgroundVisibilities(); |
| 989 | } |
| 990 | |
| 991 | // We use DimLayers behind SurfaceViews to prevent holes while resizing and creating. |
| 992 | // However, we need to ensure one SurfaceView doesn't cover another when they are both placed |
| 993 | // below the main app window (as traditionally a SurfaceView which is never drawn |
| 994 | // to is totally translucent). So we look at all our SurfaceView backgrounds and only enable |
| 995 | // the background for the SurfaceView with lowest Z order |
| 996 | void updateSurfaceViewBackgroundVisibilities() { |
| 997 | WindowSurfaceController.SurfaceControlWithBackground bottom = null; |
| 998 | int bottomLayer = Integer.MAX_VALUE; |
| 999 | for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) { |
| 1000 | WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i); |
| 1001 | if (sc.mVisible && sc.mLayer < bottomLayer) { |
| 1002 | bottomLayer = sc.mLayer; |
| 1003 | bottom = sc; |
| 1004 | } |
| 1005 | } |
| 1006 | for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) { |
| 1007 | WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i); |
| 1008 | sc.updateBackgroundVisibility(sc != bottom); |
| 1009 | } |
| 1010 | } |
| 1011 | |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame^] | 1012 | void resetJustMovedInStack() { |
| 1013 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 1014 | allAppWindows.get(i).resetJustMovedInStack(); |
| 1015 | } |
| 1016 | } |
| 1017 | |
| 1018 | @Override |
| 1019 | int adjustAnimLayer(int adj) { |
| 1020 | int highestAnimLayer = super.adjustAnimLayer(adj); |
| 1021 | |
| 1022 | final int windowCount = allAppWindows.size(); |
| 1023 | |
| 1024 | for (int i = 0; i < windowCount; i++) { |
| 1025 | final WindowState w = allAppWindows.get(i); |
| 1026 | w.adjustAnimLayer(adj); |
| 1027 | |
| 1028 | final int animLayer = w.mWinAnimator.mAnimLayer; |
| 1029 | if (DEBUG_LAYERS) Slog.v(TAG, "Updating layer " + w + ": " + animLayer); |
| 1030 | if (animLayer > highestAnimLayer) { |
| 1031 | highestAnimLayer = animLayer; |
| 1032 | } |
| 1033 | if (w == service.mInputMethodTarget && !service.mInputMethodTargetWaitingAnim) { |
| 1034 | service.mLayersController.setInputMethodAnimLayerAdjustment(adj); |
| 1035 | } |
| 1036 | } |
| 1037 | |
| 1038 | return highestAnimLayer; |
| 1039 | } |
| 1040 | |
| 1041 | @Override |
| 1042 | int getHighestAnimLayer() { |
| 1043 | int layer = super.getHighestAnimLayer(); |
| 1044 | for (int j = 0; j < allAppWindows.size(); j++) { |
| 1045 | final WindowState win = allAppWindows.get(j); |
| 1046 | if (win.mWinAnimator.mAnimLayer > layer) { |
| 1047 | layer = win.mWinAnimator.mAnimLayer; |
| 1048 | } |
| 1049 | } |
| 1050 | return layer; |
| 1051 | } |
| 1052 | |
| 1053 | void setWaitingForDrawnIfResizingChanged() { |
| 1054 | for (int i = allAppWindows.size() - 1; i >= 0; --i) { |
| 1055 | final WindowState win = allAppWindows.get(i); |
| 1056 | if (win.isDragResizeChanged()) { |
| 1057 | service.mWaitingForDrawn.add(win); |
| 1058 | } |
| 1059 | } |
| 1060 | } |
| 1061 | |
| 1062 | void resizeWindows() { |
| 1063 | final ArrayList<WindowState> resizingWindows = service.mResizingWindows; |
| 1064 | // Some windows won't go through the resizing process, if they don't have a surface, so |
| 1065 | // destroy all saved surfaces here. |
| 1066 | destroySavedSurfaces(); |
| 1067 | |
| 1068 | for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; --winNdx) { |
| 1069 | final WindowState win = allAppWindows.get(winNdx); |
| 1070 | if (win.mHasSurface && !resizingWindows.contains(win)) { |
| 1071 | if (DEBUG_RESIZE) Slog.d(TAG, "resizeWindows: Resizing " + win); |
| 1072 | resizingWindows.add(win); |
| 1073 | |
| 1074 | // If we are not drag resizing, force recreating of a new surface so updating |
| 1075 | // the content and positioning that surface will be in sync. |
| 1076 | // |
| 1077 | // As we use this flag as a hint to freeze surface boundary updates, |
| 1078 | // we'd like to only apply this to TYPE_BASE_APPLICATION, |
| 1079 | // windows of TYPE_APPLICATION like dialogs, could appear |
| 1080 | // to not be drag resizing while they resize, but we'd |
| 1081 | // still like to manipulate their frame to update crop, etc... |
| 1082 | // |
| 1083 | // Anyway we don't need to synchronize position and content updates for these |
| 1084 | // windows since they aren't at the base layer and could be moved around anyway. |
| 1085 | if (!win.computeDragResizing() && win.mAttrs.type == TYPE_BASE_APPLICATION && |
| 1086 | !mTask.mStack.getBoundsAnimating() && !win.isGoneForLayoutLw() && |
| 1087 | !mTask.inPinnedWorkspace()) { |
| 1088 | win.setResizedWhileNotDragResizing(true); |
| 1089 | } |
| 1090 | } |
| 1091 | if (win.isGoneForLayoutLw()) { |
| 1092 | win.mResizedWhileGone = true; |
| 1093 | } |
| 1094 | } |
| 1095 | } |
| 1096 | |
| 1097 | void moveWindows() { |
| 1098 | for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; --winNdx) { |
| 1099 | final WindowState win = allAppWindows.get(winNdx); |
| 1100 | if (DEBUG_RESIZE) Slog.d(TAG, "moveWindows: Moving " + win); |
| 1101 | win.mMovedByResize = true; |
| 1102 | } |
| 1103 | } |
| 1104 | |
| 1105 | void notifyMovedInStack() { |
| 1106 | for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; --winNdx) { |
| 1107 | final WindowState win = allAppWindows.get(winNdx); |
| 1108 | win.notifyMovedInStack(); |
| 1109 | } |
| 1110 | } |
| 1111 | |
| 1112 | void resetDragResizingChangeReported() { |
| 1113 | for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; --winNdx) { |
| 1114 | final WindowState win = allAppWindows.get(winNdx); |
| 1115 | win.resetDragResizingChangeReported(); |
| 1116 | } |
| 1117 | } |
| 1118 | |
| 1119 | void detachDisplay() { |
| 1120 | boolean doAnotherLayoutPass = false; |
| 1121 | for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; --winNdx) { |
| 1122 | // We are in the middle of changing the state of displays/stacks/tasks. We need |
| 1123 | // to finish that, before we let layout interfere with it. |
| 1124 | service.removeWindowLocked(allAppWindows.get(winNdx)); |
| 1125 | doAnotherLayoutPass = true; |
| 1126 | } |
| 1127 | if (doAnotherLayoutPass) { |
| 1128 | service.mWindowPlacerLocked.requestTraversal(); |
| 1129 | } |
| 1130 | } |
| 1131 | |
| 1132 | void forceWindowsScaleableInTransaction(boolean force) { |
| 1133 | for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; --winNdx) { |
| 1134 | final WindowStateAnimator winAnimator = allAppWindows.get(winNdx).mWinAnimator; |
| 1135 | if (winAnimator == null || !winAnimator.hasSurface()) { |
| 1136 | continue; |
| 1137 | } |
| 1138 | winAnimator.mSurfaceController.forceScaleableInTransaction(force); |
| 1139 | } |
| 1140 | } |
| 1141 | |
| 1142 | boolean isAnimating() { |
| 1143 | for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; --winNdx) { |
| 1144 | final WindowStateAnimator winAnimator = allAppWindows.get(winNdx).mWinAnimator; |
| 1145 | if (winAnimator.isAnimationSet() || winAnimator.mWin.mAnimatingExit) { |
| 1146 | return true; |
| 1147 | } |
| 1148 | } |
| 1149 | return false; |
| 1150 | } |
| 1151 | |
| 1152 | void setAppLayoutChanges(int changes, String reason, int displayId) { |
| 1153 | final WindowAnimator windowAnimator = mAppAnimator.mAnimator; |
| 1154 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 1155 | if (displayId == allAppWindows.get(i).getDisplayId()) { |
| 1156 | windowAnimator.setPendingLayoutChanges(displayId, changes); |
| 1157 | if (DEBUG_LAYOUT_REPEATS) { |
| 1158 | service.mWindowPlacerLocked.debugLayoutRepeats( |
| 1159 | reason, windowAnimator.getPendingLayoutChanges(displayId)); |
| 1160 | } |
| 1161 | break; |
| 1162 | } |
| 1163 | } |
| 1164 | } |
| 1165 | |
| 1166 | void removeReplacedWindowIfNeeded(WindowState replacement) { |
| 1167 | for (int i = allAppWindows.size() - 1; i >= 0; i--) { |
| 1168 | final WindowState win = allAppWindows.get(i); |
| 1169 | if (win.mWillReplaceWindow && win.mReplacingWindow == replacement |
| 1170 | && replacement.hasDrawnLw()) { |
| 1171 | replacement.mSkipEnterAnimationForSeamlessReplacement = false; |
| 1172 | win.removeReplacedWindow(); |
| 1173 | } |
| 1174 | } |
| 1175 | } |
| 1176 | |
| 1177 | void startFreezingScreen() { |
| 1178 | if (DEBUG_ORIENTATION) logWithStack(TAG, "Set freezing of " + appToken + ": hidden=" |
| 1179 | + hidden + " freezing=" + mAppAnimator.freezingScreen); |
| 1180 | if (!hiddenRequested) { |
| 1181 | if (!mAppAnimator.freezingScreen) { |
| 1182 | mAppAnimator.freezingScreen = true; |
| 1183 | mAppAnimator.lastFreezeDuration = 0; |
| 1184 | service.mAppsFreezingScreen++; |
| 1185 | if (service.mAppsFreezingScreen == 1) { |
| 1186 | service.startFreezingDisplayLocked(false, 0, 0); |
| 1187 | service.mH.removeMessages(H.APP_FREEZE_TIMEOUT); |
| 1188 | service.mH.sendEmptyMessageDelayed(H.APP_FREEZE_TIMEOUT, 2000); |
| 1189 | } |
| 1190 | } |
| 1191 | final int count = allAppWindows.size(); |
| 1192 | for (int i = 0; i < count; i++) { |
| 1193 | final WindowState w = allAppWindows.get(i); |
| 1194 | w.mAppFreezing = true; |
| 1195 | } |
| 1196 | } |
| 1197 | } |
| 1198 | |
| 1199 | void stopFreezingScreen(boolean unfreezeSurfaceNow, boolean force) { |
| 1200 | if (!mAppAnimator.freezingScreen) { |
| 1201 | return; |
| 1202 | } |
| 1203 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Clear freezing of " + this + " force=" + force); |
| 1204 | final int count = allAppWindows.size(); |
| 1205 | boolean unfrozeWindows = false; |
| 1206 | for (int i = 0; i < count; i++) { |
| 1207 | final WindowState w = allAppWindows.get(i); |
| 1208 | if (w.mAppFreezing) { |
| 1209 | w.mAppFreezing = false; |
| 1210 | if (w.mHasSurface && !w.mOrientationChanging |
| 1211 | && service.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_TIMEOUT) { |
| 1212 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "set mOrientationChanging of " + w); |
| 1213 | w.mOrientationChanging = true; |
| 1214 | service.mWindowPlacerLocked.mOrientationChangeComplete = false; |
| 1215 | } |
| 1216 | w.mLastFreezeDuration = 0; |
| 1217 | unfrozeWindows = true; |
| 1218 | w.setDisplayLayoutNeeded(); |
| 1219 | } |
| 1220 | } |
| 1221 | if (force || unfrozeWindows) { |
| 1222 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "No longer freezing: " + this); |
| 1223 | mAppAnimator.freezingScreen = false; |
| 1224 | mAppAnimator.lastFreezeDuration = |
| 1225 | (int)(SystemClock.elapsedRealtime() - service.mDisplayFreezeTime); |
| 1226 | service.mAppsFreezingScreen--; |
| 1227 | service.mLastFinishedFreezeSource = this; |
| 1228 | } |
| 1229 | if (unfreezeSurfaceNow) { |
| 1230 | if (unfrozeWindows) { |
| 1231 | service.mWindowPlacerLocked.performSurfacePlacement(); |
| 1232 | } |
| 1233 | service.stopFreezingDisplayLocked(); |
| 1234 | } |
| 1235 | } |
| 1236 | |
| 1237 | boolean transferStartingWindow(IBinder transferFrom) { |
| 1238 | final AppWindowToken fromToken = service.findAppWindowToken(transferFrom); |
| 1239 | if (fromToken == null) { |
| 1240 | return false; |
| 1241 | } |
| 1242 | |
| 1243 | final WindowState tStartingWindow = fromToken.startingWindow; |
| 1244 | if (tStartingWindow != null && fromToken.startingView != null) { |
| 1245 | // In this case, the starting icon has already been displayed, so start |
| 1246 | // letting windows get shown immediately without any more transitions. |
| 1247 | service.mSkipAppTransitionAnimation = true; |
| 1248 | |
| 1249 | if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Moving existing starting " + tStartingWindow |
| 1250 | + " from " + fromToken + " to " + this); |
| 1251 | |
| 1252 | final long origId = Binder.clearCallingIdentity(); |
| 1253 | |
| 1254 | // Transfer the starting window over to the new token. |
| 1255 | startingData = fromToken.startingData; |
| 1256 | startingView = fromToken.startingView; |
| 1257 | startingDisplayed = fromToken.startingDisplayed; |
| 1258 | fromToken.startingDisplayed = false; |
| 1259 | startingWindow = tStartingWindow; |
| 1260 | reportedVisible = fromToken.reportedVisible; |
| 1261 | fromToken.startingData = null; |
| 1262 | fromToken.startingView = null; |
| 1263 | fromToken.startingWindow = null; |
| 1264 | fromToken.startingMoved = true; |
| 1265 | tStartingWindow.mToken = this; |
| 1266 | tStartingWindow.mRootToken = this; |
| 1267 | tStartingWindow.mAppToken = this; |
| 1268 | |
| 1269 | if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE || DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, |
| 1270 | "Removing starting window: " + tStartingWindow); |
| 1271 | tStartingWindow.getWindowList().remove(tStartingWindow); |
| 1272 | service.mWindowsChanged = true; |
| 1273 | if (DEBUG_ADD_REMOVE) Slog.v(TAG_WM, |
| 1274 | "Removing starting " + tStartingWindow + " from " + fromToken); |
| 1275 | fromToken.removeWindow(tStartingWindow); |
| 1276 | fromToken.allAppWindows.remove(tStartingWindow); |
| 1277 | addWindowToList(tStartingWindow); |
| 1278 | |
| 1279 | // Propagate other interesting state between the tokens. If the old token is displayed, |
| 1280 | // we should immediately force the new one to be displayed. If it is animating, we need |
| 1281 | // to move that animation to the new one. |
| 1282 | if (fromToken.allDrawn) { |
| 1283 | allDrawn = true; |
| 1284 | deferClearAllDrawn = fromToken.deferClearAllDrawn; |
| 1285 | } |
| 1286 | if (fromToken.firstWindowDrawn) { |
| 1287 | firstWindowDrawn = true; |
| 1288 | } |
| 1289 | if (!fromToken.hidden) { |
| 1290 | hidden = false; |
| 1291 | hiddenRequested = false; |
| 1292 | } |
| 1293 | if (clientHidden != fromToken.clientHidden) { |
| 1294 | clientHidden = fromToken.clientHidden; |
| 1295 | sendAppVisibilityToClients(); |
| 1296 | } |
| 1297 | fromToken.mAppAnimator.transferCurrentAnimation( |
| 1298 | mAppAnimator, tStartingWindow.mWinAnimator); |
| 1299 | |
| 1300 | service.updateFocusedWindowLocked( |
| 1301 | UPDATE_FOCUS_WILL_PLACE_SURFACES, true /*updateInputWindows*/); |
| 1302 | service.getDefaultDisplayContentLocked().layoutNeeded = true; |
| 1303 | service.mWindowPlacerLocked.performSurfacePlacement(); |
| 1304 | Binder.restoreCallingIdentity(origId); |
| 1305 | return true; |
| 1306 | } else if (fromToken.startingData != null) { |
| 1307 | // The previous app was getting ready to show a |
| 1308 | // starting window, but hasn't yet done so. Steal it! |
| 1309 | if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, |
| 1310 | "Moving pending starting from " + fromToken + " to " + this); |
| 1311 | startingData = fromToken.startingData; |
| 1312 | fromToken.startingData = null; |
| 1313 | fromToken.startingMoved = true; |
| 1314 | final Message m = service.mH.obtainMessage(H.ADD_STARTING, this); |
| 1315 | // Note: we really want to do sendMessageAtFrontOfQueue() because we want to process the |
| 1316 | // message ASAP, before any other queued messages. |
| 1317 | service.mH.sendMessageAtFrontOfQueue(m); |
| 1318 | return true; |
| 1319 | } |
| 1320 | |
| 1321 | final AppWindowAnimator tAppAnimator = fromToken.mAppAnimator; |
| 1322 | final AppWindowAnimator wAppAnimator = mAppAnimator; |
| 1323 | if (tAppAnimator.thumbnail != null) { |
| 1324 | // The old token is animating with a thumbnail, transfer that to the new token. |
| 1325 | if (wAppAnimator.thumbnail != null) { |
| 1326 | wAppAnimator.thumbnail.destroy(); |
| 1327 | } |
| 1328 | wAppAnimator.thumbnail = tAppAnimator.thumbnail; |
| 1329 | wAppAnimator.thumbnailLayer = tAppAnimator.thumbnailLayer; |
| 1330 | wAppAnimator.thumbnailAnimation = tAppAnimator.thumbnailAnimation; |
| 1331 | tAppAnimator.thumbnail = null; |
| 1332 | } |
| 1333 | return false; |
| 1334 | } |
| 1335 | |
| 1336 | int getWindowsCount() { |
| 1337 | return allAppWindows.size(); |
| 1338 | } |
| 1339 | |
| 1340 | void setAllAppWinAnimators() { |
| 1341 | final ArrayList<WindowStateAnimator> allAppWinAnimators = mAppAnimator.mAllAppWinAnimators; |
| 1342 | allAppWinAnimators.clear(); |
| 1343 | |
| 1344 | final int windowsCount = allAppWindows.size(); |
| 1345 | for (int j = 0; j < windowsCount; j++) { |
| 1346 | allAppWinAnimators.add(allAppWindows.get(j).mWinAnimator); |
| 1347 | } |
| 1348 | } |
| 1349 | |
| 1350 | /** Returns true if the app token windows list is empty. */ |
| 1351 | @Override |
| 1352 | boolean isEmpty() { |
| 1353 | return allAppWindows.isEmpty(); |
| 1354 | } |
| 1355 | |
Craig Mautner | dbb7991 | 2012-03-01 18:59:14 -0800 | [diff] [blame] | 1356 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1357 | void dump(PrintWriter pw, String prefix) { |
| 1358 | super.dump(pw, prefix); |
| 1359 | if (appToken != null) { |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1360 | pw.print(prefix); pw.print("app=true voiceInteraction="); pw.println(voiceInteraction); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1361 | } |
| 1362 | if (allAppWindows.size() > 0) { |
| 1363 | pw.print(prefix); pw.print("allAppWindows="); pw.println(allAppWindows); |
| 1364 | } |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 1365 | pw.print(prefix); pw.print("task="); pw.println(mTask); |
| 1366 | pw.print(prefix); pw.print(" appFullscreen="); pw.print(appFullscreen); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1367 | pw.print(" requestedOrientation="); pw.println(requestedOrientation); |
| 1368 | pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested); |
| 1369 | pw.print(" clientHidden="); pw.print(clientHidden); |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 1370 | pw.print(" reportedDrawn="); pw.print(reportedDrawn); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1371 | pw.print(" reportedVisible="); pw.println(reportedVisible); |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 1372 | if (paused) { |
| 1373 | pw.print(prefix); pw.print("paused="); pw.println(paused); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1374 | } |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 1375 | if (mAppStopped) { |
| 1376 | pw.print(prefix); pw.print("mAppStopped="); pw.println(mAppStopped); |
| 1377 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1378 | if (numInterestingWindows != 0 || numDrawnWindows != 0 |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1379 | || allDrawn || mAppAnimator.allDrawn) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1380 | pw.print(prefix); pw.print("numInterestingWindows="); |
| 1381 | pw.print(numInterestingWindows); |
| 1382 | pw.print(" numDrawnWindows="); pw.print(numDrawnWindows); |
| 1383 | pw.print(" inPendingTransaction="); pw.print(inPendingTransaction); |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1384 | pw.print(" allDrawn="); pw.print(allDrawn); |
| 1385 | pw.print(" (animator="); pw.print(mAppAnimator.allDrawn); |
| 1386 | pw.println(")"); |
| 1387 | } |
| 1388 | if (inPendingTransaction) { |
| 1389 | pw.print(prefix); pw.print("inPendingTransaction="); |
| 1390 | pw.println(inPendingTransaction); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1391 | } |
Craig Mautner | 799bc1d | 2015-01-14 10:33:48 -0800 | [diff] [blame] | 1392 | if (startingData != null || removed || firstWindowDrawn || mIsExiting) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1393 | pw.print(prefix); pw.print("startingData="); pw.print(startingData); |
| 1394 | pw.print(" removed="); pw.print(removed); |
Craig Mautner | 3d7ca31 | 2015-01-08 10:56:00 -0800 | [diff] [blame] | 1395 | pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn); |
Craig Mautner | 799bc1d | 2015-01-14 10:33:48 -0800 | [diff] [blame] | 1396 | pw.print(" mIsExiting="); pw.println(mIsExiting); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1397 | } |
| 1398 | if (startingWindow != null || startingView != null |
| 1399 | || startingDisplayed || startingMoved) { |
| 1400 | pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow); |
| 1401 | pw.print(" startingView="); pw.print(startingView); |
| 1402 | pw.print(" startingDisplayed="); pw.print(startingDisplayed); |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 1403 | pw.print(" startingMoved="); pw.println(startingMoved); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1404 | } |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 1405 | if (!mFrozenBounds.isEmpty()) { |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 1406 | pw.print(prefix); pw.print("mFrozenBounds="); pw.println(mFrozenBounds); |
Jorim Jaggi | 26c8c42 | 2016-05-09 19:57:25 -0700 | [diff] [blame] | 1407 | pw.print(prefix); pw.print("mFrozenMergedConfig="); pw.println(mFrozenMergedConfig); |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 1408 | } |
| 1409 | if (mPendingRelaunchCount != 0) { |
| 1410 | pw.print(prefix); pw.print("mPendingRelaunchCount="); pw.println(mPendingRelaunchCount); |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 1411 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1412 | } |
| 1413 | |
| 1414 | @Override |
| 1415 | public String toString() { |
| 1416 | if (stringName == null) { |
| 1417 | StringBuilder sb = new StringBuilder(); |
| 1418 | sb.append("AppWindowToken{"); |
| 1419 | sb.append(Integer.toHexString(System.identityHashCode(this))); |
| 1420 | sb.append(" token="); sb.append(token); sb.append('}'); |
| 1421 | stringName = sb.toString(); |
| 1422 | } |
| 1423 | return stringName; |
| 1424 | } |
Jeff Brown | e9bdb31 | 2012-04-05 15:30:10 -0700 | [diff] [blame] | 1425 | } |