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

Commit 09120546 authored by Lucas Silva's avatar Lucas Silva
Browse files

Implement dream out overlay transition

The overlay should blur and animate the complications when the dream is waking up. This adds a new API to DreamOverlayService to get notified of dreams waking, so that it can run the animation. When the animation is done, we communicate back to the DreamService so that it may finish itself.

A delay was added to the touch handler which hides the overlay when a
touch happens, in order to ensure the exit animation has a chance to
complete first.

Bug: 220311554
Test: atest DreamOverlayAnimationsControllerTest
Test: atest HideComplicationTouchHandlerTest
Test: atest DreamOverlayContainerViewControllerTest
Test: atest DreamOverlayServiceTest
Test: flashed device and verified animation looks correct when tapping
dream to exit

Change-Id: Ibccd45aefbf9b8aeb462d843794c3434c49a6bf2
parent 2d7fb7b2
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -49,6 +49,17 @@ public abstract class DreamOverlayService extends Service {
            mShowComplications = shouldShowComplications;
            onStartDream(layoutParams);
        }

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

    IDreamOverlayCallback mDreamOverlayCallback;
@@ -70,6 +81,17 @@ public abstract class DreamOverlayService extends Service {
     */
    public abstract void onStartDream(@NonNull WindowManager.LayoutParams layoutParams);

    /**
     * This method is overridden by implementations to handle when the dream has been requested
     * to wakeup. This allows any overlay animations to run.
     *
     * @param onCompleteCallback The callback to trigger to notify the dream service that the
     *                           overlay has completed waking up.
     * @hide
     */
    public void onWakeUp(@NonNull Runnable onCompleteCallback) {
    }

    /**
     * This method is invoked to request the dream exit.
     */
+20 −2
Original line number Diff line number Diff line
@@ -312,7 +312,14 @@ public class DreamService extends Service implements Window.Callback {
        @Override
        public void onExitRequested() {
            // Simply finish dream when exit is requested.
            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());
        }
    };

@@ -975,8 +982,19 @@ public class DreamService extends Service implements Window.Callback {
     * </p>
     */
    public void onWakeUp() {
        if (mOverlayConnection != null) {
            mOverlayConnection.addConsumer(overlay -> {
                try {
                    overlay.wakeUp();
                } catch (RemoteException e) {
                    Slog.e(TAG, "Error waking the overlay service", e);
                    finish();
                }
            });
        } else {
            finish();
        }
    }

    /** {@inheritDoc} */
    @Override
+3 −0
Original line number Diff line number Diff line
@@ -38,4 +38,7 @@ interface IDreamOverlay {
    */
    void startDream(in LayoutParams params, in IDreamOverlayCallback callback,
        in String dreamComponent, in boolean shouldShowComplications);

    /** Called when the dream is waking, to do any exit animations */
    void wakeUp();
}
+3 −0
Original line number Diff line number Diff line
@@ -28,4 +28,7 @@ interface IDreamOverlayCallback {
    * Invoked to request the dream exit.
    */
    void onExitRequested();

    /** Invoked when the dream overlay wakeUp animation is complete. */
    void onWakeUpComplete();
}
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -2485,7 +2485,7 @@
    <!-- The duration in milliseconds of the dream opening animation.  -->
    <integer name="config_dreamOpenAnimationDuration">250</integer>
    <!-- The duration in milliseconds of the dream closing animation.  -->
    <integer name="config_dreamCloseAnimationDuration">100</integer>
    <integer name="config_dreamCloseAnimationDuration">300</integer>

    <!-- Whether to dismiss the active dream when an activity is started. Doesn't apply to
         assistant activities (ACTIVITY_TYPE_ASSISTANT) -->
Loading