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