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