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

Commit 6019a225 authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Merge "Attemp to release bitmap resource for ImmobileIconDrawable" into main

parents 5e112d23 b46cbdac
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -56,6 +56,8 @@ import com.android.internal.R;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.policy.DecorView;

import java.io.Closeable;
import java.io.IOException;
import java.time.Duration;
import java.time.Instant;
import java.util.function.Consumer;
@@ -568,6 +570,12 @@ public final class SplashScreenView extends FrameLayout {
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        releaseAnimationSurfaceHost();
        if (mIconView instanceof ImageView imageView
                && imageView.getDrawable() instanceof Closeable closeableDrawable) {
            try {
                closeableDrawable.close();
            } catch (IOException ignore) { }
        }
    }

    @Override
+12 −1
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.window.SplashScreenView;

import com.android.internal.R;

import java.io.Closeable;
import java.util.function.LongConsumer;

/**
@@ -100,7 +101,7 @@ public class SplashscreenIconDrawableFactory {
     * Drawable pre-drawing the scaled icon in a separate thread to increase the speed of the
     * final drawing.
     */
    private static class ImmobileIconDrawable extends Drawable {
    private static class ImmobileIconDrawable extends Drawable implements Closeable {
        private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG
                | Paint.FILTER_BITMAP_FLAG);
        private final Matrix mMatrix = new Matrix();
@@ -154,6 +155,16 @@ public class SplashscreenIconDrawableFactory {
        public int getOpacity() {
            return 1;
        }

        @Override
        public void close() {
            synchronized (mPaint) {
                if (mIconBitmap != null) {
                    mIconBitmap.recycle();
                    mIconBitmap = null;
                }
            }
        }
    }

    /**