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

Commit 10943335 authored by Craig Mautner's avatar Craig Mautner Committed by Android (Google) Code Review
Browse files

Merge "Step 1 in consolidating wallpaper animation."

parents 1d11e356 9e809448
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -164,7 +164,7 @@ public class AppWindowAnimator {
        }
        }
        transformation.clear();
        transformation.clear();
        final boolean more = animation.getTransformation(currentTime, transformation);
        final boolean more = animation.getTransformation(currentTime, transformation);
        if (WindowManagerService.DEBUG_ANIM) Slog.v(
        if (false && WindowManagerService.DEBUG_ANIM) Slog.v(
            TAG, "Stepped animation in " + mAppToken + ": more=" + more + ", xform=" + transformation);
            TAG, "Stepped animation in " + mAppToken + ": more=" + more + ", xform=" + transformation);
        if (!more) {
        if (!more) {
            animation = null;
            animation = null;
+52 −60
Original line number Original line Diff line number Diff line
@@ -47,9 +47,6 @@ public class WindowAnimator {
    private class InnerLoopParams {
    private class InnerLoopParams {
        boolean mTokenMayBeDrawn;
        boolean mTokenMayBeDrawn;
        boolean mForceHiding;
        boolean mForceHiding;
        WindowState mDetachedWallpaper = null;
        WindowState mWindowAnimationBackground;
        int mWindowAnimationBackgroundColor;
    }
    }
    InnerLoopParams mInner = new InnerLoopParams();
    InnerLoopParams mInner = new InnerLoopParams();


@@ -122,6 +119,8 @@ public class WindowAnimator {
                }
                }
            }
            }
        };
        };

        mWindowAnimationBackgroundSurface = new DimSurface(mService.mFxSession);
    }
    }


    /** Copy all WindowManagerService params into local params here. Locked on 'this'. */
    /** Copy all WindowManagerService params into local params here. Locked on 'this'. */
