GingerbreadPurgeableDecoder.smali
.class public Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;
.super Lcom/facebook/imagepipeline/nativecode/DalvikPurgeableDecoder;
.source "GingerbreadPurgeableDecoder.java"
# static fields
.field private static sGetFileDescriptorMethod:Ljava/lang/reflect/Method;
# instance fields
.field private final mWebpBitmapFactory:Lcom/facebook/common/webp/WebpBitmapFactory;
.annotation runtime Ljavax/annotation/Nullable;
.end annotation
.end field
# 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;
return-void
.end method
.method private static copyToMemoryFile(Lcom/facebook/common/references/CloseableReference;I[B)Landroid/os/MemoryFile;
.registers 10
.param p2 # [B
.annotation runtime Ljavax/annotation/Nullable;
.end annotation
.end param
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x0,
0x0,
0x0
}
names = {
"bytesRef",
"inputLength",
"suffix"
}
.end annotation
.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
move v1, v0
goto :goto_6
.line 88
:cond_5
array-length v1, p2
:goto_6
add-int/2addr v1, p1
.line 89
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 90
invoke-virtual {v2, v0}, Landroid/os/MemoryFile;->allowPurging(Z)Z
const/4 v1, 0x1
.line 95
: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 96
: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 97
:try_start_21
invoke-virtual {v2}, Landroid/os/MemoryFile;->getOutputStream()Ljava/io/OutputStream;
move-result-object v3
.line 98
invoke-static {v5, v3}, Lcom/facebook/common/internal/ByteStreams;->copy(Ljava/io/InputStream;Ljava/io/OutputStream;)J
if-eqz p2, :cond_2e
.line 100
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 104
:cond_2e
invoke-static {p0}, Lcom/facebook/common/references/CloseableReference;->closeSafely(Lcom/facebook/common/references/CloseableReference;)V
.line 105
invoke-static {v4}, Lcom/facebook/common/internal/Closeables;->closeQuietly(Ljava/io/InputStream;)V
.line 106
invoke-static {v5}, Lcom/facebook/common/internal/Closeables;->closeQuietly(Ljava/io/InputStream;)V
.line 107
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 104
:goto_46
invoke-static {p0}, Lcom/facebook/common/references/CloseableReference;->closeSafely(Lcom/facebook/common/references/CloseableReference;)V
.line 105
invoke-static {v3}, Lcom/facebook/common/internal/Closeables;->closeQuietly(Ljava/io/InputStream;)V
.line 106
invoke-static {v5}, Lcom/facebook/common/internal/Closeables;->closeQuietly(Ljava/io/InputStream;)V
.line 107
invoke-static {p2, v1}, Lcom/facebook/common/internal/Closeables;->close(Ljava/io/Closeable;Z)V
.line 108
throw p1
.end method
.method private decodeFileDescriptorAsPurgeable(Lcom/facebook/common/references/CloseableReference;I[BLandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
.registers 6
.param p3 # [B
.annotation runtime Ljavax/annotation/Nullable;
.end annotation
.end param
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x0,
0x0,
0x0,
0x0
}
names = {
"bytesRef",
"inputLength",
"suffix",
"options"
}
.end annotation
.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 138
: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_2f
.catchall {:try_start_1 .. :try_end_5} :catchall_2d
.line 139
:try_start_5
invoke-direct {p0, p1}, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->getMemoryFileDescriptor(Landroid/os/MemoryFile;)Ljava/io/FileDescriptor;
move-result-object p2
.line 140
iget-object p3, p0, Lcom/facebook/imagepipeline/platform/GingerbreadPurgeableDecoder;->mWebpBitmapFactory:Lcom/facebook/common/webp/WebpBitmapFactory;
if-eqz p3, :cond_1f
.line 141
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 142
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_19
.catch Ljava/io/IOException; {:try_start_5 .. :try_end_19} :catch_2a
.catchall {:try_start_5 .. :try_end_19} :catchall_27
if-eqz p1, :cond_1e
.line 150
invoke-virtual {p1}, Landroid/os/MemoryFile;->close()V
:cond_1e
return-object p2
.line 144
:cond_1f
:try_start_1f
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_27
.catch Ljava/io/IOException; {:try_start_1f .. :try_end_27} :catch_2a
.catchall {:try_start_1f .. :try_end_27} :catchall_27
:catchall_27
move-exception p2
move-object v0, p1
goto :goto_35
:catch_2a
move-exception p2
move-object v0, p1
goto :goto_30
:catchall_2d
move-exception p2
goto :goto_35
:catch_2f
move-exception p2
.line 147
:goto_30
:try_start_30
invoke-static {p2}, Lcom/facebook/common/internal/Throwables;->propagate(Ljava/lang/Throwable;)Ljava/lang/RuntimeException;
move-result-object p1
throw p1
:try_end_35
.catchall {:try_start_30 .. :try_end_35} :catchall_2d
:goto_35
if-eqz v0, :cond_3a
.line 150
invoke-virtual {v0}, Landroid/os/MemoryFile;->close()V
.line 152
:cond_3a
throw p2
.end method
.method private declared-synchronized getFileDescriptorMethod()Ljava/lang/reflect/Method;
.registers 4
monitor-enter p0
.line 112
: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 114
: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 116
: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 119
: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
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x0
}
names = {
"memoryFile"
}
.end annotation
.line 124
: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
invoke-static {p1}, Lcom/facebook/common/internal/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object p1
.line 125
check-cast p1, Ljava/io/FileDescriptor;
:try_end_11
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_11} :catch_12
return-object p1
:catch_12
move-exception p1
.line 127
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 protected decodeByteArrayAsPurgeable(Lcom/facebook/common/references/CloseableReference;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
.registers 5
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x0,
0x0
}
names = {
"bytesRef",
"options"
}
.end annotation
.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 65
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 protected decodeJPEGByteArrayAsPurgeable(Lcom/facebook/common/references/CloseableReference;ILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
.registers 5
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x0,
0x0,
0x0
}
names = {
"bytesRef",
"length",
"options"
}
.end annotation
.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 81
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 82
: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