Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05cc71dc authored by Filip Gruszczynski's avatar Filip Gruszczynski Committed by Android (Google) Code Review
Browse files

Merge "Refactorings for Window Manager module."

parents 8532e6fb 24966d47
Loading
Loading
Loading
Loading
+33 −6
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@ public class AppTransition implements Dump {
    private static final int DEFAULT_APP_TRANSITION_DURATION = 336;
    private static final int THUMBNAIL_APP_TRANSITION_DURATION = 336;
    private static final int THUMBNAIL_APP_TRANSITION_ALPHA_DURATION = 336;
    private static final long APP_TRANSITION_TIMEOUT_MS = 5000;

    private final Context mContext;
    private final Handler mH;
@@ -242,10 +243,6 @@ public class AppTransition implements Dump {
        return mNextAppTransition != TRANSIT_UNSET;
    }

    boolean isTransitionNone() {
        return mNextAppTransition == TRANSIT_NONE;
    }

    boolean isTransitionEqual(int transit) {
        return mNextAppTransition == transit;
    }
@@ -254,7 +251,7 @@ public class AppTransition implements Dump {
        return mNextAppTransition;
     }

    void setAppTransition(int transit) {
    private void setAppTransition(int transit) {
        mNextAppTransition = transit;
    }

@@ -299,7 +296,7 @@ public class AppTransition implements Dump {
        return mNextAppTransitionScaleUp;
    }

    boolean prepare() {
    private boolean prepare() {
        if (!isRunning()) {
            mAppTransitionState = APP_STATE_IDLE;
            notifyAppTransitionPendingLocked();
@@ -1458,4 +1455,34 @@ public class AppTransition implements Dump {
    public void setCurrentUser(int newUserId) {
        mCurrentUserId = newUserId;
    }

    /**
     * @return true if transition is not running and should not be skipped, false if transition is
     *         already running
     */
    boolean prepareAppTransitionLocked(int transit, boolean alwaysKeepCurrent) {
        if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Prepare app transition:"
                + " transit=" + appTransitionToString(transit)
                + " " + this
                + " alwaysKeepCurrent=" + alwaysKeepCurrent
                + " Callers=" + Debug.getCallers(3));
        if (!isTransitionSet() || mNextAppTransition == TRANSIT_NONE) {
            setAppTransition(transit);
        } else if (!alwaysKeepCurrent) {
            if (transit == TRANSIT_TASK_OPEN && isTransitionEqual(TRANSIT_TASK_CLOSE)) {
                // Opening a new task always supersedes a close for the anim.
                setAppTransition(transit);
            } else if (transit == TRANSIT_ACTIVITY_OPEN
                    && isTransitionEqual(TRANSIT_ACTIVITY_CLOSE)) {
                // Opening a new activity always supersedes a close for the anim.
                setAppTransition(transit);
            }
        }
        boolean prepared = prepare();
        if (isTransitionSet()) {
            mH.removeMessages(H.APP_TRANSITION_TIMEOUT);
            mH.sendEmptyMessageDelayed(H.APP_TRANSITION_TIMEOUT, APP_TRANSITION_TIMEOUT_MS);
        }
        return prepared;
    }
}
+1 −3
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.graphics.Rect;
import android.os.Debug;
import android.os.RemoteException;
import android.util.EventLog;
import android.util.IntArray;
import android.util.Slog;
import android.util.SparseArray;
import android.view.DisplayInfo;
@@ -34,7 +33,6 @@ import com.android.server.EventLogTags;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class TaskStack implements DimLayer.DimLayerUser {

@@ -414,7 +412,7 @@ public class TaskStack implements DimLayer.DimLayerUser {
            }
        }
        if (doAnotherLayoutPass) {
            mService.requestTraversalLocked();
            mService.mWindowPlacerLocked.requestTraversal();
        }

        if (mStackId == DOCKED_STACK_ID) {
+10 −8
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ public class WindowAnimator {
    final WindowManagerService mService;
    final Context mContext;
    final WindowManagerPolicy mPolicy;
    private final WindowSurfacePlacer mWindowPlacerLocked;

    /** Is any window animating? */
    boolean mAnimating;
@@ -112,6 +113,7 @@ public class WindowAnimator {
        mService = service;
        mContext = service.mContext;
        mPolicy = service.mPolicy;
        mWindowPlacerLocked = service.mWindowPlacerLocked;

        mAnimationFrameCallback = new Choreographer.FrameCallback() {
            public void doFrame(long frameTimeNs) {
@@ -300,7 +302,7 @@ public class WindowAnimator {
                    setPendingLayoutChanges(Display.DEFAULT_DISPLAY,
                            WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
                    if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
                        mService.mWindowPlacerLocked.debugLayoutRepeats(
                        mWindowPlacerLocked.debugLayoutRepeats(
                                "updateWindowsAndWallpaperLocked 2",
                                getPendingLayoutChanges(Display.DEFAULT_DISPLAY));
                    }
@@ -315,7 +317,7 @@ public class WindowAnimator {
                        setPendingLayoutChanges(displayId,
                                WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
                        if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
                            mService.mWindowPlacerLocked.debugLayoutRepeats(
                            mWindowPlacerLocked.debugLayoutRepeats(
                                    "updateWindowsAndWallpaperLocked 3",
                                    getPendingLayoutChanges(displayId));
                        }
@@ -410,7 +412,7 @@ public class WindowAnimator {
                        setPendingLayoutChanges(Display.DEFAULT_DISPLAY,
                                WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
                        if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
                            mService.mWindowPlacerLocked.debugLayoutRepeats(
                            mWindowPlacerLocked.debugLayoutRepeats(
                                    "updateWindowsAndWallpaperLocked 4",
                                    getPendingLayoutChanges(Display.DEFAULT_DISPLAY));
                        }
@@ -435,7 +437,7 @@ public class WindowAnimator {
                        setPendingLayoutChanges(displayId,
                                WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM);
                        if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
                            mService.mWindowPlacerLocked.debugLayoutRepeats(
                            mWindowPlacerLocked.debugLayoutRepeats(
                                    "updateWindowsAndWallpaperLocked 5",
                                    getPendingLayoutChanges(displayId));
                        }
@@ -741,15 +743,15 @@ public class WindowAnimator {

        boolean doRequest = false;
        if (mBulkUpdateParams != 0) {
            doRequest = mService.mWindowPlacerLocked.copyAnimToLayoutParamsLocked();
            doRequest = mWindowPlacerLocked.copyAnimToLayoutParamsLocked();
        }

        if (hasPendingLayoutChanges || doRequest) {
            mService.requestTraversalLocked();
            mWindowPlacerLocked.requestTraversal();
        }

        if (!mAnimating && wasAnimating) {
            mService.requestTraversalLocked();
            mWindowPlacerLocked.requestTraversal();
        }
        if (WindowManagerService.DEBUG_WINDOW_TRACE) {
            Slog.i(TAG, "!!! animate: exit mAnimating=" + mAnimating
@@ -850,7 +852,7 @@ public class WindowAnimator {
            if (displayId == windows.get(i).getDisplayId()) {
                setPendingLayoutChanges(displayId, changes);
                if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
                    mService.mWindowPlacerLocked.debugLayoutRepeats(reason,
                    mWindowPlacerLocked.debugLayoutRepeats(reason,
                            getPendingLayoutChanges(displayId));
                }
                break;
+13 −45
Original line number Diff line number Diff line
@@ -471,7 +471,6 @@ public class WindowManagerService extends IWindowManager.Stub
    int mSystemDecorLayer = 0;
    final Rect mScreenRect = new Rect();

    boolean mTraversalScheduled = false;
    boolean mDisplayFrozen = false;
    long mDisplayFreezeTime = 0;
    int mLastDisplayFreezeDuration = 0;
@@ -2773,7 +2772,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    if (displayContent != null) {
                        displayContent.layoutNeeded = true;
                    }
                    requestTraversalLocked();
                    mWindowPlacerLocked.requestTraversal();
                }
            }
        } finally {
@@ -3472,35 +3471,12 @@ public class WindowManagerService extends IWindowManager.Stub
                "prepareAppTransition()")) {
            throw new SecurityException("Requires MANAGE_APP_TOKENS permission");
        }

        synchronized(mWindowMap) {
            if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Prepare app transition:"
                    + " transit=" + AppTransition.appTransitionToString(transit)
                    + " " + mAppTransition
                    + " alwaysKeepCurrent=" + alwaysKeepCurrent
                    + " Callers=" + Debug.getCallers(3));
            if (!mAppTransition.isTransitionSet() || mAppTransition.isTransitionNone()) {
                mAppTransition.setAppTransition(transit);
            } else if (!alwaysKeepCurrent) {
                if (transit == AppTransition.TRANSIT_TASK_OPEN
                        && mAppTransition.isTransitionEqual(
                                AppTransition.TRANSIT_TASK_CLOSE)) {
                    // Opening a new task always supersedes a close for the anim.
                    mAppTransition.setAppTransition(transit);
                } else if (transit == AppTransition.TRANSIT_ACTIVITY_OPEN
                        && mAppTransition.isTransitionEqual(
                            AppTransition.TRANSIT_ACTIVITY_CLOSE)) {
                    // Opening a new activity always supersedes a close for the anim.
                    mAppTransition.setAppTransition(transit);
                }
            }
            if (okToDisplay() && mAppTransition.prepare()) {
            boolean prepared = mAppTransition.prepareAppTransitionLocked(
                    transit, alwaysKeepCurrent);
            if (prepared && okToDisplay()) {
                mSkipAppTransitionAnimation = false;
            }
            if (mAppTransition.isTransitionSet()) {
                mH.removeMessages(H.APP_TRANSITION_TIMEOUT);
                mH.sendEmptyMessageDelayed(H.APP_TRANSITION_TIMEOUT, 5000);
            }
        }
    }

@@ -3836,7 +3812,7 @@ public class WindowManagerService extends IWindowManager.Stub
            if (atoken != null) {
                atoken.appFullscreen = toOpaque;
                setWindowOpaqueLocked(token, toOpaque);
                requestTraversalLocked();
                mWindowPlacerLocked.requestTraversal();
            }
        }
    }
@@ -4841,7 +4817,7 @@ public class WindowManagerService extends IWindowManager.Stub
            mAnimator.mKeyguardGoingAway = true;
            mAnimator.mKeyguardGoingAwayToNotificationShade = keyguardGoingToNotificationShade;
            mAnimator.mKeyguardGoingAwayDisableWindowAnimations = disableWindowAnimations;
            requestTraversalLocked();
            mWindowPlacerLocked.requestTraversal();
        }
    }

@@ -7180,7 +7156,6 @@ public class WindowManagerService extends IWindowManager.Stub

                case DO_TRAVERSAL: {
                    synchronized(mWindowMap) {
                        mTraversalScheduled = false;
                        mWindowPlacerLocked.performSurfacePlacement();
                    }
                } break;
@@ -8463,14 +8438,7 @@ public class WindowManagerService extends IWindowManager.Stub

    void requestTraversal() {
        synchronized (mWindowMap) {
            requestTraversalLocked();
        }
    }

    void requestTraversalLocked() {
        if (!mTraversalScheduled) {
            mTraversalScheduled = true;
            mH.sendEmptyMessage(H.DO_TRAVERSAL);
            mWindowPlacerLocked.requestTraversal();
        }
    }

@@ -9334,6 +9302,7 @@ public class WindowManagerService extends IWindowManager.Stub
            if (mInputMethodWindow != null) {
                pw.print("  mInputMethodWindow="); pw.println(mInputMethodWindow);
            }
            mWindowPlacerLocked.dump(pw, "  ");
            mWallpaperControllerLocked.dump(pw, "  ");
            if (mInputMethodAnimLayerAdjustment != 0 ||
                    mWallpaperControllerLocked.getAnimLayerAdjustment() != 0) {
@@ -9369,7 +9338,6 @@ public class WindowManagerService extends IWindowManager.Stub
                    pw.print(" window="); pw.print(mWindowAnimationScaleSetting);
                    pw.print(" transition="); pw.print(mTransitionAnimationScaleSetting);
                    pw.print(" animator="); pw.println(mAnimatorDurationScaleSetting);
            pw.print("  mTraversalScheduled="); pw.println(mTraversalScheduled);
            pw.print(" mSkipAppTransitionAnimation=");pw.println(mSkipAppTransitionAnimation);
            pw.println("  mLayoutToAnim:");
            mAppTransition.dump(pw, "    ");
@@ -9728,7 +9696,7 @@ public class WindowManagerService extends IWindowManager.Stub
                createDisplayContentLocked(display);
                displayReady(displayId);
            }
            requestTraversalLocked();
            mWindowPlacerLocked.requestTraversal();
        }
    }

@@ -9751,7 +9719,7 @@ public class WindowManagerService extends IWindowManager.Stub
            }
        }
        mAnimator.removeDisplayLocked(displayId);
        requestTraversalLocked();
        mWindowPlacerLocked.requestTraversal();
    }

    public void onDisplayChanged(int displayId) {
@@ -9763,7 +9731,7 @@ public class WindowManagerService extends IWindowManager.Stub
        if (displayContent != null) {
            displayContent.updateDisplayInfo();
        }
        requestTraversalLocked();
        mWindowPlacerLocked.requestTraversal();
    }

    @Override
@@ -9910,7 +9878,7 @@ public class WindowManagerService extends IWindowManager.Stub
                        }
                    }
                }
                requestTraversalLocked();
                mWindowPlacerLocked.requestTraversal();
            }
            mH.removeMessages(H.WAITING_FOR_DRAWN_TIMEOUT);
            if (mWaitingForDrawn.isEmpty()) {
+1 −1
Original line number Diff line number Diff line
@@ -1640,7 +1640,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
            Slog.w(TAG, "Failed to report 'resized' to the client of " + this
                    + ", removing this window.");
            mService.mPendingRemove.add(this);
            mService.requestTraversalLocked();
            mService.mWindowPlacerLocked.requestTraversal();
        }
    }

Loading