@@ -162,46 +161,6 @@ public class WindowAnimator {
        }
        }
    }
    }


    private void testWallpaperAndBackgroundLocked() {
        final WindowState detachedWallpaper = mInner.mDetachedWallpaper;
        if (mWindowDetachedWallpaper != detachedWallpaper) {
            if (WindowManagerService.DEBUG_WALLPAPER) Slog.v(TAG,
                    "Detached wallpaper changed from " + mWindowDetachedWallpaper
                    + " to " + detachedWallpaper);
            mWindowDetachedWallpaper = detachedWallpaper;
            mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE;
        }

        if (mInner.mWindowAnimationBackgroundColor != 0) {
            // If the window that wants black is the current wallpaper
            // target, then the black goes *below* the wallpaper so we
            // don't cause the wallpaper to suddenly disappear.
            WindowState target = mInner.mWindowAnimationBackground;
            if (mService.mWallpaperTarget == target
                    || mService.mLowerWallpaperTarget == target
                    || mService.mUpperWallpaperTarget == target) {
                final int N = mWinAnimators.size();
                for (int i = 0; i < N; i++) {
                    WindowStateAnimator winAnimator = mWinAnimators.get(i);
                    if (winAnimator.mWin.mIsWallpaper) {
                        target = winAnimator.mWin;
                        break;
                    }
                }
            }
            if (mWindowAnimationBackgroundSurface == null) {
                mWindowAnimationBackgroundSurface = new DimSurface(mService.mFxSession);
            }
            final int dw = mDw;
            final int dh = mDh;
            mWindowAnimationBackgroundSurface.show(dw, dh,
                    target.mWinAnimator.mAnimLayer - WindowManagerService.LAYER_OFFSET_DIM,
                    mInner.mWindowAnimationBackgroundColor);
        } else if (mWindowAnimationBackgroundSurface != null) {
            mWindowAnimationBackgroundSurface.hide();
        }
    }

    private void updateWindowsAppsAndRotationAnimationsLocked() {
    private void updateWindowsAppsAndRotationAnimationsLocked() {
        final ArrayList<AppWindowToken> appTokens = mService.mAnimatingAppTokens;
        final ArrayList<AppWindowToken> appTokens = mService.mAnimatingAppTokens;
        int i;
        int i;
@@ -259,6 +218,9 @@ public class WindowAnimator {


        ArrayList<WindowStateAnimator> unForceHiding = null;
        ArrayList<WindowStateAnimator> unForceHiding = null;
        boolean wallpaperInUnForceHiding = false;
        boolean wallpaperInUnForceHiding = false;
        WindowStateAnimator windowAnimationBackground = null;
        int windowAnimationBackgroundColor = 0;
        WindowState detachedWallpaper = null;


        for (int i = mWinAnimators.size() - 1; i >= 0; i--) {
        for (int i = mWinAnimators.size() - 1; i >= 0; i--) {
            WindowStateAnimator winAnimator = mWinAnimators.get(i);
            WindowStateAnimator winAnimator = mWinAnimators.get(i);
@@ -281,15 +243,14 @@ public class WindowAnimator {
                    if (winAnimator.mAnimation != null) {
                    if (winAnimator.mAnimation != null) {
                        if ((flags & FLAG_SHOW_WALLPAPER) != 0
                        if ((flags & FLAG_SHOW_WALLPAPER) != 0
                                && winAnimator.mAnimation.getDetachWallpaper()) {
                                && winAnimator.mAnimation.getDetachWallpaper()) {
                            mInner.mDetachedWallpaper = win;
                            detachedWallpaper = win;
                        }
                        }
                        final int backgroundColor = winAnimator.mAnimation.getBackgroundColor();
                        final int backgroundColor = winAnimator.mAnimation.getBackgroundColor();
                        if (backgroundColor != 0) {
                        if (backgroundColor != 0) {
                            final WindowState background = mInner.mWindowAnimationBackground;
                            if (windowAnimationBackground == null || (winAnimator.mAnimLayer <
                            if (background == null || (winAnimator.mAnimLayer <
                                    windowAnimationBackground.mAnimLayer)) {
                                    background.mWinAnimator.mAnimLayer)) {
                                windowAnimationBackground = winAnimator;
                                mInner.mWindowAnimationBackground = win;
                                windowAnimationBackgroundColor = backgroundColor;
                                mInner.mWindowAnimationBackgroundColor = backgroundColor;
                            }
                            }
                        }
                        }
                    }
                    }
@@ -305,15 +266,14 @@ public class WindowAnimator {
                        && appAnimator.animating) {
                        && appAnimator.animating) {
                    if ((flags & FLAG_SHOW_WALLPAPER) != 0
                    if ((flags & FLAG_SHOW_WALLPAPER) != 0
                            && appAnimator.animation.getDetachWallpaper()) {
                            && appAnimator.animation.getDetachWallpaper()) {
                        mInner.mDetachedWallpaper = win;
                        detachedWallpaper = win;
                    }
                    }
                    final int backgroundColor = appAnimator.animation.getBackgroundColor();
                    final int backgroundColor = appAnimator.animation.getBackgroundColor();
                    if (backgroundColor != 0) {
                    if (backgroundColor != 0) {
                        final WindowState background = mInner.mWindowAnimationBackground;
                        if (windowAnimationBackground == null || (winAnimator.mAnimLayer <
                        if (background == null || (winAnimator.mAnimLayer <
                                windowAnimationBackground.mAnimLayer)) {
                                background.mWinAnimator.mAnimLayer)) {
                            windowAnimationBackground = winAnimator;
                            mInner.mWindowAnimationBackground = win;
                            windowAnimationBackgroundColor = backgroundColor;
                            mInner.mWindowAnimationBackgroundColor = backgroundColor;
                        }
                        }
                    }
                    }
                }
                }
@@ -454,6 +414,42 @@ public class WindowAnimator {
            }
            }
        } // end forall windows
        } // end forall windows


        if (mWindowDetachedWallpaper != detachedWallpaper) {
            if (WindowManagerService.DEBUG_WALLPAPER) Slog.v(TAG,
                    "Detached wallpaper changed from " + mWindowDetachedWallpaper
                    + " to " + detachedWallpaper);
            mWindowDetachedWallpaper = detachedWallpaper;
            mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE;
        }

        if (windowAnimationBackgroundColor != 0) {
            // If the window that wants black is the current wallpaper
            // target, then the black goes *below* the wallpaper so we
            // don't cause the wallpaper to suddenly disappear.
            int animLayer = windowAnimationBackground.mAnimLayer;
            WindowState win = windowAnimationBackground.mWin;
            if (windowAnimationBackground != null && mService.mWallpaperTarget == win
                    || mService.mLowerWallpaperTarget == win
                    || mService.mUpperWallpaperTarget == win) {
                final int N = mWinAnimators.size();
                for (int i = 0; i < N; i++) {
                    WindowStateAnimator winAnimator = mWinAnimators.get(i);
                    if (winAnimator.mWin.mIsWallpaper) {
                        animLayer = winAnimator.mAnimLayer;
                        break;
                    }
                }
            }

            final int dw = mDw;
            final int dh = mDh;
            mWindowAnimationBackgroundSurface.show(dw, dh,
                    animLayer - WindowManagerService.LAYER_OFFSET_DIM,
                    windowAnimationBackgroundColor);
        } else {
            mWindowAnimationBackgroundSurface.hide();
        }

        // If we have windows that are being show due to them no longer
        // If we have windows that are being show due to them no longer
        // being force-hidden, apply the appropriate animation to them.
        // being force-hidden, apply the appropriate animation to them.
        if (unForceHiding != null) {
        if (unForceHiding != null) {
@@ -517,9 +513,6 @@ public class WindowAnimator {
    private void performAnimationsLocked() {
    private void performAnimationsLocked() {
        mInner.mTokenMayBeDrawn = false;
        mInner.mTokenMayBeDrawn = false;
        mInner.mForceHiding = false;
        mInner.mForceHiding = false;
        mInner.mDetachedWallpaper = null;
        mInner.mWindowAnimationBackground = null;
        mInner.mWindowAnimationBackgroundColor = 0;


        updateWindowsAndWallpaperLocked();
        updateWindowsAndWallpaperLocked();
        if ((mPendingLayoutChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER) != 0) {
        if ((mPendingLayoutChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER) != 0) {
@@ -550,7 +543,6 @@ public class WindowAnimator {
        try {
        try {
            updateWindowsAppsAndRotationAnimationsLocked();
            updateWindowsAppsAndRotationAnimationsLocked();
            performAnimationsLocked();
            performAnimationsLocked();
            testWallpaperAndBackgroundLocked();


            // THIRD LOOP: Update the surfaces of all windows.
            // THIRD LOOP: Update the surfaces of all windows.


@@ -595,7 +587,7 @@ public class WindowAnimator {
                animToLayout.mBulkUpdateParams = mBulkUpdateParams;
                animToLayout.mBulkUpdateParams = mBulkUpdateParams;
                animToLayout.mPendingLayoutChanges = mPendingLayoutChanges;
                animToLayout.mPendingLayoutChanges = mPendingLayoutChanges;
                animToLayout.mWindowDetachedWallpaper = mWindowDetachedWallpaper;
                animToLayout.mWindowDetachedWallpaper = mWindowDetachedWallpaper;
                mService.setAnimatorParameters();
                mService.setAnimatorParametersLocked();
            }
            }
        }
        }


+22 −12
Original line number Original line Diff line number Diff line
@@ -642,7 +642,10 @@ public class WindowManagerService extends IWindowManager.Stub
    }
    }
    final LayoutFields mInnerFields = new LayoutFields();
    final LayoutFields mInnerFields = new LayoutFields();


    /* Parameters being passed from mAnimator into this. 
     * Do not modify unless holding (mWindowMap or mAnimator) and mAnimToLayout in that order */
    static class AnimatorToLayoutParams {
    static class AnimatorToLayoutParams {
        boolean mUpdateQueued;
        int mBulkUpdateParams;
        int mBulkUpdateParams;
        int mPendingLayoutChanges;
        int mPendingLayoutChanges;
        WindowState mWindowDetachedWallpaper;
        WindowState mWindowDetachedWallpaper;
@@ -877,6 +880,7 @@ public class WindowManagerService extends IWindowManager.Stub
        mHoldingScreenWakeLock.setReferenceCounted(false);
        mHoldingScreenWakeLock.setReferenceCounted(false);


        mInputManager = new InputManagerService(context, mInputMonitor);
        mInputManager = new InputManagerService(context, mInputMonitor);
        mFxSession = new SurfaceSession();
        mAnimator = new WindowAnimator(this, context, mPolicy);
        mAnimator = new WindowAnimator(this, context, mPolicy);


        PolicyThread thr = new PolicyThread(mPolicy, this, context, pm);
        PolicyThread thr = new PolicyThread(mPolicy, this, context, pm);
@@ -895,7 +899,6 @@ public class WindowManagerService extends IWindowManager.Stub


        // Add ourself to the Watchdog monitors.
        // Add ourself to the Watchdog monitors.
        Watchdog.getInstance().addMonitor(this);
        Watchdog.getInstance().addMonitor(this);
        mFxSession = new SurfaceSession();


        Surface.openTransaction();
        Surface.openTransaction();
        createWatermark();
        createWatermark();
@@ -3436,6 +3439,7 @@ public class WindowManagerService extends IWindowManager.Stub
        }
        }
    }
    }


    @Override
    public void removeWindowToken(IBinder token) {
    public void removeWindowToken(IBinder token) {
        if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
        if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
                "removeWindowToken()")) {
                "removeWindowToken()")) {
@@ -3553,6 +3557,7 @@ public class WindowManagerService extends IWindowManager.Stub
        }
        }
    }
    }


    @Override
    public void setAppGroupId(IBinder token, int groupId) {
    public void setAppGroupId(IBinder token, int groupId) {
        if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
        if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,
                "setAppStartingIcon()")) {
                "setAppStartingIcon()")) {
@@ -3595,9 +3600,9 @@ public class WindowManagerService extends IWindowManager.Stub
            if((req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) ||
            if((req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) ||
                    (req == ActivityInfo.SCREEN_ORIENTATION_BEHIND)){
                    (req == ActivityInfo.SCREEN_ORIENTATION_BEHIND)){
                continue;
                continue;
            } else {
                return (mLastWindowForcedOrientation=req);
            }
            }

            return (mLastWindowForcedOrientation=req);
        }
        }
        return (mLastWindowForcedOrientation=ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        return (mLastWindowForcedOrientation=ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }
    }
