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