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

Commit b4f51b5d authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Only use ALLOCATOR_DEFAULT when apps target Q.

Bug: 119510493
Test: manual
Change-Id: Icd7acfd9f899dce46b24db2156acbb3a98b409c8
parent 8c33a548
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import android.graphics.ImageDecoder.Source;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.DeadObjectException;
@@ -3243,8 +3244,18 @@ public abstract class ContentResolver {
        Objects.requireNonNull(uri);
        Objects.requireNonNull(size);

        // Older apps might be relying on mutable results, so only consider
        // giving them hardware bitmaps once they target Q or higher. If modern
        // apps need mutable thumbnails, they can always roll their own logic.
        final int allocator;
        if (getTargetSdkVersion() >= Build.VERSION_CODES.Q) {
            allocator = ImageDecoder.ALLOCATOR_DEFAULT;
        } else {
            allocator = ImageDecoder.ALLOCATOR_SOFTWARE;
        }

        try (ContentProviderClient client = acquireContentProviderClient(uri)) {
            return loadThumbnail(client, uri, size, signal, ImageDecoder.ALLOCATOR_DEFAULT);
            return loadThumbnail(client, uri, size, signal, allocator);
        }
    }