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

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

Merge "[Memory Leak] Fix leak of rotation button view from...

Merge "[Memory Leak] Fix leak of rotation button view from AnimatedVectorDrawable and container view" into main
parents 5871cdb4 e6521602
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -192,6 +192,28 @@ public class FloatingRotationButton implements RotationButton {
        return true;
    }

    @Override
    public void onDestroy() {
        setRotationButtonController(null);
        setOnClickListener(null);
        setOnHoverListener(null);
        setUpdatesCallback(null);

        if (mKeyButtonContainer.isAttachedToWindow()) {
            mWindowManager.removeViewImmediate(mKeyButtonContainer);
        }

        mKeyButtonView.animate().cancel();
        mAnimatedDrawable.stop();
        mKeyButtonView.setImageDrawable(null);
        // Calling AnimatedDrawable#stop() and ImageView.setImageDrawable(null) above will not let
        // RenderThread clear ref to view (via AnimatedVectorDrawable$VectorDrawableAnimatorRT)
        // quick enough for LeakCanary to ignore the leak. To mute LeakCanary, a workaround is to
        // clear the mKeyButtonView.mParent so that LeakCanary won't complain the leak on
        // mKeyButtonContainer.
        mKeyButtonContainer.removeView(mKeyButtonView);
    }

    @Override
    public boolean isVisible() {
        return mIsShowing;
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ public interface RotationButton {
    }
    default boolean show() { return false; }
    default boolean hide() { return false; }
    default void onDestroy() {}
    default boolean isVisible() {
        return false;
    }
+1 −4
Original line number Diff line number Diff line
@@ -206,10 +206,7 @@ public class RotationButtonController {
        if (mRotationButton == null) {
            return;
        }
        mRotationButton.setRotationButtonController(null);
        mRotationButton.setOnClickListener(null);
        mRotationButton.setOnHoverListener(null);
        mRotationButton.setUpdatesCallback(null);
        mRotationButton.onDestroy();
        mRotationButton = null;
    }