WebpSupportStatus.smali
.class public Lcom/facebook/common/webp/WebpSupportStatus;
.super Ljava/lang/Object;
.source "WebpSupportStatus.java"
# static fields
.field private static final EXTENDED_WEBP_HEADER_LENGTH:I = 0x15
.field private static final SIMPLE_WEBP_HEADER_LENGTH:I = 0x14
.field private static final VP8X_WEBP_BASE64:Ljava/lang/String; = "UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA=="
.field private static final WEBP_NAME_BYTES:[B
.field private static final WEBP_RIFF_BYTES:[B
.field private static final WEBP_VP8L_BYTES:[B
.field private static final WEBP_VP8X_BYTES:[B
.field private static final WEBP_VP8_BYTES:[B
.field public static final sIsExtendedWebpSupported:Z
.field public static final sIsSimpleWebpSupported:Z
.field public static final sIsWebpSupportRequired:Z
.field public static sWebpBitmapFactory:Lcom/facebook/common/webp/WebpBitmapFactory;
.annotation runtime Ljavax/annotation/Nullable;
.end annotation
.end field
.field private static sWebpLibraryChecked:Z
# direct methods
.method static constructor <clinit>()V
.registers 4
.line 19
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
const/4 v1, 0x1
const/4 v2, 0x0
const/16 v3, 0x11
if-gt v0, v3, :cond_a
move v0, v1
goto :goto_b
:cond_a
move v0, v2
:goto_b
sput-boolean v0, Lcom/facebook/common/webp/WebpSupportStatus;->sIsWebpSupportRequired:Z
.line 22
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
const/16 v3, 0xe
if-lt v0, v3, :cond_14
goto :goto_15
:cond_14
move v1, v2
:goto_15
sput-boolean v1, Lcom/facebook/common/webp/WebpSupportStatus;->sIsSimpleWebpSupported:Z
.line 25
invoke-static {}, Lcom/facebook/common/webp/WebpSupportStatus;->isExtendedWebpSupported()Z
move-result v0
sput-boolean v0, Lcom/facebook/common/webp/WebpSupportStatus;->sIsExtendedWebpSupported:Z
const/4 v0, 0x0
.line 27
sput-object v0, Lcom/facebook/common/webp/WebpSupportStatus;->sWebpBitmapFactory:Lcom/facebook/common/webp/WebpBitmapFactory;
.line 29
sput-boolean v2, Lcom/facebook/common/webp/WebpSupportStatus;->sWebpLibraryChecked:Z
const-string v0, "RIFF"
.line 78
invoke-static {v0}, Lcom/facebook/common/webp/WebpSupportStatus;->asciiBytes(Ljava/lang/String;)[B
move-result-object v0
sput-object v0, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_RIFF_BYTES:[B
const-string v0, "WEBP"
.line 79
invoke-static {v0}, Lcom/facebook/common/webp/WebpSupportStatus;->asciiBytes(Ljava/lang/String;)[B
move-result-object v0
sput-object v0, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_NAME_BYTES:[B
const-string v0, "VP8 "
.line 82
invoke-static {v0}, Lcom/facebook/common/webp/WebpSupportStatus;->asciiBytes(Ljava/lang/String;)[B
move-result-object v0
sput-object v0, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_VP8_BYTES:[B
const-string v0, "VP8L"
.line 84
invoke-static {v0}, Lcom/facebook/common/webp/WebpSupportStatus;->asciiBytes(Ljava/lang/String;)[B
move-result-object v0
sput-object v0, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_VP8L_BYTES:[B
const-string v0, "VP8X"
.line 85
invoke-static {v0}, Lcom/facebook/common/webp/WebpSupportStatus;->asciiBytes(Ljava/lang/String;)[B
move-result-object v0
sput-object v0, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_VP8X_BYTES:[B
return-void
.end method
.method public constructor <init>()V
.registers 1
.line 18
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method private static asciiBytes(Ljava/lang/String;)[B
.registers 3
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x0
}
names = {
"value"
}
.end annotation
:try_start_0
const-string v0, "ASCII"
.line 60
invoke-virtual {p0, v0}, Ljava/lang/String;->getBytes(Ljava/lang/String;)[B
move-result-object p0
:try_end_6
.catch Ljava/io/UnsupportedEncodingException; {:try_start_0 .. :try_end_6} :catch_7
return-object p0
:catch_7
move-exception p0
.line 63
new-instance v0, Ljava/lang/RuntimeException;
const-string v1, "ASCII not found!"
invoke-direct {v0, v1, p0}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
throw v0
.end method
.method public static isAnimatedWebpHeader([BI)Z
.registers 5
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x10,
0x10
}
names = {
"imageHeaderBytes",
"offset"
}
.end annotation
add-int/lit8 v0, p1, 0xc
.line 137
sget-object v1, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_VP8X_BYTES:[B
invoke-static {p0, v0, v1}, Lcom/facebook/common/webp/WebpSupportStatus;->matchBytePattern([BI[B)Z
move-result v0
add-int/lit8 p1, p1, 0x14
.line 139
aget-byte p0, p0, p1
const/4 p1, 0x2
and-int/2addr p0, p1
const/4 v1, 0x1
const/4 v2, 0x0
if-ne p0, p1, :cond_14
move p0, v1
goto :goto_15
:cond_14
move p0, v2
:goto_15
if-eqz v0, :cond_1a
if-eqz p0, :cond_1a
goto :goto_1b
:cond_1a
move v1, v2
:goto_1b
return v1
.end method
.method public static isExtendedWebpHeader([BII)Z
.registers 4
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x10,
0x10,
0x10
}
names = {
"imageHeaderBytes",
"offset",
"headerSize"
}
.end annotation
const/16 v0, 0x15
if-lt p2, v0, :cond_10
add-int/lit8 p1, p1, 0xc
.line 153
sget-object p2, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_VP8X_BYTES:[B
.line 154
invoke-static {p0, p1, p2}, Lcom/facebook/common/webp/WebpSupportStatus;->matchBytePattern([BI[B)Z
move-result p0
if-eqz p0, :cond_10
const/4 p0, 0x1
goto :goto_11
:cond_10
const/4 p0, 0x0
:goto_11
return p0
.end method
.method public static isExtendedWebpHeaderWithAlpha([BI)Z
.registers 5
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x10,
0x10
}
names = {
"imageHeaderBytes",
"offset"
}
.end annotation
add-int/lit8 v0, p1, 0xc
.line 159
sget-object v1, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_VP8X_BYTES:[B
invoke-static {p0, v0, v1}, Lcom/facebook/common/webp/WebpSupportStatus;->matchBytePattern([BI[B)Z
move-result v0
add-int/lit8 p1, p1, 0x14
.line 161
aget-byte p0, p0, p1
const/16 p1, 0x10
and-int/2addr p0, p1
const/4 v1, 0x1
const/4 v2, 0x0
if-ne p0, p1, :cond_15
move p0, v1
goto :goto_16
:cond_15
move p0, v2
:goto_16
if-eqz v0, :cond_1b
if-eqz p0, :cond_1b
goto :goto_1c
:cond_1b
move v1, v2
:goto_1c
return v1
.end method
.method private static isExtendedWebpSupported()Z
.registers 5
.line 92
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
const/16 v1, 0x11
const/4 v2, 0x0
if-ge v0, v1, :cond_8
return v2
.line 96
:cond_8
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
const/4 v3, 0x1
if-ne v0, v1, :cond_27
const-string v0, "UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA=="
.line 99
invoke-static {v0, v2}, Landroid/util/Base64;->decode(Ljava/lang/String;I)[B
move-result-object v0
.line 100
new-instance v1, Landroid/graphics/BitmapFactory$Options;
invoke-direct {v1}, Landroid/graphics/BitmapFactory$Options;-><init>()V
.line 101
iput-boolean v3, v1, Landroid/graphics/BitmapFactory$Options;->inJustDecodeBounds:Z
.line 102
array-length v4, v0
invoke-static {v0, v2, v4, v1}, Landroid/graphics/BitmapFactory;->decodeByteArray([BIILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
.line 108
iget v0, v1, Landroid/graphics/BitmapFactory$Options;->outHeight:I
if-ne v0, v3, :cond_26
iget v0, v1, Landroid/graphics/BitmapFactory$Options;->outWidth:I
if-eq v0, v3, :cond_27
:cond_26
return v2
:cond_27
return v3
.end method
.method public static isLosslessWebpHeader([BI)Z
.registers 3
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x10,
0x10
}
names = {
"imageHeaderBytes",
"offset"
}
.end annotation
add-int/lit8 p1, p1, 0xc
.line 148
sget-object v0, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_VP8L_BYTES:[B
invoke-static {p0, p1, v0}, Lcom/facebook/common/webp/WebpSupportStatus;->matchBytePattern([BI[B)Z
move-result p0
return p0
.end method
.method public static isSimpleWebpHeader([BI)Z
.registers 3
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x10,
0x10
}
names = {
"imageHeaderBytes",
"offset"
}
.end annotation
add-int/lit8 p1, p1, 0xc
.line 144
sget-object v0, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_VP8_BYTES:[B
invoke-static {p0, p1, v0}, Lcom/facebook/common/webp/WebpSupportStatus;->matchBytePattern([BI[B)Z
move-result p0
return p0
.end method
.method public static isWebpHeader([BII)Z
.registers 4
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x10,
0x10,
0x10
}
names = {
"imageHeaderBytes",
"offset",
"headerSize"
}
.end annotation
const/16 v0, 0x14
if-lt p2, v0, :cond_18
.line 176
sget-object p2, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_RIFF_BYTES:[B
.line 177
invoke-static {p0, p1, p2}, Lcom/facebook/common/webp/WebpSupportStatus;->matchBytePattern([BI[B)Z
move-result p2
if-eqz p2, :cond_18
add-int/lit8 p1, p1, 0x8
sget-object p2, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_NAME_BYTES:[B
.line 178
invoke-static {p0, p1, p2}, Lcom/facebook/common/webp/WebpSupportStatus;->matchBytePattern([BI[B)Z
move-result p0
if-eqz p0, :cond_18
const/4 p0, 0x1
goto :goto_19
:cond_18
const/4 p0, 0x0
:goto_19
return p0
.end method
.method public static isWebpSupportedByPlatform([BII)Z
.registers 4
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x10,
0x10,
0x10
}
names = {
"imageHeaderBytes",
"offset",
"headerSize"
}
.end annotation
.line 118
invoke-static {p0, p1}, Lcom/facebook/common/webp/WebpSupportStatus;->isSimpleWebpHeader([BI)Z
move-result v0
if-eqz v0, :cond_9
.line 119
sget-boolean p0, Lcom/facebook/common/webp/WebpSupportStatus;->sIsSimpleWebpSupported:Z
return p0
.line 122
:cond_9
invoke-static {p0, p1}, Lcom/facebook/common/webp/WebpSupportStatus;->isLosslessWebpHeader([BI)Z
move-result v0
if-eqz v0, :cond_12
.line 123
sget-boolean p0, Lcom/facebook/common/webp/WebpSupportStatus;->sIsExtendedWebpSupported:Z
return p0
.line 126
:cond_12
invoke-static {p0, p1, p2}, Lcom/facebook/common/webp/WebpSupportStatus;->isExtendedWebpHeader([BII)Z
move-result p2
const/4 v0, 0x0
if-eqz p2, :cond_23
.line 127
invoke-static {p0, p1}, Lcom/facebook/common/webp/WebpSupportStatus;->isAnimatedWebpHeader([BI)Z
move-result p0
if-eqz p0, :cond_20
return v0
.line 130
:cond_20
sget-boolean p0, Lcom/facebook/common/webp/WebpSupportStatus;->sIsExtendedWebpSupported:Z
return p0
:cond_23
return v0
.end method
.method public static loadWebpBitmapFactoryIfExists()Lcom/facebook/common/webp/WebpBitmapFactory;
.registers 2
.annotation runtime Ljavax/annotation/Nullable;
.end annotation
.line 32
sget-boolean v0, Lcom/facebook/common/webp/WebpSupportStatus;->sWebpLibraryChecked:Z
if-eqz v0, :cond_7
.line 33
sget-object v0, Lcom/facebook/common/webp/WebpSupportStatus;->sWebpBitmapFactory:Lcom/facebook/common/webp/WebpBitmapFactory;
return-object v0
:cond_7
const/4 v0, 0x0
:try_start_8
const-string v1, "com.facebook.webpsupport.WebpBitmapFactoryImpl"
.line 39
invoke-static {v1}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/Class;->newInstance()Ljava/lang/Object;
move-result-object v1
check-cast v1, Lcom/facebook/common/webp/WebpBitmapFactory;
:try_end_14
.catchall {:try_start_8 .. :try_end_14} :catchall_15
move-object v0, v1
:catchall_15
const/4 v1, 0x1
.line 43
sput-boolean v1, Lcom/facebook/common/webp/WebpSupportStatus;->sWebpLibraryChecked:Z
return-object v0
.end method
.method private static matchBytePattern([BI[B)Z
.registers 7
.annotation system Ldalvik/annotation/MethodParameters;
accessFlags = {
0x10,
0x10,
0x10
}
names = {
"byteArray",
"offset",
"pattern"
}
.end annotation
const/4 v0, 0x0
if-eqz p2, :cond_1e
if-nez p0, :cond_6
goto :goto_1e
.line 186
:cond_6
array-length v1, p2
add-int/2addr v1, p1
array-length v2, p0
if-le v1, v2, :cond_c
return v0
:cond_c
move v1, v0
.line 190
:goto_d
array-length v2, p2
if-ge v1, v2, :cond_1c
add-int v2, v1, p1
.line 191
aget-byte v2, p0, v2
aget-byte v3, p2, v1
if-eq v2, v3, :cond_19
return v0
:cond_19
add-int/lit8 v1, v1, 0x1
goto :goto_d
:cond_1c
const/4 p0, 0x1
return p0
:cond_1e
:goto_1e
return v0
.end method