GingerbreadPurgeableDecoder.smali
.class public Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;
.super Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;
.source "SourceFile"
# static fields
.field private static sGetFileDescriptorMethod:Ljava/lang/reflect/Method;
# instance fields
.field private final mH264BitmapFactory:Lcom/facebook/common/h264/H264BitmapFactory;
.field private final mHeifBitmapFactory:Lcom/facebook/common/heif/HeifBitmapFactory;
.field private final mWebpBitmapFactory:Lcom/facebook/common/webp/WebpBitmapFactory;
# direct methods
.method public constructor <init>()V
.registers 2
.line 51
invoke-direct {p0}, Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;-><init>()V
.line 52
invoke-static {}, Lcom/facebook/common/webp/WebpSupportStatus;->loadWebpBitmapFactoryIfExists()Lcom/facebook/common/webp/WebpBitmapFactory;
move-result-object v0
iput-object v0, p0, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->mWebpBitmapFactory:Lcom/facebook/common/webp/WebpBitmapFactory;
.line 53
invoke-static {}, Lcom/facebook/common/heif/HeifSupportStatus;->loadHeifBitmapFactoryIfExists()Lcom/facebook/common/heif/HeifBitmapFactory;
move-result-object v0
iput-object v0, p0, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->mHeifBitmapFactory:Lcom/facebook/common/heif/HeifBitmapFactory;
.line 54
invoke-static {}, Lcom/facebook/common/h264/H264SupportStatus;->loadH264BitmapFactoryIfExists()Lcom/facebook/common/h264/H264BitmapFactory;
move-result-object v0
iput-object v0, p0, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->mH264BitmapFactory:Lcom/facebook/common/h264/H264BitmapFactory;
return-void
.end method
.method private static copyToMemoryFile(Lcom/facebook/common/references/CloseableReference;I[B)Landroid/os/MemoryFile;
.registers 10
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/facebook/common/references/CloseableReference<",
"Lcom/facebook/common/memory/PooledByteBuffer;",
">;I[B)",
"Landroid/os/MemoryFile;"
}
.end annotation
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
const/4 v0, 0x0
if-nez p2, :cond_5
const/4 v1, 0x0
goto :goto_6
.line 91
:cond_5
array-length v1, p2
:goto_6
add-int/2addr v1, p1
.line 92
new-instance v2, Landroid/os/MemoryFile;
const/4 v3, 0x0
invoke-direct {v2, v3, v1}, Landroid/os/MemoryFile;-><init>(Ljava/lang/String;I)V
.line 93
invoke-virtual {v2, v0}, Landroid/os/MemoryFile;->allowPurging(Z)Z
const/4 v1, 0x1
.line 98
:try_start_11
new-instance v4, Lcom/facebook/common/memory/PooledByteBufferInputStream;
invoke-virtual {p0}, Lcom/facebook/common/references/CloseableReference;->get()Ljava/lang/Object;
move-result-object v5
check-cast v5, Lcom/facebook/common/memory/PooledByteBuffer;
invoke-direct {v4, v5}, Lcom/facebook/common/memory/PooledByteBufferInputStream;-><init>(Lcom/facebook/common/memory/PooledByteBuffer;)V
:try_end_1c
.catchall {:try_start_11 .. :try_end_1c} :catchall_43
.line 99
:try_start_1c
new-instance v5, Lcom/facebook/common/streams/LimitedInputStream;
invoke-direct {v5, v4, p1}, Lcom/facebook/common/streams/LimitedInputStream;-><init>(Ljava/io/InputStream;I)V
:try_end_21
.catchall {:try_start_1c .. :try_end_21} :catchall_3e
.line 100
:try_start_21
invoke-virtual {v2}, Landroid/os/MemoryFile;->getOutputStream()Ljava/io/OutputStream;
move-result-object v3
.line 101
invoke-static {v5, v3}, Lcom/facebook/common/internal/ByteStreams;->copy(Ljava/io/InputStream;Ljava/io/OutputStream;)J
if-eqz p2, :cond_2e
.line 103
array-length v6, p2
invoke-virtual {v2, p2, v0, p1, v6}, Landroid/os/MemoryFile;->writeBytes([BIII)V
:try_end_2e
.catchall {:try_start_21 .. :try_end_2e} :catchall_3b
.line 107
:cond_2e
invoke-static {p0}, Lcom/facebook/common/references/CloseableReference;->closeSafely(Lcom/facebook/common/references/CloseableReference;)V
.line 108
invoke-static {v4}, Lcom/facebook/common/internal/Closeables;->closeQuietly(Ljava/io/InputStream;)V
.line 109
invoke-static {v5}, Lcom/facebook/common/internal/Closeables;->closeQuietly(Ljava/io/InputStream;)V
.line 110
invoke-static {v3, v1}, Lcom/facebook/common/internal/Closeables;->close(Ljava/io/Closeable;Z)V
return-object v2
:catchall_3b
move-exception p1
move-object p2, v3
goto :goto_41
:catchall_3e
move-exception p1
move-object p2, v3
move-object v5, p2
:goto_41
move-object v3, v4
goto :goto_46
:catchall_43
move-exception p1
move-object p2, v3
move-object v5, p2
.line 107
:goto_46
invoke-static {p0}, Lcom/facebook/common/references/CloseableReference;->closeSafely(Lcom/facebook/common/references/CloseableReference;)V
.line 108
invoke-static {v3}, Lcom/facebook/common/internal/Closeables;->closeQuietly(Ljava/io/InputStream;)V
.line 109
invoke-static {v5}, Lcom/facebook/common/internal/Closeables;->closeQuietly(Ljava/io/InputStream;)V
.line 110
invoke-static {p2, v1}, Lcom/facebook/common/internal/Closeables;->close(Ljava/io/Closeable;Z)V
throw p1
.end method
.method private decodeFileDescriptorAsPurgeable(Lcom/facebook/common/references/CloseableReference;I[BLandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
.registers 7
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/facebook/common/references/CloseableReference<",
"Lcom/facebook/common/memory/PooledByteBuffer;",
">;I[B",
"Landroid/graphics/BitmapFactory$Options;",
")",
"Landroid/graphics/Bitmap;"
}
.end annotation
const/4 v0, 0x0
.line 141
:try_start_1
invoke-static {p1, p2, p3}, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->copyToMemoryFile(Lcom/facebook/common/references/CloseableReference;I[B)Landroid/os/MemoryFile;
move-result-object p1
:try_end_5
.catch Ljava/io/IOException; {:try_start_1 .. :try_end_5} :catch_51
.catchall {:try_start_1 .. :try_end_5} :catchall_4f
.line 142
:try_start_5
invoke-direct {p0, p1}, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->getMemoryFileDescriptor(Landroid/os/MemoryFile;)Ljava/io/FileDescriptor;
move-result-object p2
.line 144
iget-object p3, p0, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->mHeifBitmapFactory:Lcom/facebook/common/heif/HeifBitmapFactory;
if-eqz p3, :cond_14
.line 145
iget-object p3, p0, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->mHeifBitmapFactory:Lcom/facebook/common/heif/HeifBitmapFactory;
invoke-interface {p3, p2, v0, p4}, Lcom/facebook/common/heif/HeifBitmapFactory;->decodeFileDescriptor(Ljava/io/FileDescriptor;Landroid/graphics/Rect;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
move-result-object p3
goto :goto_15
:cond_14
move-object p3, v0
:goto_15
if-nez p3, :cond_21
.line 147
iget-object v1, p0, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->mH264BitmapFactory:Lcom/facebook/common/h264/H264BitmapFactory;
if-eqz v1, :cond_21
.line 148
iget-object p3, p0, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->mH264BitmapFactory:Lcom/facebook/common/h264/H264BitmapFactory;
invoke-interface {p3, p2, v0, p4}, Lcom/facebook/common/h264/H264BitmapFactory;->decodeFileDescriptor(Ljava/io/FileDescriptor;Landroid/graphics/Rect;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
move-result-object p3
:try_end_21
.catch Ljava/io/IOException; {:try_start_5 .. :try_end_21} :catch_4c
.catchall {:try_start_5 .. :try_end_21} :catchall_49
:cond_21
if-eqz p3, :cond_29
if-eqz p1, :cond_28
.line 163
invoke-virtual {p1}, Landroid/os/MemoryFile;->close()V
:cond_28
return-object p3
.line 153
:cond_29
:try_start_29
iget-object p3, p0, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->mWebpBitmapFactory:Lcom/facebook/common/webp/WebpBitmapFactory;
if-eqz p3, :cond_41
.line 154
iget-object p3, p0, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->mWebpBitmapFactory:Lcom/facebook/common/webp/WebpBitmapFactory;
invoke-interface {p3, p2, v0, p4}, Lcom/facebook/common/webp/WebpBitmapFactory;->decodeFileDescriptor(Ljava/io/FileDescriptor;Landroid/graphics/Rect;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
move-result-object p2
const-string p3, "BitmapFactory returned null"
.line 155
invoke-static {p2, p3}, Lcom/facebook/common/internal/Preconditions;->checkNotNull(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
move-result-object p2
check-cast p2, Landroid/graphics/Bitmap;
:try_end_3b
.catch Ljava/io/IOException; {:try_start_29 .. :try_end_3b} :catch_4c
.catchall {:try_start_29 .. :try_end_3b} :catchall_49
if-eqz p1, :cond_40
.line 163
invoke-virtual {p1}, Landroid/os/MemoryFile;->close()V
:cond_40
return-object p2
.line 157
:cond_41
:try_start_41
new-instance p2, Ljava/lang/IllegalStateException;
const-string p3, "WebpBitmapFactory is null"
invoke-direct {p2, p3}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p2
:try_end_49
.catch Ljava/io/IOException; {:try_start_41 .. :try_end_49} :catch_4c
.catchall {:try_start_41 .. :try_end_49} :catchall_49
:catchall_49
move-exception p2
move-object v0, p1
goto :goto_57
:catch_4c
move-exception p2
move-object v0, p1
goto :goto_52
:catchall_4f
move-exception p2
goto :goto_57
:catch_51
move-exception p2
.line 160
:goto_52
:try_start_52
invoke-static {p2}, Lcom/facebook/common/internal/Throwables;->propagate(Ljava/lang/Throwable;)Ljava/lang/RuntimeException;
move-result-object p1
throw p1
:try_end_57
.catchall {:try_start_52 .. :try_end_57} :catchall_4f
:goto_57
if-eqz v0, :cond_5c
.line 163
invoke-virtual {v0}, Landroid/os/MemoryFile;->close()V
:cond_5c
throw p2
.end method
.method private declared-synchronized getFileDescriptorMethod()Ljava/lang/reflect/Method;
.registers 4
monitor-enter p0
.line 115
:try_start_1
sget-object v0, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->sGetFileDescriptorMethod:Ljava/lang/reflect/Method;
:try_end_3
.catchall {:try_start_1 .. :try_end_3} :catchall_1d
if-nez v0, :cond_19
.line 117
:try_start_5
const-class v0, Landroid/os/MemoryFile;
const-string v1, "getFileDescriptor"
const/4 v2, 0x0
new-array v2, v2, [Ljava/lang/Class;
invoke-virtual {v0, v1, v2}, Ljava/lang/Class;->getDeclaredMethod(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
move-result-object v0
sput-object v0, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->sGetFileDescriptorMethod:Ljava/lang/reflect/Method;
:try_end_12
.catch Ljava/lang/Exception; {:try_start_5 .. :try_end_12} :catch_13
.catchall {:try_start_5 .. :try_end_12} :catchall_1d
goto :goto_19
:catch_13
move-exception v0
.line 119
:try_start_14
invoke-static {v0}, Lcom/facebook/common/internal/Throwables;->propagate(Ljava/lang/Throwable;)Ljava/lang/RuntimeException;
move-result-object v0
throw v0
.line 122
:cond_19
:goto_19
sget-object v0, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->sGetFileDescriptorMethod:Ljava/lang/reflect/Method;
:try_end_1b
.catchall {:try_start_14 .. :try_end_1b} :catchall_1d
monitor-exit p0
return-object v0
:catchall_1d
move-exception v0
monitor-exit p0
throw v0
.end method
.method private getMemoryFileDescriptor(Landroid/os/MemoryFile;)Ljava/io/FileDescriptor;
.registers 4
.line 127
:try_start_0
invoke-direct {p0}, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->getFileDescriptorMethod()Ljava/lang/reflect/Method;
move-result-object v0
const/4 v1, 0x0
new-array v1, v1, [Ljava/lang/Object;
invoke-virtual {v0, p1, v1}, Ljava/lang/reflect/Method;->invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
move-result-object p1
.line 128
check-cast p1, Ljava/io/FileDescriptor;
:try_end_d
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_d} :catch_e
return-object p1
:catch_e
move-exception p1
.line 130
invoke-static {p1}, Lcom/facebook/common/internal/Throwables;->propagate(Ljava/lang/Throwable;)Ljava/lang/RuntimeException;
move-result-object p1
throw p1
.end method
# virtual methods
.method public decodeByteArrayAsPurgeable(Lcom/facebook/common/references/CloseableReference;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
.registers 5
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/facebook/common/references/CloseableReference<",
"Lcom/facebook/common/memory/PooledByteBuffer;",
">;",
"Landroid/graphics/BitmapFactory$Options;",
")",
"Landroid/graphics/Bitmap;"
}
.end annotation
.line 67
invoke-virtual {p1}, Lcom/facebook/common/references/CloseableReference;->get()Ljava/lang/Object;
move-result-object v0
check-cast v0, Lcom/facebook/common/memory/PooledByteBuffer;
invoke-interface {v0}, Lcom/facebook/common/memory/PooledByteBuffer;->size()I
move-result v0
const/4 v1, 0x0
invoke-direct {p0, p1, v0, v1, p2}, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->decodeFileDescriptorAsPurgeable(Lcom/facebook/common/references/CloseableReference;I[BLandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
move-result-object p1
return-object p1
.end method
.method public decodeJPEGByteArrayAsPurgeable(Lcom/facebook/common/references/CloseableReference;ILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
.registers 5
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/facebook/common/references/CloseableReference<",
"Lcom/facebook/common/memory/PooledByteBuffer;",
">;I",
"Landroid/graphics/BitmapFactory$Options;",
")",
"Landroid/graphics/Bitmap;"
}
.end annotation
.line 83
invoke-static {p1, p2}, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->endsWithEOI(Lcom/facebook/common/references/CloseableReference;I)Z
move-result v0
if-eqz v0, :cond_8
const/4 v0, 0x0
goto :goto_a
:cond_8
sget-object v0, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->EOI:[B
.line 84
:goto_a
invoke-direct {p0, p1, p2, v0, p3}, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->decodeFileDescriptorAsPurgeable(Lcom/facebook/common/references/CloseableReference;I[BLandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
move-result-object p1
return-object p1
.end method