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

Commit 41f30659 authored by Andreas Miko's avatar Andreas Miko
Browse files

Fix multiple issues with DREAM => LOCKSCREEN transition

- The transition is now playing all parts in parallel (previously: serial) and according to spec -> proper curves, proper timings
- All parts of the transition are now based on the transition framework and are guaranteed to be synchronized
- The animations were not playing at all due to a bug in transition framework

Spec: https://direct.googleplex.com/#/spec/277250003

Bug: b/267520000
Test: atest SystemUITests
Test: manually tested and aligned with spec
Change-Id: I0a8e096d9e6c08f0ce2e7736fb5679951602cfe0
parent 4c85dc55
Loading
Loading
Loading
Loading
+5 −20
Original line number Original line Diff line number Diff line
@@ -71,13 +71,7 @@ public abstract class DreamOverlayService extends Service {


        @Override
        @Override
        public void wakeUp() {
        public void wakeUp() {
            mService.wakeUp(this, () -> {
            mService.wakeUp(this);
                try {
                    mDreamOverlayCallback.onWakeUpComplete();
                } catch (RemoteException e) {
                    Log.e(TAG, "Could not notify dream of wakeUp", e);
                }
            });
        }
        }


        @Override
        @Override
@@ -125,14 +119,14 @@ public abstract class DreamOverlayService extends Service {
        mCurrentClient = null;
        mCurrentClient = null;
    }
    }


    private void wakeUp(OverlayClient client, Runnable callback) {
    private void wakeUp(OverlayClient client) {
        // Run on executor as this is a binder call from OverlayClient.
        // Run on executor as this is a binder call from OverlayClient.
        mExecutor.execute(() -> {
        mExecutor.execute(() -> {
            if (mCurrentClient != client) {
            if (mCurrentClient != client) {
                return;
                return;
            }
            }


            onWakeUp(callback);
            onWakeUp();
        });
        });
    }
    }


@@ -190,19 +184,10 @@ public abstract class DreamOverlayService extends Service {


    /**
    /**
     * This method is overridden by implementations to handle when the dream has been requested
     * This method is overridden by implementations to handle when the dream has been requested
     * to wakeup. This allows any overlay animations to run. By default, the method will invoke
     * to wakeup.
     * the callback immediately.
     *
     * This callback will be run on the {@link Executor} provided in the constructor if provided, or
     * on the main executor if none was provided.
     *
     * @param onCompleteCallback The callback to trigger to notify the dream service that the
     *                           overlay has completed waking up.
     * @hide
     * @hide
     */
     */
    public void onWakeUp(@NonNull Runnable onCompleteCallback) {
    public void onWakeUp() {}
        onCompleteCallback.run();
    }


    /**
    /**
     * This method is overridden by implementations to handle when the dream has ended. There may
     * This method is overridden by implementations to handle when the dream has ended. There may
+1 −7
Original line number Original line Diff line number Diff line
@@ -249,13 +249,6 @@ public class DreamService extends Service implements Window.Callback {
            // Simply finish dream when exit is requested.
            // Simply finish dream when exit is requested.
            mHandler.post(() -> finish());
            mHandler.post(() -> finish());
        }
        }

        @Override
        public void onWakeUpComplete() {
            // Finish the dream once overlay animations are complete. Execute on handler since
            // this is coming in on the overlay binder.
            mHandler.post(() -> finish());
        }
    };
    };




@@ -923,6 +916,7 @@ public class DreamService extends Service implements Window.Callback {
                    overlay.wakeUp();
                    overlay.wakeUp();
                } catch (RemoteException e) {
                } catch (RemoteException e) {
                    Slog.e(TAG, "Error waking the overlay service", e);
                    Slog.e(TAG, "Error waking the overlay service", e);
                } finally {
                    finish();
                    finish();
                }
                }
            });
            });
+0 −3
Original line number Original line Diff line number Diff line
@@ -28,7 +28,4 @@ interface IDreamOverlayCallback {
    * Invoked to request the dream exit.
    * Invoked to request the dream exit.
    */
    */
    void onExitRequested();
    void onExitRequested();

    /** Invoked when the dream overlay wakeUp animation is complete. */
    void onWakeUpComplete();
}
}
 No newline at end of file
