Skip to content

Commit

Permalink
Clean Memory Leak
Browse files Browse the repository at this point in the history
Differential Revision: D65700820

fbshipit-source-id: 1464aa7efa24f076b81527fd93c6bf7048b1f8c2
  • Loading branch information
Anthony Bajoua authored and facebook-github-bot committed Nov 12, 2024
1 parent 973d3fb commit 96089bc
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.infer.annotation.Nullsafe;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.Executor;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -151,14 +152,23 @@ private String getLocalFilePath(ImageRequest imageRequest) {
private static Bitmap createThumbnailFromContentProvider(
ContentResolver contentResolver, Uri uri) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD_MR1) {
MediaMetadataRetriever mediaMetadataRetriever = null;
try {
ParcelFileDescriptor videoFile = contentResolver.openFileDescriptor(uri, "r");
Preconditions.checkNotNull(videoFile);
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
mediaMetadataRetriever = new MediaMetadataRetriever();
mediaMetadataRetriever.setDataSource(videoFile.getFileDescriptor());
return mediaMetadataRetriever.getFrameAtTime(-1);
} catch (FileNotFoundException e) {
return null;
} finally {
if (mediaMetadataRetriever != null) {
try {
mediaMetadataRetriever.release();
} catch (IOException ex) {
// Nothing to do.
}
}
}
} else {
return null;
Expand Down

0 comments on commit 96089bc

Please sign in to comment.