@@ -7252,6 +7257,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    // Used to send multiple changes from the animation side to the layout side.
                    // Used to send multiple changes from the animation side to the layout side.
                    synchronized (mWindowMap) {
                    synchronized (mWindowMap) {
                        synchronized (mAnimToLayout) {
                        synchronized (mAnimToLayout) {
                            mAnimToLayout.mUpdateQueued = false;
                            boolean doRequest = false;
                            boolean doRequest = false;
                            final int bulkUpdateParams = mAnimToLayout.mBulkUpdateParams;
                            final int bulkUpdateParams = mAnimToLayout.mBulkUpdateParams;
                            // TODO(cmautner): As the number of bits grows, use masks of bit groups to
                            // TODO(cmautner): As the number of bits grows, use masks of bit groups to
@@ -10029,7 +10035,11 @@ public class WindowManagerService extends IWindowManager.Stub
        }
        }
    }
    }


    void setAnimatorParameters() {
    /** Locked on mAnimToLayout */
    void setAnimatorParametersLocked() {
        if (!mAnimToLayout.mUpdateQueued) {
            mAnimToLayout.mUpdateQueued = true;
            mH.sendMessage(mH.obtainMessage(H.UPDATE_ANIM_PARAMETERS));
            mH.sendMessage(mH.obtainMessage(H.UPDATE_ANIM_PARAMETERS));
        }
        }
    }
    }
}
+4 −4
Original line number Original line Diff line number Diff line
@@ -203,7 +203,7 @@ class WindowStateAnimator {
        }
        }
        mTransformation.clear();
        mTransformation.clear();
        final boolean more = mAnimation.getTransformation(currentTime, mTransformation);
        final boolean more = mAnimation.getTransformation(currentTime, mTransformation);
        if (DEBUG_ANIM) Slog.v(
        if (false && DEBUG_ANIM) Slog.v(
            TAG, "Stepped animation in " + this +
            TAG, "Stepped animation in " + this +
            ": more=" + more + ", xform=" + mTransformation);
            ": more=" + more + ", xform=" + mTransformation);
        return more;
        return more;
