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 | 72919d2 | 2016-12-08 18:58:50 -0800 | [diff] [blame] | 20 | import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION; |
| 21 | import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE; |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 22 | import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 23 | import static android.view.Display.DEFAULT_DISPLAY; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 24 | import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD; |
| 25 | import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 26 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 27 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 28 | import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 29 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM; |
| 30 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; |
Wale Ogunwale | ac2561e | 2016-11-01 15:43:46 -0700 | [diff] [blame] | 31 | import static com.android.server.wm.AppTransition.TRANSIT_UNSET; |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 32 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 33 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM; |
| 34 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS; |
Wale Ogunwale | ac2561e | 2016-11-01 15:43:46 -0700 | [diff] [blame] | 35 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS_LIGHT; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 36 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT_REPEATS; |
| 37 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION; |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 38 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STARTING_WINDOW; |
Wale Ogunwale | ac2561e | 2016-11-01 15:43:46 -0700 | [diff] [blame] | 39 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TOKEN_MOVEMENT; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 40 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY; |
| 41 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_MOVEMENT; |
| 42 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; |
| 43 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 44 | import static com.android.server.wm.WindowManagerService.H.NOTIFY_ACTIVITY_DRAWN; |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 45 | import static com.android.server.wm.WindowManagerService.H.NOTIFY_STARTING_WINDOW_DRAWN; |
Wale Ogunwale | ac2561e | 2016-11-01 15:43:46 -0700 | [diff] [blame] | 46 | import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 47 | import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE_SURFACES; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 48 | import static com.android.server.wm.WindowManagerService.logWithStack; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 49 | |
Filip Gruszczynski | a590c99 | 2015-11-25 16:45:26 -0800 | [diff] [blame] | 50 | import android.annotation.NonNull; |
Jorim Jaggi | 26c8c42 | 2016-05-09 19:57:25 -0700 | [diff] [blame] | 51 | import android.content.res.Configuration; |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 52 | import android.graphics.Rect; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 53 | import android.os.Binder; |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 54 | import android.os.Debug; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 55 | import android.os.IBinder; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 56 | import android.os.SystemClock; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 57 | import android.util.Slog; |
| 58 | import android.view.IApplicationToken; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 59 | import android.view.WindowManager; |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 60 | import android.view.WindowManagerPolicy.StartingSurface; |
| 61 | |
| 62 | import com.android.internal.util.ToBooleanFunction; |
| 63 | import com.android.server.input.InputApplicationHandle; |
| 64 | import com.android.server.wm.WindowManagerService.H; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 65 | |
| 66 | import java.io.PrintWriter; |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 67 | import java.util.ArrayDeque; |
Craig Mautner | b1fd65c0 | 2013-02-05 13:34:57 -0800 | [diff] [blame] | 68 | import java.util.ArrayList; |
| 69 | |
| 70 | class AppTokenList extends ArrayList<AppWindowToken> { |
| 71 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 72 | |
| 73 | /** |
| 74 | * Version of WindowToken that is specifically for a particular application (or |
| 75 | * really activity) that is displaying windows. |
| 76 | */ |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 77 | class AppWindowToken extends WindowToken implements WindowManagerService.AppFreezeListener { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 78 | private static final String TAG = TAG_WITH_CLASS_NAME ? "AppWindowToken" : TAG_WM; |
| 79 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 80 | // Non-null only for application tokens. |
| 81 | final IApplicationToken appToken; |
| 82 | |
Filip Gruszczynski | a590c99 | 2015-11-25 16:45:26 -0800 | [diff] [blame] | 83 | @NonNull final AppWindowAnimator mAppAnimator; |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 84 | |
Wale Ogunwale | 72919d2 | 2016-12-08 18:58:50 -0800 | [diff] [blame] | 85 | final boolean mVoiceInteraction; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 86 | |
Wale Ogunwale | f619286 | 2016-09-10 13:42:30 -0700 | [diff] [blame] | 87 | // TODO: Use getParent instead? |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 88 | Task mTask; |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 89 | /** @see WindowContainer#fillsParent() */ |
| 90 | private boolean mFillsParent; |
Craig Mautner | 4c5eb22 | 2013-11-18 12:59:05 -0800 | [diff] [blame] | 91 | boolean layoutConfigChanges; |
Wale Ogunwale | 72919d2 | 2016-12-08 18:58:50 -0800 | [diff] [blame] | 92 | boolean mShowForAllUsers; |
| 93 | int mTargetSdk; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 94 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 95 | // The input dispatching timeout for this application token in nanoseconds. |
Wale Ogunwale | 72919d2 | 2016-12-08 18:58:50 -0800 | [diff] [blame] | 96 | long mInputDispatchingTimeoutNanos; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 97 | |
| 98 | // These are used for determining when all windows associated with |
| 99 | // an activity have been drawn, so they can be made visible together |
| 100 | // at the same time. |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 101 | // initialize so that it doesn't match mTransactionSequence which is an int. |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 102 | private long mLastTransactionSequence = Long.MIN_VALUE; |
| 103 | private int mNumInterestingWindows; |
| 104 | private int mNumDrawnWindows; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 105 | boolean inPendingTransaction; |
| 106 | boolean allDrawn; |
Craig Mautner | 7636dfb | 2012-11-16 15:24:11 -0800 | [diff] [blame] | 107 | // Set to true when this app creates a surface while in the middle of an animation. In that |
| 108 | // case do not clear allDrawn until the animation completes. |
| 109 | boolean deferClearAllDrawn; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 110 | |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 111 | /** |
| 112 | * These are to track the app's real drawing status if there were no saved surfaces. |
| 113 | * @see #updateDrawnWindowStates |
| 114 | */ |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 115 | boolean allDrawnExcludingSaved; |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 116 | private int mNumInterestingWindowsExcludingSaved; |
| 117 | private int mNumDrawnWindowsExcludingSaved; |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 118 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 119 | // Is this window's surface needed? This is almost like hidden, except |
| 120 | // it will sometimes be true a little earlier: when the token has |
| 121 | // been shown, but is still waiting for its app transition to execute |
| 122 | // before making its windows shown. |
| 123 | boolean hiddenRequested; |
| 124 | |
| 125 | // Have we told the window clients to hide themselves? |
| 126 | boolean clientHidden; |
| 127 | |
| 128 | // Last visibility state we reported to the app token. |
| 129 | boolean reportedVisible; |
| 130 | |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 131 | // Last drawn state we reported to the app token. |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 132 | private boolean reportedDrawn; |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 133 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 134 | // Set to true when the token has been removed from the window mgr. |
| 135 | boolean removed; |
| 136 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 137 | // Information about an application starting window if displayed. |
| 138 | StartingData startingData; |
| 139 | WindowState startingWindow; |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 140 | StartingSurface startingSurface; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 141 | boolean startingDisplayed; |
| 142 | boolean startingMoved; |
| 143 | boolean firstWindowDrawn; |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 144 | private final WindowState.UpdateReportedVisibilityResults mReportedVisibilityResults = |
| 145 | new WindowState.UpdateReportedVisibilityResults(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 146 | |
| 147 | // Input application handle used by the input dispatcher. |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 148 | final InputApplicationHandle mInputApplicationHandle; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 149 | |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 150 | // TODO: Have a WindowContainer state for tracking exiting/deferred removal. |
Craig Mautner | 799bc1d | 2015-01-14 10:33:48 -0800 | [diff] [blame] | 151 | boolean mIsExiting; |
Craig Mautner | 9ef471f | 2014-02-07 13:11:47 -0800 | [diff] [blame] | 152 | |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 153 | boolean mLaunchTaskBehind; |
Craig Mautner | 8746a47 | 2014-07-24 15:12:54 -0700 | [diff] [blame] | 154 | boolean mEnteringAnimation; |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 155 | |
Wale Ogunwale | 72919d2 | 2016-12-08 18:58:50 -0800 | [diff] [blame] | 156 | private boolean mAlwaysFocusable; |
Wale Ogunwale | 6cae765 | 2015-12-26 07:36:26 -0800 | [diff] [blame] | 157 | |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 158 | boolean mAppStopped; |
Robert Carr | fd10cd1 | 2016-06-29 16:41:50 -0700 | [diff] [blame] | 159 | int mRotationAnimationHint; |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 160 | private int mPendingRelaunchCount; |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 161 | |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 162 | private boolean mLastContainsShowWhenLockedWindow; |
| 163 | private boolean mLastContainsDismissKeyguardWindow; |
| 164 | |
Robert Carr | 91b22809 | 2016-06-28 17:32:37 -0700 | [diff] [blame] | 165 | private ArrayList<WindowSurfaceController.SurfaceControlWithBackground> mSurfaceViewBackgrounds = |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 166 | new ArrayList<>(); |
Robert Carr | 91b22809 | 2016-06-28 17:32:37 -0700 | [diff] [blame] | 167 | |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 168 | ArrayDeque<Rect> mFrozenBounds = new ArrayDeque<>(); |
Jorim Jaggi | 26c8c42 | 2016-05-09 19:57:25 -0700 | [diff] [blame] | 169 | ArrayDeque<Configuration> mFrozenMergedConfig = new ArrayDeque<>(); |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 170 | |
Wale Ogunwale | 72919d2 | 2016-12-08 18:58:50 -0800 | [diff] [blame] | 171 | AppWindowToken(WindowManagerService service, IApplicationToken token, boolean voiceInteraction, |
| 172 | DisplayContent dc, long inputDispatchingTimeoutNanos, boolean fullscreen, |
| 173 | boolean showForAllUsers, int targetSdk, int orientation, int rotationAnimationHint, |
Wale Ogunwale | 26c0dfe | 2016-12-14 14:42:30 -0800 | [diff] [blame] | 174 | int configChanges, boolean launchTaskBehind, boolean alwaysFocusable, |
| 175 | AppWindowContainerController controller) { |
Wale Ogunwale | 72919d2 | 2016-12-08 18:58:50 -0800 | [diff] [blame] | 176 | this(service, token, voiceInteraction, dc); |
Wale Ogunwale | 26c0dfe | 2016-12-14 14:42:30 -0800 | [diff] [blame] | 177 | setController(controller); |
Wale Ogunwale | 72919d2 | 2016-12-08 18:58:50 -0800 | [diff] [blame] | 178 | mInputDispatchingTimeoutNanos = inputDispatchingTimeoutNanos; |
| 179 | mFillsParent = fullscreen; |
| 180 | mShowForAllUsers = showForAllUsers; |
| 181 | mTargetSdk = targetSdk; |
| 182 | mOrientation = orientation; |
| 183 | layoutConfigChanges = (configChanges & (CONFIG_SCREEN_SIZE | CONFIG_ORIENTATION)) != 0; |
| 184 | mLaunchTaskBehind = launchTaskBehind; |
| 185 | mAlwaysFocusable = alwaysFocusable; |
| 186 | mRotationAnimationHint = rotationAnimationHint; |
| 187 | |
| 188 | // Application tokens start out hidden. |
| 189 | hidden = true; |
| 190 | hiddenRequested = true; |
| 191 | } |
| 192 | |
| 193 | AppWindowToken(WindowManagerService service, IApplicationToken token, boolean voiceInteraction, |
| 194 | DisplayContent dc) { |
| 195 | super(service, token != null ? token.asBinder() : null, TYPE_APPLICATION, true, dc); |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 196 | appToken = token; |
Wale Ogunwale | 72919d2 | 2016-12-08 18:58:50 -0800 | [diff] [blame] | 197 | mVoiceInteraction = voiceInteraction; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 198 | mInputApplicationHandle = new InputApplicationHandle(this); |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 199 | mAppAnimator = new AppWindowAnimator(this, service); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 200 | } |
| 201 | |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 202 | void onFirstWindowDrawn(WindowState win, WindowStateAnimator winAnimator) { |
| 203 | firstWindowDrawn = true; |
| 204 | |
| 205 | // We now have a good window to show, remove dead placeholders |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 206 | removeDeadWindows(); |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 207 | |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame^] | 208 | if (startingWindow != null) { |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 209 | if (DEBUG_STARTING_WINDOW || DEBUG_ANIM) Slog.v(TAG, "Finish starting " |
| 210 | + win.mToken + ": first real window is shown, no animation"); |
| 211 | // If this initial window is animating, stop it -- we will do an animation to reveal |
| 212 | // it from behind the starting window, so there is no need for it to also be doing its |
| 213 | // own stuff. |
| 214 | winAnimator.clearAnimation(); |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 215 | if (getController() != null) { |
| 216 | getController().removeStartingWindow(); |
| 217 | } |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 218 | } |
| 219 | updateReportedVisibilityLocked(); |
| 220 | } |
| 221 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 222 | void updateReportedVisibilityLocked() { |
| 223 | if (appToken == null) { |
| 224 | return; |
| 225 | } |
| 226 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 227 | if (DEBUG_VISIBILITY) Slog.v(TAG, "Update reported visibility: " + this); |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 228 | final int count = mChildren.size(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 229 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 230 | mReportedVisibilityResults.reset(); |
| 231 | |
| 232 | for (int i = 0; i < count; i++) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 233 | final WindowState win = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 234 | win.updateReportedVisibility(mReportedVisibilityResults); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 235 | } |
| 236 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 237 | int numInteresting = mReportedVisibilityResults.numInteresting; |
| 238 | int numVisible = mReportedVisibilityResults.numVisible; |
| 239 | int numDrawn = mReportedVisibilityResults.numDrawn; |
| 240 | boolean nowGone = mReportedVisibilityResults.nowGone; |
| 241 | |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 242 | boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 243 | boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting; |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 244 | if (!nowGone) { |
| 245 | // If the app is not yet gone, then it can only become visible/drawn. |
| 246 | if (!nowDrawn) { |
| 247 | nowDrawn = reportedDrawn; |
| 248 | } |
| 249 | if (!nowVisible) { |
| 250 | nowVisible = reportedVisible; |
| 251 | } |
| 252 | } |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 253 | if (DEBUG_VISIBILITY) Slog.v(TAG, "VIS " + this + ": interesting=" |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 254 | + numInteresting + " visible=" + numVisible); |
Wale Ogunwale | 26c0dfe | 2016-12-14 14:42:30 -0800 | [diff] [blame] | 255 | final AppWindowContainerController controller = getController(); |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 256 | if (nowDrawn != reportedDrawn) { |
| 257 | if (nowDrawn) { |
Wale Ogunwale | 26c0dfe | 2016-12-14 14:42:30 -0800 | [diff] [blame] | 258 | if (controller != null) { |
| 259 | controller.reportWindowsDrawn(); |
| 260 | } |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 261 | } |
| 262 | reportedDrawn = nowDrawn; |
| 263 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 264 | if (nowVisible != reportedVisible) { |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 265 | if (DEBUG_VISIBILITY) Slog.v(TAG, |
| 266 | "Visibility changed in " + this + ": vis=" + nowVisible); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 267 | reportedVisible = nowVisible; |
Wale Ogunwale | 26c0dfe | 2016-12-14 14:42:30 -0800 | [diff] [blame] | 268 | if (controller != null) { |
| 269 | if (nowVisible) { |
| 270 | controller.reportWindowsVisible(); |
| 271 | } else { |
| 272 | controller.reportWindowsGone(); |
| 273 | } |
| 274 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 275 | } |
| 276 | } |
| 277 | |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 278 | boolean setVisibility(WindowManager.LayoutParams lp, |
| 279 | boolean visible, int transit, boolean performLayout, boolean isVoiceInteraction) { |
| 280 | |
| 281 | boolean delayed = false; |
| 282 | inPendingTransaction = false; |
| 283 | |
| 284 | if (clientHidden == visible) { |
| 285 | clientHidden = !visible; |
| 286 | sendAppVisibilityToClients(); |
| 287 | } |
| 288 | |
| 289 | // Allow for state changes and animation to be applied if: |
| 290 | // * token is transitioning visibility state |
| 291 | // * or the token was marked as hidden and is exiting before we had a chance to play the |
| 292 | // transition animation |
| 293 | // * or this is an opening app and windows are being replaced. |
| 294 | boolean visibilityChanged = false; |
| 295 | if (hidden == visible || (hidden && mIsExiting) || (visible && waitingForReplacement())) { |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 296 | final AccessibilityController accessibilityController = mService.mAccessibilityController; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 297 | boolean changed = false; |
| 298 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, |
| 299 | "Changing app " + this + " hidden=" + hidden + " performLayout=" + performLayout); |
| 300 | |
| 301 | boolean runningAppAnimation = false; |
| 302 | |
| 303 | if (transit != AppTransition.TRANSIT_UNSET) { |
| 304 | if (mAppAnimator.animation == AppWindowAnimator.sDummyAnimation) { |
| 305 | mAppAnimator.setNullAnimation(); |
| 306 | } |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 307 | if (mService.applyAnimationLocked(this, lp, transit, visible, isVoiceInteraction)) { |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 308 | delayed = runningAppAnimation = true; |
| 309 | } |
| 310 | final WindowState window = findMainWindow(); |
| 311 | //TODO (multidisplay): Magnification is supported only for the default display. |
| 312 | if (window != null && accessibilityController != null |
Wale Ogunwale | b0f3b83 | 2016-10-17 10:13:07 -0700 | [diff] [blame] | 313 | && getDisplayContent().getDisplayId() == DEFAULT_DISPLAY) { |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 314 | accessibilityController.onAppWindowTransitionLocked(window, transit); |
| 315 | } |
| 316 | changed = true; |
| 317 | } |
| 318 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 319 | final int windowsCount = mChildren.size(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 320 | for (int i = 0; i < windowsCount; i++) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 321 | final WindowState win = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 322 | changed |= win.onAppVisibilityChanged(visible, runningAppAnimation); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | hidden = hiddenRequested = !visible; |
| 326 | visibilityChanged = true; |
| 327 | if (!visible) { |
| 328 | stopFreezingScreen(true, true); |
| 329 | } else { |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 330 | // If we are being set visible, and the starting window is not yet displayed, |
| 331 | // then make sure it doesn't get displayed. |
| 332 | if (startingWindow != null && !startingWindow.isDrawnLw()) { |
| 333 | startingWindow.mPolicyVisibility = false; |
| 334 | startingWindow.mPolicyVisibilityAfterAnim = false; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 335 | } |
| 336 | } |
| 337 | |
| 338 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "setVisibility: " + this |
| 339 | + ": hidden=" + hidden + " hiddenRequested=" + hiddenRequested); |
| 340 | |
| 341 | if (changed) { |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 342 | mService.mInputMonitor.setUpdateInputWindowsNeededLw(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 343 | if (performLayout) { |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 344 | mService.updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES, |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 345 | false /*updateInputWindows*/); |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 346 | mService.mWindowPlacerLocked.performSurfacePlacement(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 347 | } |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 348 | mService.mInputMonitor.updateInputWindowsLw(false /*force*/); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 349 | } |
| 350 | } |
| 351 | |
| 352 | if (mAppAnimator.animation != null) { |
| 353 | delayed = true; |
| 354 | } |
| 355 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 356 | for (int i = mChildren.size() - 1; i >= 0 && !delayed; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 357 | if ((mChildren.get(i)).isWindowAnimationSet()) { |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 358 | delayed = true; |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | if (visibilityChanged) { |
| 363 | if (visible && !delayed) { |
| 364 | // The token was made immediately visible, there will be no entrance animation. |
| 365 | // We need to inform the client the enter animation was finished. |
| 366 | mEnteringAnimation = true; |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 367 | mService.mActivityManagerAppTransitionNotifier.onAppTransitionFinishedLocked(token); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 368 | } |
| 369 | |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 370 | if (!mService.mClosingApps.contains(this) && !mService.mOpeningApps.contains(this)) { |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 371 | // The token is not closing nor opening, so even if there is an animation set, that |
| 372 | // doesn't mean that it goes through the normal app transition cycle so we have |
| 373 | // to inform the docked controller about visibility change. |
Andrii Kulian | 1e32e02 | 2016-09-16 15:29:34 -0700 | [diff] [blame] | 374 | // TODO(multi-display): notify docked divider on all displays where visibility was |
| 375 | // affected. |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 376 | mService.getDefaultDisplayContentLocked().getDockedDividerController() |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 377 | .notifyAppVisibilityChanged(); |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | return delayed; |
| 382 | } |
| 383 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 384 | WindowState findMainWindow() { |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 385 | WindowState candidate = null; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 386 | int j = mChildren.size(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 387 | while (j > 0) { |
| 388 | j--; |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 389 | final WindowState win = mChildren.get(j); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 390 | final int type = win.mAttrs.type; |
| 391 | // No need to loop through child window as base application and starting types can't be |
| 392 | // child windows. |
| 393 | if (type == TYPE_BASE_APPLICATION || type == TYPE_APPLICATION_STARTING) { |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 394 | // 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] | 395 | // happens for example when replacing windows during an activity relaunch. When |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 396 | // constructing the animation, we want the new window, not the exiting one. |
Wale Ogunwale | c48a354 | 2016-02-19 15:18:45 -0800 | [diff] [blame] | 397 | if (win.mAnimatingExit) { |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 398 | candidate = win; |
| 399 | } else { |
| 400 | return win; |
| 401 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 402 | } |
| 403 | } |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 404 | return candidate; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 405 | } |
| 406 | |
Wale Ogunwale | 6cae765 | 2015-12-26 07:36:26 -0800 | [diff] [blame] | 407 | boolean windowsAreFocusable() { |
| 408 | return StackId.canReceiveKeys(mTask.mStack.mStackId) || mAlwaysFocusable; |
Wale Ogunwale | d045c82 | 2015-12-02 09:14:28 -0800 | [diff] [blame] | 409 | } |
| 410 | |
Wale Ogunwale | 26c0dfe | 2016-12-14 14:42:30 -0800 | [diff] [blame] | 411 | AppWindowContainerController getController() { |
| 412 | final WindowContainerController controller = super.getController(); |
| 413 | return controller != null ? (AppWindowContainerController) controller : null; |
| 414 | } |
| 415 | |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 416 | @Override |
Wale Ogunwale | 44f2180 | 2016-09-02 12:49:48 -0700 | [diff] [blame] | 417 | boolean isVisible() { |
Wale Ogunwale | e471be6 | 2016-10-03 07:53:55 -0700 | [diff] [blame] | 418 | // If the app token isn't hidden then it is considered visible and there is no need to check |
| 419 | // its children windows to see if they are visible. |
| 420 | return !hidden; |
Wale Ogunwale | 44f2180 | 2016-09-02 12:49:48 -0700 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | @Override |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 424 | void removeIfPossible() { |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 425 | mIsExiting = false; |
Wale Ogunwale | 3d0bfd9 | 2016-12-05 11:38:02 -0800 | [diff] [blame] | 426 | removeAllWindowsIfPossible(); |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 427 | if (mTask != null) { |
Wale Ogunwale | f619286 | 2016-09-10 13:42:30 -0700 | [diff] [blame] | 428 | mTask.mStack.mExitingAppTokens.remove(this); |
Wale Ogunwale | 3d0bfd9 | 2016-12-05 11:38:02 -0800 | [diff] [blame] | 429 | removeImmediately(); |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 430 | } |
| 431 | } |
| 432 | |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 433 | @Override |
| 434 | boolean checkCompleteDeferredRemoval() { |
| 435 | if (mIsExiting) { |
| 436 | removeIfPossible(); |
| 437 | } |
| 438 | return super.checkCompleteDeferredRemoval(); |
| 439 | } |
| 440 | |
Wale Ogunwale | ac2561e | 2016-11-01 15:43:46 -0700 | [diff] [blame] | 441 | void onRemovedFromDisplay() { |
Wale Ogunwale | ac2561e | 2016-11-01 15:43:46 -0700 | [diff] [blame] | 442 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "Removing app token: " + this); |
| 443 | |
Wale Ogunwale | 72919d2 | 2016-12-08 18:58:50 -0800 | [diff] [blame] | 444 | boolean delayed = setVisibility(null, false, TRANSIT_UNSET, true, mVoiceInteraction); |
Wale Ogunwale | ac2561e | 2016-11-01 15:43:46 -0700 | [diff] [blame] | 445 | |
| 446 | mService.mOpeningApps.remove(this); |
Jorim Jaggi | 1b4b23e | 2016-11-15 16:30:12 -0800 | [diff] [blame] | 447 | mService.mUnknownAppVisibilityController.appRemoved(this); |
Wale Ogunwale | ac2561e | 2016-11-01 15:43:46 -0700 | [diff] [blame] | 448 | waitingToShow = false; |
| 449 | if (mService.mClosingApps.contains(this)) { |
| 450 | delayed = true; |
| 451 | } else if (mService.mAppTransition.isTransitionSet()) { |
| 452 | mService.mClosingApps.add(this); |
| 453 | delayed = true; |
| 454 | } |
| 455 | |
| 456 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "Removing app " + this + " delayed=" + delayed |
| 457 | + " animation=" + mAppAnimator.animation + " animating=" + mAppAnimator.animating); |
| 458 | |
| 459 | if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG_WM, "removeAppToken: " |
| 460 | + this + " delayed=" + delayed + " Callers=" + Debug.getCallers(4)); |
| 461 | |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 462 | if (startingData != null && getController() != null) { |
| 463 | getController().removeStartingWindow(); |
| 464 | } |
| 465 | |
Wale Ogunwale | ac2561e | 2016-11-01 15:43:46 -0700 | [diff] [blame] | 466 | final TaskStack stack = mTask.mStack; |
| 467 | if (delayed && !isEmpty()) { |
| 468 | // set the token aside because it has an active animation to be finished |
| 469 | if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG_WM, |
| 470 | "removeAppToken make exiting: " + this); |
| 471 | stack.mExitingAppTokens.add(this); |
| 472 | mIsExiting = true; |
| 473 | } else { |
| 474 | // Make sure there is no animation running on this token, so any windows associated |
| 475 | // with it will be removed as soon as their animations are complete |
| 476 | mAppAnimator.clearAnimation(); |
| 477 | mAppAnimator.animating = false; |
| 478 | removeIfPossible(); |
| 479 | } |
| 480 | |
| 481 | removed = true; |
Wale Ogunwale | ac2561e | 2016-11-01 15:43:46 -0700 | [diff] [blame] | 482 | stopFreezingScreen(true, true); |
| 483 | if (mService.mFocusedApp == this) { |
| 484 | if (DEBUG_FOCUS_LIGHT) Slog.v(TAG_WM, "Removing focused app token:" + this); |
| 485 | mService.mFocusedApp = null; |
| 486 | mService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, true /*updateInputWindows*/); |
| 487 | mService.mInputMonitor.setFocusedAppLw(null); |
| 488 | } |
| 489 | |
| 490 | if (!delayed) { |
| 491 | updateReportedVisibilityLocked(); |
| 492 | } |
Wale Ogunwale | ac2561e | 2016-11-01 15:43:46 -0700 | [diff] [blame] | 493 | } |
| 494 | |
Chong Zhang | e05bcb1 | 2016-07-26 17:47:29 -0700 | [diff] [blame] | 495 | void clearAnimatingFlags() { |
Chong Zhang | b0d2670 | 2016-08-12 16:03:29 -0700 | [diff] [blame] | 496 | boolean wallpaperMightChange = false; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 497 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 498 | final WindowState win = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 499 | wallpaperMightChange |= win.clearAnimatingFlags(); |
Chong Zhang | e05bcb1 | 2016-07-26 17:47:29 -0700 | [diff] [blame] | 500 | } |
Chong Zhang | b0d2670 | 2016-08-12 16:03:29 -0700 | [diff] [blame] | 501 | if (wallpaperMightChange) { |
| 502 | requestUpdateWallpaperIfNeeded(); |
| 503 | } |
Chong Zhang | e05bcb1 | 2016-07-26 17:47:29 -0700 | [diff] [blame] | 504 | } |
| 505 | |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 506 | void destroySurfaces() { |
Chong Zhang | 45e6d2d | 2016-07-20 18:33:56 -0700 | [diff] [blame] | 507 | destroySurfaces(false /*cleanupOnResume*/); |
| 508 | } |
| 509 | |
| 510 | /** |
| 511 | * Destroy surfaces which have been marked as eligible by the animator, taking care to ensure |
| 512 | * the client has finished with them. |
| 513 | * |
| 514 | * @param cleanupOnResume whether this is done when app is resumed without fully stopped. If |
| 515 | * set to true, destroy only surfaces of removed windows, and clear relevant flags of the |
| 516 | * others so that they are ready to be reused. If set to false (common case), destroy all |
| 517 | * surfaces that's eligible, if the app is already stopped. |
| 518 | */ |
Chong Zhang | 45e6d2d | 2016-07-20 18:33:56 -0700 | [diff] [blame] | 519 | private void destroySurfaces(boolean cleanupOnResume) { |
Wale Ogunwale | b0f3b83 | 2016-10-17 10:13:07 -0700 | [diff] [blame] | 520 | boolean destroyedSomething = false; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 521 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 522 | final WindowState win = mChildren.get(i); |
Wale Ogunwale | b0f3b83 | 2016-10-17 10:13:07 -0700 | [diff] [blame] | 523 | destroyedSomething |= win.destroySurface(cleanupOnResume, mAppStopped); |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 524 | } |
Wale Ogunwale | b0f3b83 | 2016-10-17 10:13:07 -0700 | [diff] [blame] | 525 | if (destroyedSomething) { |
| 526 | final DisplayContent dc = getDisplayContent(); |
Wale Ogunwale | c69694a | 2016-10-18 13:51:15 -0700 | [diff] [blame] | 527 | dc.assignWindowLayers(true /*setLayoutNeeded*/); |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 528 | } |
| 529 | } |
| 530 | |
Wale Ogunwale | 8d5a542 | 2016-03-03 18:28:21 -0800 | [diff] [blame] | 531 | /** |
Chong Zhang | 45e6d2d | 2016-07-20 18:33:56 -0700 | [diff] [blame] | 532 | * Notify that the app is now resumed, and it was not stopped before, perform a clean |
| 533 | * up of the surfaces |
Wale Ogunwale | 8d5a542 | 2016-03-03 18:28:21 -0800 | [diff] [blame] | 534 | */ |
Chong Zhang | ad24f96 | 2016-08-25 12:12:33 -0700 | [diff] [blame] | 535 | void notifyAppResumed(boolean wasStopped, boolean allowSavedSurface) { |
| 536 | if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppResumed: wasStopped=" + wasStopped |
| 537 | + " allowSavedSurface=" + allowSavedSurface + " " + this); |
Chong Zhang | 45e6d2d | 2016-07-20 18:33:56 -0700 | [diff] [blame] | 538 | mAppStopped = false; |
| 539 | if (!wasStopped) { |
| 540 | destroySurfaces(true /*cleanupOnResume*/); |
Wale Ogunwale | 8d5a542 | 2016-03-03 18:28:21 -0800 | [diff] [blame] | 541 | } |
Chong Zhang | ad24f96 | 2016-08-25 12:12:33 -0700 | [diff] [blame] | 542 | if (!allowSavedSurface) { |
| 543 | destroySavedSurfaces(); |
| 544 | } |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 545 | } |
| 546 | |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 547 | /** |
Chong Zhang | 45e6d2d | 2016-07-20 18:33:56 -0700 | [diff] [blame] | 548 | * Notify that the app has stopped, and it is okay to destroy any surfaces which were |
| 549 | * keeping alive in case they were still being used. |
| 550 | */ |
| 551 | void notifyAppStopped() { |
| 552 | if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppStopped: " + this); |
| 553 | mAppStopped = true; |
| 554 | destroySurfaces(); |
| 555 | // Remove any starting window that was added for this app if they are still around. |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 556 | if (getController() != null) { |
| 557 | getController().removeStartingWindow(); |
| 558 | } |
Chong Zhang | 45e6d2d | 2016-07-20 18:33:56 -0700 | [diff] [blame] | 559 | } |
| 560 | |
| 561 | /** |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 562 | * Checks whether we should save surfaces for this app. |
| 563 | * |
| 564 | * @return true if the surfaces should be saved, false otherwise. |
| 565 | */ |
| 566 | boolean shouldSaveSurface() { |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 567 | // We want to save surface if the app's windows are "allDrawn". |
| 568 | // (If we started entering animation early with saved surfaces, allDrawn |
| 569 | // should have been restored to true. So we'll save again in that case |
| 570 | // even if app didn't actually finish drawing.) |
| 571 | return allDrawn; |
Robert Carr | 13f7be9e | 2015-12-02 18:39:45 -0800 | [diff] [blame] | 572 | } |
| 573 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 574 | private boolean canRestoreSurfaces() { |
| 575 | for (int i = mChildren.size() -1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 576 | final WindowState w = mChildren.get(i); |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 577 | if (w.canRestoreSurface()) { |
Robert Carr | 13f7be9e | 2015-12-02 18:39:45 -0800 | [diff] [blame] | 578 | return true; |
| 579 | } |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 580 | } |
| 581 | return false; |
| 582 | } |
| 583 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 584 | private void clearWasVisibleBeforeClientHidden() { |
| 585 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 586 | final WindowState w = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 587 | w.clearWasVisibleBeforeClientHidden(); |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 588 | } |
| 589 | } |
| 590 | |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 591 | /** |
| 592 | * Whether the app has some window that is invisible in layout, but |
| 593 | * animating with saved surface. |
| 594 | */ |
| 595 | boolean isAnimatingInvisibleWithSavedSurface() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 596 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 597 | final WindowState w = mChildren.get(i); |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 598 | if (w.isAnimatingInvisibleWithSavedSurface()) { |
| 599 | return true; |
| 600 | } |
| 601 | } |
| 602 | return false; |
| 603 | } |
| 604 | |
| 605 | /** |
| 606 | * Hide all window surfaces that's still invisible in layout but animating |
| 607 | * with a saved surface, and mark them destroying. |
| 608 | */ |
| 609 | void stopUsingSavedSurfaceLocked() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 610 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 611 | final WindowState w = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 612 | w.stopUsingSavedSurface(); |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 613 | } |
| 614 | destroySurfaces(); |
| 615 | } |
| 616 | |
Chong Zhang | f58631a | 2016-05-24 16:02:10 -0700 | [diff] [blame] | 617 | void markSavedSurfaceExiting() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 618 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 619 | final WindowState w = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 620 | w.markSavedSurfaceExiting(); |
Chong Zhang | f58631a | 2016-05-24 16:02:10 -0700 | [diff] [blame] | 621 | } |
| 622 | } |
| 623 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 624 | void restoreSavedSurfaceForInterestingWindows() { |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 625 | if (!canRestoreSurfaces()) { |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 626 | clearWasVisibleBeforeClientHidden(); |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 627 | return; |
| 628 | } |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 629 | |
| 630 | // Check if all interesting windows are drawn and we can mark allDrawn=true. |
| 631 | int interestingNotDrawn = -1; |
| 632 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 633 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 634 | final WindowState w = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 635 | interestingNotDrawn = w.restoreSavedSurfaceForInterestingWindow(); |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 636 | } |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 637 | |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 638 | if (!allDrawn) { |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 639 | allDrawn = (interestingNotDrawn == 0); |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 640 | if (allDrawn) { |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 641 | mService.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget(); |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 642 | } |
| 643 | } |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 644 | clearWasVisibleBeforeClientHidden(); |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 645 | |
| 646 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG, |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 647 | "restoreSavedSurfaceForInterestingWindows: " + this + " allDrawn=" + allDrawn |
| 648 | + " interestingNotDrawn=" + interestingNotDrawn); |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 649 | } |
| 650 | |
| 651 | void destroySavedSurfaces() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 652 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 653 | final WindowState win = mChildren.get(i); |
Robert Carr | 13f7be9e | 2015-12-02 18:39:45 -0800 | [diff] [blame] | 654 | win.destroySavedSurface(); |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 655 | } |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 656 | } |
| 657 | |
| 658 | void clearAllDrawn() { |
| 659 | allDrawn = false; |
| 660 | deferClearAllDrawn = false; |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 661 | allDrawnExcludingSaved = false; |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 662 | } |
| 663 | |
Wale Ogunwale | fa854eb | 2016-09-20 13:43:52 -0700 | [diff] [blame] | 664 | void postWindowRemoveStartingWindowCleanup(WindowState win) { |
Wale Ogunwale | 92fc372 | 2016-08-05 12:19:08 -0700 | [diff] [blame] | 665 | // TODO: Something smells about the code below...Is there a better way? |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 666 | if (startingWindow == win) { |
| 667 | if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Notify removed startingWindow " + win); |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 668 | if (getController() != null) { |
| 669 | getController().removeStartingWindow(); |
| 670 | } |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 671 | } else if (mChildren.size() == 0 && startingData != null) { |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 672 | // If this is the last window and we had requested a starting transition window, |
| 673 | // well there is no point now. |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame^] | 674 | if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Nulling last startingData"); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 675 | startingData = null; |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 676 | } else if (mChildren.size() == 1 && startingSurface != null) { |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 677 | // If this is the last window except for a starting transition window, |
| 678 | // we need to get rid of the starting transition. |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 679 | if (getController() != null) { |
| 680 | getController().removeStartingWindow(); |
| 681 | } |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 682 | } |
| 683 | } |
| 684 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 685 | void removeDeadWindows() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 686 | for (int winNdx = mChildren.size() - 1; winNdx >= 0; --winNdx) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 687 | WindowState win = mChildren.get(winNdx); |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 688 | if (win.mAppDied) { |
Wale Ogunwale | 92fc372 | 2016-08-05 12:19:08 -0700 | [diff] [blame] | 689 | if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.w(TAG, |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 690 | "removeDeadWindows: " + win); |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 691 | // Set mDestroying, we don't want any animation or delayed removal here. |
| 692 | win.mDestroying = true; |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 693 | // Also removes child windows. |
Wale Ogunwale | 92fc372 | 2016-08-05 12:19:08 -0700 | [diff] [blame] | 694 | win.removeIfPossible(); |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 695 | } |
| 696 | } |
| 697 | } |
| 698 | |
Wale Ogunwale | e42d0e1 | 2016-05-02 16:40:59 -0700 | [diff] [blame] | 699 | boolean hasWindowsAlive() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 700 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 701 | // No need to loop through child windows as the answer should be the same as that of the |
| 702 | // parent window. |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 703 | if (!(mChildren.get(i)).mAppDied) { |
Wale Ogunwale | e42d0e1 | 2016-05-02 16:40:59 -0700 | [diff] [blame] | 704 | return true; |
| 705 | } |
| 706 | } |
| 707 | return false; |
| 708 | } |
| 709 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 710 | void setWillReplaceWindows(boolean animate) { |
Wale Ogunwale | 455fac5 | 2016-07-21 07:24:49 -0700 | [diff] [blame] | 711 | if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, |
| 712 | "Marking app token " + this + " with replacing windows."); |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 713 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 714 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 715 | final WindowState w = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 716 | w.setWillReplaceWindow(animate); |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 717 | } |
| 718 | if (animate) { |
| 719 | // Set-up dummy animation so we can start treating windows associated with this |
| 720 | // token like they are in transition before the new app window is ready for us to |
| 721 | // run the real transition animation. |
| 722 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 723 | "setWillReplaceWindow() Setting dummy animation on: " + this); |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 724 | mAppAnimator.setDummyAnimation(); |
| 725 | } |
| 726 | } |
| 727 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 728 | void setWillReplaceChildWindows() { |
Wale Ogunwale | 455fac5 | 2016-07-21 07:24:49 -0700 | [diff] [blame] | 729 | if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + this |
Robert Carr | 23fa16b | 2016-01-13 13:19:58 -0800 | [diff] [blame] | 730 | + " with replacing child windows."); |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 731 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 732 | final WindowState w = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 733 | w.setWillReplaceChildWindows(); |
Robert Carr | 23fa16b | 2016-01-13 13:19:58 -0800 | [diff] [blame] | 734 | } |
| 735 | } |
| 736 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 737 | void clearWillReplaceWindows() { |
Wale Ogunwale | 455fac5 | 2016-07-21 07:24:49 -0700 | [diff] [blame] | 738 | if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, |
| 739 | "Resetting app token " + this + " of replacing window marks."); |
Chong Zhang | f596cd5 | 2016-01-05 13:42:44 -0800 | [diff] [blame] | 740 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 741 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 742 | final WindowState w = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 743 | w.clearWillReplaceWindow(); |
Chong Zhang | f596cd5 | 2016-01-05 13:42:44 -0800 | [diff] [blame] | 744 | } |
| 745 | } |
| 746 | |
Chong Zhang | 4d7369a | 2016-04-25 16:09:14 -0700 | [diff] [blame] | 747 | void requestUpdateWallpaperIfNeeded() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 748 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 749 | final WindowState w = mChildren.get(i); |
Chong Zhang | 4d7369a | 2016-04-25 16:09:14 -0700 | [diff] [blame] | 750 | w.requestUpdateWallpaperIfNeeded(); |
| 751 | } |
| 752 | } |
| 753 | |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 754 | boolean isRelaunching() { |
| 755 | return mPendingRelaunchCount > 0; |
| 756 | } |
| 757 | |
| 758 | void startRelaunching() { |
| 759 | if (canFreezeBounds()) { |
| 760 | freezeBounds(); |
| 761 | } |
| 762 | mPendingRelaunchCount++; |
| 763 | } |
| 764 | |
| 765 | void finishRelaunching() { |
| 766 | if (canFreezeBounds()) { |
| 767 | unfreezeBounds(); |
| 768 | } |
| 769 | if (mPendingRelaunchCount > 0) { |
| 770 | mPendingRelaunchCount--; |
| 771 | } |
| 772 | } |
| 773 | |
Wale Ogunwale | 8fd7542 | 2016-06-24 14:20:37 -0700 | [diff] [blame] | 774 | void clearRelaunching() { |
Wale Ogunwale | 37dbafc | 2016-06-27 10:15:20 -0700 | [diff] [blame] | 775 | if (mPendingRelaunchCount == 0) { |
| 776 | return; |
| 777 | } |
Wale Ogunwale | 8fd7542 | 2016-06-24 14:20:37 -0700 | [diff] [blame] | 778 | if (canFreezeBounds()) { |
| 779 | unfreezeBounds(); |
| 780 | } |
| 781 | mPendingRelaunchCount = 0; |
| 782 | } |
| 783 | |
Wale Ogunwale | 07bcab7 | 2016-10-14 15:30:09 -0700 | [diff] [blame] | 784 | /** |
| 785 | * Returns true if the new child window we are adding to this token is considered greater than |
| 786 | * the existing child window in this token in terms of z-order. |
| 787 | */ |
| 788 | @Override |
| 789 | protected boolean isFirstChildWindowGreaterThanSecond(WindowState newWindow, |
| 790 | WindowState existingWindow) { |
| 791 | final int type1 = newWindow.mAttrs.type; |
| 792 | final int type2 = existingWindow.mAttrs.type; |
| 793 | |
| 794 | // Base application windows should be z-ordered BELOW all other windows in the app token. |
| 795 | if (type1 == TYPE_BASE_APPLICATION && type2 != TYPE_BASE_APPLICATION) { |
| 796 | return false; |
| 797 | } else if (type1 != TYPE_BASE_APPLICATION && type2 == TYPE_BASE_APPLICATION) { |
| 798 | return true; |
| 799 | } |
| 800 | |
| 801 | // Starting windows should be z-ordered ABOVE all other windows in the app token. |
| 802 | if (type1 == TYPE_APPLICATION_STARTING && type2 != TYPE_APPLICATION_STARTING) { |
| 803 | return true; |
| 804 | } else if (type1 != TYPE_APPLICATION_STARTING && type2 == TYPE_APPLICATION_STARTING) { |
| 805 | return false; |
| 806 | } |
| 807 | |
| 808 | // Otherwise the new window is greater than the existing window. |
| 809 | return true; |
| 810 | } |
| 811 | |
Wale Ogunwale | 92fc372 | 2016-08-05 12:19:08 -0700 | [diff] [blame] | 812 | @Override |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 813 | void addWindow(WindowState w) { |
Wale Ogunwale | 92fc372 | 2016-08-05 12:19:08 -0700 | [diff] [blame] | 814 | super.addWindow(w); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 815 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 816 | boolean gotReplacementWindow = false; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 817 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 818 | final WindowState candidate = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 819 | gotReplacementWindow |= candidate.setReplacementWindowIfNeeded(w); |
| 820 | } |
Wale Ogunwale | 92fc372 | 2016-08-05 12:19:08 -0700 | [diff] [blame] | 821 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 822 | // if we got a replacement window, reset the timeout to give drawing more time |
| 823 | if (gotReplacementWindow) { |
| 824 | mService.scheduleWindowReplacementTimeouts(this); |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 825 | } |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 826 | checkKeyguardFlagsChanged(); |
| 827 | } |
| 828 | |
| 829 | @Override |
| 830 | void removeChild(WindowState child) { |
| 831 | super.removeChild(child); |
| 832 | checkKeyguardFlagsChanged(); |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 833 | } |
| 834 | |
Wale Ogunwale | b0f3b83 | 2016-10-17 10:13:07 -0700 | [diff] [blame] | 835 | private boolean waitingForReplacement() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 836 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 837 | final WindowState candidate = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 838 | if (candidate.waitingForReplacement()) { |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 839 | return true; |
| 840 | } |
| 841 | } |
| 842 | return false; |
| 843 | } |
| 844 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 845 | void onWindowReplacementTimeout() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 846 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 847 | (mChildren.get(i)).onWindowReplacementTimeout(); |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 848 | } |
| 849 | } |
| 850 | |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 851 | private boolean canFreezeBounds() { |
| 852 | // For freeform windows, we can't freeze the bounds at the moment because this would make |
| 853 | // the resizing unresponsive. |
| 854 | return mTask != null && !mTask.inFreeformWorkspace(); |
| 855 | } |
| 856 | |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 857 | /** |
| 858 | * Freezes the task bounds. The size of this task reported the app will be fixed to the bounds |
| 859 | * freezed by {@link Task#prepareFreezingBounds} until {@link #unfreezeBounds} gets called, even |
| 860 | * if they change in the meantime. If the bounds are already frozen, the bounds will be frozen |
| 861 | * with a queue. |
| 862 | */ |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 863 | private void freezeBounds() { |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 864 | mFrozenBounds.offer(new Rect(mTask.mPreparedFrozenBounds)); |
Jorim Jaggi | 26c8c42 | 2016-05-09 19:57:25 -0700 | [diff] [blame] | 865 | |
| 866 | if (mTask.mPreparedFrozenMergedConfig.equals(Configuration.EMPTY)) { |
| 867 | // We didn't call prepareFreezingBounds on the task, so use the current value. |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 868 | mFrozenMergedConfig.offer(new Configuration(mTask.getConfiguration())); |
Jorim Jaggi | 26c8c42 | 2016-05-09 19:57:25 -0700 | [diff] [blame] | 869 | } else { |
| 870 | mFrozenMergedConfig.offer(new Configuration(mTask.mPreparedFrozenMergedConfig)); |
| 871 | } |
Andrii Kulian | b10330d | 2016-09-16 13:51:46 -0700 | [diff] [blame] | 872 | // Calling unset() to make it equal to Configuration.EMPTY. |
| 873 | mTask.mPreparedFrozenMergedConfig.unset(); |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 874 | } |
| 875 | |
| 876 | /** |
| 877 | * Unfreezes the previously frozen bounds. See {@link #freezeBounds}. |
| 878 | */ |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 879 | private void unfreezeBounds() { |
Wale Ogunwale | 37dbafc | 2016-06-27 10:15:20 -0700 | [diff] [blame] | 880 | if (!mFrozenBounds.isEmpty()) { |
| 881 | mFrozenBounds.remove(); |
| 882 | } |
| 883 | if (!mFrozenMergedConfig.isEmpty()) { |
| 884 | mFrozenMergedConfig.remove(); |
| 885 | } |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 886 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 887 | final WindowState win = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 888 | win.onUnfreezeBounds(); |
Jorim Jaggi | 4846ee3 | 2016-01-07 17:39:12 +0100 | [diff] [blame] | 889 | } |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 890 | mService.mWindowPlacerLocked.performSurfacePlacement(); |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 891 | } |
| 892 | |
Robert Carr | 91b22809 | 2016-06-28 17:32:37 -0700 | [diff] [blame] | 893 | void addSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) { |
| 894 | mSurfaceViewBackgrounds.add(background); |
| 895 | } |
| 896 | |
| 897 | void removeSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) { |
| 898 | mSurfaceViewBackgrounds.remove(background); |
| 899 | updateSurfaceViewBackgroundVisibilities(); |
| 900 | } |
| 901 | |
| 902 | // We use DimLayers behind SurfaceViews to prevent holes while resizing and creating. |
| 903 | // However, we need to ensure one SurfaceView doesn't cover another when they are both placed |
| 904 | // below the main app window (as traditionally a SurfaceView which is never drawn |
| 905 | // to is totally translucent). So we look at all our SurfaceView backgrounds and only enable |
| 906 | // the background for the SurfaceView with lowest Z order |
| 907 | void updateSurfaceViewBackgroundVisibilities() { |
| 908 | WindowSurfaceController.SurfaceControlWithBackground bottom = null; |
| 909 | int bottomLayer = Integer.MAX_VALUE; |
| 910 | for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) { |
| 911 | WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i); |
| 912 | if (sc.mVisible && sc.mLayer < bottomLayer) { |
| 913 | bottomLayer = sc.mLayer; |
| 914 | bottom = sc; |
| 915 | } |
| 916 | } |
| 917 | for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) { |
| 918 | WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i); |
| 919 | sc.updateBackgroundVisibility(sc != bottom); |
| 920 | } |
| 921 | } |
| 922 | |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 923 | void resetJustMovedInStack() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 924 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 925 | (mChildren.get(i)).resetJustMovedInStack(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 926 | } |
| 927 | } |
| 928 | |
| 929 | void notifyMovedInStack() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 930 | for (int winNdx = mChildren.size() - 1; winNdx >= 0; --winNdx) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 931 | final WindowState win = mChildren.get(winNdx); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 932 | win.notifyMovedInStack(); |
| 933 | } |
| 934 | } |
| 935 | |
Wale Ogunwale | b0f3b83 | 2016-10-17 10:13:07 -0700 | [diff] [blame] | 936 | void setAppLayoutChanges(int changes, String reason) { |
| 937 | if (!mChildren.isEmpty()) { |
| 938 | final DisplayContent dc = getDisplayContent(); |
| 939 | dc.pendingLayoutChanges |= changes; |
| 940 | if (DEBUG_LAYOUT_REPEATS) { |
| 941 | mService.mWindowPlacerLocked.debugLayoutRepeats(reason, dc.pendingLayoutChanges); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 942 | } |
| 943 | } |
| 944 | } |
| 945 | |
| 946 | void removeReplacedWindowIfNeeded(WindowState replacement) { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 947 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 948 | final WindowState win = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 949 | if (win.removeReplacedWindowIfNeeded(replacement)) { |
| 950 | return; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 951 | } |
| 952 | } |
| 953 | } |
| 954 | |
| 955 | void startFreezingScreen() { |
| 956 | if (DEBUG_ORIENTATION) logWithStack(TAG, "Set freezing of " + appToken + ": hidden=" |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 957 | + hidden + " freezing=" + mAppAnimator.freezingScreen + " hiddenRequested=" |
| 958 | + hiddenRequested); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 959 | if (!hiddenRequested) { |
| 960 | if (!mAppAnimator.freezingScreen) { |
| 961 | mAppAnimator.freezingScreen = true; |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 962 | mService.registerAppFreezeListener(this); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 963 | mAppAnimator.lastFreezeDuration = 0; |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 964 | mService.mAppsFreezingScreen++; |
| 965 | if (mService.mAppsFreezingScreen == 1) { |
| 966 | mService.startFreezingDisplayLocked(false, 0, 0); |
| 967 | mService.mH.removeMessages(H.APP_FREEZE_TIMEOUT); |
| 968 | mService.mH.sendEmptyMessageDelayed(H.APP_FREEZE_TIMEOUT, 2000); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 969 | } |
| 970 | } |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 971 | final int count = mChildren.size(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 972 | for (int i = 0; i < count; i++) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 973 | final WindowState w = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 974 | w.onStartFreezingScreen(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 975 | } |
| 976 | } |
| 977 | } |
| 978 | |
| 979 | void stopFreezingScreen(boolean unfreezeSurfaceNow, boolean force) { |
| 980 | if (!mAppAnimator.freezingScreen) { |
| 981 | return; |
| 982 | } |
| 983 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Clear freezing of " + this + " force=" + force); |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 984 | final int count = mChildren.size(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 985 | boolean unfrozeWindows = false; |
| 986 | for (int i = 0; i < count; i++) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 987 | final WindowState w = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 988 | unfrozeWindows |= w.onStopFreezingScreen(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 989 | } |
| 990 | if (force || unfrozeWindows) { |
| 991 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "No longer freezing: " + this); |
| 992 | mAppAnimator.freezingScreen = false; |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 993 | mService.unregisterAppFreezeListener(this); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 994 | mAppAnimator.lastFreezeDuration = |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 995 | (int)(SystemClock.elapsedRealtime() - mService.mDisplayFreezeTime); |
| 996 | mService.mAppsFreezingScreen--; |
| 997 | mService.mLastFinishedFreezeSource = this; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 998 | } |
| 999 | if (unfreezeSurfaceNow) { |
| 1000 | if (unfrozeWindows) { |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 1001 | mService.mWindowPlacerLocked.performSurfacePlacement(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1002 | } |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 1003 | mService.stopFreezingDisplayLocked(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1004 | } |
| 1005 | } |
| 1006 | |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1007 | @Override |
| 1008 | public void onAppFreezeTimeout() { |
| 1009 | Slog.w(TAG_WM, "Force clearing freeze: " + this); |
| 1010 | stopFreezingScreen(true, true); |
| 1011 | } |
| 1012 | |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1013 | boolean transferStartingWindow(IBinder transferFrom) { |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 1014 | final AppWindowToken fromToken = getDisplayContent().getAppWindowToken(transferFrom); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1015 | if (fromToken == null) { |
| 1016 | return false; |
| 1017 | } |
| 1018 | |
| 1019 | final WindowState tStartingWindow = fromToken.startingWindow; |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 1020 | if (tStartingWindow != null && fromToken.startingSurface != null) { |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1021 | // In this case, the starting icon has already been displayed, so start |
| 1022 | // letting windows get shown immediately without any more transitions. |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 1023 | mService.mSkipAppTransitionAnimation = true; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1024 | |
| 1025 | if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Moving existing starting " + tStartingWindow |
| 1026 | + " from " + fromToken + " to " + this); |
| 1027 | |
| 1028 | final long origId = Binder.clearCallingIdentity(); |
| 1029 | |
| 1030 | // Transfer the starting window over to the new token. |
| 1031 | startingData = fromToken.startingData; |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 1032 | startingSurface = fromToken.startingSurface; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1033 | startingDisplayed = fromToken.startingDisplayed; |
| 1034 | fromToken.startingDisplayed = false; |
| 1035 | startingWindow = tStartingWindow; |
| 1036 | reportedVisible = fromToken.reportedVisible; |
| 1037 | fromToken.startingData = null; |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 1038 | fromToken.startingSurface = null; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1039 | fromToken.startingWindow = null; |
| 1040 | fromToken.startingMoved = true; |
| 1041 | tStartingWindow.mToken = this; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1042 | tStartingWindow.mAppToken = this; |
| 1043 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 1044 | if (DEBUG_ADD_REMOVE || DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1045 | "Removing starting " + tStartingWindow + " from " + fromToken); |
Wale Ogunwale | fa854eb | 2016-09-20 13:43:52 -0700 | [diff] [blame] | 1046 | fromToken.removeChild(tStartingWindow); |
| 1047 | fromToken.postWindowRemoveStartingWindowCleanup(tStartingWindow); |
Wale Ogunwale | 92fc372 | 2016-08-05 12:19:08 -0700 | [diff] [blame] | 1048 | addWindow(tStartingWindow); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1049 | |
| 1050 | // Propagate other interesting state between the tokens. If the old token is displayed, |
| 1051 | // we should immediately force the new one to be displayed. If it is animating, we need |
| 1052 | // to move that animation to the new one. |
| 1053 | if (fromToken.allDrawn) { |
| 1054 | allDrawn = true; |
| 1055 | deferClearAllDrawn = fromToken.deferClearAllDrawn; |
| 1056 | } |
| 1057 | if (fromToken.firstWindowDrawn) { |
| 1058 | firstWindowDrawn = true; |
| 1059 | } |
| 1060 | if (!fromToken.hidden) { |
| 1061 | hidden = false; |
| 1062 | hiddenRequested = false; |
| 1063 | } |
| 1064 | if (clientHidden != fromToken.clientHidden) { |
| 1065 | clientHidden = fromToken.clientHidden; |
| 1066 | sendAppVisibilityToClients(); |
| 1067 | } |
| 1068 | fromToken.mAppAnimator.transferCurrentAnimation( |
| 1069 | mAppAnimator, tStartingWindow.mWinAnimator); |
| 1070 | |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 1071 | mService.updateFocusedWindowLocked( |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1072 | UPDATE_FOCUS_WILL_PLACE_SURFACES, true /*updateInputWindows*/); |
Andrii Kulian | 5406e7a | 2016-10-21 11:55:23 -0700 | [diff] [blame] | 1073 | getDisplayContent().setLayoutNeeded(); |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 1074 | mService.mWindowPlacerLocked.performSurfacePlacement(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1075 | Binder.restoreCallingIdentity(origId); |
| 1076 | return true; |
| 1077 | } else if (fromToken.startingData != null) { |
| 1078 | // The previous app was getting ready to show a |
| 1079 | // starting window, but hasn't yet done so. Steal it! |
| 1080 | if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, |
| 1081 | "Moving pending starting from " + fromToken + " to " + this); |
| 1082 | startingData = fromToken.startingData; |
| 1083 | fromToken.startingData = null; |
| 1084 | fromToken.startingMoved = true; |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 1085 | if (getController() != null) { |
| 1086 | getController().scheduleAddStartingWindow(); |
| 1087 | } |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1088 | return true; |
| 1089 | } |
| 1090 | |
| 1091 | final AppWindowAnimator tAppAnimator = fromToken.mAppAnimator; |
| 1092 | final AppWindowAnimator wAppAnimator = mAppAnimator; |
| 1093 | if (tAppAnimator.thumbnail != null) { |
| 1094 | // The old token is animating with a thumbnail, transfer that to the new token. |
| 1095 | if (wAppAnimator.thumbnail != null) { |
| 1096 | wAppAnimator.thumbnail.destroy(); |
| 1097 | } |
| 1098 | wAppAnimator.thumbnail = tAppAnimator.thumbnail; |
| 1099 | wAppAnimator.thumbnailLayer = tAppAnimator.thumbnailLayer; |
| 1100 | wAppAnimator.thumbnailAnimation = tAppAnimator.thumbnailAnimation; |
| 1101 | tAppAnimator.thumbnail = null; |
| 1102 | } |
| 1103 | return false; |
| 1104 | } |
| 1105 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 1106 | boolean isLastWindow(WindowState win) { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 1107 | return mChildren.size() == 1 && mChildren.get(0) == win; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1108 | } |
| 1109 | |
| 1110 | void setAllAppWinAnimators() { |
| 1111 | final ArrayList<WindowStateAnimator> allAppWinAnimators = mAppAnimator.mAllAppWinAnimators; |
| 1112 | allAppWinAnimators.clear(); |
| 1113 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 1114 | final int windowsCount = mChildren.size(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1115 | for (int j = 0; j < windowsCount; j++) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 1116 | (mChildren.get(j)).addWinAnimatorToList(allAppWinAnimators); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1117 | } |
| 1118 | } |
| 1119 | |
Wale Ogunwale | 9adfe57 | 2016-09-08 20:43:58 -0700 | [diff] [blame] | 1120 | @Override |
| 1121 | void onAppTransitionDone() { |
| 1122 | sendingToBottom = false; |
| 1123 | } |
| 1124 | |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 1125 | /** |
| 1126 | * We override because this class doesn't want its children affecting its reported orientation |
| 1127 | * in anyway. |
| 1128 | */ |
| 1129 | @Override |
| 1130 | int getOrientation() { |
| 1131 | if (hidden || hiddenRequested) { |
| 1132 | return SCREEN_ORIENTATION_UNSET; |
| 1133 | } |
| 1134 | return mOrientation; |
| 1135 | } |
| 1136 | |
Wale Ogunwale | b198b74 | 2016-12-01 08:44:09 -0800 | [diff] [blame] | 1137 | /** Returns the app's preferred orientation regardless of its currently visibility state. */ |
| 1138 | int getOrientationIgnoreVisibility() { |
| 1139 | return mOrientation; |
| 1140 | } |
| 1141 | |
Craig Mautner | dbb7991 | 2012-03-01 18:59:14 -0800 | [diff] [blame] | 1142 | @Override |
Wale Ogunwale | b0f3b83 | 2016-10-17 10:13:07 -0700 | [diff] [blame] | 1143 | void checkAppWindowsReadyToShow() { |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1144 | if (allDrawn == mAppAnimator.allDrawn) { |
| 1145 | return; |
| 1146 | } |
| 1147 | |
| 1148 | mAppAnimator.allDrawn = allDrawn; |
| 1149 | if (!allDrawn) { |
| 1150 | return; |
| 1151 | } |
| 1152 | |
| 1153 | // The token has now changed state to having all windows shown... what to do, what to do? |
| 1154 | if (mAppAnimator.freezingScreen) { |
| 1155 | mAppAnimator.showAllWindowsLocked(); |
| 1156 | stopFreezingScreen(false, true); |
| 1157 | if (DEBUG_ORIENTATION) Slog.i(TAG, |
| 1158 | "Setting mOrientationChangeComplete=true because wtoken " + this |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 1159 | + " numInteresting=" + mNumInterestingWindows + " numDrawn=" + mNumDrawnWindows); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1160 | // This will set mOrientationChangeComplete and cause a pass through layout. |
| 1161 | setAppLayoutChanges(FINISH_LAYOUT_REDO_WALLPAPER, |
Wale Ogunwale | b0f3b83 | 2016-10-17 10:13:07 -0700 | [diff] [blame] | 1162 | "checkAppWindowsReadyToShow: freezingScreen"); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1163 | } else { |
Wale Ogunwale | b0f3b83 | 2016-10-17 10:13:07 -0700 | [diff] [blame] | 1164 | setAppLayoutChanges(FINISH_LAYOUT_REDO_ANIM, "checkAppWindowsReadyToShow"); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1165 | |
| 1166 | // We can now show all of the drawn windows! |
| 1167 | if (!mService.mOpeningApps.contains(this)) { |
| 1168 | mService.mAnimator.orAnimating(mAppAnimator.showAllWindowsLocked()); |
| 1169 | } |
| 1170 | } |
| 1171 | } |
| 1172 | |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 1173 | void updateAllDrawn(DisplayContent dc) { |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1174 | if (!allDrawn) { |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 1175 | final int numInteresting = mNumInterestingWindows; |
| 1176 | if (numInteresting > 0 && mNumDrawnWindows >= numInteresting) { |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1177 | if (DEBUG_VISIBILITY) Slog.v(TAG, "allDrawn: " + this |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 1178 | + " interesting=" + numInteresting + " drawn=" + mNumDrawnWindows); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1179 | allDrawn = true; |
| 1180 | // Force an additional layout pass where |
| 1181 | // WindowStateAnimator#commitFinishDrawingLocked() will call performShowLocked(). |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 1182 | dc.setLayoutNeeded(); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1183 | mService.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget(); |
| 1184 | } |
| 1185 | } |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 1186 | |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1187 | if (!allDrawnExcludingSaved) { |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 1188 | int numInteresting = mNumInterestingWindowsExcludingSaved; |
| 1189 | if (numInteresting > 0 && mNumDrawnWindowsExcludingSaved >= numInteresting) { |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1190 | if (DEBUG_VISIBILITY) Slog.v(TAG, "allDrawnExcludingSaved: " + this |
| 1191 | + " interesting=" + numInteresting |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 1192 | + " drawn=" + mNumDrawnWindowsExcludingSaved); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1193 | allDrawnExcludingSaved = true; |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 1194 | dc.setLayoutNeeded(); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1195 | if (isAnimatingInvisibleWithSavedSurface() |
| 1196 | && !mService.mFinishedEarlyAnim.contains(this)) { |
| 1197 | mService.mFinishedEarlyAnim.add(this); |
| 1198 | } |
| 1199 | } |
| 1200 | } |
| 1201 | } |
| 1202 | |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 1203 | /** |
| 1204 | * Updated this app token tracking states for interesting and drawn windows based on the window. |
| 1205 | * |
| 1206 | * @return Returns true if the input window is considered interesting and drawn while all the |
| 1207 | * windows in this app token where not considered drawn as of the last pass. |
| 1208 | */ |
| 1209 | boolean updateDrawnWindowStates(WindowState w) { |
| 1210 | if (DEBUG_STARTING_WINDOW && w == startingWindow) { |
| 1211 | Slog.d(TAG, "updateWindows: starting " + w + " isOnScreen=" + w.isOnScreen() |
| 1212 | + " allDrawn=" + allDrawn + " freezingScreen=" + mAppAnimator.freezingScreen); |
| 1213 | } |
| 1214 | |
| 1215 | if (allDrawn && allDrawnExcludingSaved && !mAppAnimator.freezingScreen) { |
| 1216 | return false; |
| 1217 | } |
| 1218 | |
| 1219 | if (mLastTransactionSequence != mService.mTransactionSequence) { |
| 1220 | mLastTransactionSequence = mService.mTransactionSequence; |
| 1221 | mNumInterestingWindows = mNumDrawnWindows = 0; |
| 1222 | mNumInterestingWindowsExcludingSaved = 0; |
| 1223 | mNumDrawnWindowsExcludingSaved = 0; |
| 1224 | startingDisplayed = false; |
| 1225 | } |
| 1226 | |
| 1227 | final WindowStateAnimator winAnimator = w.mWinAnimator; |
| 1228 | |
| 1229 | boolean isInterestingAndDrawn = false; |
| 1230 | |
| 1231 | if (!allDrawn && w.mightAffectAllDrawn(false /* visibleOnly */)) { |
| 1232 | if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) { |
| 1233 | Slog.v(TAG, "Eval win " + w + ": isDrawn=" + w.isDrawnLw() |
| 1234 | + ", isAnimationSet=" + winAnimator.isAnimationSet()); |
| 1235 | if (!w.isDrawnLw()) { |
| 1236 | Slog.v(TAG, "Not displayed: s=" + winAnimator.mSurfaceController |
| 1237 | + " pv=" + w.mPolicyVisibility |
| 1238 | + " mDrawState=" + winAnimator.drawStateToString() |
| 1239 | + " ph=" + w.isParentWindowHidden() + " th=" + hiddenRequested |
| 1240 | + " a=" + winAnimator.mAnimating); |
| 1241 | } |
| 1242 | } |
| 1243 | |
| 1244 | if (w != startingWindow) { |
| 1245 | if (w.isInteresting()) { |
| 1246 | mNumInterestingWindows++; |
| 1247 | if (w.isDrawnLw()) { |
| 1248 | mNumDrawnWindows++; |
| 1249 | |
| 1250 | if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) Slog.v(TAG, "tokenMayBeDrawn: " |
| 1251 | + this + " w=" + w + " numInteresting=" + mNumInterestingWindows |
| 1252 | + " freezingScreen=" + mAppAnimator.freezingScreen |
| 1253 | + " mAppFreezing=" + w.mAppFreezing); |
| 1254 | |
| 1255 | isInterestingAndDrawn = true; |
| 1256 | } |
| 1257 | } |
| 1258 | } else if (w.isDrawnLw()) { |
| 1259 | mService.mH.sendEmptyMessage(NOTIFY_STARTING_WINDOW_DRAWN); |
| 1260 | startingDisplayed = true; |
| 1261 | } |
| 1262 | } |
| 1263 | |
| 1264 | if (!allDrawnExcludingSaved && w.mightAffectAllDrawn(true /* visibleOnly */)) { |
| 1265 | if (w != startingWindow && w.isInteresting()) { |
| 1266 | mNumInterestingWindowsExcludingSaved++; |
| 1267 | if (w.isDrawnLw() && !w.isAnimatingWithSavedSurface()) { |
| 1268 | mNumDrawnWindowsExcludingSaved++; |
| 1269 | |
| 1270 | if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) Slog.v(TAG, |
| 1271 | "tokenMayBeDrawnExcludingSaved: " + this + " w=" + w |
| 1272 | + " numInteresting=" + mNumInterestingWindowsExcludingSaved |
| 1273 | + " freezingScreen=" + mAppAnimator.freezingScreen |
| 1274 | + " mAppFreezing=" + w.mAppFreezing); |
| 1275 | |
| 1276 | isInterestingAndDrawn = true; |
| 1277 | } |
| 1278 | } |
| 1279 | } |
| 1280 | |
| 1281 | return isInterestingAndDrawn; |
| 1282 | } |
| 1283 | |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1284 | @Override |
Wale Ogunwale | b0f3b83 | 2016-10-17 10:13:07 -0700 | [diff] [blame] | 1285 | void stepAppWindowsAnimation(long currentTime) { |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1286 | mAppAnimator.wasAnimating = mAppAnimator.animating; |
Wale Ogunwale | b0f3b83 | 2016-10-17 10:13:07 -0700 | [diff] [blame] | 1287 | if (mAppAnimator.stepAnimationLocked(currentTime)) { |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1288 | mAppAnimator.animating = true; |
| 1289 | mService.mAnimator.setAnimating(true); |
| 1290 | mService.mAnimator.mAppWindowAnimating = true; |
| 1291 | } else if (mAppAnimator.wasAnimating) { |
| 1292 | // stopped animating, do one more pass through the layout |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 1293 | setAppLayoutChanges(FINISH_LAYOUT_REDO_WALLPAPER, |
| 1294 | DEBUG_LAYOUT_REPEATS ? "appToken " + this + " done" : null); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1295 | if (DEBUG_ANIM) Slog.v(TAG, "updateWindowsApps...: done animating " + this); |
| 1296 | } |
| 1297 | } |
| 1298 | |
Wale Ogunwale | 9adfe57 | 2016-09-08 20:43:58 -0700 | [diff] [blame] | 1299 | @Override |
Wale Ogunwale | f4ebe2e | 2016-11-09 13:24:43 -0800 | [diff] [blame] | 1300 | boolean forAllWindows(ToBooleanFunction<WindowState> callback, boolean traverseTopToBottom) { |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 1301 | // For legacy reasons we process the TaskStack.mExitingAppTokens first in DisplayContent |
| 1302 | // before the non-exiting app tokens. So, we skip the exiting app tokens here. |
| 1303 | // TODO: Investigate if we need to continue to do this or if we can just process them |
| 1304 | // in-order. |
| 1305 | if (mIsExiting && !waitingForReplacement()) { |
Wale Ogunwale | f4ebe2e | 2016-11-09 13:24:43 -0800 | [diff] [blame] | 1306 | return false; |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 1307 | } |
Wale Ogunwale | f4ebe2e | 2016-11-09 13:24:43 -0800 | [diff] [blame] | 1308 | return forAllWindowsUnchecked(callback, traverseTopToBottom); |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 1309 | } |
| 1310 | |
Wale Ogunwale | f4ebe2e | 2016-11-09 13:24:43 -0800 | [diff] [blame] | 1311 | boolean forAllWindowsUnchecked(ToBooleanFunction<WindowState> callback, |
| 1312 | boolean traverseTopToBottom) { |
| 1313 | return super.forAllWindows(callback, traverseTopToBottom); |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 1314 | } |
| 1315 | |
| 1316 | @Override |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 1317 | AppWindowToken asAppWindowToken() { |
| 1318 | // I am an app window token! |
| 1319 | return this; |
| 1320 | } |
| 1321 | |
| 1322 | @Override |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 1323 | boolean fillsParent() { |
| 1324 | return mFillsParent; |
| 1325 | } |
| 1326 | |
| 1327 | void setFillsParent(boolean fillsParent) { |
| 1328 | mFillsParent = fillsParent; |
| 1329 | } |
| 1330 | |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1331 | boolean containsDismissKeyguardWindow() { |
| 1332 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
| 1333 | if ((mChildren.get(i).mAttrs.flags & FLAG_DISMISS_KEYGUARD) != 0) { |
| 1334 | return true; |
| 1335 | } |
| 1336 | } |
| 1337 | return false; |
| 1338 | } |
| 1339 | |
| 1340 | boolean containsShowWhenLockedWindow() { |
| 1341 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
| 1342 | if ((mChildren.get(i).mAttrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0) { |
| 1343 | return true; |
| 1344 | } |
| 1345 | } |
| 1346 | return false; |
| 1347 | } |
| 1348 | |
| 1349 | void checkKeyguardFlagsChanged() { |
| 1350 | final boolean containsDismissKeyguard = containsDismissKeyguardWindow(); |
| 1351 | final boolean containsShowWhenLocked = containsShowWhenLockedWindow(); |
| 1352 | if (containsDismissKeyguard != mLastContainsDismissKeyguardWindow |
| 1353 | || containsShowWhenLocked != mLastContainsShowWhenLockedWindow) { |
| 1354 | mService.notifyKeyguardFlagsChanged(null /* callback */); |
| 1355 | } |
| 1356 | mLastContainsDismissKeyguardWindow = containsDismissKeyguard; |
| 1357 | mLastContainsShowWhenLockedWindow = containsShowWhenLocked; |
| 1358 | } |
| 1359 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 1360 | WindowState getImeTargetBelowWindow(WindowState w) { |
| 1361 | final int index = mChildren.indexOf(w); |
| 1362 | if (index > 0) { |
| 1363 | final WindowState target = mChildren.get(index - 1); |
| 1364 | if (target.canBeImeTarget()) { |
| 1365 | return target; |
| 1366 | } |
| 1367 | } |
| 1368 | return null; |
| 1369 | } |
| 1370 | |
| 1371 | WindowState getHighestAnimLayerWindow(WindowState currentTarget) { |
| 1372 | WindowState candidate = null; |
| 1373 | for (int i = mChildren.indexOf(currentTarget); i >= 0; i--) { |
| 1374 | final WindowState w = mChildren.get(i); |
| 1375 | if (w.mRemoved) { |
| 1376 | continue; |
| 1377 | } |
| 1378 | if (candidate == null || w.mWinAnimator.mAnimLayer > |
| 1379 | candidate.mWinAnimator.mAnimLayer) { |
| 1380 | candidate = w; |
| 1381 | } |
| 1382 | } |
| 1383 | return candidate; |
| 1384 | } |
| 1385 | |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 1386 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1387 | void dump(PrintWriter pw, String prefix) { |
| 1388 | super.dump(pw, prefix); |
| 1389 | if (appToken != null) { |
Wale Ogunwale | 72919d2 | 2016-12-08 18:58:50 -0800 | [diff] [blame] | 1390 | pw.println(prefix + "app=true mVoiceInteraction=" + mVoiceInteraction); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1391 | } |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 1392 | pw.print(prefix); pw.print("task="); pw.println(mTask); |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 1393 | pw.print(prefix); pw.print(" mFillsParent="); pw.print(mFillsParent); |
| 1394 | pw.print(" mOrientation="); pw.println(mOrientation); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1395 | pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested); |
| 1396 | pw.print(" clientHidden="); pw.print(clientHidden); |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 1397 | pw.print(" reportedDrawn="); pw.print(reportedDrawn); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1398 | pw.print(" reportedVisible="); pw.println(reportedVisible); |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 1399 | if (paused) { |
| 1400 | pw.print(prefix); pw.print("paused="); pw.println(paused); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1401 | } |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 1402 | if (mAppStopped) { |
| 1403 | pw.print(prefix); pw.print("mAppStopped="); pw.println(mAppStopped); |
| 1404 | } |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 1405 | if (mNumInterestingWindows != 0 || mNumDrawnWindows != 0 |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1406 | || allDrawn || mAppAnimator.allDrawn) { |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 1407 | pw.print(prefix); pw.print("mNumInterestingWindows="); |
| 1408 | pw.print(mNumInterestingWindows); |
| 1409 | pw.print(" mNumDrawnWindows="); pw.print(mNumDrawnWindows); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1410 | pw.print(" inPendingTransaction="); pw.print(inPendingTransaction); |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1411 | pw.print(" allDrawn="); pw.print(allDrawn); |
| 1412 | pw.print(" (animator="); pw.print(mAppAnimator.allDrawn); |
| 1413 | pw.println(")"); |
| 1414 | } |
| 1415 | if (inPendingTransaction) { |
| 1416 | pw.print(prefix); pw.print("inPendingTransaction="); |
| 1417 | pw.println(inPendingTransaction); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1418 | } |
Craig Mautner | 799bc1d | 2015-01-14 10:33:48 -0800 | [diff] [blame] | 1419 | if (startingData != null || removed || firstWindowDrawn || mIsExiting) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1420 | pw.print(prefix); pw.print("startingData="); pw.print(startingData); |
| 1421 | pw.print(" removed="); pw.print(removed); |
Craig Mautner | 3d7ca31 | 2015-01-08 10:56:00 -0800 | [diff] [blame] | 1422 | pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn); |
Craig Mautner | 799bc1d | 2015-01-14 10:33:48 -0800 | [diff] [blame] | 1423 | pw.print(" mIsExiting="); pw.println(mIsExiting); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1424 | } |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 1425 | if (startingWindow != null || startingSurface != null |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1426 | || startingDisplayed || startingMoved) { |
| 1427 | pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow); |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 1428 | pw.print(" startingSurface="); pw.print(startingSurface); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1429 | pw.print(" startingDisplayed="); pw.print(startingDisplayed); |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 1430 | pw.print(" startingMoved="); pw.println(startingMoved); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1431 | } |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 1432 | if (!mFrozenBounds.isEmpty()) { |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 1433 | pw.print(prefix); pw.print("mFrozenBounds="); pw.println(mFrozenBounds); |
Jorim Jaggi | 26c8c42 | 2016-05-09 19:57:25 -0700 | [diff] [blame] | 1434 | pw.print(prefix); pw.print("mFrozenMergedConfig="); pw.println(mFrozenMergedConfig); |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 1435 | } |
| 1436 | if (mPendingRelaunchCount != 0) { |
| 1437 | pw.print(prefix); pw.print("mPendingRelaunchCount="); pw.println(mPendingRelaunchCount); |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 1438 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1439 | } |
| 1440 | |
| 1441 | @Override |
| 1442 | public String toString() { |
| 1443 | if (stringName == null) { |
| 1444 | StringBuilder sb = new StringBuilder(); |
| 1445 | sb.append("AppWindowToken{"); |
| 1446 | sb.append(Integer.toHexString(System.identityHashCode(this))); |
| 1447 | sb.append(" token="); sb.append(token); sb.append('}'); |
| 1448 | stringName = sb.toString(); |
| 1449 | } |
Wale Ogunwale | ba51ca2 | 2016-09-23 06:06:54 -0700 | [diff] [blame] | 1450 | return stringName + ((mIsExiting) ? " mIsExiting=" : ""); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1451 | } |
Jeff Brown | e9bdb31 | 2012-04-05 15:30:10 -0700 | [diff] [blame] | 1452 | } |