Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1 | package com.android.server.wm; |
| 2 | |
Jorim Jaggi | 275561a | 2016-02-23 10:11:02 -0500 | [diff] [blame] | 3 | import static android.app.ActivityManagerInternal.APP_TRANSITION_SAVED_SURFACE; |
| 4 | import static android.app.ActivityManagerInternal.APP_TRANSITION_STARTING_WINDOW; |
| 5 | import static android.app.ActivityManagerInternal.APP_TRANSITION_TIMEOUT; |
| 6 | import static android.app.ActivityManagerInternal.APP_TRANSITION_WINDOWS_DRAWN; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 7 | import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; |
| 8 | import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; |
| 9 | import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
| 10 | import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION; |
| 11 | import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; |
Chong Zhang | b58bbcc | 2016-03-23 11:57:36 -0700 | [diff] [blame] | 12 | import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 13 | import static android.view.WindowManager.LayoutParams.TYPE_DREAM; |
| 14 | import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 15 | import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG; |
| 16 | import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR; |
| 17 | import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; |
| 18 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM; |
| 19 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG; |
| 20 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT; |
| 21 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; |
Jorim Jaggi | 192086e | 2016-03-11 17:17:03 +0100 | [diff] [blame] | 22 | import static com.android.server.wm.AppWindowAnimator.PROLONG_ANIMATION_AT_START; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 23 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG; |
| 24 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE; |
| 25 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS; |
| 26 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT; |
| 27 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT_REPEATS; |
| 28 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION; |
| 29 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_POWER; |
| 30 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STARTING_WINDOW; |
| 31 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TOKEN_MOVEMENT; |
| 32 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY; |
| 33 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WALLPAPER_LIGHT; |
| 34 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_TRACE; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 35 | import static com.android.server.wm.WindowManagerDebugConfig.SHOW_LIGHT_TRANSACTIONS; |
| 36 | import static com.android.server.wm.WindowManagerDebugConfig.SHOW_TRANSACTIONS; |
Jorim Jaggi | 192086e | 2016-03-11 17:17:03 +0100 | [diff] [blame] | 37 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 38 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
Jorim Jaggi | 192086e | 2016-03-11 17:17:03 +0100 | [diff] [blame] | 39 | import static com.android.server.wm.WindowManagerService.H.DO_TRAVERSAL; |
| 40 | import static com.android.server.wm.WindowManagerService.H.NOTIFY_ACTIVITY_DRAWN; |
| 41 | import static com.android.server.wm.WindowManagerService.H.NOTIFY_APP_TRANSITION_STARTING; |
| 42 | import static com.android.server.wm.WindowManagerService.H.NOTIFY_STARTING_WINDOW_DRAWN; |
| 43 | import static com.android.server.wm.WindowManagerService.H.REPORT_LOSING_FOCUS; |
| 44 | import static com.android.server.wm.WindowManagerService.H.REPORT_WINDOWS_CHANGE; |
| 45 | import static com.android.server.wm.WindowManagerService.H.SEND_NEW_CONFIGURATION; |
| 46 | import static com.android.server.wm.WindowManagerService.H.UPDATE_DOCKED_STACK_DIVIDER; |
| 47 | import static com.android.server.wm.WindowManagerService.H.WINDOW_FREEZE_TIMEOUT; |
| 48 | import static com.android.server.wm.WindowManagerService.LAYOUT_REPEAT_THRESHOLD; |
| 49 | import static com.android.server.wm.WindowManagerService.MAX_ANIMATION_DURATION; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 50 | import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_PLACING_SURFACES; |
| 51 | import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE_SURFACES; |
| 52 | import static com.android.server.wm.WindowManagerService.WINDOWS_FREEZING_SCREENS_NONE; |
| 53 | |
| 54 | import android.graphics.Bitmap; |
| 55 | import android.graphics.Canvas; |
| 56 | import android.graphics.PixelFormat; |
| 57 | import android.graphics.Rect; |
| 58 | import android.os.Debug; |
| 59 | import android.os.PowerManager; |
| 60 | import android.os.RemoteException; |
| 61 | import android.os.SystemClock; |
| 62 | import android.os.Trace; |
| 63 | import android.provider.Settings; |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 64 | import android.util.ArraySet; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 65 | import android.util.Slog; |
| 66 | import android.view.Display; |
| 67 | import android.view.DisplayInfo; |
| 68 | import android.view.Surface; |
| 69 | import android.view.SurfaceControl; |
| 70 | import android.view.View; |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 71 | import android.view.WindowManager.LayoutParams; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 72 | import android.view.animation.Animation; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 73 | |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 74 | import java.io.PrintWriter; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 75 | import java.util.ArrayList; |
| 76 | |
| 77 | /** |
| 78 | * Positions windows and their surfaces. |
| 79 | * |
| 80 | * It sets positions of windows by calculating their frames and then applies this by positioning |
| 81 | * surfaces according to these frames. Z layer is still assigned withing WindowManagerService. |
| 82 | */ |
| 83 | class WindowSurfacePlacer { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 84 | private static final String TAG = TAG_WITH_CLASS_NAME ? "WindowSurfacePlacer" : TAG_WM; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 85 | private final WindowManagerService mService; |
| 86 | private final WallpaperController mWallpaperControllerLocked; |
| 87 | |
| 88 | private boolean mInLayout = false; |
| 89 | |
| 90 | /** Only do a maximum of 6 repeated layouts. After that quit */ |
| 91 | private int mLayoutRepeatCount; |
| 92 | |
| 93 | static final int SET_UPDATE_ROTATION = 1 << 0; |
| 94 | static final int SET_WALLPAPER_MAY_CHANGE = 1 << 1; |
| 95 | static final int SET_FORCE_HIDING_CHANGED = 1 << 2; |
| 96 | static final int SET_ORIENTATION_CHANGE_COMPLETE = 1 << 3; |
| 97 | static final int SET_TURN_ON_SCREEN = 1 << 4; |
| 98 | static final int SET_WALLPAPER_ACTION_PENDING = 1 << 5; |
| 99 | |
| 100 | boolean mWallpaperMayChange = false; |
| 101 | boolean mOrientationChangeComplete = true; |
| 102 | boolean mWallpaperActionPending = false; |
| 103 | |
| 104 | private boolean mWallpaperForceHidingChanged = false; |
| 105 | private Object mLastWindowFreezeSource = null; |
| 106 | private Session mHoldScreen = null; |
| 107 | private boolean mObscured = false; |
| 108 | private boolean mSyswin = false; |
| 109 | private float mScreenBrightness = -1; |
| 110 | private float mButtonBrightness = -1; |
| 111 | private long mUserActivityTimeout = -1; |
| 112 | private boolean mUpdateRotation = false; |
| 113 | private final Rect mTmpStartRect = new Rect(); |
Wale Ogunwale | b4ec0a3 | 2015-12-14 10:31:43 -0800 | [diff] [blame] | 114 | private final Rect mTmpContentRect = new Rect(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 115 | |
| 116 | // Set to true when the display contains content to show the user. |
| 117 | // When false, the display manager may choose to mirror or blank the display. |
| 118 | private boolean mDisplayHasContent = false; |
| 119 | |
| 120 | // Only set while traversing the default display based on its content. |
| 121 | // Affects the behavior of mirroring on secondary displays. |
| 122 | private boolean mObscureApplicationContentOnSecondaryDisplays = false; |
| 123 | |
| 124 | private float mPreferredRefreshRate = 0; |
| 125 | |
| 126 | private int mPreferredModeId = 0; |
| 127 | |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 128 | private boolean mTraversalScheduled; |
Jorim Jaggi | c402520 | 2015-10-22 16:43:34 +0200 | [diff] [blame] | 129 | private int mDeferDepth = 0; |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 130 | |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 131 | private static final class LayerAndToken { |
| 132 | public int layer; |
| 133 | public AppWindowToken token; |
| 134 | } |
| 135 | private final LayerAndToken mTmpLayerAndToken = new LayerAndToken(); |
| 136 | |
Jorim Jaggi | 3dac63a | 2016-03-01 12:37:07 +0100 | [diff] [blame] | 137 | private final ArrayList<SurfaceControl> mPendingDestroyingSurfaces = new ArrayList<>(); |
| 138 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 139 | public WindowSurfacePlacer(WindowManagerService service) { |
| 140 | mService = service; |
| 141 | mWallpaperControllerLocked = mService.mWallpaperControllerLocked; |
| 142 | } |
| 143 | |
Jorim Jaggi | c402520 | 2015-10-22 16:43:34 +0200 | [diff] [blame] | 144 | /** |
| 145 | * See {@link WindowManagerService#deferSurfaceLayout()} |
| 146 | */ |
| 147 | void deferLayout() { |
| 148 | mDeferDepth++; |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * See {@link WindowManagerService#continueSurfaceLayout()} |
| 153 | */ |
| 154 | void continueLayout() { |
| 155 | mDeferDepth--; |
| 156 | if (mDeferDepth <= 0) { |
| 157 | performSurfacePlacement(); |
| 158 | } |
| 159 | } |
| 160 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 161 | final void performSurfacePlacement() { |
Jorim Jaggi | c402520 | 2015-10-22 16:43:34 +0200 | [diff] [blame] | 162 | if (mDeferDepth > 0) { |
| 163 | return; |
| 164 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 165 | int loopCount = 6; |
| 166 | do { |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 167 | mTraversalScheduled = false; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 168 | performSurfacePlacementLoop(); |
| 169 | mService.mH.removeMessages(DO_TRAVERSAL); |
| 170 | loopCount--; |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 171 | } while (mTraversalScheduled && loopCount > 0); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 172 | mWallpaperActionPending = false; |
| 173 | } |
| 174 | |
| 175 | private void performSurfacePlacementLoop() { |
| 176 | if (mInLayout) { |
| 177 | if (DEBUG) { |
| 178 | throw new RuntimeException("Recursive call!"); |
| 179 | } |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 180 | Slog.w(TAG, "performLayoutAndPlaceSurfacesLocked called while in layout. Callers=" |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 181 | + Debug.getCallers(3)); |
| 182 | return; |
| 183 | } |
| 184 | |
| 185 | if (mService.mWaitingForConfig) { |
| 186 | // Our configuration has changed (most likely rotation), but we |
| 187 | // don't yet have the complete configuration to report to |
| 188 | // applications. Don't do any window layout until we have it. |
| 189 | return; |
| 190 | } |
| 191 | |
| 192 | if (!mService.mDisplayReady) { |
| 193 | // Not yet initialized, nothing to do. |
| 194 | return; |
| 195 | } |
| 196 | |
| 197 | Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "wmLayout"); |
| 198 | mInLayout = true; |
| 199 | |
| 200 | boolean recoveringMemory = false; |
| 201 | if (!mService.mForceRemoves.isEmpty()) { |
| 202 | recoveringMemory = true; |
| 203 | // Wait a little bit for things to settle down, and off we go. |
| 204 | while (!mService.mForceRemoves.isEmpty()) { |
| 205 | WindowState ws = mService.mForceRemoves.remove(0); |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 206 | Slog.i(TAG, "Force removing: " + ws); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 207 | mService.removeWindowInnerLocked(ws); |
| 208 | } |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 209 | Slog.w(TAG, "Due to memory failure, waiting a bit for next layout"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 210 | Object tmp = new Object(); |
| 211 | synchronized (tmp) { |
| 212 | try { |
| 213 | tmp.wait(250); |
| 214 | } catch (InterruptedException e) { |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | try { |
| 220 | performSurfacePlacementInner(recoveringMemory); |
| 221 | |
| 222 | mInLayout = false; |
| 223 | |
| 224 | if (mService.needsLayout()) { |
| 225 | if (++mLayoutRepeatCount < 6) { |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 226 | requestTraversal(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 227 | } else { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 228 | Slog.e(TAG, "Performed 6 layouts in a row. Skipping"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 229 | mLayoutRepeatCount = 0; |
| 230 | } |
| 231 | } else { |
| 232 | mLayoutRepeatCount = 0; |
| 233 | } |
| 234 | |
| 235 | if (mService.mWindowsChanged && !mService.mWindowChangeListeners.isEmpty()) { |
| 236 | mService.mH.removeMessages(REPORT_WINDOWS_CHANGE); |
| 237 | mService.mH.sendEmptyMessage(REPORT_WINDOWS_CHANGE); |
| 238 | } |
| 239 | } catch (RuntimeException e) { |
| 240 | mInLayout = false; |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 241 | Slog.wtf(TAG, "Unhandled exception while laying out windows", e); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER); |
| 245 | } |
| 246 | |
| 247 | void debugLayoutRepeats(final String msg, int pendingLayoutChanges) { |
| 248 | if (mLayoutRepeatCount >= LAYOUT_REPEAT_THRESHOLD) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 249 | Slog.v(TAG, "Layouts looping: " + msg + |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 250 | ", mPendingLayoutChanges = 0x" + Integer.toHexString(pendingLayoutChanges)); |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | // "Something has changed! Let's make it correct now." |
| 255 | private void performSurfacePlacementInner(boolean recoveringMemory) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 256 | if (DEBUG_WINDOW_TRACE) Slog.v(TAG, "performSurfacePlacementInner: entry. Called by " |
| 257 | + Debug.getCallers(3)); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 258 | |
| 259 | int i; |
| 260 | boolean updateInputWindowsNeeded = false; |
| 261 | |
| 262 | if (mService.mFocusMayChange) { |
| 263 | mService.mFocusMayChange = false; |
| 264 | updateInputWindowsNeeded = mService.updateFocusedWindowLocked( |
| 265 | UPDATE_FOCUS_WILL_PLACE_SURFACES, false /*updateInputWindows*/); |
| 266 | } |
| 267 | |
| 268 | // Initialize state of exiting tokens. |
| 269 | final int numDisplays = mService.mDisplayContents.size(); |
| 270 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
| 271 | final DisplayContent displayContent = mService.mDisplayContents.valueAt(displayNdx); |
| 272 | for (i=displayContent.mExitingTokens.size()-1; i>=0; i--) { |
| 273 | displayContent.mExitingTokens.get(i).hasVisible = false; |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | for (int stackNdx = mService.mStackIdToStack.size() - 1; stackNdx >= 0; --stackNdx) { |
| 278 | // Initialize state of exiting applications. |
| 279 | final AppTokenList exitingAppTokens = |
| 280 | mService.mStackIdToStack.valueAt(stackNdx).mExitingAppTokens; |
| 281 | for (int tokenNdx = exitingAppTokens.size() - 1; tokenNdx >= 0; --tokenNdx) { |
| 282 | exitingAppTokens.get(tokenNdx).hasVisible = false; |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | mHoldScreen = null; |
| 287 | mScreenBrightness = -1; |
| 288 | mButtonBrightness = -1; |
| 289 | mUserActivityTimeout = -1; |
| 290 | mObscureApplicationContentOnSecondaryDisplays = false; |
| 291 | |
| 292 | mService.mTransactionSequence++; |
| 293 | |
| 294 | final DisplayContent defaultDisplay = mService.getDefaultDisplayContentLocked(); |
| 295 | final DisplayInfo defaultInfo = defaultDisplay.getDisplayInfo(); |
| 296 | final int defaultDw = defaultInfo.logicalWidth; |
| 297 | final int defaultDh = defaultInfo.logicalHeight; |
| 298 | |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 299 | if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 300 | ">>> OPEN TRANSACTION performLayoutAndPlaceSurfaces"); |
| 301 | SurfaceControl.openTransaction(); |
| 302 | try { |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 303 | applySurfaceChangesTransaction(recoveringMemory, numDisplays, defaultDw, defaultDh); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 304 | } catch (RuntimeException e) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 305 | Slog.wtf(TAG, "Unhandled exception in Window Manager", e); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 306 | } finally { |
| 307 | SurfaceControl.closeTransaction(); |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 308 | if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 309 | "<<< CLOSE TRANSACTION performLayoutAndPlaceSurfaces"); |
| 310 | } |
| 311 | |
| 312 | final WindowList defaultWindows = defaultDisplay.getWindowList(); |
| 313 | |
| 314 | // If we are ready to perform an app transition, check through |
| 315 | // all of the app tokens to be shown and see if they are ready |
| 316 | // to go. |
| 317 | if (mService.mAppTransition.isReady()) { |
| 318 | defaultDisplay.pendingLayoutChanges |= handleAppTransitionReadyLocked(defaultWindows); |
| 319 | if (DEBUG_LAYOUT_REPEATS) |
| 320 | debugLayoutRepeats("after handleAppTransitionReadyLocked", |
| 321 | defaultDisplay.pendingLayoutChanges); |
| 322 | } |
| 323 | |
| 324 | if (!mService.mAnimator.mAppWindowAnimating && mService.mAppTransition.isRunning()) { |
| 325 | // We have finished the animation of an app transition. To do |
| 326 | // this, we have delayed a lot of operations like showing and |
| 327 | // hiding apps, moving apps in Z-order, etc. The app token list |
| 328 | // reflects the correct Z-order, but the window list may now |
| 329 | // be out of sync with it. So here we will just rebuild the |
| 330 | // entire app window list. Fun! |
| 331 | defaultDisplay.pendingLayoutChanges |= |
| 332 | mService.handleAnimatingStoppedAndTransitionLocked(); |
| 333 | if (DEBUG_LAYOUT_REPEATS) |
| 334 | debugLayoutRepeats("after handleAnimStopAndXitionLock", |
| 335 | defaultDisplay.pendingLayoutChanges); |
| 336 | } |
| 337 | |
| 338 | if (mWallpaperForceHidingChanged && defaultDisplay.pendingLayoutChanges == 0 |
| 339 | && !mService.mAppTransition.isReady()) { |
| 340 | // At this point, there was a window with a wallpaper that |
| 341 | // was force hiding other windows behind it, but now it |
| 342 | // is going away. This may be simple -- just animate |
| 343 | // away the wallpaper and its window -- or it may be |
| 344 | // hard -- the wallpaper now needs to be shown behind |
| 345 | // something that was hidden. |
| 346 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_LAYOUT; |
| 347 | if (DEBUG_LAYOUT_REPEATS) |
| 348 | debugLayoutRepeats("after animateAwayWallpaperLocked", |
| 349 | defaultDisplay.pendingLayoutChanges); |
| 350 | } |
| 351 | mWallpaperForceHidingChanged = false; |
| 352 | |
| 353 | if (mWallpaperMayChange) { |
| 354 | if (DEBUG_WALLPAPER_LIGHT) |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 355 | Slog.v(TAG, "Wallpaper may change! Adjusting"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 356 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER; |
| 357 | if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("WallpaperMayChange", |
| 358 | defaultDisplay.pendingLayoutChanges); |
| 359 | } |
| 360 | |
| 361 | if (mService.mFocusMayChange) { |
| 362 | mService.mFocusMayChange = false; |
| 363 | if (mService.updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES, |
| 364 | false /*updateInputWindows*/)) { |
| 365 | updateInputWindowsNeeded = true; |
| 366 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_ANIM; |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | if (mService.needsLayout()) { |
| 371 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_LAYOUT; |
| 372 | if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("mLayoutNeeded", |
| 373 | defaultDisplay.pendingLayoutChanges); |
| 374 | } |
| 375 | |
| 376 | for (i = mService.mResizingWindows.size() - 1; i >= 0; i--) { |
| 377 | WindowState win = mService.mResizingWindows.get(i); |
| 378 | if (win.mAppFreezing) { |
| 379 | // Don't remove this window until rotation has completed. |
| 380 | continue; |
| 381 | } |
Chong Zhang | db20b5f | 2015-10-23 14:01:43 -0700 | [diff] [blame] | 382 | // Discard the saved surface if window size is changed, it can't be reused. |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 383 | if (win.mAppToken != null) { |
| 384 | win.mAppToken.destroySavedSurfaces(); |
Chong Zhang | db20b5f | 2015-10-23 14:01:43 -0700 | [diff] [blame] | 385 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 386 | win.reportResized(); |
| 387 | mService.mResizingWindows.remove(i); |
| 388 | } |
| 389 | |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 390 | if (DEBUG_ORIENTATION && mService.mDisplayFrozen) Slog.v(TAG, |
| 391 | "With display frozen, orientationChangeComplete=" + mOrientationChangeComplete); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 392 | if (mOrientationChangeComplete) { |
| 393 | if (mService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_NONE) { |
| 394 | mService.mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_NONE; |
| 395 | mService.mLastFinishedFreezeSource = mLastWindowFreezeSource; |
| 396 | mService.mH.removeMessages(WINDOW_FREEZE_TIMEOUT); |
| 397 | } |
| 398 | mService.stopFreezingDisplayLocked(); |
| 399 | } |
| 400 | |
| 401 | // Destroy the surface of any windows that are no longer visible. |
Filip Gruszczynski | 19723a4 | 2015-11-25 15:01:48 -0800 | [diff] [blame] | 402 | boolean wallpaperDestroyed = false; |
| 403 | i = mService.mDestroySurface.size(); |
| 404 | if (i > 0) { |
| 405 | do { |
| 406 | i--; |
| 407 | WindowState win = mService.mDestroySurface.get(i); |
| 408 | win.mDestroying = false; |
| 409 | if (mService.mInputMethodWindow == win) { |
| 410 | mService.mInputMethodWindow = null; |
| 411 | } |
| 412 | if (mWallpaperControllerLocked.isWallpaperTarget(win)) { |
| 413 | wallpaperDestroyed = true; |
| 414 | } |
Robert Carr | 13f7be9e | 2015-12-02 18:39:45 -0800 | [diff] [blame] | 415 | win.destroyOrSaveSurface(); |
Filip Gruszczynski | 19723a4 | 2015-11-25 15:01:48 -0800 | [diff] [blame] | 416 | } while (i > 0); |
| 417 | mService.mDestroySurface.clear(); |
| 418 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 419 | |
| 420 | // Time to remove any exiting tokens? |
| 421 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
| 422 | final DisplayContent displayContent = mService.mDisplayContents.valueAt(displayNdx); |
| 423 | ArrayList<WindowToken> exitingTokens = displayContent.mExitingTokens; |
| 424 | for (i = exitingTokens.size() - 1; i >= 0; i--) { |
| 425 | WindowToken token = exitingTokens.get(i); |
| 426 | if (!token.hasVisible) { |
| 427 | exitingTokens.remove(i); |
| 428 | if (token.windowType == TYPE_WALLPAPER) { |
| 429 | mWallpaperControllerLocked.removeWallpaperToken(token); |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | // Time to remove any exiting applications? |
| 436 | for (int stackNdx = mService.mStackIdToStack.size() - 1; stackNdx >= 0; --stackNdx) { |
| 437 | // Initialize state of exiting applications. |
| 438 | final AppTokenList exitingAppTokens = |
| 439 | mService.mStackIdToStack.valueAt(stackNdx).mExitingAppTokens; |
| 440 | for (i = exitingAppTokens.size() - 1; i >= 0; i--) { |
| 441 | AppWindowToken token = exitingAppTokens.get(i); |
| 442 | if (!token.hasVisible && !mService.mClosingApps.contains(token) && |
| 443 | (!token.mIsExiting || token.allAppWindows.isEmpty())) { |
| 444 | // Make sure there is no animation running on this token, |
| 445 | // so any windows associated with it will be removed as |
| 446 | // soon as their animations are complete |
| 447 | token.mAppAnimator.clearAnimation(); |
| 448 | token.mAppAnimator.animating = false; |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 449 | if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, |
| 450 | "performLayout: App token exiting now removed" + token); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 451 | token.removeAppFromTaskLocked(); |
| 452 | } |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | if (wallpaperDestroyed) { |
| 457 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER; |
| 458 | defaultDisplay.layoutNeeded = true; |
| 459 | } |
| 460 | |
| 461 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
| 462 | final DisplayContent displayContent = mService.mDisplayContents.valueAt(displayNdx); |
| 463 | if (displayContent.pendingLayoutChanges != 0) { |
| 464 | displayContent.layoutNeeded = true; |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | // Finally update all input windows now that the window changes have stabilized. |
| 469 | mService.mInputMonitor.updateInputWindowsLw(true /*force*/); |
| 470 | |
| 471 | mService.setHoldScreenLocked(mHoldScreen); |
| 472 | if (!mService.mDisplayFrozen) { |
| 473 | if (mScreenBrightness < 0 || mScreenBrightness > 1.0f) { |
| 474 | mService.mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager(-1); |
| 475 | } else { |
| 476 | mService.mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager( |
| 477 | toBrightnessOverride(mScreenBrightness)); |
| 478 | } |
| 479 | if (mButtonBrightness < 0 |
| 480 | || mButtonBrightness > 1.0f) { |
| 481 | mService.mPowerManagerInternal.setButtonBrightnessOverrideFromWindowManager(-1); |
| 482 | } else { |
| 483 | mService.mPowerManagerInternal.setButtonBrightnessOverrideFromWindowManager( |
| 484 | toBrightnessOverride(mButtonBrightness)); |
| 485 | } |
| 486 | mService.mPowerManagerInternal.setUserActivityTimeoutOverrideFromWindowManager( |
| 487 | mUserActivityTimeout); |
| 488 | } |
| 489 | |
| 490 | if (mService.mTurnOnScreen) { |
| 491 | if (mService.mAllowTheaterModeWakeFromLayout |
| 492 | || Settings.Global.getInt(mService.mContext.getContentResolver(), |
| 493 | Settings.Global.THEATER_MODE_ON, 0) == 0) { |
| 494 | if (DEBUG_VISIBILITY || DEBUG_POWER) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 495 | Slog.v(TAG, "Turning screen on after layout!"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 496 | } |
| 497 | mService.mPowerManager.wakeUp(SystemClock.uptimeMillis(), |
| 498 | "android.server.wm:TURN_ON"); |
| 499 | } |
| 500 | mService.mTurnOnScreen = false; |
| 501 | } |
| 502 | |
| 503 | if (mUpdateRotation) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 504 | if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-rotate rotation"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 505 | if (mService.updateRotationUncheckedLocked(false)) { |
| 506 | mService.mH.sendEmptyMessage(SEND_NEW_CONFIGURATION); |
| 507 | } else { |
| 508 | mUpdateRotation = false; |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | if (mService.mWaitingForDrawnCallback != null || |
| 513 | (mOrientationChangeComplete && !defaultDisplay.layoutNeeded && |
| 514 | !mUpdateRotation)) { |
| 515 | mService.checkDrawnWindowsLocked(); |
| 516 | } |
| 517 | |
| 518 | final int N = mService.mPendingRemove.size(); |
| 519 | if (N > 0) { |
| 520 | if (mService.mPendingRemoveTmp.length < N) { |
| 521 | mService.mPendingRemoveTmp = new WindowState[N+10]; |
| 522 | } |
| 523 | mService.mPendingRemove.toArray(mService.mPendingRemoveTmp); |
| 524 | mService.mPendingRemove.clear(); |
| 525 | DisplayContentList displayList = new DisplayContentList(); |
| 526 | for (i = 0; i < N; i++) { |
| 527 | WindowState w = mService.mPendingRemoveTmp[i]; |
| 528 | mService.removeWindowInnerLocked(w); |
| 529 | final DisplayContent displayContent = w.getDisplayContent(); |
| 530 | if (displayContent != null && !displayList.contains(displayContent)) { |
| 531 | displayList.add(displayContent); |
| 532 | } |
| 533 | } |
| 534 | |
| 535 | for (DisplayContent displayContent : displayList) { |
Filip Gruszczynski | 92e432c | 2015-12-15 19:17:09 -0800 | [diff] [blame] | 536 | mService.mLayersController.assignLayersLocked(displayContent.getWindowList()); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 537 | displayContent.layoutNeeded = true; |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | // Remove all deferred displays stacks, tasks, and activities. |
| 542 | for (int displayNdx = mService.mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) { |
| 543 | mService.mDisplayContents.valueAt(displayNdx).checkForDeferredActions(); |
| 544 | } |
| 545 | |
| 546 | if (updateInputWindowsNeeded) { |
| 547 | mService.mInputMonitor.updateInputWindowsLw(false /*force*/); |
| 548 | } |
Chong Zhang | b15758a | 2015-11-17 12:12:03 -0800 | [diff] [blame] | 549 | mService.setFocusTaskRegionLocked(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 550 | |
| 551 | // Check to see if we are now in a state where the screen should |
| 552 | // be enabled, because the window obscured flags have changed. |
| 553 | mService.enableScreenIfNeededLocked(); |
| 554 | |
| 555 | mService.scheduleAnimationLocked(); |
Jorim Jaggi | 3dac63a | 2016-03-01 12:37:07 +0100 | [diff] [blame] | 556 | mService.mWindowPlacerLocked.destroyPendingSurfaces(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 557 | |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 558 | if (DEBUG_WINDOW_TRACE) Slog.e(TAG, |
Wale Ogunwale | 69cf50f | 2015-11-13 11:08:36 -0800 | [diff] [blame] | 559 | "performSurfacePlacementInner exit: animating=" + mService.mAnimator.isAnimating()); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 560 | } |
| 561 | |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 562 | private void applySurfaceChangesTransaction(boolean recoveringMemory, int numDisplays, |
| 563 | int defaultDw, int defaultDh) { |
| 564 | if (mService.mWatermark != null) { |
| 565 | mService.mWatermark.positionSurface(defaultDw, defaultDh); |
| 566 | } |
| 567 | if (mService.mStrictModeFlash != null) { |
| 568 | mService.mStrictModeFlash.positionSurface(defaultDw, defaultDh); |
| 569 | } |
| 570 | if (mService.mCircularDisplayMask != null) { |
| 571 | mService.mCircularDisplayMask.positionSurface(defaultDw, defaultDh, |
| 572 | mService.mRotation); |
| 573 | } |
| 574 | if (mService.mEmulatorDisplayOverlay != null) { |
| 575 | mService.mEmulatorDisplayOverlay.positionSurface(defaultDw, defaultDh, |
| 576 | mService.mRotation); |
| 577 | } |
| 578 | |
| 579 | boolean focusDisplayed = false; |
| 580 | |
| 581 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
| 582 | final DisplayContent displayContent = mService.mDisplayContents.valueAt(displayNdx); |
| 583 | boolean updateAllDrawn = false; |
| 584 | WindowList windows = displayContent.getWindowList(); |
| 585 | DisplayInfo displayInfo = displayContent.getDisplayInfo(); |
| 586 | final int displayId = displayContent.getDisplayId(); |
| 587 | final int dw = displayInfo.logicalWidth; |
| 588 | final int dh = displayInfo.logicalHeight; |
| 589 | final int innerDw = displayInfo.appWidth; |
| 590 | final int innerDh = displayInfo.appHeight; |
| 591 | final boolean isDefaultDisplay = (displayId == Display.DEFAULT_DISPLAY); |
| 592 | |
| 593 | // Reset for each display. |
| 594 | mDisplayHasContent = false; |
| 595 | mPreferredRefreshRate = 0; |
| 596 | mPreferredModeId = 0; |
| 597 | |
| 598 | int repeats = 0; |
| 599 | do { |
| 600 | repeats++; |
| 601 | if (repeats > 6) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 602 | Slog.w(TAG, "Animation repeat aborted after too many iterations"); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 603 | displayContent.layoutNeeded = false; |
| 604 | break; |
| 605 | } |
| 606 | |
| 607 | if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats( |
| 608 | "On entry to LockedInner", displayContent.pendingLayoutChanges); |
| 609 | |
| 610 | if ((displayContent.pendingLayoutChanges & FINISH_LAYOUT_REDO_WALLPAPER) != 0 && |
| 611 | mWallpaperControllerLocked.adjustWallpaperWindows()) { |
Filip Gruszczynski | 92e432c | 2015-12-15 19:17:09 -0800 | [diff] [blame] | 612 | mService.mLayersController.assignLayersLocked(windows); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 613 | displayContent.layoutNeeded = true; |
| 614 | } |
| 615 | |
| 616 | if (isDefaultDisplay |
| 617 | && (displayContent.pendingLayoutChanges & FINISH_LAYOUT_REDO_CONFIG) != 0) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 618 | if (DEBUG_LAYOUT) Slog.v(TAG, "Computing new config from layout"); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 619 | if (mService.updateOrientationFromAppTokensLocked(true)) { |
| 620 | displayContent.layoutNeeded = true; |
| 621 | mService.mH.sendEmptyMessage(SEND_NEW_CONFIGURATION); |
| 622 | } |
| 623 | } |
| 624 | |
| 625 | if ((displayContent.pendingLayoutChanges & FINISH_LAYOUT_REDO_LAYOUT) != 0) { |
| 626 | displayContent.layoutNeeded = true; |
| 627 | } |
| 628 | |
| 629 | // FIRST LOOP: Perform a layout, if needed. |
| 630 | if (repeats < LAYOUT_REPEAT_THRESHOLD) { |
| 631 | performLayoutLockedInner(displayContent, repeats == 1, |
| 632 | false /* updateInputWindows */); |
| 633 | } else { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 634 | Slog.w(TAG, "Layout repeat skipped after too many iterations"); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 635 | } |
| 636 | |
| 637 | // FIRST AND ONE HALF LOOP: Make WindowManagerPolicy think |
| 638 | // it is animating. |
| 639 | displayContent.pendingLayoutChanges = 0; |
| 640 | |
| 641 | if (isDefaultDisplay) { |
| 642 | mService.mPolicy.beginPostLayoutPolicyLw(dw, dh); |
| 643 | for (int i = windows.size() - 1; i >= 0; i--) { |
| 644 | WindowState w = windows.get(i); |
| 645 | if (w.mHasSurface) { |
| 646 | mService.mPolicy.applyPostLayoutPolicyLw(w, w.mAttrs, |
| 647 | w.mAttachedWindow); |
| 648 | } |
| 649 | } |
| 650 | displayContent.pendingLayoutChanges |= |
| 651 | mService.mPolicy.finishPostLayoutPolicyLw(); |
| 652 | if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("after finishPostLayoutPolicyLw", |
| 653 | displayContent.pendingLayoutChanges); |
| 654 | } |
| 655 | } while (displayContent.pendingLayoutChanges != 0); |
| 656 | |
| 657 | mObscured = false; |
| 658 | mSyswin = false; |
| 659 | displayContent.resetDimming(); |
| 660 | |
| 661 | // Only used if default window |
| 662 | final boolean someoneLosingFocus = !mService.mLosingFocus.isEmpty(); |
| 663 | |
| 664 | for (int i = windows.size() - 1; i >= 0; i--) { |
| 665 | WindowState w = windows.get(i); |
Robert Carr | 0d00c2e | 2016-02-29 17:45:02 -0800 | [diff] [blame] | 666 | final Task task = w.getTask(); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 667 | final boolean obscuredChanged = w.mObscured != mObscured; |
| 668 | |
| 669 | // Update effect. |
| 670 | w.mObscured = mObscured; |
| 671 | if (!mObscured) { |
Chong Zhang | 0abb20f | 2015-11-19 14:17:31 -0800 | [diff] [blame] | 672 | handleNotObscuredLocked(w, displayInfo); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 673 | } |
| 674 | |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 675 | w.applyDimLayerIfNeeded(); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 676 | |
| 677 | if (isDefaultDisplay && obscuredChanged |
| 678 | && mWallpaperControllerLocked.isWallpaperTarget(w) && w.isVisibleLw()) { |
| 679 | // This is the wallpaper target and its obscured state |
| 680 | // changed... make sure the current wallaper's visibility |
| 681 | // has been updated accordingly. |
| 682 | mWallpaperControllerLocked.updateWallpaperVisibility(); |
| 683 | } |
| 684 | |
| 685 | final WindowStateAnimator winAnimator = w.mWinAnimator; |
| 686 | |
| 687 | // If the window has moved due to its containing content frame changing, then |
Filip Gruszczynski | f52dd20 | 2015-11-15 20:36:38 -0800 | [diff] [blame] | 688 | // notify the listeners and optionally animate it. Simply checking a change of |
| 689 | // position is not enough, because being move due to dock divider is not a trigger |
| 690 | // for animation. |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 691 | if (w.hasMoved()) { |
| 692 | // Frame has moved, containing content frame has also moved, and we're not |
| 693 | // currently animating... let's do something. |
| 694 | final int left = w.mFrame.left; |
| 695 | final int top = w.mFrame.top; |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 696 | final boolean adjustedForMinimizedDockOrIme = task != null |
| 697 | && (task.mStack.isAdjustedForMinimizedDockedStack() |
| 698 | || task.mStack.isAdjustedForIme()); |
Filip Gruszczynski | f52dd20 | 2015-11-15 20:36:38 -0800 | [diff] [blame] | 699 | if ((w.mAttrs.privateFlags & PRIVATE_FLAG_NO_MOVE_ANIMATION) == 0 |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 700 | && !w.isDragResizing() && !adjustedForMinimizedDockOrIme |
Jorim Jaggi | 192086e | 2016-03-11 17:17:03 +0100 | [diff] [blame] | 701 | && (task == null || !w.getTask().mStack.getFreezeMovementAnimations()) |
| 702 | && !w.mWinAnimator.mLastHidden) { |
Filip Gruszczynski | f52dd20 | 2015-11-15 20:36:38 -0800 | [diff] [blame] | 703 | winAnimator.setMoveAnimation(left, top); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 704 | } |
| 705 | |
| 706 | //TODO (multidisplay): Accessibility supported only for the default display. |
| 707 | if (mService.mAccessibilityController != null |
| 708 | && displayId == Display.DEFAULT_DISPLAY) { |
| 709 | mService.mAccessibilityController.onSomeWindowResizedOrMovedLocked(); |
| 710 | } |
| 711 | |
| 712 | try { |
| 713 | w.mClient.moved(left, top); |
| 714 | } catch (RemoteException e) { |
| 715 | } |
Jorim Jaggi | 192086e | 2016-03-11 17:17:03 +0100 | [diff] [blame] | 716 | w.mMovedByResize = false; |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 717 | } |
| 718 | |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 719 | //Slog.i(TAG, "Window " + this + " clearing mContentChanged - done placing"); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 720 | w.mContentChanged = false; |
| 721 | |
| 722 | // Moved from updateWindowsAndWallpaperLocked(). |
| 723 | if (w.mHasSurface) { |
| 724 | // Take care of the window being ready to display. |
| 725 | final boolean committed = winAnimator.commitFinishDrawingLocked(); |
| 726 | if (isDefaultDisplay && committed) { |
| 727 | if (w.mAttrs.type == TYPE_DREAM) { |
| 728 | // HACK: When a dream is shown, it may at that |
| 729 | // point hide the lock screen. So we need to |
| 730 | // redo the layout to let the phone window manager |
| 731 | // make this happen. |
| 732 | displayContent.pendingLayoutChanges |= |
| 733 | FINISH_LAYOUT_REDO_LAYOUT; |
| 734 | if (DEBUG_LAYOUT_REPEATS) { |
| 735 | debugLayoutRepeats("dream and commitFinishDrawingLocked true", |
| 736 | displayContent.pendingLayoutChanges); |
| 737 | } |
| 738 | } |
| 739 | if ((w.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) { |
| 740 | if (DEBUG_WALLPAPER_LIGHT) |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 741 | Slog.v(TAG, "First draw done in potential wallpaper target " + w); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 742 | mWallpaperMayChange = true; |
| 743 | displayContent.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER; |
| 744 | if (DEBUG_LAYOUT_REPEATS) { |
| 745 | debugLayoutRepeats("wallpaper and commitFinishDrawingLocked true", |
| 746 | displayContent.pendingLayoutChanges); |
| 747 | } |
| 748 | } |
| 749 | } |
Filip Gruszczynski | c46f41c | 2016-01-05 11:29:21 -0800 | [diff] [blame] | 750 | if (!winAnimator.isAnimating()) { |
| 751 | // Updates the shown frame before we set up the surface. This is needed |
| 752 | // because the resizing could change the top-left position (in addition to |
| 753 | // size) of the window. setSurfaceBoundariesLocked uses mShownPosition to |
| 754 | // position the surface. We only apply it to windows that aren't animating, |
| 755 | // because we depend on the animation to calculate the correct shown frame |
| 756 | // on the next animation step. |
| 757 | winAnimator.computeShownFrameLocked(); |
| 758 | } |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 759 | winAnimator.setSurfaceBoundariesLocked(recoveringMemory); |
| 760 | } |
| 761 | |
| 762 | final AppWindowToken atoken = w.mAppToken; |
| 763 | if (DEBUG_STARTING_WINDOW && atoken != null && w == atoken.startingWindow) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 764 | Slog.d(TAG, "updateWindows: starting " + w |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 765 | + " isOnScreen=" + w.isOnScreen() + " allDrawn=" + atoken.allDrawn |
| 766 | + " freezingScreen=" + atoken.mAppAnimator.freezingScreen); |
| 767 | } |
| 768 | if (atoken != null && (!atoken.allDrawn || atoken.mAppAnimator.freezingScreen)) { |
| 769 | if (atoken.lastTransactionSequence != mService.mTransactionSequence) { |
| 770 | atoken.lastTransactionSequence = mService.mTransactionSequence; |
| 771 | atoken.numInterestingWindows = atoken.numDrawnWindows = 0; |
| 772 | atoken.startingDisplayed = false; |
| 773 | } |
| 774 | if ((w.isOnScreenIgnoringKeyguard() |
| 775 | || winAnimator.mAttrType == TYPE_BASE_APPLICATION) |
Wale Ogunwale | c48a354 | 2016-02-19 15:18:45 -0800 | [diff] [blame] | 776 | && !w.mAnimatingExit && !w.mDestroying) { |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 777 | if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 778 | Slog.v(TAG, "Eval win " + w + ": isDrawn=" |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 779 | + w.isDrawnLw() |
| 780 | + ", isAnimating=" + winAnimator.isAnimating()); |
| 781 | if (!w.isDrawnLw()) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 782 | Slog.v(TAG, "Not displayed: s=" |
Robert Carr | e6a8351 | 2015-11-03 16:09:21 -0800 | [diff] [blame] | 783 | + winAnimator.mSurfaceController |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 784 | + " pv=" + w.mPolicyVisibility |
| 785 | + " mDrawState=" + winAnimator.drawStateToString() |
| 786 | + " ah=" + w.mAttachedHidden |
| 787 | + " th=" + atoken.hiddenRequested |
| 788 | + " a=" + winAnimator.mAnimating); |
| 789 | } |
| 790 | } |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 791 | if (w != atoken.startingWindow) { |
| 792 | if (!w.mAppDied && |
| 793 | (!atoken.mAppAnimator.freezingScreen || !w.mAppFreezing)) { |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 794 | atoken.numInterestingWindows++; |
| 795 | if (w.isDrawnLw()) { |
| 796 | atoken.numDrawnWindows++; |
| 797 | if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 798 | Slog.v(TAG, "tokenMayBeDrawn: " + atoken |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 799 | + " freezingScreen=" |
| 800 | + atoken.mAppAnimator.freezingScreen |
| 801 | + " mAppFreezing=" + w.mAppFreezing); |
| 802 | updateAllDrawn = true; |
| 803 | } |
| 804 | } |
| 805 | } else if (w.isDrawnLw()) { |
Jorim Jaggi | 275561a | 2016-02-23 10:11:02 -0500 | [diff] [blame] | 806 | mService.mH.sendEmptyMessage(NOTIFY_STARTING_WINDOW_DRAWN); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 807 | atoken.startingDisplayed = true; |
| 808 | } |
| 809 | } |
| 810 | } |
| 811 | |
| 812 | if (isDefaultDisplay && someoneLosingFocus && w == mService.mCurrentFocus |
| 813 | && w.isDisplayedLw()) { |
| 814 | focusDisplayed = true; |
| 815 | } |
| 816 | |
| 817 | mService.updateResizingWindows(w); |
| 818 | } |
| 819 | |
| 820 | mService.mDisplayManagerInternal.setDisplayProperties(displayId, |
| 821 | mDisplayHasContent, |
| 822 | mPreferredRefreshRate, |
| 823 | mPreferredModeId, |
| 824 | true /* inTraversal, must call performTraversalInTrans... below */); |
| 825 | |
| 826 | mService.getDisplayContentLocked(displayId).stopDimmingIfNeeded(); |
| 827 | |
| 828 | if (updateAllDrawn) { |
| 829 | updateAllDrawnLocked(displayContent); |
| 830 | } |
| 831 | } |
| 832 | |
| 833 | if (focusDisplayed) { |
| 834 | mService.mH.sendEmptyMessage(REPORT_LOSING_FOCUS); |
| 835 | } |
| 836 | |
| 837 | // Give the display manager a chance to adjust properties |
| 838 | // like display rotation if it needs to. |
| 839 | mService.mDisplayManagerInternal.performTraversalInTransactionFromWindowManager(); |
| 840 | } |
| 841 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 842 | boolean isInLayout() { |
| 843 | return mInLayout; |
| 844 | } |
| 845 | |
| 846 | final void performLayoutLockedInner(final DisplayContent displayContent, |
| 847 | boolean initial, boolean updateInputWindows) { |
| 848 | if (!displayContent.layoutNeeded) { |
| 849 | return; |
| 850 | } |
| 851 | displayContent.layoutNeeded = false; |
| 852 | WindowList windows = displayContent.getWindowList(); |
| 853 | boolean isDefaultDisplay = displayContent.isDefaultDisplay; |
| 854 | |
| 855 | DisplayInfo displayInfo = displayContent.getDisplayInfo(); |
| 856 | final int dw = displayInfo.logicalWidth; |
| 857 | final int dh = displayInfo.logicalHeight; |
| 858 | |
| 859 | if (mService.mInputConsumer != null) { |
| 860 | mService.mInputConsumer.layout(dw, dh); |
| 861 | } |
| 862 | |
Vladislav Kaznacheev | 0d50d86 | 2016-03-29 15:43:28 -0700 | [diff] [blame] | 863 | if (mService.mWallpaperInputConsumer != null) { |
| 864 | mService.mWallpaperInputConsumer.layout(dw, dh); |
| 865 | } |
| 866 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 867 | final int N = windows.size(); |
| 868 | int i; |
| 869 | |
| 870 | if (DEBUG_LAYOUT) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 871 | Slog.v(TAG, "-------------------------------------"); |
| 872 | Slog.v(TAG, "performLayout: needed=" |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 873 | + displayContent.layoutNeeded + " dw=" + dw + " dh=" + dh); |
| 874 | } |
| 875 | |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 876 | mService.mPolicy.beginLayoutLw(isDefaultDisplay, dw, dh, mService.mRotation, |
| 877 | mService.mCurConfiguration.uiMode); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 878 | if (isDefaultDisplay) { |
| 879 | // Not needed on non-default displays. |
| 880 | mService.mSystemDecorLayer = mService.mPolicy.getSystemDecorLayerLw(); |
| 881 | mService.mScreenRect.set(0, 0, dw, dh); |
| 882 | } |
| 883 | |
Wale Ogunwale | b4ec0a3 | 2015-12-14 10:31:43 -0800 | [diff] [blame] | 884 | mService.mPolicy.getContentRectLw(mTmpContentRect); |
| 885 | displayContent.resize(mTmpContentRect); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 886 | |
| 887 | int seq = mService.mLayoutSeq+1; |
| 888 | if (seq < 0) seq = 0; |
| 889 | mService.mLayoutSeq = seq; |
| 890 | |
| 891 | boolean behindDream = false; |
| 892 | |
| 893 | // First perform layout of any root windows (not attached |
| 894 | // to another window). |
| 895 | int topAttached = -1; |
| 896 | for (i = N-1; i >= 0; i--) { |
| 897 | final WindowState win = windows.get(i); |
| 898 | |
| 899 | // Don't do layout of a window if it is not visible, or |
| 900 | // soon won't be visible, to avoid wasting time and funky |
| 901 | // changes while a window is animating away. |
| 902 | final boolean gone = (behindDream && mService.mPolicy.canBeForceHidden(win, win.mAttrs)) |
| 903 | || win.isGoneForLayoutLw(); |
| 904 | |
| 905 | if (DEBUG_LAYOUT && !win.mLayoutAttached) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 906 | Slog.v(TAG, "1ST PASS " + win |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 907 | + ": gone=" + gone + " mHaveFrame=" + win.mHaveFrame |
| 908 | + " mLayoutAttached=" + win.mLayoutAttached |
| 909 | + " screen changed=" + win.isConfigChanged()); |
| 910 | final AppWindowToken atoken = win.mAppToken; |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 911 | if (gone) Slog.v(TAG, " GONE: mViewVisibility=" |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 912 | + win.mViewVisibility + " mRelayoutCalled=" |
| 913 | + win.mRelayoutCalled + " hidden=" |
| 914 | + win.mRootToken.hidden + " hiddenRequested=" |
| 915 | + (atoken != null && atoken.hiddenRequested) |
| 916 | + " mAttachedHidden=" + win.mAttachedHidden); |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 917 | else Slog.v(TAG, " VIS: mViewVisibility=" |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 918 | + win.mViewVisibility + " mRelayoutCalled=" |
| 919 | + win.mRelayoutCalled + " hidden=" |
| 920 | + win.mRootToken.hidden + " hiddenRequested=" |
| 921 | + (atoken != null && atoken.hiddenRequested) |
| 922 | + " mAttachedHidden=" + win.mAttachedHidden); |
| 923 | } |
| 924 | |
| 925 | // If this view is GONE, then skip it -- keep the current |
| 926 | // frame, and let the caller know so they can ignore it |
| 927 | // if they want. (We do the normal layout for INVISIBLE |
| 928 | // windows, since that means "perform layout as normal, |
| 929 | // just don't display"). |
| 930 | if (!gone || !win.mHaveFrame || win.mLayoutNeeded |
| 931 | || ((win.isConfigChanged() || win.setInsetsChanged()) && |
| 932 | ((win.mAttrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 || |
| 933 | (win.mHasSurface && win.mAppToken != null && |
| 934 | win.mAppToken.layoutConfigChanges)))) { |
| 935 | if (!win.mLayoutAttached) { |
| 936 | if (initial) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 937 | //Slog.i(TAG, "Window " + this + " clearing mContentChanged - initial"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 938 | win.mContentChanged = false; |
| 939 | } |
| 940 | if (win.mAttrs.type == TYPE_DREAM) { |
| 941 | // Don't layout windows behind a dream, so that if it |
| 942 | // does stuff like hide the status bar we won't get a |
| 943 | // bad transition when it goes away. |
| 944 | behindDream = true; |
| 945 | } |
| 946 | win.mLayoutNeeded = false; |
| 947 | win.prelayout(); |
| 948 | mService.mPolicy.layoutWindowLw(win, null); |
| 949 | win.mLayoutSeq = seq; |
Chong Zhang | 4c9ba52a | 2015-11-10 18:36:33 -0800 | [diff] [blame] | 950 | |
| 951 | // Window frames may have changed. Update dim layer with the new bounds. |
| 952 | final Task task = win.getTask(); |
| 953 | if (task != null) { |
| 954 | displayContent.mDimLayerController.updateDimLayer(task); |
| 955 | } |
| 956 | |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 957 | if (DEBUG_LAYOUT) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 958 | " LAYOUT: mFrame=" |
| 959 | + win.mFrame + " mContainingFrame=" |
| 960 | + win.mContainingFrame + " mDisplayFrame=" |
| 961 | + win.mDisplayFrame); |
| 962 | } else { |
| 963 | if (topAttached < 0) topAttached = i; |
| 964 | } |
| 965 | } |
| 966 | } |
| 967 | |
| 968 | boolean attachedBehindDream = false; |
| 969 | |
| 970 | // Now perform layout of attached windows, which usually |
| 971 | // depend on the position of the window they are attached to. |
| 972 | // XXX does not deal with windows that are attached to windows |
| 973 | // that are themselves attached. |
| 974 | for (i = topAttached; i >= 0; i--) { |
| 975 | final WindowState win = windows.get(i); |
| 976 | |
| 977 | if (win.mLayoutAttached) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 978 | if (DEBUG_LAYOUT) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 979 | "2ND PASS " + win + " mHaveFrame=" + win.mHaveFrame + " mViewVisibility=" |
| 980 | + win.mViewVisibility + " mRelayoutCalled=" + win.mRelayoutCalled); |
| 981 | // If this view is GONE, then skip it -- keep the current |
| 982 | // frame, and let the caller know so they can ignore it |
| 983 | // if they want. (We do the normal layout for INVISIBLE |
| 984 | // windows, since that means "perform layout as normal, |
| 985 | // just don't display"). |
| 986 | if (attachedBehindDream && mService.mPolicy.canBeForceHidden(win, win.mAttrs)) { |
| 987 | continue; |
| 988 | } |
| 989 | if ((win.mViewVisibility != View.GONE && win.mRelayoutCalled) |
| 990 | || !win.mHaveFrame || win.mLayoutNeeded) { |
| 991 | if (initial) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 992 | //Slog.i(TAG, "Window " + this + " clearing mContentChanged - initial"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 993 | win.mContentChanged = false; |
| 994 | } |
| 995 | win.mLayoutNeeded = false; |
| 996 | win.prelayout(); |
| 997 | mService.mPolicy.layoutWindowLw(win, win.mAttachedWindow); |
| 998 | win.mLayoutSeq = seq; |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 999 | if (DEBUG_LAYOUT) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1000 | " LAYOUT: mFrame=" + win.mFrame + " mContainingFrame=" |
| 1001 | + win.mContainingFrame + " mDisplayFrame=" + win.mDisplayFrame); |
| 1002 | } |
| 1003 | } else if (win.mAttrs.type == TYPE_DREAM) { |
| 1004 | // Don't layout windows behind a dream, so that if it |
| 1005 | // does stuff like hide the status bar we won't get a |
| 1006 | // bad transition when it goes away. |
| 1007 | attachedBehindDream = behindDream; |
| 1008 | } |
| 1009 | } |
| 1010 | |
Chong Zhang | 4c9ba52a | 2015-11-10 18:36:33 -0800 | [diff] [blame] | 1011 | // Window frames may have changed. Tell the input dispatcher about it. |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1012 | mService.mInputMonitor.setUpdateInputWindowsNeededLw(); |
| 1013 | if (updateInputWindows) { |
| 1014 | mService.mInputMonitor.updateInputWindowsLw(false /*force*/); |
| 1015 | } |
| 1016 | |
| 1017 | mService.mPolicy.finishLayoutLw(); |
Jorim Jaggi | 61f39a7 | 2015-10-29 16:54:18 +0100 | [diff] [blame] | 1018 | mService.mH.sendEmptyMessage(UPDATE_DOCKED_STACK_DIVIDER); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1019 | } |
| 1020 | |
| 1021 | /** |
| 1022 | * @param windows List of windows on default display. |
| 1023 | * @return bitmap indicating if another pass through layout must be made. |
| 1024 | */ |
| 1025 | private int handleAppTransitionReadyLocked(WindowList windows) { |
| 1026 | int appsCount = mService.mOpeningApps.size(); |
| 1027 | if (!transitionGoodToGo(appsCount)) { |
| 1028 | return 0; |
| 1029 | } |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1030 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "**** GOOD TO GO"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1031 | int transit = mService.mAppTransition.getAppTransition(); |
| 1032 | if (mService.mSkipAppTransitionAnimation) { |
| 1033 | transit = AppTransition.TRANSIT_UNSET; |
| 1034 | } |
| 1035 | mService.mSkipAppTransitionAnimation = false; |
| 1036 | mService.mNoAnimationNotifyOnTransitionFinished.clear(); |
| 1037 | |
| 1038 | mService.mH.removeMessages(APP_TRANSITION_TIMEOUT); |
| 1039 | |
| 1040 | mService.rebuildAppWindowListLocked(); |
| 1041 | |
| 1042 | mWallpaperMayChange = false; |
| 1043 | |
| 1044 | // The top-most window will supply the layout params, |
| 1045 | // and we will determine it below. |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1046 | LayoutParams animLp = null; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1047 | int bestAnimLayer = -1; |
| 1048 | boolean fullscreenAnim = false; |
| 1049 | boolean voiceInteraction = false; |
| 1050 | |
| 1051 | final WindowState lowerWallpaperTarget = |
| 1052 | mWallpaperControllerLocked.getLowerWallpaperTarget(); |
| 1053 | final WindowState upperWallpaperTarget = |
| 1054 | mWallpaperControllerLocked.getUpperWallpaperTarget(); |
| 1055 | |
| 1056 | boolean openingAppHasWallpaper = false; |
| 1057 | boolean closingAppHasWallpaper = false; |
| 1058 | final AppWindowToken lowerWallpaperAppToken; |
| 1059 | final AppWindowToken upperWallpaperAppToken; |
| 1060 | if (lowerWallpaperTarget == null) { |
| 1061 | lowerWallpaperAppToken = upperWallpaperAppToken = null; |
| 1062 | } else { |
| 1063 | lowerWallpaperAppToken = lowerWallpaperTarget.mAppToken; |
| 1064 | upperWallpaperAppToken = upperWallpaperTarget.mAppToken; |
| 1065 | } |
| 1066 | |
| 1067 | int i; |
| 1068 | // Do a first pass through the tokens for two |
| 1069 | // things: |
| 1070 | // (1) Determine if both the closing and opening |
| 1071 | // app token sets are wallpaper targets, in which |
| 1072 | // case special animations are needed |
| 1073 | // (since the wallpaper needs to stay static |
| 1074 | // behind them). |
| 1075 | // (2) Find the layout params of the top-most |
| 1076 | // application window in the tokens, which is |
| 1077 | // what will control the animation theme. |
| 1078 | final int closingAppsCount = mService.mClosingApps.size(); |
| 1079 | appsCount = closingAppsCount + mService.mOpeningApps.size(); |
| 1080 | for (i = 0; i < appsCount; i++) { |
| 1081 | final AppWindowToken wtoken; |
| 1082 | if (i < closingAppsCount) { |
| 1083 | wtoken = mService.mClosingApps.valueAt(i); |
| 1084 | if (wtoken == lowerWallpaperAppToken || wtoken == upperWallpaperAppToken) { |
| 1085 | closingAppHasWallpaper = true; |
| 1086 | } |
| 1087 | } else { |
| 1088 | wtoken = mService.mOpeningApps.valueAt(i - closingAppsCount); |
| 1089 | if (wtoken == lowerWallpaperAppToken || wtoken == upperWallpaperAppToken) { |
| 1090 | openingAppHasWallpaper = true; |
| 1091 | } |
| 1092 | } |
| 1093 | |
| 1094 | voiceInteraction |= wtoken.voiceInteraction; |
| 1095 | |
| 1096 | if (wtoken.appFullscreen) { |
| 1097 | WindowState ws = wtoken.findMainWindow(); |
| 1098 | if (ws != null) { |
| 1099 | animLp = ws.mAttrs; |
| 1100 | bestAnimLayer = ws.mLayer; |
| 1101 | fullscreenAnim = true; |
| 1102 | } |
| 1103 | } else if (!fullscreenAnim) { |
| 1104 | WindowState ws = wtoken.findMainWindow(); |
| 1105 | if (ws != null) { |
| 1106 | if (ws.mLayer > bestAnimLayer) { |
| 1107 | animLp = ws.mAttrs; |
| 1108 | bestAnimLayer = ws.mLayer; |
| 1109 | } |
| 1110 | } |
| 1111 | } |
| 1112 | } |
| 1113 | |
| 1114 | transit = maybeUpdateTransitToWallpaper(transit, openingAppHasWallpaper, |
| 1115 | closingAppHasWallpaper, lowerWallpaperTarget, upperWallpaperTarget); |
| 1116 | |
| 1117 | // If all closing windows are obscured, then there is |
| 1118 | // no need to do an animation. This is the case, for |
| 1119 | // example, when this transition is being done behind |
| 1120 | // the lock screen. |
| 1121 | if (!mService.mPolicy.allowAppAnimationsLw()) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1122 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1123 | "Animations disallowed by keyguard or dream."); |
| 1124 | animLp = null; |
| 1125 | } |
| 1126 | |
| 1127 | processApplicationsAnimatingInPlace(transit); |
| 1128 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1129 | mTmpLayerAndToken.token = null; |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1130 | handleClosingApps(transit, animLp, voiceInteraction, mTmpLayerAndToken); |
| 1131 | final AppWindowToken topClosingApp = mTmpLayerAndToken.token; |
| 1132 | final int topClosingLayer = mTmpLayerAndToken.layer; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1133 | |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1134 | final AppWindowToken topOpeningApp = handleOpeningApps(transit, |
| 1135 | animLp, voiceInteraction, topClosingLayer); |
| 1136 | |
| 1137 | final AppWindowAnimator openingAppAnimator = (topOpeningApp == null) ? null : |
| 1138 | topOpeningApp.mAppAnimator; |
| 1139 | final AppWindowAnimator closingAppAnimator = (topClosingApp == null) ? null : |
| 1140 | topClosingApp.mAppAnimator; |
| 1141 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1142 | mService.mAppTransition.goodToGo(openingAppAnimator, closingAppAnimator, |
| 1143 | mService.mOpeningApps, mService.mClosingApps); |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1144 | mService.mAppTransition.postAnimationCallback(); |
| 1145 | mService.mAppTransition.clear(); |
| 1146 | |
| 1147 | mService.mOpeningApps.clear(); |
| 1148 | mService.mClosingApps.clear(); |
| 1149 | |
| 1150 | // This has changed the visibility of windows, so perform |
| 1151 | // a new layout to get them all up-to-date. |
| 1152 | mService.getDefaultDisplayContentLocked().layoutNeeded = true; |
| 1153 | |
| 1154 | // TODO(multidisplay): IMEs are only supported on the default display. |
| 1155 | if (windows == mService.getDefaultWindowListLocked() |
| 1156 | && !mService.moveInputMethodWindowsIfNeededLocked(true)) { |
Filip Gruszczynski | 92e432c | 2015-12-15 19:17:09 -0800 | [diff] [blame] | 1157 | mService.mLayersController.assignLayersLocked(windows); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1158 | } |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1159 | mService.updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES, |
| 1160 | true /*updateInputWindows*/); |
| 1161 | mService.mFocusMayChange = false; |
| 1162 | mService.notifyActivityDrawnForKeyguard(); |
| 1163 | return FINISH_LAYOUT_REDO_LAYOUT | FINISH_LAYOUT_REDO_CONFIG; |
| 1164 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1165 | |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1166 | private AppWindowToken handleOpeningApps(int transit, LayoutParams animLp, |
| 1167 | boolean voiceInteraction, int topClosingLayer) { |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1168 | AppWindowToken topOpeningApp = null; |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1169 | final int appsCount = mService.mOpeningApps.size(); |
| 1170 | for (int i = 0; i < appsCount; i++) { |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1171 | AppWindowToken wtoken = mService.mOpeningApps.valueAt(i); |
| 1172 | final AppWindowAnimator appAnimator = wtoken.mAppAnimator; |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1173 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Now opening app" + wtoken); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1174 | |
| 1175 | if (!appAnimator.usingTransferredAnimation) { |
| 1176 | appAnimator.clearThumbnail(); |
Chong Zhang | 65d15d0 | 2016-03-14 13:59:32 -0700 | [diff] [blame] | 1177 | appAnimator.setNullAnimation(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1178 | } |
| 1179 | wtoken.inPendingTransaction = false; |
Chong Zhang | eb22e8e | 2016-01-20 19:52:22 -0800 | [diff] [blame] | 1180 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1181 | if (!mService.setTokenVisibilityLocked( |
| 1182 | wtoken, animLp, true, transit, false, voiceInteraction)){ |
| 1183 | // This token isn't going to be animating. Add it to the list of tokens to |
| 1184 | // be notified of app transition complete since the notification will not be |
| 1185 | // sent be the app window animator. |
| 1186 | mService.mNoAnimationNotifyOnTransitionFinished.add(wtoken.token); |
| 1187 | } |
| 1188 | wtoken.updateReportedVisibilityLocked(); |
| 1189 | wtoken.waitingToShow = false; |
| 1190 | |
| 1191 | appAnimator.mAllAppWinAnimators.clear(); |
| 1192 | final int windowsCount = wtoken.allAppWindows.size(); |
| 1193 | for (int j = 0; j < windowsCount; j++) { |
| 1194 | appAnimator.mAllAppWinAnimators.add(wtoken.allAppWindows.get(j).mWinAnimator); |
| 1195 | } |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1196 | if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, |
Filip Gruszczynski | 974eb3d | 2015-10-23 17:33:11 -0700 | [diff] [blame] | 1197 | ">>> OPEN TRANSACTION handleAppTransitionReadyLocked()"); |
| 1198 | SurfaceControl.openTransaction(); |
| 1199 | try { |
Wale Ogunwale | 69cf50f | 2015-11-13 11:08:36 -0800 | [diff] [blame] | 1200 | mService.mAnimator.orAnimating(appAnimator.showAllWindowsLocked()); |
Filip Gruszczynski | 974eb3d | 2015-10-23 17:33:11 -0700 | [diff] [blame] | 1201 | } finally { |
| 1202 | SurfaceControl.closeTransaction(); |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1203 | if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, |
Filip Gruszczynski | 974eb3d | 2015-10-23 17:33:11 -0700 | [diff] [blame] | 1204 | "<<< CLOSE TRANSACTION handleAppTransitionReadyLocked()"); |
| 1205 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1206 | mService.mAnimator.mAppWindowAnimating |= appAnimator.isAnimating(); |
| 1207 | |
| 1208 | int topOpeningLayer = 0; |
| 1209 | if (animLp != null) { |
| 1210 | int layer = -1; |
| 1211 | for (int j = 0; j < wtoken.windows.size(); j++) { |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 1212 | final WindowState win = wtoken.windows.get(j); |
Wale Ogunwale | c48a354 | 2016-02-19 15:18:45 -0800 | [diff] [blame] | 1213 | // Clearing the mAnimatingExit flag before entering animation. It will be set to true |
Filip Gruszczynski | 78a08ee | 2015-11-08 18:04:32 -0800 | [diff] [blame] | 1214 | // if app window is removed, or window relayout to invisible. We don't want to |
| 1215 | // clear it out for windows that get replaced, because the animation depends on |
| 1216 | // the flag to remove the replaced window. |
Robert Carr | 7fed68d | 2016-01-19 21:24:57 -0800 | [diff] [blame] | 1217 | // |
Wale Ogunwale | c48a354 | 2016-02-19 15:18:45 -0800 | [diff] [blame] | 1218 | // We also don't clear the mAnimatingExit flag for windows which have the |
Robert Carr | 7fed68d | 2016-01-19 21:24:57 -0800 | [diff] [blame] | 1219 | // mRemoveOnExit flag. This indicates an explicit remove request has been issued |
| 1220 | // by the client. We should let animation proceed and not clear this flag or |
| 1221 | // they won't eventually be removed by WindowStateAnimator#finishExit. |
| 1222 | if (!win.mWillReplaceWindow && !win.mRemoveOnExit) { |
Wale Ogunwale | c48a354 | 2016-02-19 15:18:45 -0800 | [diff] [blame] | 1223 | win.mAnimatingExit = false; |
Filip Gruszczynski | 78a08ee | 2015-11-08 18:04:32 -0800 | [diff] [blame] | 1224 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1225 | if (win.mWinAnimator.mAnimLayer > layer) { |
| 1226 | layer = win.mWinAnimator.mAnimLayer; |
| 1227 | } |
| 1228 | } |
| 1229 | if (topOpeningApp == null || layer > topOpeningLayer) { |
| 1230 | topOpeningApp = wtoken; |
| 1231 | topOpeningLayer = layer; |
| 1232 | } |
| 1233 | } |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1234 | if (mService.mAppTransition.isNextAppTransitionThumbnailUp()) { |
| 1235 | createThumbnailAppAnimator(transit, wtoken, topOpeningLayer, topClosingLayer); |
| 1236 | } |
Jorim Jaggi | 192086e | 2016-03-11 17:17:03 +0100 | [diff] [blame] | 1237 | if (mService.mAppTransition.getAppTransition() |
| 1238 | == AppTransition.TRANSIT_DOCK_TASK_FROM_RECENTS) { |
| 1239 | appAnimator.startProlongAnimation(PROLONG_ANIMATION_AT_START); |
| 1240 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1241 | } |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1242 | return topOpeningApp; |
| 1243 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1244 | |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1245 | private void handleClosingApps(int transit, LayoutParams animLp, boolean voiceInteraction, |
| 1246 | LayerAndToken layerAndToken) { |
| 1247 | final int appsCount; |
| 1248 | appsCount = mService.mClosingApps.size(); |
| 1249 | for (int i = 0; i < appsCount; i++) { |
| 1250 | AppWindowToken wtoken = mService.mClosingApps.valueAt(i); |
| 1251 | final AppWindowAnimator appAnimator = wtoken.mAppAnimator; |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1252 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Now closing app " + wtoken); |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1253 | appAnimator.clearThumbnail(); |
Chong Zhang | 65d15d0 | 2016-03-14 13:59:32 -0700 | [diff] [blame] | 1254 | appAnimator.setNullAnimation(); |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1255 | wtoken.inPendingTransaction = false; |
| 1256 | mService.setTokenVisibilityLocked(wtoken, animLp, false, transit, false, |
| 1257 | voiceInteraction); |
| 1258 | wtoken.updateReportedVisibilityLocked(); |
| 1259 | // Force the allDrawn flag, because we want to start |
| 1260 | // this guy's animations regardless of whether it's |
| 1261 | // gotten drawn. |
| 1262 | wtoken.allDrawn = true; |
| 1263 | wtoken.deferClearAllDrawn = false; |
| 1264 | // Ensure that apps that are mid-starting are also scheduled to have their |
| 1265 | // starting windows removed after the animation is complete |
Wale Ogunwale | c48a354 | 2016-02-19 15:18:45 -0800 | [diff] [blame] | 1266 | if (wtoken.startingWindow != null && !wtoken.startingWindow.mAnimatingExit) { |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1267 | mService.scheduleRemoveStartingWindowLocked(wtoken); |
| 1268 | } |
| 1269 | mService.mAnimator.mAppWindowAnimating |= appAnimator.isAnimating(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1270 | |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1271 | if (animLp != null) { |
| 1272 | int layer = -1; |
| 1273 | for (int j = 0; j < wtoken.windows.size(); j++) { |
| 1274 | WindowState win = wtoken.windows.get(j); |
| 1275 | if (win.mWinAnimator.mAnimLayer > layer) { |
| 1276 | layer = win.mWinAnimator.mAnimLayer; |
| 1277 | } |
| 1278 | } |
| 1279 | if (layerAndToken.token == null || layer > layerAndToken.layer) { |
| 1280 | layerAndToken.token = wtoken; |
| 1281 | layerAndToken.layer = layer; |
| 1282 | } |
| 1283 | } |
| 1284 | if (mService.mAppTransition.isNextAppTransitionThumbnailDown()) { |
| 1285 | createThumbnailAppAnimator(transit, wtoken, 0, layerAndToken.layer); |
| 1286 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1287 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1288 | } |
| 1289 | |
| 1290 | private boolean transitionGoodToGo(int appsCount) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1291 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1292 | "Checking " + appsCount + " opening apps (frozen=" |
| 1293 | + mService.mDisplayFrozen + " timeout=" |
| 1294 | + mService.mAppTransition.isTimeout() + ")..."); |
Jorim Jaggi | 275561a | 2016-02-23 10:11:02 -0500 | [diff] [blame] | 1295 | int reason = APP_TRANSITION_TIMEOUT; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1296 | if (!mService.mAppTransition.isTimeout()) { |
| 1297 | for (int i = 0; i < appsCount; i++) { |
| 1298 | AppWindowToken wtoken = mService.mOpeningApps.valueAt(i); |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1299 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1300 | "Check opening app=" + wtoken + ": allDrawn=" |
| 1301 | + wtoken.allDrawn + " startingDisplayed=" |
| 1302 | + wtoken.startingDisplayed + " startingMoved=" |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 1303 | + wtoken.startingMoved + " isRelaunching()=" |
| 1304 | + wtoken.isRelaunching()); |
| 1305 | |
| 1306 | if (wtoken.isRelaunching()) { |
| 1307 | return false; |
| 1308 | } |
Chong Zhang | db20b5f | 2015-10-23 14:01:43 -0700 | [diff] [blame] | 1309 | |
Jorim Jaggi | 275561a | 2016-02-23 10:11:02 -0500 | [diff] [blame] | 1310 | final boolean drawnBeforeRestoring = wtoken.allDrawn; |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 1311 | wtoken.restoreSavedSurfaces(); |
| 1312 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1313 | if (!wtoken.allDrawn && !wtoken.startingDisplayed && !wtoken.startingMoved) { |
| 1314 | return false; |
| 1315 | } |
Jorim Jaggi | 275561a | 2016-02-23 10:11:02 -0500 | [diff] [blame] | 1316 | if (wtoken.allDrawn) { |
| 1317 | reason = drawnBeforeRestoring ? APP_TRANSITION_WINDOWS_DRAWN |
| 1318 | : APP_TRANSITION_SAVED_SURFACE; |
| 1319 | } else { |
| 1320 | reason = APP_TRANSITION_STARTING_WINDOW; |
| 1321 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1322 | } |
| 1323 | |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1324 | // We also need to wait for the specs to be fetched, if needed. |
| 1325 | if (mService.mAppTransition.isFetchingAppTransitionsSpecs()) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1326 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "isFetchingAppTransitionSpecs=true"); |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1327 | return false; |
| 1328 | } |
| 1329 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1330 | // If the wallpaper is visible, we need to check it's ready too. |
Jorim Jaggi | 275561a | 2016-02-23 10:11:02 -0500 | [diff] [blame] | 1331 | boolean wallpaperReady = !mWallpaperControllerLocked.isWallpaperVisible() || |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1332 | mWallpaperControllerLocked.wallpaperTransitionReady(); |
Jorim Jaggi | 275561a | 2016-02-23 10:11:02 -0500 | [diff] [blame] | 1333 | if (wallpaperReady) { |
| 1334 | mService.mH.obtainMessage(NOTIFY_APP_TRANSITION_STARTING, reason, 0).sendToTarget(); |
| 1335 | return true; |
| 1336 | } |
| 1337 | return false; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1338 | } |
Jorim Jaggi | 275561a | 2016-02-23 10:11:02 -0500 | [diff] [blame] | 1339 | mService.mH.obtainMessage(NOTIFY_APP_TRANSITION_STARTING, reason, 0).sendToTarget(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1340 | return true; |
| 1341 | } |
| 1342 | |
| 1343 | private int maybeUpdateTransitToWallpaper(int transit, boolean openingAppHasWallpaper, |
| 1344 | boolean closingAppHasWallpaper, WindowState lowerWallpaperTarget, |
| 1345 | WindowState upperWallpaperTarget) { |
| 1346 | // if wallpaper is animating in or out set oldWallpaper to null else to wallpaper |
| 1347 | final WindowState wallpaperTarget = mWallpaperControllerLocked.getWallpaperTarget(); |
| 1348 | final WindowState oldWallpaper = |
| 1349 | mWallpaperControllerLocked.isWallpaperTargetAnimating() |
| 1350 | ? null : wallpaperTarget; |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1351 | final ArraySet<AppWindowToken> openingApps = mService.mOpeningApps; |
| 1352 | final ArraySet<AppWindowToken> closingApps = mService.mClosingApps; |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1353 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1354 | "New wallpaper target=" + wallpaperTarget |
| 1355 | + ", oldWallpaper=" + oldWallpaper |
| 1356 | + ", lower target=" + lowerWallpaperTarget |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1357 | + ", upper target=" + upperWallpaperTarget |
| 1358 | + ", openingApps=" + openingApps |
| 1359 | + ", closingApps=" + closingApps); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1360 | mService.mAnimateWallpaperWithTarget = false; |
| 1361 | if (closingAppHasWallpaper && openingAppHasWallpaper) { |
| 1362 | if (DEBUG_APP_TRANSITIONS) |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1363 | Slog.v(TAG, "Wallpaper animation!"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1364 | switch (transit) { |
| 1365 | case AppTransition.TRANSIT_ACTIVITY_OPEN: |
| 1366 | case AppTransition.TRANSIT_TASK_OPEN: |
| 1367 | case AppTransition.TRANSIT_TASK_TO_FRONT: |
| 1368 | transit = AppTransition.TRANSIT_WALLPAPER_INTRA_OPEN; |
| 1369 | break; |
| 1370 | case AppTransition.TRANSIT_ACTIVITY_CLOSE: |
| 1371 | case AppTransition.TRANSIT_TASK_CLOSE: |
| 1372 | case AppTransition.TRANSIT_TASK_TO_BACK: |
| 1373 | transit = AppTransition.TRANSIT_WALLPAPER_INTRA_CLOSE; |
| 1374 | break; |
| 1375 | } |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1376 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1377 | "New transit: " + AppTransition.appTransitionToString(transit)); |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1378 | } else if (oldWallpaper != null && !mService.mOpeningApps.isEmpty() |
| 1379 | && !openingApps.contains(oldWallpaper.mAppToken) |
| 1380 | && closingApps.contains(oldWallpaper.mAppToken)) { |
| 1381 | // We are transitioning from an activity with a wallpaper to one without. |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1382 | transit = AppTransition.TRANSIT_WALLPAPER_CLOSE; |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1383 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1384 | "New transit away from wallpaper: " |
| 1385 | + AppTransition.appTransitionToString(transit)); |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1386 | } else if (wallpaperTarget != null && wallpaperTarget.isVisibleLw() && |
| 1387 | openingApps.contains(wallpaperTarget.mAppToken)) { |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1388 | // We are transitioning from an activity without |
| 1389 | // a wallpaper to now showing the wallpaper |
| 1390 | transit = AppTransition.TRANSIT_WALLPAPER_OPEN; |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1391 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1392 | "New transit into wallpaper: " |
| 1393 | + AppTransition.appTransitionToString(transit)); |
| 1394 | } else { |
| 1395 | mService.mAnimateWallpaperWithTarget = true; |
| 1396 | } |
| 1397 | return transit; |
| 1398 | } |
| 1399 | |
| 1400 | /** |
| 1401 | * @param w WindowState this method is applied to. |
Chong Zhang | 0abb20f | 2015-11-19 14:17:31 -0800 | [diff] [blame] | 1402 | * @param dispInfo info of the display that the window's obscuring state is checked against. |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1403 | */ |
Chong Zhang | 0abb20f | 2015-11-19 14:17:31 -0800 | [diff] [blame] | 1404 | private void handleNotObscuredLocked(final WindowState w, final DisplayInfo dispInfo) { |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1405 | final LayoutParams attrs = w.mAttrs; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1406 | final int attrFlags = attrs.flags; |
| 1407 | final boolean canBeSeen = w.isDisplayedLw(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1408 | |
Chong Zhang | 0abb20f | 2015-11-19 14:17:31 -0800 | [diff] [blame] | 1409 | if (canBeSeen && w.isObscuringFullscreen(dispInfo)) { |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1410 | // This window completely covers everything behind it, |
| 1411 | // so we want to leave all of them as undimmed (for |
| 1412 | // performance reasons). |
| 1413 | mObscured = true; |
| 1414 | } |
| 1415 | |
| 1416 | if (w.mHasSurface) { |
| 1417 | if ((attrFlags&FLAG_KEEP_SCREEN_ON) != 0) { |
| 1418 | mHoldScreen = w.mSession; |
| 1419 | } |
| 1420 | if (!mSyswin && w.mAttrs.screenBrightness >= 0 |
| 1421 | && mScreenBrightness < 0) { |
| 1422 | mScreenBrightness = w.mAttrs.screenBrightness; |
| 1423 | } |
| 1424 | if (!mSyswin && w.mAttrs.buttonBrightness >= 0 |
| 1425 | && mButtonBrightness < 0) { |
| 1426 | mButtonBrightness = w.mAttrs.buttonBrightness; |
| 1427 | } |
| 1428 | if (!mSyswin && w.mAttrs.userActivityTimeout >= 0 |
| 1429 | && mUserActivityTimeout < 0) { |
| 1430 | mUserActivityTimeout = w.mAttrs.userActivityTimeout; |
| 1431 | } |
| 1432 | |
| 1433 | final int type = attrs.type; |
| 1434 | if (canBeSeen |
| 1435 | && (type == TYPE_SYSTEM_DIALOG |
| 1436 | || type == TYPE_SYSTEM_ERROR |
| 1437 | || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0)) { |
| 1438 | mSyswin = true; |
| 1439 | } |
| 1440 | |
| 1441 | if (canBeSeen) { |
| 1442 | // This function assumes that the contents of the default display are |
| 1443 | // processed first before secondary displays. |
| 1444 | final DisplayContent displayContent = w.getDisplayContent(); |
| 1445 | if (displayContent != null && displayContent.isDefaultDisplay) { |
| 1446 | // While a dream or keyguard is showing, obscure ordinary application |
| 1447 | // content on secondary displays (by forcibly enabling mirroring unless |
| 1448 | // there is other content we want to show) but still allow opaque |
| 1449 | // keyguard dialogs to be shown. |
| 1450 | if (type == TYPE_DREAM || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
| 1451 | mObscureApplicationContentOnSecondaryDisplays = true; |
| 1452 | } |
| 1453 | mDisplayHasContent = true; |
| 1454 | } else if (displayContent != null && |
| 1455 | (!mObscureApplicationContentOnSecondaryDisplays |
| 1456 | || (mObscured && type == TYPE_KEYGUARD_DIALOG))) { |
| 1457 | // Allow full screen keyguard presentation dialogs to be seen. |
| 1458 | mDisplayHasContent = true; |
| 1459 | } |
| 1460 | if (mPreferredRefreshRate == 0 |
| 1461 | && w.mAttrs.preferredRefreshRate != 0) { |
| 1462 | mPreferredRefreshRate = w.mAttrs.preferredRefreshRate; |
| 1463 | } |
| 1464 | if (mPreferredModeId == 0 |
| 1465 | && w.mAttrs.preferredDisplayModeId != 0) { |
| 1466 | mPreferredModeId = w.mAttrs.preferredDisplayModeId; |
| 1467 | } |
| 1468 | } |
| 1469 | } |
| 1470 | } |
| 1471 | |
| 1472 | private void updateAllDrawnLocked(DisplayContent displayContent) { |
| 1473 | // See if any windows have been drawn, so they (and others |
| 1474 | // associated with them) can now be shown. |
| 1475 | ArrayList<TaskStack> stacks = displayContent.getStacks(); |
| 1476 | for (int stackNdx = stacks.size() - 1; stackNdx >= 0; --stackNdx) { |
| 1477 | final ArrayList<Task> tasks = stacks.get(stackNdx).getTasks(); |
| 1478 | for (int taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) { |
| 1479 | final AppTokenList tokens = tasks.get(taskNdx).mAppTokens; |
| 1480 | for (int tokenNdx = tokens.size() - 1; tokenNdx >= 0; --tokenNdx) { |
| 1481 | final AppWindowToken wtoken = tokens.get(tokenNdx); |
| 1482 | if (!wtoken.allDrawn) { |
| 1483 | int numInteresting = wtoken.numInterestingWindows; |
| 1484 | if (numInteresting > 0 && wtoken.numDrawnWindows >= numInteresting) { |
| 1485 | if (DEBUG_VISIBILITY) |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1486 | Slog.v(TAG, "allDrawn: " + wtoken |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1487 | + " interesting=" + numInteresting |
| 1488 | + " drawn=" + wtoken.numDrawnWindows); |
| 1489 | wtoken.allDrawn = true; |
| 1490 | // Force an additional layout pass where WindowStateAnimator# |
| 1491 | // commitFinishDrawingLocked() will call performShowLocked(). |
| 1492 | displayContent.layoutNeeded = true; |
| 1493 | mService.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, |
| 1494 | wtoken.token).sendToTarget(); |
| 1495 | } |
| 1496 | } |
| 1497 | } |
| 1498 | } |
| 1499 | } |
| 1500 | } |
| 1501 | |
| 1502 | private static int toBrightnessOverride(float value) { |
| 1503 | return (int)(value * PowerManager.BRIGHTNESS_ON); |
| 1504 | } |
| 1505 | |
| 1506 | private void processApplicationsAnimatingInPlace(int transit) { |
| 1507 | if (transit == AppTransition.TRANSIT_TASK_IN_PLACE) { |
| 1508 | // Find the focused window |
| 1509 | final WindowState win = mService.findFocusedWindowLocked( |
| 1510 | mService.getDefaultDisplayContentLocked()); |
| 1511 | if (win != null) { |
| 1512 | final AppWindowToken wtoken = win.mAppToken; |
| 1513 | final AppWindowAnimator appAnimator = wtoken.mAppAnimator; |
| 1514 | if (DEBUG_APP_TRANSITIONS) |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1515 | Slog.v(TAG, "Now animating app in place " + wtoken); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1516 | appAnimator.clearThumbnail(); |
Chong Zhang | 65d15d0 | 2016-03-14 13:59:32 -0700 | [diff] [blame] | 1517 | appAnimator.setNullAnimation(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1518 | mService.updateTokenInPlaceLocked(wtoken, transit); |
| 1519 | wtoken.updateReportedVisibilityLocked(); |
| 1520 | |
| 1521 | appAnimator.mAllAppWinAnimators.clear(); |
| 1522 | final int N = wtoken.allAppWindows.size(); |
| 1523 | for (int j = 0; j < N; j++) { |
| 1524 | appAnimator.mAllAppWinAnimators.add(wtoken.allAppWindows.get(j).mWinAnimator); |
| 1525 | } |
| 1526 | mService.mAnimator.mAppWindowAnimating |= appAnimator.isAnimating(); |
Wale Ogunwale | 69cf50f | 2015-11-13 11:08:36 -0800 | [diff] [blame] | 1527 | mService.mAnimator.orAnimating(appAnimator.showAllWindowsLocked()); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1528 | } |
| 1529 | } |
| 1530 | } |
| 1531 | |
| 1532 | private void createThumbnailAppAnimator(int transit, AppWindowToken appToken, |
| 1533 | int openingLayer, int closingLayer) { |
| 1534 | AppWindowAnimator openingAppAnimator = (appToken == null) ? null : appToken.mAppAnimator; |
| 1535 | if (openingAppAnimator == null || openingAppAnimator.animation == null) { |
| 1536 | return; |
| 1537 | } |
| 1538 | final int taskId = appToken.mTask.mTaskId; |
| 1539 | Bitmap thumbnailHeader = mService.mAppTransition.getAppTransitionThumbnailHeader(taskId); |
| 1540 | if (thumbnailHeader == null || thumbnailHeader.getConfig() == Bitmap.Config.ALPHA_8) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1541 | if (DEBUG_APP_TRANSITIONS) Slog.d(TAG, "No thumbnail header bitmap for: " + taskId); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1542 | return; |
| 1543 | } |
| 1544 | // This thumbnail animation is very special, we need to have |
| 1545 | // an extra surface with the thumbnail included with the animation. |
| 1546 | Rect dirty = new Rect(0, 0, thumbnailHeader.getWidth(), thumbnailHeader.getHeight()); |
| 1547 | try { |
| 1548 | // TODO(multi-display): support other displays |
| 1549 | final DisplayContent displayContent = mService.getDefaultDisplayContentLocked(); |
| 1550 | final Display display = displayContent.getDisplay(); |
| 1551 | final DisplayInfo displayInfo = displayContent.getDisplayInfo(); |
| 1552 | |
| 1553 | // Create a new surface for the thumbnail |
| 1554 | SurfaceControl surfaceControl = new SurfaceControl(mService.mFxSession, |
| 1555 | "thumbnail anim", dirty.width(), dirty.height(), |
| 1556 | PixelFormat.TRANSLUCENT, SurfaceControl.HIDDEN); |
| 1557 | surfaceControl.setLayerStack(display.getLayerStack()); |
| 1558 | if (SHOW_TRANSACTIONS) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1559 | Slog.i(TAG, " THUMBNAIL " + surfaceControl + ": CREATE"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1560 | } |
| 1561 | |
| 1562 | // Draw the thumbnail onto the surface |
| 1563 | Surface drawSurface = new Surface(); |
| 1564 | drawSurface.copyFrom(surfaceControl); |
| 1565 | Canvas c = drawSurface.lockCanvas(dirty); |
| 1566 | c.drawBitmap(thumbnailHeader, 0, 0, null); |
| 1567 | drawSurface.unlockCanvasAndPost(c); |
| 1568 | drawSurface.release(); |
| 1569 | |
| 1570 | // Get the thumbnail animation |
| 1571 | Animation anim; |
| 1572 | if (mService.mAppTransition.isNextThumbnailTransitionAspectScaled()) { |
| 1573 | // If this is a multi-window scenario, we use the windows frame as |
| 1574 | // destination of the thumbnail header animation. If this is a full screen |
| 1575 | // window scenario, we use the whole display as the target. |
| 1576 | WindowState win = appToken.findMainWindow(); |
| 1577 | Rect appRect = win != null ? win.getContentFrameLw() : |
| 1578 | new Rect(0, 0, displayInfo.appWidth, displayInfo.appHeight); |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 1579 | Rect insets = win != null ? win.mContentInsets : null; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1580 | // For the new aspect-scaled transition, we want it to always show |
| 1581 | // above the animating opening/closing window, and we want to |
| 1582 | // synchronize its thumbnail surface with the surface for the |
| 1583 | // open/close animation (only on the way down) |
| 1584 | anim = mService.mAppTransition.createThumbnailAspectScaleAnimationLocked(appRect, |
Jorim Jaggi | 0907200 | 2016-03-25 16:48:42 -0700 | [diff] [blame] | 1585 | insets, thumbnailHeader, taskId, mService.mCurConfiguration.orientation); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1586 | openingAppAnimator.thumbnailForceAboveLayer = Math.max(openingLayer, closingLayer); |
| 1587 | openingAppAnimator.deferThumbnailDestruction = |
| 1588 | !mService.mAppTransition.isNextThumbnailTransitionScaleUp(); |
| 1589 | } else { |
| 1590 | anim = mService.mAppTransition.createThumbnailScaleAnimationLocked( |
| 1591 | displayInfo.appWidth, displayInfo.appHeight, transit, thumbnailHeader); |
| 1592 | } |
| 1593 | anim.restrictDuration(MAX_ANIMATION_DURATION); |
| 1594 | anim.scaleCurrentDuration(mService.getTransitionAnimationScaleLocked()); |
| 1595 | |
| 1596 | openingAppAnimator.thumbnail = surfaceControl; |
| 1597 | openingAppAnimator.thumbnailLayer = openingLayer; |
| 1598 | openingAppAnimator.thumbnailAnimation = anim; |
| 1599 | mService.mAppTransition.getNextAppTransitionStartRect(taskId, mTmpStartRect); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1600 | } catch (Surface.OutOfResourcesException e) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1601 | Slog.e(TAG, "Can't allocate thumbnail/Canvas surface w=" |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1602 | + dirty.width() + " h=" + dirty.height(), e); |
| 1603 | openingAppAnimator.clearThumbnail(); |
| 1604 | } |
| 1605 | } |
| 1606 | |
| 1607 | boolean copyAnimToLayoutParamsLocked() { |
| 1608 | boolean doRequest = false; |
| 1609 | |
| 1610 | final int bulkUpdateParams = mService.mAnimator.mBulkUpdateParams; |
| 1611 | if ((bulkUpdateParams & SET_UPDATE_ROTATION) != 0) { |
| 1612 | mUpdateRotation = true; |
| 1613 | doRequest = true; |
| 1614 | } |
| 1615 | if ((bulkUpdateParams & SET_WALLPAPER_MAY_CHANGE) != 0) { |
| 1616 | mWallpaperMayChange = true; |
| 1617 | doRequest = true; |
| 1618 | } |
| 1619 | if ((bulkUpdateParams & SET_FORCE_HIDING_CHANGED) != 0) { |
| 1620 | mWallpaperForceHidingChanged = true; |
| 1621 | doRequest = true; |
| 1622 | } |
| 1623 | if ((bulkUpdateParams & SET_ORIENTATION_CHANGE_COMPLETE) == 0) { |
| 1624 | mOrientationChangeComplete = false; |
| 1625 | } else { |
| 1626 | mOrientationChangeComplete = true; |
| 1627 | mLastWindowFreezeSource = mService.mAnimator.mLastWindowFreezeSource; |
| 1628 | if (mService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_NONE) { |
| 1629 | doRequest = true; |
| 1630 | } |
| 1631 | } |
| 1632 | if ((bulkUpdateParams & SET_TURN_ON_SCREEN) != 0) { |
| 1633 | mService.mTurnOnScreen = true; |
| 1634 | } |
| 1635 | if ((bulkUpdateParams & SET_WALLPAPER_ACTION_PENDING) != 0) { |
| 1636 | mWallpaperActionPending = true; |
| 1637 | } |
| 1638 | |
| 1639 | return doRequest; |
| 1640 | } |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 1641 | |
| 1642 | void requestTraversal() { |
| 1643 | if (!mTraversalScheduled) { |
| 1644 | mTraversalScheduled = true; |
| 1645 | mService.mH.sendEmptyMessage(DO_TRAVERSAL); |
| 1646 | } |
| 1647 | } |
| 1648 | |
Jorim Jaggi | 3dac63a | 2016-03-01 12:37:07 +0100 | [diff] [blame] | 1649 | /** |
| 1650 | * Puts the {@param surface} into a pending list to be destroyed after the current transaction |
| 1651 | * has been committed. |
| 1652 | */ |
| 1653 | void destroyAfterTransaction(SurfaceControl surface) { |
| 1654 | mPendingDestroyingSurfaces.add(surface); |
| 1655 | } |
| 1656 | |
| 1657 | /** |
| 1658 | * Destroys any surfaces that have been put into the pending list with |
| 1659 | * {@link #destroyAfterTransaction}. |
| 1660 | */ |
| 1661 | void destroyPendingSurfaces() { |
| 1662 | for (int i = mPendingDestroyingSurfaces.size() - 1; i >= 0; i--) { |
| 1663 | mPendingDestroyingSurfaces.get(i).destroy(); |
| 1664 | } |
| 1665 | mPendingDestroyingSurfaces.clear(); |
| 1666 | } |
| 1667 | |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 1668 | public void dump(PrintWriter pw, String prefix) { |
| 1669 | pw.print(prefix); pw.print("mTraversalScheduled="); pw.println(mTraversalScheduled); |
| 1670 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1671 | } |