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

Commit 84f6e018 authored by Jon Miranda's avatar Jon Miranda
Browse files

Fix depth jumping around during transitions.

This is caused because we use mDepth for depth comparisons, but there are
cases where we set mDepth but we do not pass that value to WallpaperManager
(ie. surface is null or not valid) and that leads us into
inconsistent states.

Bug: 155780358
Change-Id: I3faf14416d5783ad472892425eb0bd37dd469a46
parent c577bb84
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -102,11 +102,30 @@ public class DepthController implements StateHandler<LauncherState> {
     */
    private float mDepth;

    private View.OnAttachStateChangeListener mOnAttachListener;

    public DepthController(Launcher l) {
        mLauncher = l;
    }

    private void ensureDependencies() {
        if (mLauncher.getRootView() != null && mOnAttachListener == null) {
            mOnAttachListener = new View.OnAttachStateChangeListener() {
                @Override
                public void onViewAttachedToWindow(View view) {
                    // To handle the case where window token is invalid during last setDepth call.
                    IBinder windowToken = mLauncher.getRootView().getWindowToken();
                    if (windowToken != null) {
                        mWallpaperManager.setWallpaperZoomOut(windowToken, mDepth);
                    }
                }

                @Override
                public void onViewDetachedFromWindow(View view) {
                }
            };
            mLauncher.getRootView().addOnAttachStateChangeListener(mOnAttachListener);
        }
        if (mWallpaperManager != null) {
            return;
        }
@@ -184,10 +203,10 @@ public class DepthController implements StateHandler<LauncherState> {
            return;
        }

        mDepth = depthF;
        if (mSurface == null || !mSurface.isValid()) {
            return;
        }
        mDepth = depthF;
        ensureDependencies();
        IBinder windowToken = mLauncher.getRootView().getWindowToken();
        if (windowToken != null) {