Merge "Only use ALLOCATOR_DEFAULT when apps target Q."
This commit is contained in:
committed by
Android (Google) Code Review
commit
ee135b64ef
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user