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

Commit 187aa9c3 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[Divider] Fix two bugs in interactive divider" into main

parents b3e41e16 7c3ba804
Loading
Loading
Loading
Loading
+28 −7
Original line number Diff line number Diff line
@@ -256,8 +256,10 @@ class DividerPresenter implements View.OnTouchListener {
    static Color getContainerBackgroundColor(
            @NonNull TaskFragmentContainer container, @NonNull Color defaultColor) {
        final Activity activity = container.getTopNonFinishingActivity();
        if (activity == null || !activity.isResumed()) {
            // This can happen when the top activity in the container is from a different process.
        if (activity == null) {
            // This can happen when the activities in the container are from a different process.
            // TODO(b/340984203) Report whether the top activity is in the same process. Use default
            // color if not.
            return defaultColor;
        }

@@ -515,8 +517,11 @@ class DividerPresenter implements View.OnTouchListener {
    private void onStartDragging() {
        mRenderer.mIsDragging = true;
        mRenderer.mDragHandle.setPressed(mRenderer.mIsDragging);
        mRenderer.updateSurface();

        // Veil visibility change should be applied together with the surface boost transaction in
        // the wct.
        final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
        mRenderer.updateSurface(t);
        mRenderer.showVeils(t);

        // Callbacks must be executed on the executor to release mLock and prevent deadlocks.
@@ -532,18 +537,18 @@ class DividerPresenter implements View.OnTouchListener {

    @GuardedBy("mLock")
    private void onDrag() {
        final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
        mRenderer.updateSurface(t);
        t.apply();
        mRenderer.updateSurface();
    }

    @GuardedBy("mLock")
    private void onFinishDragging() {
        mDividerPosition = adjustDividerPositionForSnapPoints(mDividerPosition);
        mRenderer.setDividerPosition(mDividerPosition);
        mRenderer.updateSurface();

        // Veil visibility change should be applied together with the surface boost transaction in
        // the wct.
        final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
        mRenderer.updateSurface(t);
        mRenderer.hideVeils(t);

        // Callbacks must be executed on the executor to release mLock and prevent deadlocks.
@@ -994,6 +999,22 @@ class DividerPresenter implements View.OnTouchListener {
         * Updates the positions and crops of the divider surface and veil surfaces. This method
         * should be called when {@link #mProperties} is changed or while dragging to update the
         * position of the divider surface and the veil surfaces.
         *
         * This method applies the changes in a stand-alone surface transaction immediately.
         */
        private void updateSurface() {
            final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
            updateSurface(t);
            t.apply();
        }

        /**
         * Updates the positions and crops of the divider surface and veil surfaces. This method
         * should be called when {@link #mProperties} is changed or while dragging to update the
         * position of the divider surface and the veil surfaces.
         *
         * This method applies the changes in the provided surface transaction and can be synced
         * with other changes.
         */
        private void updateSurface(@NonNull SurfaceControl.Transaction t) {
            final Rect taskBounds = mProperties.mConfiguration.windowConfiguration.getBounds();
+1 −8
Original line number Diff line number Diff line
@@ -631,15 +631,8 @@ public class DividerPresenterTest {
        assertEquals(defaultColor,
                DividerPresenter.getContainerBackgroundColor(container, defaultColor));

        // When the top non-finishing activity is not resumed, the default color should be returned.
        // When the top non-finishing activity is non-null, its background color should be returned.
        when(container.getTopNonFinishingActivity()).thenReturn(activity);
        when(activity.isResumed()).thenReturn(false);
        assertEquals(defaultColor,
                DividerPresenter.getContainerBackgroundColor(container, defaultColor));

        // When the top non-finishing activity is resumed, its background color should be returned.
        when(container.getTopNonFinishingActivity()).thenReturn(activity);
        when(activity.isResumed()).thenReturn(true);
        assertEquals(activityBackgroundColor,
                DividerPresenter.getContainerBackgroundColor(container, defaultColor));
    }