Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.server.wm; |
| 18 | |
Wale Ogunwale | 6cae765 | 2015-12-26 07:36:26 -0800 | [diff] [blame] | 19 | import static android.app.ActivityManager.StackId; |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 20 | import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 21 | import static android.view.Display.DEFAULT_DISPLAY; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 22 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 23 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 24 | import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 25 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM; |
| 26 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 27 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM; |
| 28 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS; |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 29 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 30 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT_REPEATS; |
| 31 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION; |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 32 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STARTING_WINDOW; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 33 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY; |
| 34 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_MOVEMENT; |
| 35 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; |
| 36 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 37 | import static com.android.server.wm.WindowManagerService.H.NOTIFY_ACTIVITY_DRAWN; |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 38 | import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_NONE; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 39 | import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE_SURFACES; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 40 | import static com.android.server.wm.WindowManagerService.logWithStack; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 41 | |
Jeff Brown | 4532e61 | 2012-04-05 14:27:12 -0700 | [diff] [blame] | 42 | import com.android.server.input.InputApplicationHandle; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 43 | import com.android.server.wm.WindowManagerService.H; |
| 44 | |
Filip Gruszczynski | a590c99 | 2015-11-25 16:45:26 -0800 | [diff] [blame] | 45 | import android.annotation.NonNull; |
Jorim Jaggi | 26c8c42 | 2016-05-09 19:57:25 -0700 | [diff] [blame] | 46 | import android.content.res.Configuration; |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 47 | import android.graphics.Rect; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 48 | import android.os.Binder; |
| 49 | import android.os.IBinder; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 50 | import android.os.Message; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 51 | import android.os.SystemClock; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 52 | import android.util.Slog; |
| 53 | import android.view.IApplicationToken; |
| 54 | import android.view.View; |
| 55 | import android.view.WindowManager; |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 56 | import android.view.animation.Animation; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 57 | |
| 58 | import java.io.PrintWriter; |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 59 | import java.util.ArrayDeque; |
Craig Mautner | b1fd65c0 | 2013-02-05 13:34:57 -0800 | [diff] [blame] | 60 | import java.util.ArrayList; |
| 61 | |
| 62 | class AppTokenList extends ArrayList<AppWindowToken> { |
| 63 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 64 | |
| 65 | /** |
| 66 | * Version of WindowToken that is specifically for a particular application (or |
| 67 | * really activity) that is displaying windows. |
| 68 | */ |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 69 | class AppWindowToken extends WindowToken implements WindowManagerService.AppFreezeListener { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 70 | private static final String TAG = TAG_WITH_CLASS_NAME ? "AppWindowToken" : TAG_WM; |
| 71 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 72 | // Non-null only for application tokens. |
| 73 | final IApplicationToken appToken; |
| 74 | |
Filip Gruszczynski | a590c99 | 2015-11-25 16:45:26 -0800 | [diff] [blame] | 75 | @NonNull final AppWindowAnimator mAppAnimator; |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 76 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 77 | final boolean voiceInteraction; |
| 78 | |
Wale Ogunwale | f619286 | 2016-09-10 13:42:30 -0700 | [diff] [blame] | 79 | // TODO: Use getParent instead? |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 80 | Task mTask; |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 81 | /** @see WindowContainer#fillsParent() */ |
| 82 | private boolean mFillsParent; |
Craig Mautner | 4c5eb22 | 2013-11-18 12:59:05 -0800 | [diff] [blame] | 83 | boolean layoutConfigChanges; |
Wale Ogunwale | 6dfdfd6 | 2015-04-15 12:01:38 -0700 | [diff] [blame] | 84 | boolean showForAllUsers; |
Yorke Lee | 0e85247 | 2016-06-15 10:03:18 -0700 | [diff] [blame] | 85 | int targetSdk; |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 86 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 87 | // The input dispatching timeout for this application token in nanoseconds. |
| 88 | long inputDispatchingTimeoutNanos; |
| 89 | |
| 90 | // These are used for determining when all windows associated with |
| 91 | // an activity have been drawn, so they can be made visible together |
| 92 | // at the same time. |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 93 | // initialize so that it doesn't match mTransactionSequence which is an int. |
| 94 | long lastTransactionSequence = Long.MIN_VALUE; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 95 | int numInterestingWindows; |
| 96 | int numDrawnWindows; |
| 97 | boolean inPendingTransaction; |
| 98 | boolean allDrawn; |
Craig Mautner | 7636dfb | 2012-11-16 15:24:11 -0800 | [diff] [blame] | 99 | // Set to true when this app creates a surface while in the middle of an animation. In that |
| 100 | // case do not clear allDrawn until the animation completes. |
| 101 | boolean deferClearAllDrawn; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 102 | |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 103 | // These are to track the app's real drawing status if there were no saved surfaces. |
| 104 | boolean allDrawnExcludingSaved; |
| 105 | int numInterestingWindowsExcludingSaved; |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 106 | int numDrawnWindowsExcludingSaved; |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 107 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 108 | // Is this window's surface needed? This is almost like hidden, except |
| 109 | // it will sometimes be true a little earlier: when the token has |
| 110 | // been shown, but is still waiting for its app transition to execute |
| 111 | // before making its windows shown. |
| 112 | boolean hiddenRequested; |
| 113 | |
| 114 | // Have we told the window clients to hide themselves? |
| 115 | boolean clientHidden; |
| 116 | |
| 117 | // Last visibility state we reported to the app token. |
| 118 | boolean reportedVisible; |
| 119 | |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 120 | // Last drawn state we reported to the app token. |
| 121 | boolean reportedDrawn; |
| 122 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 123 | // Set to true when the token has been removed from the window mgr. |
| 124 | boolean removed; |
| 125 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 126 | // Information about an application starting window if displayed. |
| 127 | StartingData startingData; |
| 128 | WindowState startingWindow; |
| 129 | View startingView; |
| 130 | boolean startingDisplayed; |
| 131 | boolean startingMoved; |
| 132 | boolean firstWindowDrawn; |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 133 | private final WindowState.UpdateReportedVisibilityResults mReportedVisibilityResults = |
| 134 | new WindowState.UpdateReportedVisibilityResults(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 135 | |
| 136 | // Input application handle used by the input dispatcher. |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 137 | final InputApplicationHandle mInputApplicationHandle; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 138 | |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 139 | // TODO: Have a WindowContainer state for tracking exiting/deferred removal. |
Craig Mautner | 799bc1d | 2015-01-14 10:33:48 -0800 | [diff] [blame] | 140 | boolean mIsExiting; |
Craig Mautner | 9ef471f | 2014-02-07 13:11:47 -0800 | [diff] [blame] | 141 | |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 142 | boolean mLaunchTaskBehind; |
Craig Mautner | 8746a47 | 2014-07-24 15:12:54 -0700 | [diff] [blame] | 143 | boolean mEnteringAnimation; |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 144 | |
Wale Ogunwale | 6cae765 | 2015-12-26 07:36:26 -0800 | [diff] [blame] | 145 | boolean mAlwaysFocusable; |
| 146 | |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 147 | boolean mAppStopped; |
Robert Carr | fd10cd1 | 2016-06-29 16:41:50 -0700 | [diff] [blame] | 148 | int mRotationAnimationHint; |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 149 | int mPendingRelaunchCount; |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 150 | |
Robert Carr | 91b22809 | 2016-06-28 17:32:37 -0700 | [diff] [blame] | 151 | private ArrayList<WindowSurfaceController.SurfaceControlWithBackground> mSurfaceViewBackgrounds = |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 152 | new ArrayList<>(); |
Robert Carr | 91b22809 | 2016-06-28 17:32:37 -0700 | [diff] [blame] | 153 | |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 154 | ArrayDeque<Rect> mFrozenBounds = new ArrayDeque<>(); |
Jorim Jaggi | 26c8c42 | 2016-05-09 19:57:25 -0700 | [diff] [blame] | 155 | ArrayDeque<Configuration> mFrozenMergedConfig = new ArrayDeque<>(); |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 156 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 157 | AppWindowToken(WindowManagerService service, IApplicationToken token, boolean _voiceInteraction) { |
| 158 | super(service, token != null ? token.asBinder() : null, TYPE_APPLICATION, true); |
| 159 | appToken = token; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 160 | voiceInteraction = _voiceInteraction; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 161 | mInputApplicationHandle = new InputApplicationHandle(this); |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 162 | mAppAnimator = new AppWindowAnimator(this, service); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 163 | } |
| 164 | |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 165 | void onFirstWindowDrawn(WindowState win, WindowStateAnimator winAnimator) { |
| 166 | firstWindowDrawn = true; |
| 167 | |
| 168 | // We now have a good window to show, remove dead placeholders |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 169 | removeDeadWindows(); |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 170 | |
| 171 | if (startingData != null) { |
| 172 | if (DEBUG_STARTING_WINDOW || DEBUG_ANIM) Slog.v(TAG, "Finish starting " |
| 173 | + win.mToken + ": first real window is shown, no animation"); |
| 174 | // If this initial window is animating, stop it -- we will do an animation to reveal |
| 175 | // it from behind the starting window, so there is no need for it to also be doing its |
| 176 | // own stuff. |
| 177 | winAnimator.clearAnimation(); |
| 178 | winAnimator.mService.mFinishedStarting.add(this); |
| 179 | winAnimator.mService.mH.sendEmptyMessage(H.FINISHED_STARTING); |
| 180 | } |
| 181 | updateReportedVisibilityLocked(); |
| 182 | } |
| 183 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 184 | void updateReportedVisibilityLocked() { |
| 185 | if (appToken == null) { |
| 186 | return; |
| 187 | } |
| 188 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 189 | if (DEBUG_VISIBILITY) Slog.v(TAG, "Update reported visibility: " + this); |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 190 | final int count = mChildren.size(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 191 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 192 | mReportedVisibilityResults.reset(); |
| 193 | |
| 194 | for (int i = 0; i < count; i++) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 195 | final WindowState win = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 196 | win.updateReportedVisibility(mReportedVisibilityResults); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 197 | } |
| 198 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 199 | int numInteresting = mReportedVisibilityResults.numInteresting; |
| 200 | int numVisible = mReportedVisibilityResults.numVisible; |
| 201 | int numDrawn = mReportedVisibilityResults.numDrawn; |
| 202 | boolean nowGone = mReportedVisibilityResults.nowGone; |
| 203 | |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 204 | boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 205 | boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting; |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 206 | if (!nowGone) { |
| 207 | // If the app is not yet gone, then it can only become visible/drawn. |
| 208 | if (!nowDrawn) { |
| 209 | nowDrawn = reportedDrawn; |
| 210 | } |
| 211 | if (!nowVisible) { |
| 212 | nowVisible = reportedVisible; |
| 213 | } |
| 214 | } |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 215 | if (DEBUG_VISIBILITY) Slog.v(TAG, "VIS " + this + ": interesting=" |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 216 | + numInteresting + " visible=" + numVisible); |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 217 | if (nowDrawn != reportedDrawn) { |
| 218 | if (nowDrawn) { |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 219 | mService.mH.obtainMessage(H.REPORT_APPLICATION_TOKEN_DRAWN, this).sendToTarget(); |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 220 | } |
| 221 | reportedDrawn = nowDrawn; |
| 222 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 223 | if (nowVisible != reportedVisible) { |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 224 | if (DEBUG_VISIBILITY) Slog.v(TAG, |
| 225 | "Visibility changed in " + this + ": vis=" + nowVisible); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 226 | reportedVisible = nowVisible; |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 227 | mService.mH.obtainMessage(H.REPORT_APPLICATION_TOKEN_WINDOWS, |
| 228 | nowVisible ? 1 : 0, nowGone ? 1 : 0, this).sendToTarget(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 229 | } |
| 230 | } |
| 231 | |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 232 | boolean setVisibility(WindowManager.LayoutParams lp, |
| 233 | boolean visible, int transit, boolean performLayout, boolean isVoiceInteraction) { |
| 234 | |
| 235 | boolean delayed = false; |
| 236 | inPendingTransaction = false; |
| 237 | |
| 238 | if (clientHidden == visible) { |
| 239 | clientHidden = !visible; |
| 240 | sendAppVisibilityToClients(); |
| 241 | } |
| 242 | |
| 243 | // Allow for state changes and animation to be applied if: |
| 244 | // * token is transitioning visibility state |
| 245 | // * or the token was marked as hidden and is exiting before we had a chance to play the |
| 246 | // transition animation |
| 247 | // * or this is an opening app and windows are being replaced. |
| 248 | boolean visibilityChanged = false; |
| 249 | if (hidden == visible || (hidden && mIsExiting) || (visible && waitingForReplacement())) { |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 250 | final AccessibilityController accessibilityController = mService.mAccessibilityController; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 251 | boolean changed = false; |
| 252 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, |
| 253 | "Changing app " + this + " hidden=" + hidden + " performLayout=" + performLayout); |
| 254 | |
| 255 | boolean runningAppAnimation = false; |
| 256 | |
| 257 | if (transit != AppTransition.TRANSIT_UNSET) { |
| 258 | if (mAppAnimator.animation == AppWindowAnimator.sDummyAnimation) { |
| 259 | mAppAnimator.setNullAnimation(); |
| 260 | } |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 261 | if (mService.applyAnimationLocked(this, lp, transit, visible, isVoiceInteraction)) { |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 262 | delayed = runningAppAnimation = true; |
| 263 | } |
| 264 | final WindowState window = findMainWindow(); |
| 265 | //TODO (multidisplay): Magnification is supported only for the default display. |
| 266 | if (window != null && accessibilityController != null |
| 267 | && window.getDisplayId() == DEFAULT_DISPLAY) { |
| 268 | accessibilityController.onAppWindowTransitionLocked(window, transit); |
| 269 | } |
| 270 | changed = true; |
| 271 | } |
| 272 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 273 | final int windowsCount = mChildren.size(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 274 | for (int i = 0; i < windowsCount; i++) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 275 | final WindowState win = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 276 | changed |= win.onAppVisibilityChanged(visible, runningAppAnimation); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | hidden = hiddenRequested = !visible; |
| 280 | visibilityChanged = true; |
| 281 | if (!visible) { |
| 282 | stopFreezingScreen(true, true); |
| 283 | } else { |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 284 | // If we are being set visible, and the starting window is not yet displayed, |
| 285 | // then make sure it doesn't get displayed. |
| 286 | if (startingWindow != null && !startingWindow.isDrawnLw()) { |
| 287 | startingWindow.mPolicyVisibility = false; |
| 288 | startingWindow.mPolicyVisibilityAfterAnim = false; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 289 | } |
| 290 | } |
| 291 | |
| 292 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "setVisibility: " + this |
| 293 | + ": hidden=" + hidden + " hiddenRequested=" + hiddenRequested); |
| 294 | |
| 295 | if (changed) { |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 296 | mService.mInputMonitor.setUpdateInputWindowsNeededLw(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 297 | if (performLayout) { |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 298 | mService.updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES, |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 299 | false /*updateInputWindows*/); |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 300 | mService.mWindowPlacerLocked.performSurfacePlacement(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 301 | } |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 302 | mService.mInputMonitor.updateInputWindowsLw(false /*force*/); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 303 | } |
| 304 | } |
| 305 | |
| 306 | if (mAppAnimator.animation != null) { |
| 307 | delayed = true; |
| 308 | } |
| 309 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 310 | for (int i = mChildren.size() - 1; i >= 0 && !delayed; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 311 | if ((mChildren.get(i)).isWindowAnimationSet()) { |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 312 | delayed = true; |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | if (visibilityChanged) { |
| 317 | if (visible && !delayed) { |
| 318 | // The token was made immediately visible, there will be no entrance animation. |
| 319 | // We need to inform the client the enter animation was finished. |
| 320 | mEnteringAnimation = true; |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 321 | mService.mActivityManagerAppTransitionNotifier.onAppTransitionFinishedLocked(token); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 322 | } |
| 323 | |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 324 | if (!mService.mClosingApps.contains(this) && !mService.mOpeningApps.contains(this)) { |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 325 | // The token is not closing nor opening, so even if there is an animation set, that |
| 326 | // doesn't mean that it goes through the normal app transition cycle so we have |
| 327 | // to inform the docked controller about visibility change. |
Andrii Kulian | 1e32e02 | 2016-09-16 15:29:34 -0700 | [diff] [blame] | 328 | // TODO(multi-display): notify docked divider on all displays where visibility was |
| 329 | // affected. |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 330 | mService.getDefaultDisplayContentLocked().getDockedDividerController() |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 331 | .notifyAppVisibilityChanged(); |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | return delayed; |
| 336 | } |
| 337 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 338 | WindowState findMainWindow() { |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 339 | WindowState candidate = null; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 340 | int j = mChildren.size(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 341 | while (j > 0) { |
| 342 | j--; |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 343 | final WindowState win = mChildren.get(j); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 344 | final int type = win.mAttrs.type; |
| 345 | // No need to loop through child window as base application and starting types can't be |
| 346 | // child windows. |
| 347 | if (type == TYPE_BASE_APPLICATION || type == TYPE_APPLICATION_STARTING) { |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 348 | // 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] | 349 | // happens for example when replacing windows during an activity relaunch. When |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 350 | // constructing the animation, we want the new window, not the exiting one. |
Wale Ogunwale | c48a354 | 2016-02-19 15:18:45 -0800 | [diff] [blame] | 351 | if (win.mAnimatingExit) { |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 352 | candidate = win; |
| 353 | } else { |
| 354 | return win; |
| 355 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 356 | } |
| 357 | } |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 358 | return candidate; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 359 | } |
| 360 | |
Wale Ogunwale | 6cae765 | 2015-12-26 07:36:26 -0800 | [diff] [blame] | 361 | boolean windowsAreFocusable() { |
| 362 | return StackId.canReceiveKeys(mTask.mStack.mStackId) || mAlwaysFocusable; |
Wale Ogunwale | d045c82 | 2015-12-02 09:14:28 -0800 | [diff] [blame] | 363 | } |
| 364 | |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 365 | @Override |
Wale Ogunwale | 44f2180 | 2016-09-02 12:49:48 -0700 | [diff] [blame] | 366 | boolean isVisible() { |
| 367 | if (hidden) { |
| 368 | // TODO: Should this be checking hiddenRequested instead of hidden? |
| 369 | return false; |
| 370 | } |
| 371 | return super.isVisible(); |
| 372 | } |
| 373 | |
| 374 | @Override |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 375 | void removeIfPossible() { |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 376 | mIsExiting = false; |
| 377 | removeAllWindows(); |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 378 | if (mTask != null) { |
Wale Ogunwale | f619286 | 2016-09-10 13:42:30 -0700 | [diff] [blame] | 379 | mTask.mStack.mExitingAppTokens.remove(this); |
| 380 | mTask.removeChild(this); |
Craig Mautner | e3119b7 | 2015-01-20 15:02:36 -0800 | [diff] [blame] | 381 | } |
| 382 | } |
| 383 | |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 384 | @Override |
| 385 | boolean checkCompleteDeferredRemoval() { |
| 386 | if (mIsExiting) { |
| 387 | removeIfPossible(); |
| 388 | } |
| 389 | return super.checkCompleteDeferredRemoval(); |
| 390 | } |
| 391 | |
Chong Zhang | e05bcb1 | 2016-07-26 17:47:29 -0700 | [diff] [blame] | 392 | void clearAnimatingFlags() { |
Chong Zhang | b0d2670 | 2016-08-12 16:03:29 -0700 | [diff] [blame] | 393 | boolean wallpaperMightChange = false; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 394 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 395 | final WindowState win = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 396 | wallpaperMightChange |= win.clearAnimatingFlags(); |
Chong Zhang | e05bcb1 | 2016-07-26 17:47:29 -0700 | [diff] [blame] | 397 | } |
Chong Zhang | b0d2670 | 2016-08-12 16:03:29 -0700 | [diff] [blame] | 398 | if (wallpaperMightChange) { |
| 399 | requestUpdateWallpaperIfNeeded(); |
| 400 | } |
Chong Zhang | e05bcb1 | 2016-07-26 17:47:29 -0700 | [diff] [blame] | 401 | } |
| 402 | |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 403 | void destroySurfaces() { |
Chong Zhang | 45e6d2d | 2016-07-20 18:33:56 -0700 | [diff] [blame] | 404 | destroySurfaces(false /*cleanupOnResume*/); |
| 405 | } |
| 406 | |
| 407 | /** |
| 408 | * Destroy surfaces which have been marked as eligible by the animator, taking care to ensure |
| 409 | * the client has finished with them. |
| 410 | * |
| 411 | * @param cleanupOnResume whether this is done when app is resumed without fully stopped. If |
| 412 | * set to true, destroy only surfaces of removed windows, and clear relevant flags of the |
| 413 | * others so that they are ready to be reused. If set to false (common case), destroy all |
| 414 | * surfaces that's eligible, if the app is already stopped. |
| 415 | */ |
Chong Zhang | 45e6d2d | 2016-07-20 18:33:56 -0700 | [diff] [blame] | 416 | private void destroySurfaces(boolean cleanupOnResume) { |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 417 | final DisplayContentList displayList = new DisplayContentList(); |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 418 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 419 | final WindowState win = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 420 | final boolean destroyed = win.destroySurface(cleanupOnResume, mAppStopped); |
Chong Zhang | eb66557 | 2016-05-09 18:28:27 -0700 | [diff] [blame] | 421 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 422 | if (destroyed) { |
| 423 | final DisplayContent displayContent = win.getDisplayContent(); |
| 424 | if (displayContent != null && !displayList.contains(displayContent)) { |
| 425 | displayList.add(displayContent); |
| 426 | } |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 427 | } |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 428 | } |
| 429 | for (int i = 0; i < displayList.size(); i++) { |
| 430 | final DisplayContent displayContent = displayList.get(i); |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 431 | mService.mLayersController.assignLayersLocked(displayContent.getWindowList()); |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 432 | displayContent.layoutNeeded = true; |
| 433 | } |
| 434 | } |
| 435 | |
Wale Ogunwale | 8d5a542 | 2016-03-03 18:28:21 -0800 | [diff] [blame] | 436 | /** |
Chong Zhang | 45e6d2d | 2016-07-20 18:33:56 -0700 | [diff] [blame] | 437 | * Notify that the app is now resumed, and it was not stopped before, perform a clean |
| 438 | * up of the surfaces |
Wale Ogunwale | 8d5a542 | 2016-03-03 18:28:21 -0800 | [diff] [blame] | 439 | */ |
Chong Zhang | ad24f96 | 2016-08-25 12:12:33 -0700 | [diff] [blame] | 440 | void notifyAppResumed(boolean wasStopped, boolean allowSavedSurface) { |
| 441 | if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppResumed: wasStopped=" + wasStopped |
| 442 | + " allowSavedSurface=" + allowSavedSurface + " " + this); |
Chong Zhang | 45e6d2d | 2016-07-20 18:33:56 -0700 | [diff] [blame] | 443 | mAppStopped = false; |
| 444 | if (!wasStopped) { |
| 445 | destroySurfaces(true /*cleanupOnResume*/); |
Wale Ogunwale | 8d5a542 | 2016-03-03 18:28:21 -0800 | [diff] [blame] | 446 | } |
Chong Zhang | ad24f96 | 2016-08-25 12:12:33 -0700 | [diff] [blame] | 447 | if (!allowSavedSurface) { |
| 448 | destroySavedSurfaces(); |
| 449 | } |
Robert Carr | e12aece | 2016-02-02 22:43:27 -0800 | [diff] [blame] | 450 | } |
| 451 | |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 452 | /** |
Chong Zhang | 45e6d2d | 2016-07-20 18:33:56 -0700 | [diff] [blame] | 453 | * Notify that the app has stopped, and it is okay to destroy any surfaces which were |
| 454 | * keeping alive in case they were still being used. |
| 455 | */ |
| 456 | void notifyAppStopped() { |
| 457 | if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppStopped: " + this); |
| 458 | mAppStopped = true; |
| 459 | destroySurfaces(); |
| 460 | // Remove any starting window that was added for this app if they are still around. |
| 461 | mTask.mService.scheduleRemoveStartingWindowLocked(this); |
| 462 | } |
| 463 | |
| 464 | /** |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 465 | * Checks whether we should save surfaces for this app. |
| 466 | * |
| 467 | * @return true if the surfaces should be saved, false otherwise. |
| 468 | */ |
| 469 | boolean shouldSaveSurface() { |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 470 | // We want to save surface if the app's windows are "allDrawn". |
| 471 | // (If we started entering animation early with saved surfaces, allDrawn |
| 472 | // should have been restored to true. So we'll save again in that case |
| 473 | // even if app didn't actually finish drawing.) |
| 474 | return allDrawn; |
Robert Carr | 13f7be9e | 2015-12-02 18:39:45 -0800 | [diff] [blame] | 475 | } |
| 476 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 477 | private boolean canRestoreSurfaces() { |
| 478 | for (int i = mChildren.size() -1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 479 | final WindowState w = mChildren.get(i); |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 480 | if (w.canRestoreSurface()) { |
Robert Carr | 13f7be9e | 2015-12-02 18:39:45 -0800 | [diff] [blame] | 481 | return true; |
| 482 | } |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 483 | } |
| 484 | return false; |
| 485 | } |
| 486 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 487 | private void clearWasVisibleBeforeClientHidden() { |
| 488 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 489 | final WindowState w = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 490 | w.clearWasVisibleBeforeClientHidden(); |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 491 | } |
| 492 | } |
| 493 | |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 494 | /** |
| 495 | * Whether the app has some window that is invisible in layout, but |
| 496 | * animating with saved surface. |
| 497 | */ |
| 498 | boolean isAnimatingInvisibleWithSavedSurface() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 499 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 500 | final WindowState w = mChildren.get(i); |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 501 | if (w.isAnimatingInvisibleWithSavedSurface()) { |
| 502 | return true; |
| 503 | } |
| 504 | } |
| 505 | return false; |
| 506 | } |
| 507 | |
| 508 | /** |
| 509 | * Hide all window surfaces that's still invisible in layout but animating |
| 510 | * with a saved surface, and mark them destroying. |
| 511 | */ |
| 512 | void stopUsingSavedSurfaceLocked() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 513 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 514 | final WindowState w = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 515 | w.stopUsingSavedSurface(); |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 516 | } |
| 517 | destroySurfaces(); |
| 518 | } |
| 519 | |
Chong Zhang | f58631a | 2016-05-24 16:02:10 -0700 | [diff] [blame] | 520 | void markSavedSurfaceExiting() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 521 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 522 | final WindowState w = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 523 | w.markSavedSurfaceExiting(); |
Chong Zhang | f58631a | 2016-05-24 16:02:10 -0700 | [diff] [blame] | 524 | } |
| 525 | } |
| 526 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 527 | void restoreSavedSurfaceForInterestingWindows() { |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 528 | if (!canRestoreSurfaces()) { |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 529 | clearWasVisibleBeforeClientHidden(); |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 530 | return; |
| 531 | } |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 532 | |
| 533 | // Check if all interesting windows are drawn and we can mark allDrawn=true. |
| 534 | int interestingNotDrawn = -1; |
| 535 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 536 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 537 | final WindowState w = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 538 | interestingNotDrawn = w.restoreSavedSurfaceForInterestingWindow(); |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 539 | } |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 540 | |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 541 | if (!allDrawn) { |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 542 | allDrawn = (interestingNotDrawn == 0); |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 543 | if (allDrawn) { |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 544 | mService.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget(); |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 545 | } |
| 546 | } |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 547 | clearWasVisibleBeforeClientHidden(); |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 548 | |
| 549 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG, |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 550 | "restoreSavedSurfaceForInterestingWindows: " + this + " allDrawn=" + allDrawn |
| 551 | + " interestingNotDrawn=" + interestingNotDrawn); |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | void destroySavedSurfaces() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 555 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 556 | final WindowState win = mChildren.get(i); |
Robert Carr | 13f7be9e | 2015-12-02 18:39:45 -0800 | [diff] [blame] | 557 | win.destroySavedSurface(); |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 558 | } |
Chong Zhang | 9214704 | 2016-05-09 12:47:11 -0700 | [diff] [blame] | 559 | } |
| 560 | |
| 561 | void clearAllDrawn() { |
| 562 | allDrawn = false; |
| 563 | deferClearAllDrawn = false; |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 564 | allDrawnExcludingSaved = false; |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 565 | } |
| 566 | |
Wale Ogunwale | fa854eb | 2016-09-20 13:43:52 -0700 | [diff] [blame] | 567 | void postWindowRemoveStartingWindowCleanup(WindowState win) { |
Wale Ogunwale | 92fc372 | 2016-08-05 12:19:08 -0700 | [diff] [blame] | 568 | // TODO: Something smells about the code below...Is there a better way? |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 569 | if (startingWindow == win) { |
| 570 | if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Notify removed startingWindow " + win); |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 571 | mService.scheduleRemoveStartingWindowLocked(this); |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 572 | } else if (mChildren.size() == 0 && startingData != null) { |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 573 | // If this is the last window and we had requested a starting transition window, |
| 574 | // well there is no point now. |
| 575 | if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Nulling last startingWindow"); |
| 576 | startingData = null; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 577 | } else if (mChildren.size() == 1 && startingView != null) { |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 578 | // If this is the last window except for a starting transition window, |
| 579 | // we need to get rid of the starting transition. |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 580 | mService.scheduleRemoveStartingWindowLocked(this); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 581 | } |
| 582 | } |
| 583 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 584 | void removeDeadWindows() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 585 | for (int winNdx = mChildren.size() - 1; winNdx >= 0; --winNdx) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 586 | WindowState win = mChildren.get(winNdx); |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 587 | if (win.mAppDied) { |
Wale Ogunwale | 92fc372 | 2016-08-05 12:19:08 -0700 | [diff] [blame] | 588 | if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.w(TAG, |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 589 | "removeDeadWindows: " + win); |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 590 | // Set mDestroying, we don't want any animation or delayed removal here. |
| 591 | win.mDestroying = true; |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 592 | // Also removes child windows. |
Wale Ogunwale | 92fc372 | 2016-08-05 12:19:08 -0700 | [diff] [blame] | 593 | win.removeIfPossible(); |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 594 | } |
| 595 | } |
| 596 | } |
| 597 | |
Wale Ogunwale | e42d0e1 | 2016-05-02 16:40:59 -0700 | [diff] [blame] | 598 | boolean hasWindowsAlive() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 599 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 600 | // No need to loop through child windows as the answer should be the same as that of the |
| 601 | // parent window. |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 602 | if (!(mChildren.get(i)).mAppDied) { |
Wale Ogunwale | e42d0e1 | 2016-05-02 16:40:59 -0700 | [diff] [blame] | 603 | return true; |
| 604 | } |
| 605 | } |
| 606 | return false; |
| 607 | } |
| 608 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 609 | void setWillReplaceWindows(boolean animate) { |
Wale Ogunwale | 455fac5 | 2016-07-21 07:24:49 -0700 | [diff] [blame] | 610 | if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, |
| 611 | "Marking app token " + this + " with replacing windows."); |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 612 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 613 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 614 | final WindowState w = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 615 | w.setWillReplaceWindow(animate); |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 616 | } |
| 617 | if (animate) { |
| 618 | // Set-up dummy animation so we can start treating windows associated with this |
| 619 | // token like they are in transition before the new app window is ready for us to |
| 620 | // run the real transition animation. |
| 621 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 622 | "setWillReplaceWindow() Setting dummy animation on: " + this); |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 623 | mAppAnimator.setDummyAnimation(); |
| 624 | } |
| 625 | } |
| 626 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 627 | void setWillReplaceChildWindows() { |
Wale Ogunwale | 455fac5 | 2016-07-21 07:24:49 -0700 | [diff] [blame] | 628 | if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + this |
Robert Carr | 23fa16b | 2016-01-13 13:19:58 -0800 | [diff] [blame] | 629 | + " with replacing child windows."); |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 630 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 631 | final WindowState w = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 632 | w.setWillReplaceChildWindows(); |
Robert Carr | 23fa16b | 2016-01-13 13:19:58 -0800 | [diff] [blame] | 633 | } |
| 634 | } |
| 635 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 636 | void clearWillReplaceWindows() { |
Wale Ogunwale | 455fac5 | 2016-07-21 07:24:49 -0700 | [diff] [blame] | 637 | if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, |
| 638 | "Resetting app token " + this + " of replacing window marks."); |
Chong Zhang | f596cd5 | 2016-01-05 13:42:44 -0800 | [diff] [blame] | 639 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 640 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 641 | final WindowState w = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 642 | w.clearWillReplaceWindow(); |
Chong Zhang | f596cd5 | 2016-01-05 13:42:44 -0800 | [diff] [blame] | 643 | } |
| 644 | } |
| 645 | |
Chong Zhang | 4d7369a | 2016-04-25 16:09:14 -0700 | [diff] [blame] | 646 | void requestUpdateWallpaperIfNeeded() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 647 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 648 | final WindowState w = mChildren.get(i); |
Chong Zhang | 4d7369a | 2016-04-25 16:09:14 -0700 | [diff] [blame] | 649 | w.requestUpdateWallpaperIfNeeded(); |
| 650 | } |
| 651 | } |
| 652 | |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 653 | boolean isRelaunching() { |
| 654 | return mPendingRelaunchCount > 0; |
| 655 | } |
| 656 | |
| 657 | void startRelaunching() { |
| 658 | if (canFreezeBounds()) { |
| 659 | freezeBounds(); |
| 660 | } |
| 661 | mPendingRelaunchCount++; |
| 662 | } |
| 663 | |
| 664 | void finishRelaunching() { |
| 665 | if (canFreezeBounds()) { |
| 666 | unfreezeBounds(); |
| 667 | } |
| 668 | if (mPendingRelaunchCount > 0) { |
| 669 | mPendingRelaunchCount--; |
| 670 | } |
| 671 | } |
| 672 | |
Wale Ogunwale | 8fd7542 | 2016-06-24 14:20:37 -0700 | [diff] [blame] | 673 | void clearRelaunching() { |
Wale Ogunwale | 37dbafc | 2016-06-27 10:15:20 -0700 | [diff] [blame] | 674 | if (mPendingRelaunchCount == 0) { |
| 675 | return; |
| 676 | } |
Wale Ogunwale | 8fd7542 | 2016-06-24 14:20:37 -0700 | [diff] [blame] | 677 | if (canFreezeBounds()) { |
| 678 | unfreezeBounds(); |
| 679 | } |
| 680 | mPendingRelaunchCount = 0; |
| 681 | } |
| 682 | |
Wale Ogunwale | 92fc372 | 2016-08-05 12:19:08 -0700 | [diff] [blame] | 683 | @Override |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 684 | void addWindow(WindowState w) { |
Wale Ogunwale | 92fc372 | 2016-08-05 12:19:08 -0700 | [diff] [blame] | 685 | super.addWindow(w); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 686 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 687 | boolean gotReplacementWindow = false; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 688 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 689 | final WindowState candidate = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 690 | gotReplacementWindow |= candidate.setReplacementWindowIfNeeded(w); |
| 691 | } |
Wale Ogunwale | 92fc372 | 2016-08-05 12:19:08 -0700 | [diff] [blame] | 692 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 693 | // if we got a replacement window, reset the timeout to give drawing more time |
| 694 | if (gotReplacementWindow) { |
| 695 | mService.scheduleWindowReplacementTimeouts(this); |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 696 | } |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 697 | } |
| 698 | |
| 699 | boolean waitingForReplacement() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 700 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 701 | final WindowState candidate = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 702 | if (candidate.waitingForReplacement()) { |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 703 | return true; |
| 704 | } |
| 705 | } |
| 706 | return false; |
| 707 | } |
| 708 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 709 | void onWindowReplacementTimeout() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 710 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 711 | (mChildren.get(i)).onWindowReplacementTimeout(); |
Robert Carr | a1eb439 | 2015-12-10 12:43:51 -0800 | [diff] [blame] | 712 | } |
| 713 | } |
| 714 | |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 715 | private boolean canFreezeBounds() { |
| 716 | // For freeform windows, we can't freeze the bounds at the moment because this would make |
| 717 | // the resizing unresponsive. |
| 718 | return mTask != null && !mTask.inFreeformWorkspace(); |
| 719 | } |
| 720 | |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 721 | /** |
| 722 | * Freezes the task bounds. The size of this task reported the app will be fixed to the bounds |
| 723 | * freezed by {@link Task#prepareFreezingBounds} until {@link #unfreezeBounds} gets called, even |
| 724 | * if they change in the meantime. If the bounds are already frozen, the bounds will be frozen |
| 725 | * with a queue. |
| 726 | */ |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 727 | private void freezeBounds() { |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 728 | mFrozenBounds.offer(new Rect(mTask.mPreparedFrozenBounds)); |
Jorim Jaggi | 26c8c42 | 2016-05-09 19:57:25 -0700 | [diff] [blame] | 729 | |
| 730 | if (mTask.mPreparedFrozenMergedConfig.equals(Configuration.EMPTY)) { |
| 731 | // We didn't call prepareFreezingBounds on the task, so use the current value. |
Andrii Kulian | 8072d11 | 2016-09-16 11:11:01 -0700 | [diff] [blame] | 732 | final Configuration config = new Configuration(mService.mGlobalConfiguration); |
Jorim Jaggi | 26c8c42 | 2016-05-09 19:57:25 -0700 | [diff] [blame] | 733 | config.updateFrom(mTask.mOverrideConfig); |
| 734 | mFrozenMergedConfig.offer(config); |
| 735 | } else { |
| 736 | mFrozenMergedConfig.offer(new Configuration(mTask.mPreparedFrozenMergedConfig)); |
| 737 | } |
Andrii Kulian | b10330d | 2016-09-16 13:51:46 -0700 | [diff] [blame] | 738 | // Calling unset() to make it equal to Configuration.EMPTY. |
| 739 | mTask.mPreparedFrozenMergedConfig.unset(); |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 740 | } |
| 741 | |
| 742 | /** |
| 743 | * Unfreezes the previously frozen bounds. See {@link #freezeBounds}. |
| 744 | */ |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 745 | private void unfreezeBounds() { |
Wale Ogunwale | 37dbafc | 2016-06-27 10:15:20 -0700 | [diff] [blame] | 746 | if (!mFrozenBounds.isEmpty()) { |
| 747 | mFrozenBounds.remove(); |
| 748 | } |
| 749 | if (!mFrozenMergedConfig.isEmpty()) { |
| 750 | mFrozenMergedConfig.remove(); |
| 751 | } |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 752 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 753 | final WindowState win = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 754 | win.onUnfreezeBounds(); |
Jorim Jaggi | 4846ee3 | 2016-01-07 17:39:12 +0100 | [diff] [blame] | 755 | } |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 756 | mService.mWindowPlacerLocked.performSurfacePlacement(); |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 757 | } |
| 758 | |
Robert Carr | 91b22809 | 2016-06-28 17:32:37 -0700 | [diff] [blame] | 759 | void addSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) { |
| 760 | mSurfaceViewBackgrounds.add(background); |
| 761 | } |
| 762 | |
| 763 | void removeSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) { |
| 764 | mSurfaceViewBackgrounds.remove(background); |
| 765 | updateSurfaceViewBackgroundVisibilities(); |
| 766 | } |
| 767 | |
| 768 | // We use DimLayers behind SurfaceViews to prevent holes while resizing and creating. |
| 769 | // However, we need to ensure one SurfaceView doesn't cover another when they are both placed |
| 770 | // below the main app window (as traditionally a SurfaceView which is never drawn |
| 771 | // to is totally translucent). So we look at all our SurfaceView backgrounds and only enable |
| 772 | // the background for the SurfaceView with lowest Z order |
| 773 | void updateSurfaceViewBackgroundVisibilities() { |
| 774 | WindowSurfaceController.SurfaceControlWithBackground bottom = null; |
| 775 | int bottomLayer = Integer.MAX_VALUE; |
| 776 | for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) { |
| 777 | WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i); |
| 778 | if (sc.mVisible && sc.mLayer < bottomLayer) { |
| 779 | bottomLayer = sc.mLayer; |
| 780 | bottom = sc; |
| 781 | } |
| 782 | } |
| 783 | for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) { |
| 784 | WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i); |
| 785 | sc.updateBackgroundVisibility(sc != bottom); |
| 786 | } |
| 787 | } |
| 788 | |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 789 | /** |
| 790 | * See {@link WindowManagerService#overridePlayingAppAnimationsLw} |
| 791 | */ |
| 792 | void overridePlayingAppAnimations(Animation a) { |
| 793 | if (mAppAnimator.isAnimating()) { |
| 794 | final WindowState win = findMainWindow(); |
| 795 | final int width = win.mContainingFrame.width(); |
| 796 | final int height = win.mContainingFrame.height(); |
| 797 | mAppAnimator.setAnimation(a, width, height, false, STACK_CLIP_NONE); |
| 798 | } |
| 799 | } |
| 800 | |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 801 | void resetJustMovedInStack() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 802 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 803 | (mChildren.get(i)).resetJustMovedInStack(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 804 | } |
| 805 | } |
| 806 | |
| 807 | void notifyMovedInStack() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 808 | for (int winNdx = mChildren.size() - 1; winNdx >= 0; --winNdx) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 809 | final WindowState win = mChildren.get(winNdx); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 810 | win.notifyMovedInStack(); |
| 811 | } |
| 812 | } |
| 813 | |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 814 | void setAppLayoutChanges(int changes, String reason, int displayId) { |
| 815 | final WindowAnimator windowAnimator = mAppAnimator.mAnimator; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 816 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 817 | // Child windows will be on the same display as their parents. |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 818 | if (displayId == (mChildren.get(i)).getDisplayId()) { |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 819 | windowAnimator.setPendingLayoutChanges(displayId, changes); |
| 820 | if (DEBUG_LAYOUT_REPEATS) { |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 821 | mService.mWindowPlacerLocked.debugLayoutRepeats( |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 822 | reason, windowAnimator.getPendingLayoutChanges(displayId)); |
| 823 | } |
| 824 | break; |
| 825 | } |
| 826 | } |
| 827 | } |
| 828 | |
| 829 | void removeReplacedWindowIfNeeded(WindowState replacement) { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 830 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 831 | final WindowState win = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 832 | if (win.removeReplacedWindowIfNeeded(replacement)) { |
| 833 | return; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 834 | } |
| 835 | } |
| 836 | } |
| 837 | |
| 838 | void startFreezingScreen() { |
| 839 | if (DEBUG_ORIENTATION) logWithStack(TAG, "Set freezing of " + appToken + ": hidden=" |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 840 | + hidden + " freezing=" + mAppAnimator.freezingScreen + " hiddenRequested=" |
| 841 | + hiddenRequested); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 842 | if (!hiddenRequested) { |
| 843 | if (!mAppAnimator.freezingScreen) { |
| 844 | mAppAnimator.freezingScreen = true; |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 845 | mService.registerAppFreezeListener(this); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 846 | mAppAnimator.lastFreezeDuration = 0; |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 847 | mService.mAppsFreezingScreen++; |
| 848 | if (mService.mAppsFreezingScreen == 1) { |
| 849 | mService.startFreezingDisplayLocked(false, 0, 0); |
| 850 | mService.mH.removeMessages(H.APP_FREEZE_TIMEOUT); |
| 851 | mService.mH.sendEmptyMessageDelayed(H.APP_FREEZE_TIMEOUT, 2000); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 852 | } |
| 853 | } |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 854 | final int count = mChildren.size(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 855 | for (int i = 0; i < count; i++) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 856 | final WindowState w = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 857 | w.onStartFreezingScreen(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 858 | } |
| 859 | } |
| 860 | } |
| 861 | |
| 862 | void stopFreezingScreen(boolean unfreezeSurfaceNow, boolean force) { |
| 863 | if (!mAppAnimator.freezingScreen) { |
| 864 | return; |
| 865 | } |
| 866 | 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] | 867 | final int count = mChildren.size(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 868 | boolean unfrozeWindows = false; |
| 869 | for (int i = 0; i < count; i++) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 870 | final WindowState w = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 871 | unfrozeWindows |= w.onStopFreezingScreen(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 872 | } |
| 873 | if (force || unfrozeWindows) { |
| 874 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "No longer freezing: " + this); |
| 875 | mAppAnimator.freezingScreen = false; |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 876 | mService.unregisterAppFreezeListener(this); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 877 | mAppAnimator.lastFreezeDuration = |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 878 | (int)(SystemClock.elapsedRealtime() - mService.mDisplayFreezeTime); |
| 879 | mService.mAppsFreezingScreen--; |
| 880 | mService.mLastFinishedFreezeSource = this; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 881 | } |
| 882 | if (unfreezeSurfaceNow) { |
| 883 | if (unfrozeWindows) { |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 884 | mService.mWindowPlacerLocked.performSurfacePlacement(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 885 | } |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 886 | mService.stopFreezingDisplayLocked(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 887 | } |
| 888 | } |
| 889 | |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 890 | @Override |
| 891 | public void onAppFreezeTimeout() { |
| 892 | Slog.w(TAG_WM, "Force clearing freeze: " + this); |
| 893 | stopFreezingScreen(true, true); |
| 894 | } |
| 895 | |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 896 | boolean transferStartingWindow(IBinder transferFrom) { |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 897 | final AppWindowToken fromToken = mService.findAppWindowToken(transferFrom); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 898 | if (fromToken == null) { |
| 899 | return false; |
| 900 | } |
| 901 | |
| 902 | final WindowState tStartingWindow = fromToken.startingWindow; |
| 903 | if (tStartingWindow != null && fromToken.startingView != null) { |
| 904 | // In this case, the starting icon has already been displayed, so start |
| 905 | // letting windows get shown immediately without any more transitions. |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 906 | mService.mSkipAppTransitionAnimation = true; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 907 | |
| 908 | if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Moving existing starting " + tStartingWindow |
| 909 | + " from " + fromToken + " to " + this); |
| 910 | |
| 911 | final long origId = Binder.clearCallingIdentity(); |
| 912 | |
| 913 | // Transfer the starting window over to the new token. |
| 914 | startingData = fromToken.startingData; |
| 915 | startingView = fromToken.startingView; |
| 916 | startingDisplayed = fromToken.startingDisplayed; |
| 917 | fromToken.startingDisplayed = false; |
| 918 | startingWindow = tStartingWindow; |
| 919 | reportedVisible = fromToken.reportedVisible; |
| 920 | fromToken.startingData = null; |
| 921 | fromToken.startingView = null; |
| 922 | fromToken.startingWindow = null; |
| 923 | fromToken.startingMoved = true; |
| 924 | tStartingWindow.mToken = this; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 925 | tStartingWindow.mAppToken = this; |
| 926 | |
| 927 | if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE || DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, |
| 928 | "Removing starting window: " + tStartingWindow); |
| 929 | tStartingWindow.getWindowList().remove(tStartingWindow); |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 930 | mService.mWindowsChanged = true; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 931 | if (DEBUG_ADD_REMOVE) Slog.v(TAG_WM, |
| 932 | "Removing starting " + tStartingWindow + " from " + fromToken); |
Wale Ogunwale | fa854eb | 2016-09-20 13:43:52 -0700 | [diff] [blame] | 933 | fromToken.removeChild(tStartingWindow); |
| 934 | fromToken.postWindowRemoveStartingWindowCleanup(tStartingWindow); |
Wale Ogunwale | 92fc372 | 2016-08-05 12:19:08 -0700 | [diff] [blame] | 935 | addWindow(tStartingWindow); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 936 | |
| 937 | // Propagate other interesting state between the tokens. If the old token is displayed, |
| 938 | // we should immediately force the new one to be displayed. If it is animating, we need |
| 939 | // to move that animation to the new one. |
| 940 | if (fromToken.allDrawn) { |
| 941 | allDrawn = true; |
| 942 | deferClearAllDrawn = fromToken.deferClearAllDrawn; |
| 943 | } |
| 944 | if (fromToken.firstWindowDrawn) { |
| 945 | firstWindowDrawn = true; |
| 946 | } |
| 947 | if (!fromToken.hidden) { |
| 948 | hidden = false; |
| 949 | hiddenRequested = false; |
| 950 | } |
| 951 | if (clientHidden != fromToken.clientHidden) { |
| 952 | clientHidden = fromToken.clientHidden; |
| 953 | sendAppVisibilityToClients(); |
| 954 | } |
| 955 | fromToken.mAppAnimator.transferCurrentAnimation( |
| 956 | mAppAnimator, tStartingWindow.mWinAnimator); |
| 957 | |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 958 | mService.updateFocusedWindowLocked( |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 959 | UPDATE_FOCUS_WILL_PLACE_SURFACES, true /*updateInputWindows*/); |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 960 | mService.getDefaultDisplayContentLocked().layoutNeeded = true; |
| 961 | mService.mWindowPlacerLocked.performSurfacePlacement(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 962 | Binder.restoreCallingIdentity(origId); |
| 963 | return true; |
| 964 | } else if (fromToken.startingData != null) { |
| 965 | // The previous app was getting ready to show a |
| 966 | // starting window, but hasn't yet done so. Steal it! |
| 967 | if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, |
| 968 | "Moving pending starting from " + fromToken + " to " + this); |
| 969 | startingData = fromToken.startingData; |
| 970 | fromToken.startingData = null; |
| 971 | fromToken.startingMoved = true; |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 972 | final Message m = mService.mH.obtainMessage(H.ADD_STARTING, this); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 973 | // Note: we really want to do sendMessageAtFrontOfQueue() because we want to process the |
| 974 | // message ASAP, before any other queued messages. |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 975 | mService.mH.sendMessageAtFrontOfQueue(m); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 976 | return true; |
| 977 | } |
| 978 | |
| 979 | final AppWindowAnimator tAppAnimator = fromToken.mAppAnimator; |
| 980 | final AppWindowAnimator wAppAnimator = mAppAnimator; |
| 981 | if (tAppAnimator.thumbnail != null) { |
| 982 | // The old token is animating with a thumbnail, transfer that to the new token. |
| 983 | if (wAppAnimator.thumbnail != null) { |
| 984 | wAppAnimator.thumbnail.destroy(); |
| 985 | } |
| 986 | wAppAnimator.thumbnail = tAppAnimator.thumbnail; |
| 987 | wAppAnimator.thumbnailLayer = tAppAnimator.thumbnailLayer; |
| 988 | wAppAnimator.thumbnailAnimation = tAppAnimator.thumbnailAnimation; |
| 989 | tAppAnimator.thumbnail = null; |
| 990 | } |
| 991 | return false; |
| 992 | } |
| 993 | |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 994 | boolean isLastWindow(WindowState win) { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 995 | return mChildren.size() == 1 && mChildren.get(0) == win; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 996 | } |
| 997 | |
| 998 | void setAllAppWinAnimators() { |
| 999 | final ArrayList<WindowStateAnimator> allAppWinAnimators = mAppAnimator.mAllAppWinAnimators; |
| 1000 | allAppWinAnimators.clear(); |
| 1001 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 1002 | final int windowsCount = mChildren.size(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1003 | for (int j = 0; j < windowsCount; j++) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 1004 | (mChildren.get(j)).addWinAnimatorToList(allAppWinAnimators); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1005 | } |
| 1006 | } |
| 1007 | |
Wale Ogunwale | 9adfe57 | 2016-09-08 20:43:58 -0700 | [diff] [blame] | 1008 | @Override |
| 1009 | void onAppTransitionDone() { |
| 1010 | sendingToBottom = false; |
| 1011 | } |
| 1012 | |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 1013 | /** |
| 1014 | * We override because this class doesn't want its children affecting its reported orientation |
| 1015 | * in anyway. |
| 1016 | */ |
| 1017 | @Override |
| 1018 | int getOrientation() { |
| 1019 | if (hidden || hiddenRequested) { |
| 1020 | return SCREEN_ORIENTATION_UNSET; |
| 1021 | } |
| 1022 | return mOrientation; |
| 1023 | } |
| 1024 | |
Craig Mautner | dbb7991 | 2012-03-01 18:59:14 -0800 | [diff] [blame] | 1025 | @Override |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1026 | void checkAppWindowsReadyToShow(int displayId) { |
| 1027 | if (allDrawn == mAppAnimator.allDrawn) { |
| 1028 | return; |
| 1029 | } |
| 1030 | |
| 1031 | mAppAnimator.allDrawn = allDrawn; |
| 1032 | if (!allDrawn) { |
| 1033 | return; |
| 1034 | } |
| 1035 | |
| 1036 | // The token has now changed state to having all windows shown... what to do, what to do? |
| 1037 | if (mAppAnimator.freezingScreen) { |
| 1038 | mAppAnimator.showAllWindowsLocked(); |
| 1039 | stopFreezingScreen(false, true); |
| 1040 | if (DEBUG_ORIENTATION) Slog.i(TAG, |
| 1041 | "Setting mOrientationChangeComplete=true because wtoken " + this |
| 1042 | + " numInteresting=" + numInterestingWindows + " numDrawn=" + numDrawnWindows); |
| 1043 | // This will set mOrientationChangeComplete and cause a pass through layout. |
| 1044 | setAppLayoutChanges(FINISH_LAYOUT_REDO_WALLPAPER, |
| 1045 | "checkAppWindowsReadyToShow: freezingScreen", displayId); |
| 1046 | } else { |
| 1047 | setAppLayoutChanges(FINISH_LAYOUT_REDO_ANIM, "checkAppWindowsReadyToShow", displayId); |
| 1048 | |
| 1049 | // We can now show all of the drawn windows! |
| 1050 | if (!mService.mOpeningApps.contains(this)) { |
| 1051 | mService.mAnimator.orAnimating(mAppAnimator.showAllWindowsLocked()); |
| 1052 | } |
| 1053 | } |
| 1054 | } |
| 1055 | |
| 1056 | @Override |
| 1057 | void updateAllDrawn(int displayId) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame^] | 1058 | final DisplayContent displayContent = mService.mRoot.getDisplayContentOrCreate(displayId); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1059 | |
| 1060 | if (!allDrawn) { |
| 1061 | final int numInteresting = numInterestingWindows; |
| 1062 | if (numInteresting > 0 && numDrawnWindows >= numInteresting) { |
| 1063 | if (DEBUG_VISIBILITY) Slog.v(TAG, "allDrawn: " + this |
| 1064 | + " interesting=" + numInteresting + " drawn=" + numDrawnWindows); |
| 1065 | allDrawn = true; |
| 1066 | // Force an additional layout pass where |
| 1067 | // WindowStateAnimator#commitFinishDrawingLocked() will call performShowLocked(). |
| 1068 | displayContent.layoutNeeded = true; |
| 1069 | mService.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget(); |
| 1070 | } |
| 1071 | } |
| 1072 | if (!allDrawnExcludingSaved) { |
| 1073 | int numInteresting = numInterestingWindowsExcludingSaved; |
| 1074 | if (numInteresting > 0 && numDrawnWindowsExcludingSaved >= numInteresting) { |
| 1075 | if (DEBUG_VISIBILITY) Slog.v(TAG, "allDrawnExcludingSaved: " + this |
| 1076 | + " interesting=" + numInteresting |
| 1077 | + " drawn=" + numDrawnWindowsExcludingSaved); |
| 1078 | allDrawnExcludingSaved = true; |
| 1079 | displayContent.layoutNeeded = true; |
| 1080 | if (isAnimatingInvisibleWithSavedSurface() |
| 1081 | && !mService.mFinishedEarlyAnim.contains(this)) { |
| 1082 | mService.mFinishedEarlyAnim.add(this); |
| 1083 | } |
| 1084 | } |
| 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | @Override |
| 1089 | void stepAppWindowsAnimation(long currentTime, int displayId) { |
| 1090 | mAppAnimator.wasAnimating = mAppAnimator.animating; |
| 1091 | if (mAppAnimator.stepAnimationLocked(currentTime, displayId)) { |
| 1092 | mAppAnimator.animating = true; |
| 1093 | mService.mAnimator.setAnimating(true); |
| 1094 | mService.mAnimator.mAppWindowAnimating = true; |
| 1095 | } else if (mAppAnimator.wasAnimating) { |
| 1096 | // stopped animating, do one more pass through the layout |
| 1097 | setAppLayoutChanges( |
| 1098 | FINISH_LAYOUT_REDO_WALLPAPER, "appToken " + this + " done", displayId); |
| 1099 | if (DEBUG_ANIM) Slog.v(TAG, "updateWindowsApps...: done animating " + this); |
| 1100 | } |
| 1101 | } |
| 1102 | |
| 1103 | @Override |
Wale Ogunwale | 9adfe57 | 2016-09-08 20:43:58 -0700 | [diff] [blame] | 1104 | int rebuildWindowList(DisplayContent dc, int addIndex) { |
| 1105 | if (mIsExiting && !waitingForReplacement()) { |
| 1106 | return addIndex; |
| 1107 | } |
| 1108 | return super.rebuildWindowList(dc, addIndex); |
| 1109 | } |
| 1110 | |
| 1111 | @Override |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 1112 | AppWindowToken asAppWindowToken() { |
| 1113 | // I am an app window token! |
| 1114 | return this; |
| 1115 | } |
| 1116 | |
| 1117 | @Override |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 1118 | boolean fillsParent() { |
| 1119 | return mFillsParent; |
| 1120 | } |
| 1121 | |
| 1122 | void setFillsParent(boolean fillsParent) { |
| 1123 | mFillsParent = fillsParent; |
| 1124 | } |
| 1125 | |
| 1126 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1127 | void dump(PrintWriter pw, String prefix) { |
| 1128 | super.dump(pw, prefix); |
| 1129 | if (appToken != null) { |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1130 | pw.print(prefix); pw.print("app=true voiceInteraction="); pw.println(voiceInteraction); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1131 | } |
Craig Mautner | 83162a9 | 2015-01-26 14:43:30 -0800 | [diff] [blame] | 1132 | pw.print(prefix); pw.print("task="); pw.println(mTask); |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 1133 | pw.print(prefix); pw.print(" mFillsParent="); pw.print(mFillsParent); |
| 1134 | pw.print(" mOrientation="); pw.println(mOrientation); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1135 | pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested); |
| 1136 | pw.print(" clientHidden="); pw.print(clientHidden); |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 1137 | pw.print(" reportedDrawn="); pw.print(reportedDrawn); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1138 | pw.print(" reportedVisible="); pw.println(reportedVisible); |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 1139 | if (paused) { |
| 1140 | pw.print(prefix); pw.print("paused="); pw.println(paused); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1141 | } |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 1142 | if (mAppStopped) { |
| 1143 | pw.print(prefix); pw.print("mAppStopped="); pw.println(mAppStopped); |
| 1144 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1145 | if (numInterestingWindows != 0 || numDrawnWindows != 0 |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1146 | || allDrawn || mAppAnimator.allDrawn) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1147 | pw.print(prefix); pw.print("numInterestingWindows="); |
| 1148 | pw.print(numInterestingWindows); |
| 1149 | pw.print(" numDrawnWindows="); pw.print(numDrawnWindows); |
| 1150 | pw.print(" inPendingTransaction="); pw.print(inPendingTransaction); |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1151 | pw.print(" allDrawn="); pw.print(allDrawn); |
| 1152 | pw.print(" (animator="); pw.print(mAppAnimator.allDrawn); |
| 1153 | pw.println(")"); |
| 1154 | } |
| 1155 | if (inPendingTransaction) { |
| 1156 | pw.print(prefix); pw.print("inPendingTransaction="); |
| 1157 | pw.println(inPendingTransaction); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1158 | } |
Craig Mautner | 799bc1d | 2015-01-14 10:33:48 -0800 | [diff] [blame] | 1159 | if (startingData != null || removed || firstWindowDrawn || mIsExiting) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1160 | pw.print(prefix); pw.print("startingData="); pw.print(startingData); |
| 1161 | pw.print(" removed="); pw.print(removed); |
Craig Mautner | 3d7ca31 | 2015-01-08 10:56:00 -0800 | [diff] [blame] | 1162 | pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn); |
Craig Mautner | 799bc1d | 2015-01-14 10:33:48 -0800 | [diff] [blame] | 1163 | pw.print(" mIsExiting="); pw.println(mIsExiting); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1164 | } |
| 1165 | if (startingWindow != null || startingView != null |
| 1166 | || startingDisplayed || startingMoved) { |
| 1167 | pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow); |
| 1168 | pw.print(" startingView="); pw.print(startingView); |
| 1169 | pw.print(" startingDisplayed="); pw.print(startingDisplayed); |
Wale Ogunwale | 9017ec0 | 2016-02-25 08:55:25 -0800 | [diff] [blame] | 1170 | pw.print(" startingMoved="); pw.println(startingMoved); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1171 | } |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 1172 | if (!mFrozenBounds.isEmpty()) { |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 1173 | pw.print(prefix); pw.print("mFrozenBounds="); pw.println(mFrozenBounds); |
Jorim Jaggi | 26c8c42 | 2016-05-09 19:57:25 -0700 | [diff] [blame] | 1174 | pw.print(prefix); pw.print("mFrozenMergedConfig="); pw.println(mFrozenMergedConfig); |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 1175 | } |
| 1176 | if (mPendingRelaunchCount != 0) { |
| 1177 | pw.print(prefix); pw.print("mPendingRelaunchCount="); pw.println(mPendingRelaunchCount); |
Jorim Jaggi | 0429f35 | 2015-12-22 16:29:16 +0100 | [diff] [blame] | 1178 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1179 | } |
| 1180 | |
| 1181 | @Override |
| 1182 | public String toString() { |
| 1183 | if (stringName == null) { |
| 1184 | StringBuilder sb = new StringBuilder(); |
| 1185 | sb.append("AppWindowToken{"); |
| 1186 | sb.append(Integer.toHexString(System.identityHashCode(this))); |
| 1187 | sb.append(" token="); sb.append(token); sb.append('}'); |
| 1188 | stringName = sb.toString(); |
| 1189 | } |
| 1190 | return stringName; |
| 1191 | } |
Jeff Brown | e9bdb31 | 2012-04-05 15:30:10 -0700 | [diff] [blame] | 1192 | } |