a.smali
.class public Lcom/baidu/mapsdkplatform/comapi/commonutils/a;
.super Ljava/lang/Object;
# static fields
.field private static final a:Z
# direct methods
.method static constructor <clinit>()V
.registers 2
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
const/16 v1, 0x8
if-lt v0, v1, :cond_8
const/4 v0, 0x1
goto :goto_9
:cond_8
const/4 v0, 0x0
:goto_9
sput-boolean v0, Lcom/baidu/mapsdkplatform/comapi/commonutils/a;->a:Z
return-void
.end method
.method public constructor <init>()V
.registers 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method public static a(Ljava/lang/String;Landroid/content/Context;)Landroid/graphics/Bitmap;
.registers 4
:try_start_0
invoke-virtual {p1}, Landroid/content/Context;->getAssets()Landroid/content/res/AssetManager;
move-result-object v0
invoke-virtual {v0, p0}, Landroid/content/res/AssetManager;->open(Ljava/lang/String;)Ljava/io/InputStream;
move-result-object v0
if-eqz v0, :cond_f
invoke-static {v0}, Landroid/graphics/BitmapFactory;->decodeStream(Ljava/io/InputStream;)Landroid/graphics/Bitmap;
move-result-object p0
:try_end_e
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_e} :catch_11
return-object p0
:cond_f
const/4 p0, 0x0
return-object p0
:catch_11
move-exception v0
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
const-string v1, "assets/"
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v0
invoke-static {v0, p0, p1}, Lcom/baidu/mapsdkplatform/comapi/commonutils/a;->b(Ljava/lang/String;Ljava/lang/String;Landroid/content/Context;)Ljava/lang/String;
move-result-object p0
invoke-static {p0}, Landroid/graphics/BitmapFactory;->decodeFile(Ljava/lang/String;)Landroid/graphics/Bitmap;
move-result-object p0
return-object p0
.end method
.method private static a(Ljava/io/InputStream;Ljava/io/FileOutputStream;)V
.registers 5
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
const/16 v0, 0x1000
new-array v0, v0, [B
:goto_4
:try_start_4
invoke-virtual {p0, v0}, Ljava/io/InputStream;->read([B)I
move-result v1
const/4 v2, -0x1
if-eq v1, v2, :cond_10
const/4 v2, 0x0
invoke-virtual {p1, v0, v2, v1}, Ljava/io/FileOutputStream;->write([BII)V
goto :goto_4
:cond_10
invoke-virtual {p1}, Ljava/io/FileOutputStream;->flush()V
:try_end_13
.catchall {:try_start_4 .. :try_end_13} :catchall_1e
:try_start_13
invoke-virtual {p0}, Ljava/io/InputStream;->close()V
:try_end_16
.catch Ljava/io/IOException; {:try_start_13 .. :try_end_16} :catch_17
goto :goto_18
:catch_17
move-exception p0
:goto_18
:try_start_18
invoke-virtual {p1}, Ljava/io/FileOutputStream;->close()V
:try_end_1b
.catch Ljava/io/IOException; {:try_start_18 .. :try_end_1b} :catch_1c
goto :goto_1d
:catch_1c
move-exception p0
:goto_1d
return-void
:catchall_1e
move-exception v0
:try_start_1f
invoke-virtual {p0}, Ljava/io/InputStream;->close()V
:try_end_22
.catch Ljava/io/IOException; {:try_start_1f .. :try_end_22} :catch_23
goto :goto_24
:catch_23
move-exception p0
:goto_24
:try_start_24
invoke-virtual {p1}, Ljava/io/FileOutputStream;->close()V
:try_end_27
.catch Ljava/io/IOException; {:try_start_24 .. :try_end_27} :catch_28
goto :goto_29
:catch_28
move-exception p0
:goto_29
goto :goto_2b
:goto_2a
throw v0
:goto_2b
goto :goto_2a
.end method
.method public static a(Ljava/lang/String;Ljava/lang/String;Landroid/content/Context;)V
.registers 9
const/4 v0, 0x0
:try_start_1
invoke-virtual {p2}, Landroid/content/Context;->getAssets()Landroid/content/res/AssetManager;
move-result-object v1
invoke-virtual {v1, p0}, Landroid/content/res/AssetManager;->open(Ljava/lang/String;)Ljava/io/InputStream;
move-result-object v1
:try_end_9
.catch Ljava/lang/Exception; {:try_start_1 .. :try_end_9} :catch_6f
.catchall {:try_start_1 .. :try_end_9} :catchall_6c
if-eqz v1, :cond_5a
:try_start_b
invoke-virtual {v1}, Ljava/io/InputStream;->available()I
move-result v2
new-array v2, v2, [B
invoke-virtual {v1, v2}, Ljava/io/InputStream;->read([B)I
new-instance v3, Ljava/io/File;
new-instance v4, Ljava/lang/StringBuilder;
invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V
invoke-virtual {p2}, Landroid/content/Context;->getFilesDir()Ljava/io/File;
move-result-object v5
invoke-virtual {v5}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;
move-result-object v5
invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string v5, "/"
invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v4, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v4
invoke-direct {v3, v4}, Ljava/io/File;-><init>(Ljava/lang/String;)V
invoke-virtual {v3}, Ljava/io/File;->exists()Z
move-result v4
if-eqz v4, :cond_3e
invoke-virtual {v3}, Ljava/io/File;->delete()Z
:cond_3e
invoke-virtual {v3}, Ljava/io/File;->createNewFile()Z
new-instance v4, Ljava/io/FileOutputStream;
invoke-direct {v4, v3}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V
:try_end_46
.catch Ljava/lang/Exception; {:try_start_b .. :try_end_46} :catch_56
.catchall {:try_start_b .. :try_end_46} :catchall_52
:try_start_46
invoke-virtual {v4, v2}, Ljava/io/FileOutputStream;->write([B)V
invoke-virtual {v4}, Ljava/io/FileOutputStream;->close()V
:try_end_4c
.catch Ljava/lang/Exception; {:try_start_46 .. :try_end_4c} :catch_50
.catchall {:try_start_46 .. :try_end_4c} :catchall_4e
move-object v0, v4
goto :goto_5a
:catchall_4e
move-exception p0
goto :goto_54
:catch_50
move-exception v0
goto :goto_58
:catchall_52
move-exception p0
move-object v4, v0
:goto_54
move-object v0, v1
goto :goto_91
:catch_56
move-exception v2
move-object v4, v0
:goto_58
move-object v0, v1
goto :goto_71
:cond_5a
:goto_5a
if-eqz v1, :cond_62
:try_start_5c
invoke-virtual {v1}, Ljava/io/InputStream;->close()V
goto :goto_62
:catch_60
move-exception p0
goto :goto_68
:cond_62
:goto_62
if-eqz v0, :cond_8f
invoke-virtual {v0}, Ljava/io/FileOutputStream;->close()V
:try_end_67
.catch Ljava/io/IOException; {:try_start_5c .. :try_end_67} :catch_60
goto :goto_8f
:goto_68
invoke-virtual {p0}, Ljava/io/IOException;->printStackTrace()V
goto :goto_8f
:catchall_6c
move-exception p0
move-object v4, v0
goto :goto_91
:catch_6f
move-exception v1
move-object v4, v0
:goto_71
:try_start_71
new-instance v1, Ljava/lang/StringBuilder;
invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
const-string v2, "assets/"
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p0
invoke-static {p0, p1, p2}, Lcom/baidu/mapsdkplatform/comapi/commonutils/a;->b(Ljava/lang/String;Ljava/lang/String;Landroid/content/Context;)Ljava/lang/String;
:try_end_85
.catchall {:try_start_71 .. :try_end_85} :catchall_90
if-eqz v0, :cond_8a
:try_start_87
invoke-virtual {v0}, Ljava/io/InputStream;->close()V
:cond_8a
if-eqz v4, :cond_8f
invoke-virtual {v4}, Ljava/io/FileOutputStream;->close()V
:try_end_8f
.catch Ljava/io/IOException; {:try_start_87 .. :try_end_8f} :catch_60
:cond_8f
:goto_8f
return-void
:catchall_90
move-exception p0
:goto_91
if-eqz v0, :cond_99
:try_start_93
invoke-virtual {v0}, Ljava/io/InputStream;->close()V
goto :goto_99
:catch_97
move-exception p1
goto :goto_9f
:cond_99
:goto_99
if-eqz v4, :cond_a2
invoke-virtual {v4}, Ljava/io/FileOutputStream;->close()V
:try_end_9e
.catch Ljava/io/IOException; {:try_start_93 .. :try_end_9e} :catch_97
goto :goto_a2
:goto_9f
invoke-virtual {p1}, Ljava/io/IOException;->printStackTrace()V
:cond_a2
:goto_a2
throw p0
.end method
.method private static b(Ljava/lang/String;Ljava/lang/String;Landroid/content/Context;)Ljava/lang/String;
.registers 11
const-string v0, "/"
new-instance v1, Ljava/lang/StringBuilder;
invoke-virtual {p2}, Landroid/content/Context;->getFilesDir()Ljava/io/File;
move-result-object v2
invoke-virtual {v2}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;
move-result-object v2
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
sget-boolean v2, Lcom/baidu/mapsdkplatform/comapi/commonutils/a;->a:Z
if-eqz v2, :cond_18
invoke-virtual {p2}, Landroid/content/Context;->getPackageCodePath()Ljava/lang/String;
move-result-object v2
goto :goto_1a
:cond_18
const-string v2, ""
:goto_1a
const/4 v3, 0x0
:try_start_1b
new-instance v4, Ljava/util/zip/ZipFile;
invoke-direct {v4, v2}, Ljava/util/zip/ZipFile;-><init>(Ljava/lang/String;)V
:try_end_20
.catch Ljava/lang/Exception; {:try_start_1b .. :try_end_20} :catch_a1
.catchall {:try_start_1b .. :try_end_20} :catchall_9f
:try_start_20
invoke-virtual {p1, v0}, Ljava/lang/String;->lastIndexOf(Ljava/lang/String;)I
move-result v2
if-lez v2, :cond_5e
new-instance v5, Ljava/io/File;
invoke-virtual {p2}, Landroid/content/Context;->getFilesDir()Ljava/io/File;
move-result-object p2
invoke-virtual {p2}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;
move-result-object p2
invoke-direct {v5, p2}, Ljava/io/File;-><init>(Ljava/lang/String;)V
const/4 p2, 0x0
invoke-virtual {p1, p2, v2}, Ljava/lang/String;->substring(II)Ljava/lang/String;
move-result-object p2
add-int/lit8 v2, v2, 0x1
invoke-virtual {p1}, Ljava/lang/String;->length()I
move-result v6
invoke-virtual {p1, v2, v6}, Ljava/lang/String;->substring(II)Ljava/lang/String;
move-result-object p1
new-instance v2, Ljava/io/File;
new-instance v6, Ljava/lang/StringBuilder;
invoke-direct {v6}, Ljava/lang/StringBuilder;-><init>()V
invoke-virtual {v5}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;
move-result-object v7
invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v6, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v6, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p2
invoke-direct {v2, p2, p1}, Ljava/io/File;-><init>(Ljava/lang/String;Ljava/lang/String;)V
goto :goto_72
:cond_5e
new-instance v5, Ljava/io/File;
invoke-virtual {p2}, Landroid/content/Context;->getFilesDir()Ljava/io/File;
move-result-object p2
const-string v2, "assets"
invoke-direct {v5, p2, v2}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V
new-instance v2, Ljava/io/File;
invoke-virtual {v5}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;
move-result-object p2
invoke-direct {v2, p2, p1}, Ljava/io/File;-><init>(Ljava/lang/String;Ljava/lang/String;)V
:goto_72
invoke-virtual {v5}, Ljava/io/File;->mkdirs()Z
invoke-virtual {v4, p0}, Ljava/util/zip/ZipFile;->getEntry(Ljava/lang/String;)Ljava/util/zip/ZipEntry;
move-result-object p1
:try_end_79
.catch Ljava/lang/Exception; {:try_start_20 .. :try_end_79} :catch_9c
.catchall {:try_start_20 .. :try_end_79} :catchall_99
if-nez p1, :cond_81
:try_start_7b
invoke-virtual {v4}, Ljava/util/zip/ZipFile;->close()V
:try_end_7e
.catch Ljava/io/IOException; {:try_start_7b .. :try_end_7e} :catch_7f
goto :goto_80
:catch_7f
move-exception p0
:goto_80
return-object v3
:cond_81
:try_start_81
invoke-virtual {v4, p1}, Ljava/util/zip/ZipFile;->getInputStream(Ljava/util/zip/ZipEntry;)Ljava/io/InputStream;
move-result-object p1
new-instance p2, Ljava/io/FileOutputStream;
invoke-direct {p2, v2}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V
invoke-static {p1, p2}, Lcom/baidu/mapsdkplatform/comapi/commonutils/a;->a(Ljava/io/InputStream;Ljava/io/FileOutputStream;)V
invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
:try_end_93
.catch Ljava/lang/Exception; {:try_start_81 .. :try_end_93} :catch_9c
.catchall {:try_start_81 .. :try_end_93} :catchall_99
:try_start_93
invoke-virtual {v4}, Ljava/util/zip/ZipFile;->close()V
:try_end_96
.catch Ljava/io/IOException; {:try_start_93 .. :try_end_96} :catch_97
goto :goto_b2
:catch_97
move-exception p0
goto :goto_b2
:catchall_99
move-exception p0
move-object v3, v4
goto :goto_b7
:catch_9c
move-exception p0
move-object v3, v4
goto :goto_a2
:catchall_9f
move-exception p0
goto :goto_b7
:catch_a1
move-exception p0
:goto_a2
:try_start_a2
const-class p1, Lcom/baidu/mapsdkplatform/comapi/commonutils/a;
invoke-virtual {p1}, Ljava/lang/Class;->getSimpleName()Ljava/lang/String;
move-result-object p1
const-string p2, "copyAssetsError"
invoke-static {p1, p2, p0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
:try_end_ad
.catchall {:try_start_a2 .. :try_end_ad} :catchall_9f
if-eqz v3, :cond_b2
:try_start_af
invoke-virtual {v3}, Ljava/util/zip/ZipFile;->close()V
:try_end_b2
.catch Ljava/io/IOException; {:try_start_af .. :try_end_b2} :catch_97
:cond_b2
:goto_b2
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p0
return-object p0
:goto_b7
if-eqz v3, :cond_be
:try_start_b9
invoke-virtual {v3}, Ljava/util/zip/ZipFile;->close()V
:try_end_bc
.catch Ljava/io/IOException; {:try_start_b9 .. :try_end_bc} :catch_bd
goto :goto_be
:catch_bd
move-exception p1
:cond_be
:goto_be
throw p0
.end method