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

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

Merge "[Divider] Fix a crash because of null renderer" into main

parents f1f1852c 2bf919a4
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -565,6 +565,7 @@ class DividerPresenter implements View.OnTouchListener {
        return true;
    }

    // Only called by onTouch() and mRenderer is already null-checked.
    @GuardedBy("mLock")
    private void onStartDragging(@NonNull MotionEvent event) {
        mVelocityTracker = VelocityTracker.obtain();
@@ -590,6 +591,7 @@ class DividerPresenter implements View.OnTouchListener {
        });
    }

    // Only called by onTouch() and mRenderer is already null-checked.
    @GuardedBy("mLock")
    private void onDrag(@NonNull MotionEvent event) {
        if (mVelocityTracker != null) {
@@ -660,16 +662,21 @@ class DividerPresenter implements View.OnTouchListener {

    @GuardedBy("mLock")
    private void updateDividerPosition(int position) {
        if (mRenderer != null) {
            mRenderer.setDividerPosition(position);
            mRenderer.updateSurface();
        }
    }

    @GuardedBy("mLock")
    private void onDraggingEnd() {
        // Veil visibility change should be applied together with the surface boost transaction in
        // the wct.
        final SurfaceControl.Transaction t = new SurfaceControl.Transaction();

        if (mRenderer != null) {
            mRenderer.hideVeils(t);
        }

        // Callbacks must be executed on the executor to release mLock and prevent deadlocks.
        // mDecorSurfaceOwner may change between here and when the callback is executed,
@@ -684,9 +691,11 @@ class DividerPresenter implements View.OnTouchListener {
                        }
                    });
        });
        if (mRenderer != null) {
            mRenderer.mIsDragging = false;
            mRenderer.mDragHandle.setPressed(mRenderer.mIsDragging);
        }
    }

    /**
     * Returns the divider position adjusted for the min max ratio and fullscreen expansion.