@@ -896,7 +896,7 @@ class WindowStateAnimator {
                //Slog.i(TAG, "Not applying alpha transform");
                //Slog.i(TAG, "Not applying alpha transform");
            }
            }


            if (WindowManagerService.localLOGV && (mShownAlpha == 1.0 || mShownAlpha == 0.0)) Slog.v(
            if ((DEBUG_SURFACE_TRACE || WindowManagerService.localLOGV) && (mShownAlpha == 1.0 || mShownAlpha == 0.0)) Slog.v(
                TAG, "computeShownFrameLocked: Animating " + this +
                TAG, "computeShownFrameLocked: Animating " + this +
                " mAlpha=" + mAlpha +
                " mAlpha=" + mAlpha +
                " self=" + (selfTransformation ? mTransformation.getAlpha() : "null") +
                " self=" + (selfTransformation ? mTransformation.getAlpha() : "null") +
@@ -1144,8 +1144,8 @@ class WindowStateAnimator {
                }
                }
            }
            }
        } else {
        } else {
            if (DEBUG_ANIM) {
            if (DEBUG_ANIM && isAnimating()) {
                // Slog.v(TAG, "prepareSurface: No changes in animation for " + mWin);
                Slog.v(TAG, "prepareSurface: No changes in animation for " + this);
            }
            }
            displayed = true;
            displayed = true;
        }
        }