f.smali

.class public Lcom/huawei/updatesdk/support/pm/f;
.super Ljava/lang/Object;


# static fields
.field private static a:I


# direct methods
.method static constructor <clinit>()V
    .registers 1

    const/4 v0, -0x1

    sput v0, Lcom/huawei/updatesdk/support/pm/f;->a:I

    return-void
.end method

.method public static a(Ljava/io/File;Ljava/io/File;)Z
    .registers 5

    const/4 v1, 0x1

    const/4 v0, 0x0

    invoke-virtual {p0, p1}, Ljava/io/File;->renameTo(Ljava/io/File;)Z

    move-result v2

    if-nez v2, :cond_17

    invoke-static {p0, p1}, Lcom/huawei/updatesdk/support/pm/f;->b(Ljava/io/File;Ljava/io/File;)Z

    move-result v2

    if-nez v2, :cond_16

    const-string v1, "PkgManageUtils"

    const-string v2, "can not copy the file to new Path"

    invoke-static {v1, v2}, Lcom/huawei/updatesdk/sdk/a/b/a/a/a;->d(Ljava/lang/String;Ljava/lang/String;)V

    :goto_15
    return v0

    :cond_16
    move v0, v1

    :cond_17
    if-eqz v0, :cond_26

    invoke-virtual {p0}, Ljava/io/File;->delete()Z

    move-result v0

    if-nez v0, :cond_26

    const-string v0, "PkgManageUtils"

    const-string v2, "can not delete old file"

    invoke-static {v0, v2}, Lcom/huawei/updatesdk/sdk/a/b/a/a/a;->d(Ljava/lang/String;Ljava/lang/String;)V

    :cond_26
    move v0, v1

    goto :goto_15
.end method