+8 −4
Original line number Original line Diff line number Diff line
@@ -34,13 +34,11 @@ import com.android.systemui.complication.ComplicationLayoutParams.POSITION_TOP
import com.android.systemui.complication.ComplicationLayoutParams.Position
import com.android.systemui.complication.ComplicationLayoutParams.Position
import com.android.systemui.dreams.dagger.DreamOverlayModule
import com.android.systemui.dreams.dagger.DreamOverlayModule
import com.android.systemui.keyguard.ui.viewmodel.DreamingToLockscreenTransitionViewModel
import com.android.systemui.keyguard.ui.viewmodel.DreamingToLockscreenTransitionViewModel
import com.android.systemui.keyguard.ui.viewmodel.DreamingToLockscreenTransitionViewModel.Companion.DREAM_ANIMATION_DURATION
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.statusbar.BlurUtils
import com.android.systemui.statusbar.BlurUtils
import com.android.systemui.statusbar.CrossFadeHelper
import com.android.systemui.statusbar.CrossFadeHelper
import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener
import com.android.systemui.util.concurrency.DelayableExecutor
import javax.inject.Inject
import javax.inject.Inject
import javax.inject.Named
import javax.inject.Named
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.MutableStateFlow
@@ -129,6 +127,12 @@ constructor(
                        )
                        )
                    }
                    }
                }
                }

                launch {
                    transitionViewModel.transitionEnded.collect { _ ->
                        mOverlayStateController.setExitAnimationsRunning(false)
                    }
                }
            }
            }


            configController.removeCallback(configCallback)
            configController.removeCallback(configCallback)
@@ -251,9 +255,9 @@ constructor(
    }
    }


    /** Starts the dream content and dream overlay exit animations. */
    /** Starts the dream content and dream overlay exit animations. */
    fun wakeUp(doneCallback: Runnable, executor: DelayableExecutor) {
    fun wakeUp() {
        cancelAnimations()
        cancelAnimations()
        executor.executeDelayed(doneCallback, DREAM_ANIMATION_DURATION.inWholeMilliseconds)
        mOverlayStateController.setExitAnimationsRunning(true)
    }
    }


    /** Cancels the dream content and dream overlay animations, if they're currently running. */
    /** Cancels the dream content and dream overlay animations, if they're currently running. */
+2 −10
Original line number Original line Diff line number Diff line
@@ -31,8 +31,6 @@ import android.util.MathUtils;
import android.view.View;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup;


import androidx.annotation.NonNull;

import com.android.app.animation.Interpolators;
import com.android.app.animation.Interpolators;
import com.android.dream.lowlight.LowLightTransitionCoordinator;
import com.android.dream.lowlight.LowLightTransitionCoordinator;
import com.android.systemui.R;
import com.android.systemui.R;
@@ -46,7 +44,6 @@ import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInt
import com.android.systemui.shade.ShadeExpansionChangeEvent;
import com.android.systemui.shade.ShadeExpansionChangeEvent;
import com.android.systemui.statusbar.BlurUtils;
import com.android.systemui.statusbar.BlurUtils;
import com.android.systemui.util.ViewController;
import com.android.systemui.util.ViewController;
import com.android.systemui.util.concurrency.DelayableExecutor;


import java.util.Arrays;
import java.util.Arrays;


@@ -302,20 +299,15 @@ public class DreamOverlayContainerViewController extends


    /**
    /**
     * Handle the dream waking up and run any necessary animations.
     * Handle the dream waking up and run any necessary animations.
     *
     * @param onAnimationEnd Callback to trigger once animations are finished.
     * @param callbackExecutor Executor to execute the callback on.
     */
     */
    public void wakeUp(@NonNull Runnable onAnimationEnd,
    public void wakeUp() {
            @NonNull DelayableExecutor callbackExecutor) {
        // When swiping causes wakeup, do not run any animations as the dream should exit as soon
        // When swiping causes wakeup, do not run any animations as the dream should exit as soon
        // as possible.
        // as possible.
        if (mWakingUpFromSwipe) {
        if (mWakingUpFromSwipe) {
            onAnimationEnd.run();
            return;
            return;
        }
        }


        mDreamOverlayAnimationsController.wakeUp(onAnimationEnd, callbackExecutor);
        mDreamOverlayAnimationsController.wakeUp();
    }
    }


    @Override
    @Override
Loading