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

Commit c798beca authored by Tiger's avatar Tiger
Browse files

Release leashes which won't be used

If the insets animation will be delayed, the copied leashes won't used
anymore. In this case, we should release them. Otherwise, they will be
leaked.

Fix: 315532224
Test: presubmit
Change-Id: If7e0146e177f2c5c8ef9ee71a10bef3f9bb7a6ac
parent 237a75b1
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro
            Trace.asyncTraceEnd(Trace.TRACE_TAG_VIEW,
                    "InsetsAsyncAnimation: " + WindowInsets.Type.toString(runner.getTypes()),
                    runner.getTypes());
            releaseControls(mControl.getControls());
            InsetsController.releaseControls(mControl.getControls());
            mMainThreadHandler.post(() ->
                    mOuterCallbacks.notifyFinished(InsetsAnimationThreadControlRunner.this, shown));
        }
@@ -130,12 +130,6 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro
        });
    }

    private void releaseControls(SparseArray<InsetsSourceControl> controls) {
        for (int i = controls.size() - 1; i >= 0; i--) {
            controls.valueAt(i).release(SurfaceControl::release);
        }
    }

    @Override
    @UiThread
    public void dumpDebug(ProtoOutputStream proto, long fieldId) {
+9 −0
Original line number Diff line number Diff line
@@ -1353,6 +1353,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
                });
            }

            // The leashes are copied, but they won't be used.
            releaseControls(controls);

            // The requested visibilities should be delayed as well. Otherwise, we might override
            // the insets visibility before playing animation.
            setRequestedVisibleTypes(mReportedRequestedVisibleTypes, types);
@@ -1422,6 +1425,12 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
        }
    }

    static void releaseControls(SparseArray<InsetsSourceControl> controls) {
        for (int i = controls.size() - 1; i >= 0; i--) {
            controls.valueAt(i).release(SurfaceControl::release);
        }
    }

    // TODO(b/242962223): Make this setter restrictive.
    @Override
    public void setSystemDrivenInsetsAnimationLoggingListener(