.method private static a(Ljava/io/InputStream;Ljava/io/File;)Z
    .registers 8

    const/4 v0, 0x0

    :try_start_1
    invoke-virtual {p1}, Ljava/io/File;->exists()Z

    move-result v1

    if-eqz v1, :cond_14

    invoke-virtual {p1}, Ljava/io/File;->delete()Z

    move-result v1

    if-nez v1, :cond_14

    const-string v1, "PkgManageUtils"

    const-string v2, "destFile delete error."

    invoke-static {v1, v2}, Lcom/huawei/updatesdk/sdk/a/b/a/a/a;->b(Ljava/lang/String;Ljava/lang/String;)V

    :cond_14
    new-instance v3, Ljava/io/FileOutputStream;

    invoke-direct {v3, p1}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V
    :try_end_19
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_19} :catch_37

    const/16 v1, 0x1000

    :try_start_1b
    new-array v1, v1, [B

    :goto_1d
    invoke-virtual {p0, v1}, Ljava/io/InputStream;->read([B)I

    move-result v2

    if-ltz v2, :cond_39

    const/4 v4, 0x0

    invoke-virtual {v3, v1, v4, v2}, Ljava/io/FileOutputStream;->write([BII)V
    :try_end_27
    .catchall {:try_start_1b .. :try_end_27} :catchall_28

    goto :goto_1d

    :catchall_28
    move-exception v1

    :try_start_29
    invoke-virtual {v3}, Ljava/io/FileOutputStream;->flush()V
    :try_end_2c
    .catch Ljava/io/IOException; {:try_start_29 .. :try_end_2c} :catch_63

    :goto_2c
    :try_start_2c
    invoke-virtual {v3}, Ljava/io/FileOutputStream;->getFD()Ljava/io/FileDescriptor;

    move-result-object v2

    invoke-virtual {v2}, Ljava/io/FileDescriptor;->sync()V
    :try_end_33
    .catch Ljava/io/IOException; {:try_start_2c .. :try_end_33} :catch_6c

    :goto_33
    :try_start_33
    invoke-virtual {v3}, Ljava/io/FileOutputStream;->close()V
    :try_end_36
    .catch Ljava/io/IOException; {:try_start_33 .. :try_end_36} :catch_75

    :goto_36
    :try_start_36
    throw v1
    :try_end_37
    .catch Ljava/io/IOException; {:try_start_36 .. :try_end_37} :catch_37

    :catch_37
    move-exception v1

    :goto_38
    return v0

    :cond_39
    :try_start_39
    invoke-virtual {v3}, Ljava/io/FileOutputStream;->flush()V
    :try_end_3c
    .catch Ljava/io/IOException; {:try_start_39 .. :try_end_3c} :catch_48

    :goto_3c
    :try_start_3c
    invoke-virtual {v3}, Ljava/io/FileOutputStream;->getFD()Ljava/io/FileDescriptor;

    move-result-object v1

    invoke-virtual {v1}, Ljava/io/FileDescriptor;->sync()V
    :try_end_43
    .catch Ljava/io/IOException; {:try_start_3c .. :try_end_43} :catch_51

    :goto_43
    :try_start_43
    invoke-virtual {v3}, Ljava/io/FileOutputStream;->close()V
    :try_end_46
    .catch Ljava/io/IOException; {:try_start_43 .. :try_end_46} :catch_5a

    :goto_46
    const/4 v0, 0x1

    goto :goto_38

    :catch_48
    move-exception v1

    :try_start_49
    const-string v2, "PkgManageUtils"

    const-string v4, ""

    invoke-static {v2, v4, v1}, Lcom/huawei/updatesdk/sdk/a/b/a/a/a;->a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V

    goto :goto_3c

    :catch_51
    move-exception v1

    const-string v2, "PkgManageUtils"

    const-string v4, ""

    invoke-static {v2, v4, v1}, Lcom/huawei/updatesdk/sdk/a/b/a/a/a;->a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V

    goto :goto_43

    :catch_5a
    move-exception v1

    const-string v2, "PkgManageUtils"

    const-string v3, ""

    invoke-static {v2, v3, v1}, Lcom/huawei/updatesdk/sdk/a/b/a/a/a;->a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V

    goto :goto_46

    :catch_63
    move-exception v2

    const-string v4, "PkgManageUtils"

    const-string v5, ""

    invoke-static {v4, v5, v2}, Lcom/huawei/updatesdk/sdk/a/b/a/a/a;->a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V

    goto :goto_2c

    :catch_6c
    move-exception v2

    const-string v4, "PkgManageUtils"

    const-string v5, ""

    invoke-static {v4, v5, v2}, Lcom/huawei/updatesdk/sdk/a/b/a/a/a;->a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V

    goto :goto_33

    :catch_75
    move-exception v2

    const-string v3, "PkgManageUtils"

    const-string v4, ""

    invoke-static {v3, v4, v2}, Lcom/huawei/updatesdk/sdk/a/b/a/a/a;->a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    :try_end_7d
    .catch Ljava/io/IOException; {:try_start_49 .. :try_end_7d} :catch_37

    goto :goto_36
.end method

.method private static b(Ljava/io/File;Ljava/io/File;)Z
    .registers 4

    :try_start_0
    new-instance v1, Ljava/io/FileInputStream;

    invoke-direct {v1, p0}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V
    :try_end_5
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_5} :catch_12

    :try_start_5
    invoke-static {v1, p1}, Lcom/huawei/updatesdk/support/pm/f;->a(Ljava/io/InputStream;Ljava/io/File;)Z
    :try_end_8
    .catchall {:try_start_5 .. :try_end_8} :catchall_d

    move-result v0

    :try_start_9
    invoke-virtual {v1}, Ljava/io/InputStream;->close()V

    :goto_c
    return v0

    :catchall_d
    move-exception v0

    invoke-virtual {v1}, Ljava/io/InputStream;->close()V

    throw v0
    :try_end_12
    .catch Ljava/io/IOException; {:try_start_9 .. :try_end_12} :catch_12

    :catch_12
    move-exception v0

    const-string v0, "PkgManageUtils"

    const-string v1, "copyFile IOException"

    invoke-static {v0, v1}, Lcom/huawei/updatesdk/sdk/a/b/a/a/a;->d(Ljava/lang/String;Ljava/lang/String;)V

    const/4 v0, 0x0

    goto :goto_c
.end method