Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 19 | import android.content.res.Configuration; |
| 20 | import android.graphics.Rect; |
Ruchi Kandoi | 0d43404 | 2016-10-03 09:12:02 -0700 | [diff] [blame] | 21 | import android.hardware.power.V1_0.PowerHint; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 22 | import android.os.Binder; |
| 23 | import android.os.Debug; |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 24 | import android.os.IBinder; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 25 | import android.os.ParcelFileDescriptor; |
| 26 | import android.os.PowerManager; |
| 27 | import android.os.RemoteException; |
| 28 | import android.os.SystemClock; |
| 29 | import android.os.UserHandle; |
| 30 | import android.provider.Settings; |
| 31 | import android.util.EventLog; |
| 32 | import android.util.Slog; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 33 | import android.util.SparseIntArray; |
| 34 | import android.view.Display; |
| 35 | import android.view.DisplayInfo; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 36 | import android.view.WindowManager; |
| 37 | import com.android.internal.util.ArrayUtils; |
| 38 | import com.android.server.EventLogTags; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 39 | |
| 40 | import java.io.FileDescriptor; |
| 41 | import java.io.PrintWriter; |
| 42 | import java.util.ArrayList; |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 43 | import java.util.HashMap; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 44 | |
| 45 | import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 46 | import static android.app.AppOpsManager.MODE_ALLOWED; |
| 47 | import static android.app.AppOpsManager.MODE_DEFAULT; |
| 48 | import static android.app.AppOpsManager.OP_NONE; |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 49 | import static android.view.Display.DEFAULT_DISPLAY; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 50 | import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 51 | import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 52 | import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE; |
| 53 | import static android.view.WindowManager.LayoutParams.TYPE_DREAM; |
| 54 | import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 55 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 56 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT; |
| 57 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; |
| 58 | import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 59 | import static com.android.server.wm.AppTransition.TRANSIT_UNSET; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 60 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE; |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 61 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 62 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DISPLAY; |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 63 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS_LIGHT; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 64 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_KEEP_SCREEN_ON; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 65 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT_REPEATS; |
| 66 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION; |
| 67 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_POWER; |
| 68 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STACK; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 69 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TOKEN_MOVEMENT; |
| 70 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY; |
| 71 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WALLPAPER_LIGHT; |
| 72 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_TRACE; |
| 73 | import static com.android.server.wm.WindowManagerDebugConfig.SHOW_LIGHT_TRANSACTIONS; |
| 74 | import static com.android.server.wm.WindowManagerDebugConfig.SHOW_SURFACE_ALLOC; |
| 75 | import static com.android.server.wm.WindowManagerDebugConfig.SHOW_TRANSACTIONS; |
| 76 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_KEEP_SCREEN_ON; |
| 77 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; |
| 78 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 79 | import static com.android.server.wm.WindowManagerService.H.REPORT_LOSING_FOCUS; |
| 80 | import static com.android.server.wm.WindowManagerService.H.SEND_NEW_CONFIGURATION; |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 81 | import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 82 | import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_PLACING_SURFACES; |
| 83 | import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE_SURFACES; |
| 84 | import static com.android.server.wm.WindowManagerService.WINDOWS_FREEZING_SCREENS_NONE; |
| 85 | import static com.android.server.wm.WindowManagerService.H.WINDOW_FREEZE_TIMEOUT; |
| 86 | import static com.android.server.wm.WindowManagerService.logSurface; |
| 87 | import static com.android.server.wm.WindowSurfacePlacer.SET_FORCE_HIDING_CHANGED; |
| 88 | import static com.android.server.wm.WindowSurfacePlacer.SET_ORIENTATION_CHANGE_COMPLETE; |
| 89 | import static com.android.server.wm.WindowSurfacePlacer.SET_TURN_ON_SCREEN; |
| 90 | import static com.android.server.wm.WindowSurfacePlacer.SET_UPDATE_ROTATION; |
| 91 | import static com.android.server.wm.WindowSurfacePlacer.SET_WALLPAPER_ACTION_PENDING; |
| 92 | import static com.android.server.wm.WindowSurfacePlacer.SET_WALLPAPER_MAY_CHANGE; |
| 93 | |
| 94 | /** Root {@link WindowContainer} for the device. */ |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 95 | class RootWindowContainer extends WindowContainer<DisplayContent> { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 96 | private static final String TAG = TAG_WITH_CLASS_NAME ? "RootWindowContainer" : TAG_WM; |
| 97 | |
| 98 | WindowManagerService mService; |
| 99 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 100 | private boolean mWallpaperForceHidingChanged = false; |
| 101 | private Object mLastWindowFreezeSource = null; |
| 102 | private Session mHoldScreen = null; |
| 103 | private float mScreenBrightness = -1; |
| 104 | private float mButtonBrightness = -1; |
| 105 | private long mUserActivityTimeout = -1; |
| 106 | private boolean mUpdateRotation = false; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 107 | // Following variables are for debugging screen wakelock only. |
| 108 | // Last window that requires screen wakelock |
| 109 | WindowState mHoldScreenWindow = null; |
| 110 | // Last window that obscures all windows below |
Wale Ogunwale | d4a00a0 | 2016-10-10 11:29:17 -0700 | [diff] [blame] | 111 | WindowState mObscuringWindow = null; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 112 | // Only set while traversing the default display based on its content. |
| 113 | // Affects the behavior of mirroring on secondary displays. |
| 114 | private boolean mObscureApplicationContentOnSecondaryDisplays = false; |
| 115 | |
| 116 | private boolean mSustainedPerformanceModeEnabled = false; |
| 117 | private boolean mSustainedPerformanceModeCurrent = false; |
| 118 | |
| 119 | boolean mWallpaperMayChange = false; |
Robert Carr | 11c26c2 | 2016-09-23 12:40:27 -0700 | [diff] [blame] | 120 | // During an orientation change, we track whether all windows have rendered |
| 121 | // at the new orientation, and this will be false from changing orientation until that occurs. |
| 122 | // For seamless rotation cases this always stays true, as the windows complete their orientation |
| 123 | // changes 1 by 1 without disturbing global state. |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 124 | boolean mOrientationChangeComplete = true; |
| 125 | boolean mWallpaperActionPending = false; |
| 126 | |
| 127 | private final ArrayList<Integer> mChangedStackList = new ArrayList(); |
| 128 | |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 129 | private final ArrayList<WindowToken> mTmpTokensList = new ArrayList(); |
| 130 | |
| 131 | // Collection of binder tokens mapped to their window type we are allowed to create window |
| 132 | // tokens for but that are not current attached to any display. We need to track this here |
| 133 | // because a binder token can be added through {@link WindowManagerService#addWindowToken}, |
| 134 | // but we don't know what display windows for the token will be added to until |
| 135 | // {@link WindowManagerService#addWindow} is called. |
| 136 | private final HashMap<IBinder, Integer> mUnattachedBinderTokens = new HashMap(); |
| 137 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 138 | // State for the RemoteSurfaceTrace system used in testing. If this is enabled SurfaceControl |
| 139 | // instances will be replaced with an instance that writes a binary representation of all |
| 140 | // commands to mSurfaceTraceFd. |
| 141 | boolean mSurfaceTraceEnabled; |
| 142 | ParcelFileDescriptor mSurfaceTraceFd; |
| 143 | RemoteEventTrace mRemoteEventTrace; |
| 144 | |
Wale Ogunwale | c69694a | 2016-10-18 13:51:15 -0700 | [diff] [blame] | 145 | private final WindowLayersController mLayersController; |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 146 | final WallpaperController mWallpaperController; |
Wale Ogunwale | c69694a | 2016-10-18 13:51:15 -0700 | [diff] [blame] | 147 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 148 | RootWindowContainer(WindowManagerService service) { |
| 149 | mService = service; |
Wale Ogunwale | c69694a | 2016-10-18 13:51:15 -0700 | [diff] [blame] | 150 | mLayersController = new WindowLayersController(mService); |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 151 | mWallpaperController = new WallpaperController(mService); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | WindowState computeFocusedWindow() { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 155 | final int count = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 156 | for (int i = 0; i < count; i++) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 157 | final DisplayContent dc = mChildren.get(i); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 158 | final WindowState win = dc.findFocusedWindow(); |
| 159 | if (win != null) { |
| 160 | return win; |
| 161 | } |
| 162 | } |
| 163 | return null; |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * Retrieve the DisplayContent for the specified displayId. Will create a new DisplayContent if |
| 168 | * there is a Display for the displayId. |
| 169 | * |
| 170 | * @param displayId The display the caller is interested in. |
| 171 | * @return The DisplayContent associated with displayId or null if there is no Display for it. |
| 172 | */ |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 173 | DisplayContent getDisplayContentOrCreate(int displayId) { |
| 174 | DisplayContent dc = getDisplayContent(displayId); |
| 175 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 176 | if (dc == null) { |
| 177 | final Display display = mService.mDisplayManager.getDisplay(displayId); |
| 178 | if (display != null) { |
| 179 | dc = createDisplayContent(display); |
| 180 | } |
| 181 | } |
| 182 | return dc; |
| 183 | } |
| 184 | |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 185 | DisplayContent getDisplayContent(int displayId) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 186 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
| 187 | final DisplayContent current = mChildren.get(i); |
| 188 | if (current.getDisplayId() == displayId) { |
| 189 | return current; |
| 190 | } |
| 191 | } |
| 192 | return null; |
| 193 | } |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 194 | |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 195 | private DisplayContent createDisplayContent(final Display display) { |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 196 | final DisplayContent dc = new DisplayContent(display, mService, mLayersController, |
| 197 | mWallpaperController); |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 198 | final int displayId = display.getDisplayId(); |
| 199 | |
| 200 | if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Adding display=" + display); |
| 201 | addChild(dc, null); |
| 202 | |
| 203 | final DisplayInfo displayInfo = dc.getDisplayInfo(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 204 | final Rect rect = new Rect(); |
| 205 | mService.mDisplaySettings.getOverscanLocked(displayInfo.name, displayInfo.uniqueId, rect); |
| 206 | displayInfo.overscanLeft = rect.left; |
| 207 | displayInfo.overscanTop = rect.top; |
| 208 | displayInfo.overscanRight = rect.right; |
| 209 | displayInfo.overscanBottom = rect.bottom; |
| 210 | if (mService.mDisplayManagerInternal != null) { |
| 211 | mService.mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager( |
| 212 | displayId, displayInfo); |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 213 | mService.configureDisplayPolicyLocked(dc); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 214 | |
| 215 | // TODO(multi-display): Create an input channel for each display with touch capability. |
Andrii Kulian | 5406e7a | 2016-10-21 11:55:23 -0700 | [diff] [blame] | 216 | if (displayId == DEFAULT_DISPLAY) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 217 | dc.mTapDetector = new TaskTapPointerEventListener( |
| 218 | mService, dc); |
| 219 | mService.registerPointerEventListener(dc.mTapDetector); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 220 | mService.registerPointerEventListener(mService.mMousePositionTracker); |
| 221 | } |
| 222 | } |
| 223 | |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 224 | return dc; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | /** Adds the input stack id to the input display id and returns the bounds of the added stack.*/ |
| 228 | Rect addStackToDisplay(int stackId, int displayId, boolean onTop) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 229 | final DisplayContent dc = getDisplayContent(displayId); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 230 | if (dc == null) { |
| 231 | Slog.w(TAG_WM, "addStackToDisplay: Trying to add stackId=" + stackId |
| 232 | + " to unknown displayId=" + displayId + " callers=" + Debug.getCallers(6)); |
| 233 | return null; |
| 234 | } |
| 235 | |
| 236 | boolean attachedToDisplay = false; |
| 237 | TaskStack stack = mService.mStackIdToStack.get(stackId); |
| 238 | if (stack == null) { |
| 239 | if (DEBUG_STACK) Slog.d(TAG_WM, "attachStack: stackId=" + stackId); |
| 240 | |
| 241 | stack = dc.getStackById(stackId); |
| 242 | if (stack != null) { |
Wale Ogunwale | ba51ca2 | 2016-09-23 06:06:54 -0700 | [diff] [blame] | 243 | // It's already attached to the display...clear mDeferRemoval and move stack to |
| 244 | // appropriate z-order on display as needed. |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 245 | stack.mDeferRemoval = false; |
Wale Ogunwale | ba51ca2 | 2016-09-23 06:06:54 -0700 | [diff] [blame] | 246 | dc.moveStack(stack, onTop); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 247 | attachedToDisplay = true; |
| 248 | } else { |
| 249 | stack = new TaskStack(mService, stackId); |
| 250 | } |
| 251 | |
| 252 | mService.mStackIdToStack.put(stackId, stack); |
| 253 | if (stackId == DOCKED_STACK_ID) { |
Andrii Kulian | 5406e7a | 2016-10-21 11:55:23 -0700 | [diff] [blame] | 254 | dc.mDividerControllerLocked.notifyDockedStackExistsChanged(true); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 255 | } |
| 256 | } |
Wale Ogunwale | ba51ca2 | 2016-09-23 06:06:54 -0700 | [diff] [blame] | 257 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 258 | if (!attachedToDisplay) { |
Wale Ogunwale | ba51ca2 | 2016-09-23 06:06:54 -0700 | [diff] [blame] | 259 | dc.attachStack(stack, onTop); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 260 | } |
Wale Ogunwale | ba51ca2 | 2016-09-23 06:06:54 -0700 | [diff] [blame] | 261 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 262 | if (stack.getRawFullscreen()) { |
| 263 | return null; |
| 264 | } |
Wale Ogunwale | ba51ca2 | 2016-09-23 06:06:54 -0700 | [diff] [blame] | 265 | final Rect bounds = new Rect(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 266 | stack.getRawBounds(bounds); |
| 267 | return bounds; |
| 268 | } |
| 269 | |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 270 | boolean isLayoutNeeded() { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 271 | final int numDisplays = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 272 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 273 | final DisplayContent displayContent = mChildren.get(displayNdx); |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 274 | if (displayContent.isLayoutNeeded()) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 275 | return true; |
| 276 | } |
| 277 | } |
| 278 | return false; |
| 279 | } |
| 280 | |
| 281 | void getWindows(WindowList output) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 282 | final int count = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 283 | for (int i = 0; i < count; ++i) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 284 | final DisplayContent dc = mChildren.get(i); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 285 | dc.getWindows(output); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 286 | } |
| 287 | } |
| 288 | |
| 289 | void getWindows(WindowList output, boolean visibleOnly, boolean appsOnly) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 290 | final int numDisplays = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 291 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 292 | final ReadOnlyWindowList windowList = mChildren.get(displayNdx).getReadOnlyWindowList(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 293 | for (int winNdx = windowList.size() - 1; winNdx >= 0; --winNdx) { |
| 294 | final WindowState w = windowList.get(winNdx); |
| 295 | if ((!visibleOnly || w.mWinAnimator.getShown()) |
| 296 | && (!appsOnly || w.mAppToken != null)) { |
| 297 | output.add(w); |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | void getWindowsByName(WindowList output, String name) { |
| 304 | int objectId = 0; |
| 305 | // See if this is an object ID. |
| 306 | try { |
| 307 | objectId = Integer.parseInt(name, 16); |
| 308 | name = null; |
| 309 | } catch (RuntimeException e) { |
| 310 | } |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 311 | final int numDisplays = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 312 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 313 | final ReadOnlyWindowList windowList = mChildren.get(displayNdx).getReadOnlyWindowList(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 314 | for (int winNdx = windowList.size() - 1; winNdx >= 0; --winNdx) { |
| 315 | final WindowState w = windowList.get(winNdx); |
| 316 | if (name != null) { |
| 317 | if (w.mAttrs.getTitle().toString().contains(name)) { |
| 318 | output.add(w); |
| 319 | } |
| 320 | } else if (System.identityHashCode(w) == objectId) { |
| 321 | output.add(w); |
| 322 | } |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | WindowState findWindow(int hashCode) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 328 | final int numDisplays = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 329 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 330 | final ReadOnlyWindowList windows = mChildren.get(displayNdx).getReadOnlyWindowList(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 331 | final int numWindows = windows.size(); |
| 332 | for (int winNdx = 0; winNdx < numWindows; ++winNdx) { |
| 333 | final WindowState w = windows.get(winNdx); |
| 334 | if (System.identityHashCode(w) == hashCode) { |
| 335 | return w; |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | return null; |
| 341 | } |
| 342 | |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 343 | /** Return the window token associated with the input binder token on the input display */ |
| 344 | WindowToken getWindowToken(IBinder binder, DisplayContent dc) { |
| 345 | final WindowToken token = dc.getWindowToken(binder); |
| 346 | if (token != null) { |
| 347 | return token; |
| 348 | } |
| 349 | |
| 350 | // There is no window token mapped to the binder on the display. Create and map a window |
| 351 | // token if it is currently allowed. |
| 352 | if (!mUnattachedBinderTokens.containsKey(binder)) { |
| 353 | return null; |
| 354 | } |
| 355 | |
| 356 | final int type = mUnattachedBinderTokens.get(binder); |
| 357 | return new WindowToken(mService, binder, type, true, dc); |
| 358 | } |
| 359 | |
| 360 | /** Returns all window tokens mapped to the input binder. */ |
| 361 | ArrayList<WindowToken> getWindowTokens(IBinder binder) { |
| 362 | mTmpTokensList.clear(); |
| 363 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
| 364 | final DisplayContent dc = mChildren.get(i); |
| 365 | final WindowToken token = dc.getWindowToken(binder); |
| 366 | if (token != null) { |
| 367 | mTmpTokensList.add(token); |
| 368 | } |
| 369 | } |
| 370 | return mTmpTokensList; |
| 371 | } |
| 372 | |
| 373 | /** |
| 374 | * Returns the app window token for the input binder if it exist in the system. |
| 375 | * NOTE: Only one AppWindowToken is allowed to exist in the system for a binder token, since |
| 376 | * AppWindowToken represents an activity which can only exist on one display. |
| 377 | */ |
| 378 | AppWindowToken getAppWindowToken(IBinder binder) { |
| 379 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
| 380 | final DisplayContent dc = mChildren.get(i); |
| 381 | final AppWindowToken atoken = dc.getAppWindowToken(binder); |
| 382 | if (atoken != null) { |
| 383 | return atoken; |
| 384 | } |
| 385 | } |
| 386 | return null; |
| 387 | } |
| 388 | |
| 389 | /** Returns the display object the input window token is currently mapped on. */ |
| 390 | DisplayContent getWindowTokenDisplay(WindowToken token) { |
| 391 | if (token == null) { |
| 392 | return null; |
| 393 | } |
| 394 | |
| 395 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
| 396 | final DisplayContent dc = mChildren.get(i); |
| 397 | final WindowToken current = dc.getWindowToken(token.token); |
| 398 | if (current == token) { |
| 399 | return dc; |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | return null; |
| 404 | } |
| 405 | |
| 406 | void addWindowToken(IBinder binder, int type) { |
| 407 | if (mUnattachedBinderTokens.containsKey(binder)) { |
| 408 | Slog.w(TAG_WM, "addWindowToken: Attempted to add existing binder token: " + binder); |
| 409 | return; |
| 410 | } |
| 411 | |
| 412 | final ArrayList<WindowToken> tokens = getWindowTokens(binder); |
| 413 | |
| 414 | if (!tokens.isEmpty()) { |
| 415 | Slog.w(TAG_WM, "addWindowToken: Attempted to add binder token: " + binder |
| 416 | + " for already created window tokens: " + tokens); |
| 417 | return; |
| 418 | } |
| 419 | |
| 420 | mUnattachedBinderTokens.put(binder, type); |
| 421 | |
| 422 | // TODO(multi-display): By default we add this to the default display, but maybe we |
| 423 | // should provide an API for a token to be added to any display? |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 424 | final DisplayContent dc = getDisplayContent(DEFAULT_DISPLAY); |
| 425 | final WindowToken token = new WindowToken(mService, binder, type, true, dc); |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 426 | if (type == TYPE_WALLPAPER) { |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 427 | dc.mWallpaperController.addWallpaperToken(token); |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 428 | } |
| 429 | } |
| 430 | |
| 431 | ArrayList<WindowToken> removeWindowToken(IBinder binder) { |
| 432 | mUnattachedBinderTokens.remove(binder); |
| 433 | |
| 434 | mTmpTokensList.clear(); |
| 435 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
| 436 | final DisplayContent dc = mChildren.get(i); |
| 437 | final WindowToken token = dc.removeWindowToken(binder); |
| 438 | if (token != null) { |
| 439 | mTmpTokensList.add(token); |
| 440 | } |
| 441 | } |
| 442 | return mTmpTokensList; |
| 443 | } |
| 444 | |
| 445 | /** |
| 446 | * Removed the mapping to the input binder for the system if it no longer as a window token |
| 447 | * associated with it on any display. |
| 448 | */ |
| 449 | void removeWindowTokenIfPossible(IBinder binder) { |
| 450 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
| 451 | final DisplayContent dc = mChildren.get(i); |
| 452 | final WindowToken token = dc.getWindowToken(binder); |
| 453 | if (token != null) { |
| 454 | return; |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | mUnattachedBinderTokens.remove(binder); |
| 459 | } |
| 460 | |
| 461 | void removeAppToken(IBinder binder) { |
| 462 | final ArrayList<WindowToken> removedTokens = removeWindowToken(binder); |
| 463 | if (removedTokens == null || removedTokens.isEmpty()) { |
| 464 | Slog.w(TAG_WM, "removeAppToken: Attempted to remove non-existing token: " + binder); |
| 465 | return; |
| 466 | } |
| 467 | |
| 468 | for (int i = removedTokens.size() - 1; i >= 0; --i) { |
| 469 | WindowToken wtoken = removedTokens.get(i); |
| 470 | AppWindowToken appToken = wtoken.asAppWindowToken(); |
| 471 | |
| 472 | if (appToken == null) { |
| 473 | Slog.w(TAG_WM, |
| 474 | "Attempted to remove non-App token: " + binder + " wtoken=" + wtoken); |
| 475 | continue; |
| 476 | } |
| 477 | |
| 478 | AppWindowToken startingToken = null; |
| 479 | |
| 480 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "Removing app token: " + appToken); |
| 481 | |
| 482 | boolean delayed = appToken.setVisibility(null, false, TRANSIT_UNSET, true, |
| 483 | appToken.voiceInteraction); |
| 484 | |
| 485 | mService.mOpeningApps.remove(appToken); |
| 486 | appToken.waitingToShow = false; |
| 487 | if (mService.mClosingApps.contains(appToken)) { |
| 488 | delayed = true; |
| 489 | } else if (mService.mAppTransition.isTransitionSet()) { |
| 490 | mService.mClosingApps.add(appToken); |
| 491 | delayed = true; |
| 492 | } |
| 493 | |
| 494 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "Removing app " + appToken |
| 495 | + " delayed=" + delayed |
| 496 | + " animation=" + appToken.mAppAnimator.animation |
| 497 | + " animating=" + appToken.mAppAnimator.animating); |
| 498 | |
| 499 | if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG_WM, "removeAppToken: " |
| 500 | + appToken + " delayed=" + delayed + " Callers=" + Debug.getCallers(4)); |
| 501 | |
| 502 | final TaskStack stack = appToken.mTask.mStack; |
| 503 | if (delayed && !appToken.isEmpty()) { |
| 504 | // set the token aside because it has an active animation to be finished |
| 505 | if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG_WM, |
| 506 | "removeAppToken make exiting: " + appToken); |
| 507 | stack.mExitingAppTokens.add(appToken); |
| 508 | appToken.mIsExiting = true; |
| 509 | } else { |
| 510 | // Make sure there is no animation running on this token, so any windows associated |
| 511 | // with it will be removed as soon as their animations are complete |
| 512 | appToken.mAppAnimator.clearAnimation(); |
| 513 | appToken.mAppAnimator.animating = false; |
| 514 | appToken.removeIfPossible(); |
| 515 | } |
| 516 | |
| 517 | appToken.removed = true; |
| 518 | if (appToken.startingData != null) { |
| 519 | startingToken = appToken; |
| 520 | } |
| 521 | appToken.stopFreezingScreen(true, true); |
| 522 | if (mService.mFocusedApp == appToken) { |
| 523 | if (DEBUG_FOCUS_LIGHT) Slog.v(TAG_WM, "Removing focused app token:" + appToken); |
| 524 | mService.mFocusedApp = null; |
| 525 | mService.updateFocusedWindowLocked( |
| 526 | UPDATE_FOCUS_NORMAL, true /*updateInputWindows*/); |
| 527 | mService.mInputMonitor.setFocusedAppLw(null); |
| 528 | } |
| 529 | |
| 530 | if (!delayed) { |
| 531 | appToken.updateReportedVisibilityLocked(); |
| 532 | } |
| 533 | |
| 534 | // Will only remove if startingToken non null. |
| 535 | mService.scheduleRemoveStartingWindowLocked(startingToken); |
| 536 | } |
| 537 | } |
| 538 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 539 | // TODO: Users would have their own window containers under the display container? |
| 540 | void switchUser() { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 541 | final int count = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 542 | for (int i = 0; i < count; ++i) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 543 | final DisplayContent dc = mChildren.get(i); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 544 | dc.switchUser(); |
| 545 | } |
| 546 | } |
| 547 | |
Andrii Kulian | 5406e7a | 2016-10-21 11:55:23 -0700 | [diff] [blame] | 548 | /** |
| 549 | * Set new display override config and return array of ids of stacks that were changed during |
| 550 | * update. If called for the default display, global configuration will also be updated. |
| 551 | */ |
| 552 | int[] setDisplayOverrideConfigurationIfNeeded(Configuration newConfiguration, int displayId) { |
| 553 | final DisplayContent displayContent = getDisplayContent(displayId); |
| 554 | if (displayContent == null) { |
| 555 | throw new IllegalArgumentException("Display not found for id: " + displayId); |
| 556 | } |
| 557 | |
| 558 | final Configuration currentConfig = displayContent.getOverrideConfiguration(); |
| 559 | final boolean configChanged = currentConfig.diff(newConfiguration) != 0; |
| 560 | if (!configChanged) { |
| 561 | return null; |
| 562 | } |
| 563 | displayContent.onOverrideConfigurationChanged(currentConfig); |
| 564 | |
| 565 | if (displayId == DEFAULT_DISPLAY) { |
| 566 | // Override configuration of the default display duplicates global config. In this case |
| 567 | // we also want to update the global config. |
| 568 | return setGlobalConfigurationIfNeeded(newConfiguration); |
| 569 | } else { |
| 570 | return updateStackBoundsAfterConfigChange(displayId); |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | private int[] setGlobalConfigurationIfNeeded(Configuration newConfiguration) { |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 575 | final boolean configChanged = getConfiguration().diff(newConfiguration) != 0; |
| 576 | if (!configChanged) { |
| 577 | return null; |
| 578 | } |
| 579 | onConfigurationChanged(newConfiguration); |
| 580 | return updateStackBoundsAfterConfigChange(); |
| 581 | } |
| 582 | |
| 583 | @Override |
| 584 | void onConfigurationChanged(Configuration newParentConfig) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 585 | prepareFreezingTaskBounds(); |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 586 | super.onConfigurationChanged(newParentConfig); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 587 | |
| 588 | mService.mPolicy.onConfigurationChanged(); |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 589 | } |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 590 | |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 591 | /** |
| 592 | * Callback used to trigger bounds update after configuration change and get ids of stacks whose |
| 593 | * bounds were updated. |
| 594 | */ |
Wale Ogunwale | d4a00a0 | 2016-10-10 11:29:17 -0700 | [diff] [blame] | 595 | private int[] updateStackBoundsAfterConfigChange() { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 596 | mChangedStackList.clear(); |
| 597 | |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 598 | final int numDisplays = mChildren.size(); |
| 599 | for (int i = 0; i < numDisplays; ++i) { |
| 600 | final DisplayContent dc = mChildren.get(i); |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 601 | dc.updateStackBoundsAfterConfigChange(mChangedStackList); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | return mChangedStackList.isEmpty() ? null : ArrayUtils.convertToIntArray(mChangedStackList); |
| 605 | } |
| 606 | |
Andrii Kulian | 5406e7a | 2016-10-21 11:55:23 -0700 | [diff] [blame] | 607 | /** Same as {@link #updateStackBoundsAfterConfigChange()} but only for a specific display. */ |
| 608 | private int[] updateStackBoundsAfterConfigChange(int displayId) { |
| 609 | mChangedStackList.clear(); |
| 610 | |
| 611 | final DisplayContent dc = getDisplayContent(displayId); |
| 612 | dc.updateStackBoundsAfterConfigChange(mChangedStackList); |
| 613 | |
| 614 | return mChangedStackList.isEmpty() ? null : ArrayUtils.convertToIntArray(mChangedStackList); |
| 615 | } |
| 616 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 617 | private void prepareFreezingTaskBounds() { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 618 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
| 619 | mChildren.get(i).prepareFreezingTaskBounds(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 620 | } |
| 621 | } |
| 622 | |
| 623 | void setSecureSurfaceState(int userId, boolean disabled) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 624 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 625 | final ReadOnlyWindowList windows = mChildren.get(i).getReadOnlyWindowList(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 626 | for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) { |
| 627 | final WindowState win = windows.get(winNdx); |
| 628 | if (win.mHasSurface && userId == UserHandle.getUserId(win.mOwnerUid)) { |
| 629 | win.mWinAnimator.setSecureLocked(disabled); |
| 630 | } |
| 631 | } |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | void updateAppOpsState() { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 636 | final int count = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 637 | for (int i = 0; i < count; ++i) { |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 638 | final ReadOnlyWindowList windows = mChildren.get(i).getReadOnlyWindowList(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 639 | final int numWindows = windows.size(); |
| 640 | for (int winNdx = 0; winNdx < numWindows; ++winNdx) { |
| 641 | final WindowState win = windows.get(winNdx); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 642 | if (win.mAppOp == OP_NONE) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 643 | continue; |
| 644 | } |
| 645 | final int mode = mService.mAppOps.checkOpNoThrow(win.mAppOp, win.getOwningUid(), |
| 646 | win.getOwningPackage()); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 647 | win.setAppOpVisibilityLw(mode == MODE_ALLOWED || mode == MODE_DEFAULT); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 648 | } |
| 649 | } |
| 650 | } |
| 651 | |
| 652 | boolean canShowStrictModeViolation(int pid) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 653 | final int count = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 654 | for (int i = 0; i < count; ++i) { |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 655 | final ReadOnlyWindowList windows = mChildren.get(i).getReadOnlyWindowList(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 656 | final int numWindows = windows.size(); |
| 657 | for (int winNdx = 0; winNdx < numWindows; ++winNdx) { |
| 658 | final WindowState ws = windows.get(winNdx); |
| 659 | if (ws.mSession.mPid == pid && ws.isVisibleLw()) { |
| 660 | return true; |
| 661 | } |
| 662 | } |
| 663 | } |
| 664 | return false; |
| 665 | } |
| 666 | |
| 667 | void closeSystemDialogs(String reason) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 668 | final int count = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 669 | for (int i = 0; i < count; ++i) { |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 670 | final ReadOnlyWindowList windows = mChildren.get(i).getReadOnlyWindowList(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 671 | final int numWindows = windows.size(); |
| 672 | for (int j = 0; j < numWindows; ++j) { |
| 673 | final WindowState w = windows.get(j); |
| 674 | if (w.mHasSurface) { |
| 675 | try { |
| 676 | w.mClient.closeSystemDialogs(reason); |
| 677 | } catch (RemoteException e) { |
| 678 | } |
| 679 | } |
| 680 | } |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | void removeReplacedWindows() { |
| 685 | if (SHOW_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION removeReplacedWindows"); |
| 686 | mService.openSurfaceTransaction(); |
| 687 | try { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 688 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
| 689 | DisplayContent dc = mChildren.get(i); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 690 | final ReadOnlyWindowList windows = mChildren.get(i).getReadOnlyWindowList(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 691 | for (int j = windows.size() - 1; j >= 0; j--) { |
| 692 | final WindowState win = windows.get(j); |
| 693 | final AppWindowToken aToken = win.mAppToken; |
| 694 | if (aToken != null) { |
| 695 | aToken.removeReplacedWindowIfNeeded(win); |
| 696 | } |
| 697 | } |
| 698 | } |
| 699 | } finally { |
| 700 | mService.closeSurfaceTransaction(); |
| 701 | if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION removeReplacedWindows"); |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | boolean hasPendingLayoutChanges(WindowAnimator animator) { |
| 706 | boolean hasChanges = false; |
| 707 | |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 708 | final int count = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 709 | for (int i = 0; i < count; ++i) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 710 | final DisplayContent dc = mChildren.get(i); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 711 | final int pendingChanges = animator.getPendingLayoutChanges(dc.getDisplayId()); |
| 712 | if ((pendingChanges & FINISH_LAYOUT_REDO_WALLPAPER) != 0) { |
| 713 | animator.mBulkUpdateParams |= SET_WALLPAPER_ACTION_PENDING; |
| 714 | } |
| 715 | if (pendingChanges != 0) { |
| 716 | hasChanges = true; |
| 717 | } |
| 718 | } |
| 719 | |
| 720 | return hasChanges; |
| 721 | } |
| 722 | |
| 723 | void updateInputWindows(InputMonitor inputMonitor, WindowState inputFocus, boolean inDrag) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 724 | final int count = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 725 | for (int i = 0; i < count; ++i) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 726 | final DisplayContent dc = mChildren.get(i); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 727 | dc.updateInputWindows(inputMonitor, inputFocus, inDrag); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 728 | } |
| 729 | } |
| 730 | |
| 731 | boolean reclaimSomeSurfaceMemory(WindowStateAnimator winAnimator, String operation, |
| 732 | boolean secure) { |
| 733 | final WindowSurfaceController surfaceController = winAnimator.mSurfaceController; |
| 734 | boolean leakedSurface = false; |
| 735 | boolean killedApps = false; |
| 736 | |
| 737 | EventLog.writeEvent(EventLogTags.WM_NO_SURFACE_MEMORY, winAnimator.mWin.toString(), |
| 738 | winAnimator.mSession.mPid, operation); |
| 739 | |
| 740 | final long callingIdentity = Binder.clearCallingIdentity(); |
| 741 | try { |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 742 | // There was some problem...first, do a sanity check of the window list to make sure |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 743 | // we haven't left any dangling surfaces around. |
| 744 | |
| 745 | Slog.i(TAG_WM, "Out of memory for surface! Looking for leaks..."); |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 746 | final int numDisplays = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 747 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 748 | leakedSurface |= mChildren.get(displayNdx).destroyLeakedSurfaces(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 749 | } |
| 750 | |
| 751 | if (!leakedSurface) { |
| 752 | Slog.w(TAG_WM, "No leaked surfaces; killing applications!"); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 753 | final SparseIntArray pidCandidates = new SparseIntArray(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 754 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 755 | final ReadOnlyWindowList windows = |
| 756 | mChildren.get(displayNdx).getReadOnlyWindowList(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 757 | final int numWindows = windows.size(); |
| 758 | for (int winNdx = 0; winNdx < numWindows; ++winNdx) { |
| 759 | final WindowState ws = windows.get(winNdx); |
| 760 | if (mService.mForceRemoves.contains(ws)) { |
| 761 | continue; |
| 762 | } |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 763 | final WindowStateAnimator wsa = ws.mWinAnimator; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 764 | if (wsa.mSurfaceController != null) { |
| 765 | pidCandidates.append(wsa.mSession.mPid, wsa.mSession.mPid); |
| 766 | } |
| 767 | } |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 768 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 769 | if (pidCandidates.size() > 0) { |
| 770 | int[] pids = new int[pidCandidates.size()]; |
| 771 | for (int i = 0; i < pids.length; i++) { |
| 772 | pids[i] = pidCandidates.keyAt(i); |
| 773 | } |
| 774 | try { |
| 775 | if (mService.mActivityManager.killPids(pids, "Free memory", secure)) { |
| 776 | killedApps = true; |
| 777 | } |
| 778 | } catch (RemoteException e) { |
| 779 | } |
| 780 | } |
| 781 | } |
| 782 | } |
| 783 | |
| 784 | if (leakedSurface || killedApps) { |
| 785 | // We managed to reclaim some memory, so get rid of the trouble surface and ask the |
| 786 | // app to request another one. |
| 787 | Slog.w(TAG_WM, |
| 788 | "Looks like we have reclaimed some memory, clearing surface for retry."); |
| 789 | if (surfaceController != null) { |
| 790 | if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) logSurface(winAnimator.mWin, |
| 791 | "RECOVER DESTROY", false); |
| 792 | winAnimator.destroySurface(); |
| 793 | mService.scheduleRemoveStartingWindowLocked(winAnimator.mWin.mAppToken); |
| 794 | } |
| 795 | |
| 796 | try { |
| 797 | winAnimator.mWin.mClient.dispatchGetNewSurface(); |
| 798 | } catch (RemoteException e) { |
| 799 | } |
| 800 | } |
| 801 | } finally { |
| 802 | Binder.restoreCallingIdentity(callingIdentity); |
| 803 | } |
| 804 | |
| 805 | return leakedSurface || killedApps; |
| 806 | } |
| 807 | |
| 808 | // "Something has changed! Let's make it correct now." |
| 809 | // TODO: Super crazy long method that should be broken down... |
| 810 | void performSurfacePlacement(boolean recoveringMemory) { |
| 811 | if (DEBUG_WINDOW_TRACE) Slog.v(TAG, "performSurfacePlacementInner: entry. Called by " |
| 812 | + Debug.getCallers(3)); |
| 813 | |
| 814 | int i; |
| 815 | boolean updateInputWindowsNeeded = false; |
| 816 | |
| 817 | if (mService.mFocusMayChange) { |
| 818 | mService.mFocusMayChange = false; |
| 819 | updateInputWindowsNeeded = mService.updateFocusedWindowLocked( |
| 820 | UPDATE_FOCUS_WILL_PLACE_SURFACES, false /*updateInputWindows*/); |
| 821 | } |
| 822 | |
| 823 | // Initialize state of exiting tokens. |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 824 | final int numDisplays = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 825 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 826 | final DisplayContent displayContent = mChildren.get(displayNdx); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 827 | for (i = displayContent.mExitingTokens.size() - 1; i >= 0; i--) { |
| 828 | displayContent.mExitingTokens.get(i).hasVisible = false; |
| 829 | } |
| 830 | } |
| 831 | |
| 832 | for (int stackNdx = mService.mStackIdToStack.size() - 1; stackNdx >= 0; --stackNdx) { |
| 833 | // Initialize state of exiting applications. |
| 834 | final AppTokenList exitingAppTokens = |
| 835 | mService.mStackIdToStack.valueAt(stackNdx).mExitingAppTokens; |
| 836 | for (int tokenNdx = exitingAppTokens.size() - 1; tokenNdx >= 0; --tokenNdx) { |
| 837 | exitingAppTokens.get(tokenNdx).hasVisible = false; |
| 838 | } |
| 839 | } |
| 840 | |
| 841 | mHoldScreen = null; |
| 842 | mScreenBrightness = -1; |
| 843 | mButtonBrightness = -1; |
| 844 | mUserActivityTimeout = -1; |
| 845 | mObscureApplicationContentOnSecondaryDisplays = false; |
| 846 | mSustainedPerformanceModeCurrent = false; |
| 847 | mService.mTransactionSequence++; |
| 848 | |
| 849 | // TODO(multi-display): |
| 850 | final DisplayContent defaultDisplay = mService.getDefaultDisplayContentLocked(); |
| 851 | final DisplayInfo defaultInfo = defaultDisplay.getDisplayInfo(); |
| 852 | final int defaultDw = defaultInfo.logicalWidth; |
| 853 | final int defaultDh = defaultInfo.logicalHeight; |
| 854 | |
| 855 | if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, |
| 856 | ">>> OPEN TRANSACTION performLayoutAndPlaceSurfaces"); |
| 857 | mService.openSurfaceTransaction(); |
| 858 | try { |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 859 | applySurfaceChangesTransaction(recoveringMemory, defaultDw, defaultDh); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 860 | } catch (RuntimeException e) { |
| 861 | Slog.wtf(TAG, "Unhandled exception in Window Manager", e); |
| 862 | } finally { |
| 863 | mService.closeSurfaceTransaction(); |
| 864 | if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, |
| 865 | "<<< CLOSE TRANSACTION performLayoutAndPlaceSurfaces"); |
| 866 | } |
| 867 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 868 | final WindowSurfacePlacer surfacePlacer = mService.mWindowPlacerLocked; |
| 869 | |
| 870 | // If we are ready to perform an app transition, check through all of the app tokens to be |
| 871 | // shown and see if they are ready to go. |
| 872 | if (mService.mAppTransition.isReady()) { |
| 873 | defaultDisplay.pendingLayoutChanges |= |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 874 | surfacePlacer.handleAppTransitionReadyLocked(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 875 | if (DEBUG_LAYOUT_REPEATS) |
| 876 | surfacePlacer.debugLayoutRepeats("after handleAppTransitionReadyLocked", |
| 877 | defaultDisplay.pendingLayoutChanges); |
| 878 | } |
| 879 | |
| 880 | if (!mService.mAnimator.mAppWindowAnimating && mService.mAppTransition.isRunning()) { |
| 881 | // We have finished the animation of an app transition. To do this, we have delayed a |
| 882 | // lot of operations like showing and hiding apps, moving apps in Z-order, etc. The app |
| 883 | // token list reflects the correct Z-order, but the window list may now be out of sync |
| 884 | // with it. So here we will just rebuild the entire app window list. Fun! |
| 885 | defaultDisplay.pendingLayoutChanges |= |
| 886 | mService.handleAnimatingStoppedAndTransitionLocked(); |
| 887 | if (DEBUG_LAYOUT_REPEATS) |
| 888 | surfacePlacer.debugLayoutRepeats("after handleAnimStopAndXitionLock", |
| 889 | defaultDisplay.pendingLayoutChanges); |
| 890 | } |
| 891 | |
| 892 | if (mWallpaperForceHidingChanged && defaultDisplay.pendingLayoutChanges == 0 |
| 893 | && !mService.mAppTransition.isReady()) { |
| 894 | // At this point, there was a window with a wallpaper that was force hiding other |
| 895 | // windows behind it, but now it is going away. This may be simple -- just animate away |
| 896 | // the wallpaper and its window -- or it may be hard -- the wallpaper now needs to be |
| 897 | // shown behind something that was hidden. |
| 898 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_LAYOUT; |
| 899 | if (DEBUG_LAYOUT_REPEATS) surfacePlacer.debugLayoutRepeats( |
| 900 | "after animateAwayWallpaperLocked", defaultDisplay.pendingLayoutChanges); |
| 901 | } |
| 902 | mWallpaperForceHidingChanged = false; |
| 903 | |
| 904 | if (mWallpaperMayChange) { |
| 905 | if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG, "Wallpaper may change! Adjusting"); |
| 906 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER; |
| 907 | if (DEBUG_LAYOUT_REPEATS) surfacePlacer.debugLayoutRepeats("WallpaperMayChange", |
| 908 | defaultDisplay.pendingLayoutChanges); |
| 909 | } |
| 910 | |
| 911 | if (mService.mFocusMayChange) { |
| 912 | mService.mFocusMayChange = false; |
| 913 | if (mService.updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES, |
| 914 | false /*updateInputWindows*/)) { |
| 915 | updateInputWindowsNeeded = true; |
| 916 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_ANIM; |
| 917 | } |
| 918 | } |
| 919 | |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 920 | if (isLayoutNeeded()) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 921 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_LAYOUT; |
| 922 | if (DEBUG_LAYOUT_REPEATS) surfacePlacer.debugLayoutRepeats("mLayoutNeeded", |
| 923 | defaultDisplay.pendingLayoutChanges); |
| 924 | } |
| 925 | |
| 926 | for (i = mService.mResizingWindows.size() - 1; i >= 0; i--) { |
| 927 | WindowState win = mService.mResizingWindows.get(i); |
| 928 | if (win.mAppFreezing) { |
| 929 | // Don't remove this window until rotation has completed. |
| 930 | continue; |
| 931 | } |
| 932 | // Discard the saved surface if window size is changed, it can't be reused. |
| 933 | if (win.mAppToken != null) { |
| 934 | win.mAppToken.destroySavedSurfaces(); |
| 935 | } |
| 936 | win.reportResized(); |
| 937 | mService.mResizingWindows.remove(i); |
| 938 | } |
| 939 | |
| 940 | if (DEBUG_ORIENTATION && mService.mDisplayFrozen) Slog.v(TAG, |
| 941 | "With display frozen, orientationChangeComplete=" + mOrientationChangeComplete); |
| 942 | if (mOrientationChangeComplete) { |
| 943 | if (mService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_NONE) { |
| 944 | mService.mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_NONE; |
| 945 | mService.mLastFinishedFreezeSource = mLastWindowFreezeSource; |
| 946 | mService.mH.removeMessages(WINDOW_FREEZE_TIMEOUT); |
| 947 | } |
| 948 | mService.stopFreezingDisplayLocked(); |
| 949 | } |
| 950 | |
| 951 | // Destroy the surface of any windows that are no longer visible. |
| 952 | boolean wallpaperDestroyed = false; |
| 953 | i = mService.mDestroySurface.size(); |
| 954 | if (i > 0) { |
| 955 | do { |
| 956 | i--; |
| 957 | WindowState win = mService.mDestroySurface.get(i); |
| 958 | win.mDestroying = false; |
| 959 | if (mService.mInputMethodWindow == win) { |
| 960 | mService.mInputMethodWindow = null; |
| 961 | } |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 962 | if (win.getDisplayContent().mWallpaperController.isWallpaperTarget(win)) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 963 | wallpaperDestroyed = true; |
| 964 | } |
| 965 | win.destroyOrSaveSurface(); |
| 966 | } while (i > 0); |
| 967 | mService.mDestroySurface.clear(); |
| 968 | } |
| 969 | |
| 970 | // Time to remove any exiting tokens? |
| 971 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 972 | final DisplayContent displayContent = mChildren.get(displayNdx); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 973 | ArrayList<WindowToken> exitingTokens = displayContent.mExitingTokens; |
| 974 | for (i = exitingTokens.size() - 1; i >= 0; i--) { |
| 975 | WindowToken token = exitingTokens.get(i); |
| 976 | if (!token.hasVisible) { |
| 977 | exitingTokens.remove(i); |
| 978 | if (token.windowType == TYPE_WALLPAPER) { |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 979 | displayContent.mWallpaperController.removeWallpaperToken(token); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 980 | } |
| 981 | } |
| 982 | } |
| 983 | } |
| 984 | |
| 985 | // Time to remove any exiting applications? |
| 986 | for (int stackNdx = mService.mStackIdToStack.size() - 1; stackNdx >= 0; --stackNdx) { |
| 987 | // Initialize state of exiting applications. |
| 988 | final AppTokenList exitingAppTokens = |
| 989 | mService.mStackIdToStack.valueAt(stackNdx).mExitingAppTokens; |
| 990 | for (i = exitingAppTokens.size() - 1; i >= 0; i--) { |
| 991 | final AppWindowToken token = exitingAppTokens.get(i); |
| 992 | if (!token.hasVisible && !mService.mClosingApps.contains(token) && |
| 993 | (!token.mIsExiting || token.isEmpty())) { |
| 994 | // Make sure there is no animation running on this token, so any windows |
| 995 | // associated with it will be removed as soon as their animations are complete |
| 996 | token.mAppAnimator.clearAnimation(); |
| 997 | token.mAppAnimator.animating = false; |
| 998 | if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, |
| 999 | "performLayout: App token exiting now removed" + token); |
| 1000 | token.removeIfPossible(); |
| 1001 | } |
| 1002 | } |
| 1003 | } |
| 1004 | |
| 1005 | if (wallpaperDestroyed) { |
| 1006 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER; |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 1007 | defaultDisplay.setLayoutNeeded(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1008 | } |
| 1009 | |
| 1010 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 1011 | final DisplayContent displayContent = mChildren.get(displayNdx); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1012 | if (displayContent.pendingLayoutChanges != 0) { |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 1013 | displayContent.setLayoutNeeded(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1014 | } |
| 1015 | } |
| 1016 | |
| 1017 | // Finally update all input windows now that the window changes have stabilized. |
| 1018 | mService.mInputMonitor.updateInputWindowsLw(true /*force*/); |
| 1019 | |
| 1020 | mService.setHoldScreenLocked(mHoldScreen); |
| 1021 | if (!mService.mDisplayFrozen) { |
| 1022 | if (mScreenBrightness < 0 || mScreenBrightness > 1.0f) { |
| 1023 | mService.mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager(-1); |
| 1024 | } else { |
| 1025 | mService.mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager( |
| 1026 | toBrightnessOverride(mScreenBrightness)); |
| 1027 | } |
| 1028 | if (mButtonBrightness < 0 || mButtonBrightness > 1.0f) { |
| 1029 | mService.mPowerManagerInternal.setButtonBrightnessOverrideFromWindowManager(-1); |
| 1030 | } else { |
| 1031 | mService.mPowerManagerInternal.setButtonBrightnessOverrideFromWindowManager( |
| 1032 | toBrightnessOverride(mButtonBrightness)); |
| 1033 | } |
| 1034 | mService.mPowerManagerInternal.setUserActivityTimeoutOverrideFromWindowManager( |
| 1035 | mUserActivityTimeout); |
| 1036 | } |
| 1037 | |
| 1038 | if (mSustainedPerformanceModeCurrent != mSustainedPerformanceModeEnabled) { |
| 1039 | mSustainedPerformanceModeEnabled = mSustainedPerformanceModeCurrent; |
| 1040 | mService.mPowerManagerInternal.powerHint( |
Ruchi Kandoi | 0d43404 | 2016-10-03 09:12:02 -0700 | [diff] [blame] | 1041 | PowerHint.SUSTAINED_PERFORMANCE, |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1042 | (mSustainedPerformanceModeEnabled ? 1 : 0)); |
| 1043 | } |
| 1044 | |
| 1045 | if (mService.mTurnOnScreen) { |
| 1046 | if (mService.mAllowTheaterModeWakeFromLayout |
| 1047 | || Settings.Global.getInt(mService.mContext.getContentResolver(), |
| 1048 | Settings.Global.THEATER_MODE_ON, 0) == 0) { |
| 1049 | if (DEBUG_VISIBILITY || DEBUG_POWER) { |
| 1050 | Slog.v(TAG, "Turning screen on after layout!"); |
| 1051 | } |
| 1052 | mService.mPowerManager.wakeUp(SystemClock.uptimeMillis(), |
| 1053 | "android.server.wm:TURN_ON"); |
| 1054 | } |
| 1055 | mService.mTurnOnScreen = false; |
| 1056 | } |
| 1057 | |
| 1058 | if (mUpdateRotation) { |
| 1059 | if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-rotate rotation"); |
Andrii Kulian | 5406e7a | 2016-10-21 11:55:23 -0700 | [diff] [blame] | 1060 | // TODO(multi-display): Update rotation for different displays separately. |
| 1061 | final int displayId = defaultDisplay.getDisplayId(); |
| 1062 | if (mService.updateRotationUncheckedLocked(false, displayId)) { |
| 1063 | mService.mH.obtainMessage(SEND_NEW_CONFIGURATION, displayId).sendToTarget(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1064 | } else { |
| 1065 | mUpdateRotation = false; |
| 1066 | } |
| 1067 | } |
| 1068 | |
| 1069 | if (mService.mWaitingForDrawnCallback != null || |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 1070 | (mOrientationChangeComplete && !defaultDisplay.isLayoutNeeded() |
| 1071 | && !mUpdateRotation)) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1072 | mService.checkDrawnWindowsLocked(); |
| 1073 | } |
| 1074 | |
| 1075 | final int N = mService.mPendingRemove.size(); |
| 1076 | if (N > 0) { |
| 1077 | if (mService.mPendingRemoveTmp.length < N) { |
| 1078 | mService.mPendingRemoveTmp = new WindowState[N+10]; |
| 1079 | } |
| 1080 | mService.mPendingRemove.toArray(mService.mPendingRemoveTmp); |
| 1081 | mService.mPendingRemove.clear(); |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 1082 | ArrayList<DisplayContent> displayList = new ArrayList(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1083 | for (i = 0; i < N; i++) { |
| 1084 | final WindowState w = mService.mPendingRemoveTmp[i]; |
| 1085 | w.removeImmediately(); |
| 1086 | final DisplayContent displayContent = w.getDisplayContent(); |
| 1087 | if (displayContent != null && !displayList.contains(displayContent)) { |
| 1088 | displayList.add(displayContent); |
| 1089 | } |
| 1090 | } |
| 1091 | |
Wale Ogunwale | c69694a | 2016-10-18 13:51:15 -0700 | [diff] [blame] | 1092 | for (int j = displayList.size() - 1; j >= 0; --j) { |
| 1093 | final DisplayContent dc = displayList.get(j); |
| 1094 | dc.assignWindowLayers(true /*setLayoutNeeded*/); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1095 | } |
| 1096 | } |
| 1097 | |
| 1098 | // Remove all deferred displays stacks, tasks, and activities. |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 1099 | for (int displayNdx = mChildren.size() - 1; displayNdx >= 0; --displayNdx) { |
| 1100 | mChildren.get(displayNdx).checkCompleteDeferredRemoval(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1101 | } |
| 1102 | |
| 1103 | if (updateInputWindowsNeeded) { |
| 1104 | mService.mInputMonitor.updateInputWindowsLw(false /*force*/); |
| 1105 | } |
| 1106 | mService.setFocusTaskRegionLocked(); |
| 1107 | |
| 1108 | // Check to see if we are now in a state where the screen should |
| 1109 | // be enabled, because the window obscured flags have changed. |
| 1110 | mService.enableScreenIfNeededLocked(); |
| 1111 | |
| 1112 | mService.scheduleAnimationLocked(); |
| 1113 | mService.mWindowPlacerLocked.destroyPendingSurfaces(); |
| 1114 | |
| 1115 | if (DEBUG_WINDOW_TRACE) Slog.e(TAG, |
| 1116 | "performSurfacePlacementInner exit: animating=" + mService.mAnimator.isAnimating()); |
| 1117 | } |
| 1118 | |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 1119 | private void applySurfaceChangesTransaction(boolean recoveringMemory, int defaultDw, |
| 1120 | int defaultDh) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1121 | mHoldScreenWindow = null; |
Wale Ogunwale | d4a00a0 | 2016-10-10 11:29:17 -0700 | [diff] [blame] | 1122 | mObscuringWindow = null; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1123 | |
| 1124 | if (mService.mWatermark != null) { |
| 1125 | mService.mWatermark.positionSurface(defaultDw, defaultDh); |
| 1126 | } |
| 1127 | if (mService.mStrictModeFlash != null) { |
| 1128 | mService.mStrictModeFlash.positionSurface(defaultDw, defaultDh); |
| 1129 | } |
| 1130 | if (mService.mCircularDisplayMask != null) { |
| 1131 | mService.mCircularDisplayMask.positionSurface(defaultDw, defaultDh, mService.mRotation); |
| 1132 | } |
| 1133 | if (mService.mEmulatorDisplayOverlay != null) { |
| 1134 | mService.mEmulatorDisplayOverlay.positionSurface(defaultDw, defaultDh, |
| 1135 | mService.mRotation); |
| 1136 | } |
| 1137 | |
| 1138 | boolean focusDisplayed = false; |
| 1139 | |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 1140 | final int count = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1141 | for (int j = 0; j < count; ++j) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 1142 | final DisplayContent dc = mChildren.get(j); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 1143 | focusDisplayed |= dc.applySurfaceChangesTransaction(recoveringMemory); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1144 | } |
| 1145 | |
| 1146 | if (focusDisplayed) { |
| 1147 | mService.mH.sendEmptyMessage(REPORT_LOSING_FOCUS); |
| 1148 | } |
| 1149 | |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 1150 | // Give the display manager a chance to adjust properties like display rotation if it needs |
| 1151 | // to. |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1152 | mService.mDisplayManagerInternal.performTraversalInTransactionFromWindowManager(); |
| 1153 | } |
| 1154 | |
| 1155 | /** |
| 1156 | * @param w WindowState this method is applied to. |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 1157 | * @param obscured True if there is a window on top of this obscuring the display. |
| 1158 | * @param syswin System window? |
| 1159 | * @return True when the display contains content to show the user. When false, the display |
| 1160 | * manager may choose to mirror or blank the display. |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1161 | */ |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 1162 | boolean handleNotObscuredLocked(WindowState w, boolean obscured, boolean syswin) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1163 | final WindowManager.LayoutParams attrs = w.mAttrs; |
| 1164 | final int attrFlags = attrs.flags; |
| 1165 | final boolean canBeSeen = w.isDisplayedLw(); |
| 1166 | final int privateflags = attrs.privateFlags; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 1167 | boolean displayHasContent = false; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1168 | |
| 1169 | if (w.mHasSurface && canBeSeen) { |
| 1170 | if ((attrFlags & FLAG_KEEP_SCREEN_ON) != 0) { |
| 1171 | mHoldScreen = w.mSession; |
| 1172 | mHoldScreenWindow = w; |
| 1173 | } else if (DEBUG_KEEP_SCREEN_ON && w == mService.mLastWakeLockHoldingWindow) { |
| 1174 | Slog.d(TAG_KEEP_SCREEN_ON, "handleNotObscuredLocked: " + w + " was holding " |
| 1175 | + "screen wakelock but no longer has FLAG_KEEP_SCREEN_ON!!! called by" |
| 1176 | + Debug.getCallers(10)); |
| 1177 | } |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 1178 | if (!syswin && w.mAttrs.screenBrightness >= 0 && mScreenBrightness < 0) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1179 | mScreenBrightness = w.mAttrs.screenBrightness; |
| 1180 | } |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 1181 | if (!syswin && w.mAttrs.buttonBrightness >= 0 && mButtonBrightness < 0) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1182 | mButtonBrightness = w.mAttrs.buttonBrightness; |
| 1183 | } |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 1184 | if (!syswin && w.mAttrs.userActivityTimeout >= 0 && mUserActivityTimeout < 0) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1185 | mUserActivityTimeout = w.mAttrs.userActivityTimeout; |
| 1186 | } |
| 1187 | |
| 1188 | final int type = attrs.type; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1189 | // This function assumes that the contents of the default display are processed first |
| 1190 | // before secondary displays. |
| 1191 | final DisplayContent displayContent = w.getDisplayContent(); |
| 1192 | if (displayContent != null && displayContent.isDefaultDisplay) { |
| 1193 | // While a dream or keyguard is showing, obscure ordinary application content on |
| 1194 | // secondary displays (by forcibly enabling mirroring unless there is other content |
| 1195 | // we want to show) but still allow opaque keyguard dialogs to be shown. |
| 1196 | if (type == TYPE_DREAM || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
| 1197 | mObscureApplicationContentOnSecondaryDisplays = true; |
| 1198 | } |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 1199 | displayHasContent = true; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1200 | } else if (displayContent != null && |
| 1201 | (!mObscureApplicationContentOnSecondaryDisplays |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 1202 | || (obscured && type == TYPE_KEYGUARD_DIALOG))) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1203 | // Allow full screen keyguard presentation dialogs to be seen. |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 1204 | displayHasContent = true; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1205 | } |
| 1206 | if ((privateflags & PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE) != 0) { |
| 1207 | mSustainedPerformanceModeCurrent = true; |
| 1208 | } |
| 1209 | } |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 1210 | |
| 1211 | return displayHasContent; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1212 | } |
| 1213 | |
| 1214 | boolean copyAnimToLayoutParams() { |
| 1215 | boolean doRequest = false; |
| 1216 | |
| 1217 | final int bulkUpdateParams = mService.mAnimator.mBulkUpdateParams; |
| 1218 | if ((bulkUpdateParams & SET_UPDATE_ROTATION) != 0) { |
| 1219 | mUpdateRotation = true; |
| 1220 | doRequest = true; |
| 1221 | } |
| 1222 | if ((bulkUpdateParams & SET_WALLPAPER_MAY_CHANGE) != 0) { |
| 1223 | mWallpaperMayChange = true; |
| 1224 | doRequest = true; |
| 1225 | } |
| 1226 | if ((bulkUpdateParams & SET_FORCE_HIDING_CHANGED) != 0) { |
| 1227 | mWallpaperForceHidingChanged = true; |
| 1228 | doRequest = true; |
| 1229 | } |
| 1230 | if ((bulkUpdateParams & SET_ORIENTATION_CHANGE_COMPLETE) == 0) { |
| 1231 | mOrientationChangeComplete = false; |
| 1232 | } else { |
| 1233 | mOrientationChangeComplete = true; |
| 1234 | mLastWindowFreezeSource = mService.mAnimator.mLastWindowFreezeSource; |
| 1235 | if (mService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_NONE) { |
| 1236 | doRequest = true; |
| 1237 | } |
| 1238 | } |
| 1239 | if ((bulkUpdateParams & SET_TURN_ON_SCREEN) != 0) { |
| 1240 | mService.mTurnOnScreen = true; |
| 1241 | } |
| 1242 | if ((bulkUpdateParams & SET_WALLPAPER_ACTION_PENDING) != 0) { |
| 1243 | mWallpaperActionPending = true; |
| 1244 | } |
| 1245 | |
| 1246 | return doRequest; |
| 1247 | } |
| 1248 | |
| 1249 | private static int toBrightnessOverride(float value) { |
| 1250 | return (int)(value * PowerManager.BRIGHTNESS_ON); |
| 1251 | } |
| 1252 | |
| 1253 | void enableSurfaceTrace(ParcelFileDescriptor pfd) { |
| 1254 | final FileDescriptor fd = pfd.getFileDescriptor(); |
| 1255 | if (mSurfaceTraceEnabled) { |
| 1256 | disableSurfaceTrace(); |
| 1257 | } |
| 1258 | mSurfaceTraceEnabled = true; |
| 1259 | mRemoteEventTrace = new RemoteEventTrace(mService, fd); |
| 1260 | mSurfaceTraceFd = pfd; |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 1261 | for (int displayNdx = mChildren.size() - 1; displayNdx >= 0; --displayNdx) { |
| 1262 | final DisplayContent dc = mChildren.get(displayNdx); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1263 | dc.enableSurfaceTrace(fd); |
| 1264 | } |
| 1265 | } |
| 1266 | |
| 1267 | void disableSurfaceTrace() { |
| 1268 | mSurfaceTraceEnabled = false; |
| 1269 | mRemoteEventTrace = null; |
| 1270 | mSurfaceTraceFd = null; |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 1271 | for (int displayNdx = mChildren.size() - 1; displayNdx >= 0; --displayNdx) { |
| 1272 | final DisplayContent dc = mChildren.get(displayNdx); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1273 | dc.disableSurfaceTrace(); |
| 1274 | } |
| 1275 | } |
| 1276 | |
| 1277 | void dumpDisplayContents(PrintWriter pw) { |
| 1278 | pw.println("WINDOW MANAGER DISPLAY CONTENTS (dumpsys window displays)"); |
| 1279 | if (mService.mDisplayReady) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 1280 | final int count = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1281 | for (int i = 0; i < count; ++i) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 1282 | final DisplayContent displayContent = mChildren.get(i); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1283 | displayContent.dump(" ", pw); |
| 1284 | } |
| 1285 | } else { |
| 1286 | pw.println(" NO DISPLAY"); |
| 1287 | } |
| 1288 | } |
| 1289 | |
| 1290 | void dumpLayoutNeededDisplayIds(PrintWriter pw) { |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 1291 | if (!isLayoutNeeded()) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1292 | return; |
| 1293 | } |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 1294 | pw.print(" mLayoutNeeded on displays="); |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 1295 | final int count = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1296 | for (int displayNdx = 0; displayNdx < count; ++displayNdx) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 1297 | final DisplayContent displayContent = mChildren.get(displayNdx); |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 1298 | if (displayContent.isLayoutNeeded()) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1299 | pw.print(displayContent.getDisplayId()); |
| 1300 | } |
| 1301 | } |
| 1302 | pw.println(); |
| 1303 | } |
| 1304 | |
| 1305 | void dumpWindowsNoHeader(PrintWriter pw, boolean dumpAll, ArrayList<WindowState> windows) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 1306 | final int numDisplays = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1307 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame^] | 1308 | final ReadOnlyWindowList windowList = mChildren.get(displayNdx).getReadOnlyWindowList(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1309 | for (int winNdx = windowList.size() - 1; winNdx >= 0; --winNdx) { |
| 1310 | final WindowState w = windowList.get(winNdx); |
| 1311 | if (windows == null || windows.contains(w)) { |
| 1312 | pw.println(" Window #" + winNdx + " " + w + ":"); |
| 1313 | w.dump(pw, " ", dumpAll || windows != null); |
| 1314 | } |
| 1315 | } |
| 1316 | } |
| 1317 | } |
Wale Ogunwale | ba51ca2 | 2016-09-23 06:06:54 -0700 | [diff] [blame] | 1318 | |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 1319 | void dumpTokens(PrintWriter pw, boolean dumpAll) { |
| 1320 | pw.println(" All tokens:"); |
| 1321 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
| 1322 | mChildren.get(i).dumpTokens(pw, dumpAll); |
| 1323 | } |
| 1324 | } |
| 1325 | |
Wale Ogunwale | ba51ca2 | 2016-09-23 06:06:54 -0700 | [diff] [blame] | 1326 | @Override |
| 1327 | String getName() { |
| 1328 | return "ROOT"; |
| 1329 | } |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1330 | } |