FileLockUtil.smali

.class public Lcom/umeng/commonsdk/utils/FileLockUtil;
.super Ljava/lang/Object;
.source "FileLockUtil.java"


# instance fields
.field private final lockObject:Ljava/lang/Object;


# direct methods
.method public constructor <init>()V
    .registers 2

    .prologue
    .line 15
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 17
    new-instance v0, Ljava/lang/Object;

    invoke-direct {v0}, Ljava/lang/Object;-><init>()V

    iput-object v0, p0, Lcom/umeng/commonsdk/utils/FileLockUtil;->lockObject:Ljava/lang/Object;

    return-void
.end method

.method private static getFileLock(Ljava/lang/String;)Ljava/nio/channels/FileLock;
    .registers 4

    .prologue
    const/4 v0, 0x0

    .line 139
    .line 142
    :try_start_1
    new-instance v1, Ljava/io/RandomAccessFile;

    const-string v2, "rw"

    invoke-direct {v1, p0, v2}, Ljava/io/RandomAccessFile;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    .line 143
    invoke-virtual {v1}, Ljava/io/RandomAccessFile;->getChannel()Ljava/nio/channels/FileChannel;
    :try_end_b
    .catch Ljava/io/FileNotFoundException; {:try_start_1 .. :try_end_b} :catch_11
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_b} :catch_21

    move-result-object v2

    .line 144
    :try_start_c
    invoke-virtual {v2}, Ljava/nio/channels/FileChannel;->lock()Ljava/nio/channels/FileLock;
    :try_end_f
    .catch Ljava/io/FileNotFoundException; {:try_start_c .. :try_end_f} :catch_29
    .catch Ljava/io/IOException; {:try_start_c .. :try_end_f} :catch_27

    move-result-object v0

    .line 160
    :cond_10
    :goto_10
    return-object v0

    .line 146
    :catch_11
    move-exception v1

    move-object v2, v0

    .line 147
    :goto_13
    invoke-virtual {v1}, Ljava/io/FileNotFoundException;->printStackTrace()V

    .line 152
    :goto_16
    if-eqz v2, :cond_10

    .line 154
    :try_start_18
    invoke-virtual {v2}, Ljava/nio/channels/FileChannel;->close()V
    :try_end_1b
    .catch Ljava/io/IOException; {:try_start_18 .. :try_end_1b} :catch_1c

    goto :goto_10

    .line 155
    :catch_1c
    move-exception v1

    .line 156
    invoke-virtual {v1}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_10

    .line 148
    :catch_21
    move-exception v1

    move-object v2, v0

    .line 149
    :goto_23
    invoke-virtual {v1}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_16

    .line 148
    :catch_27
    move-exception v1

    goto :goto_23

    .line 146
    :catch_29
    move-exception v1

    goto :goto_13
.end method


# virtual methods
.method public doFileOperateion(Ljava/io/File;Lcom/umeng/commonsdk/utils/FileLockCallback;)V
    .registers 6

    .prologue
    .line 80
    invoke-virtual {p1}, Ljava/io/File;->exists()Z

    move-result v0

    if-nez v0, :cond_7

    .line 100
    :goto_6
    return-void

    .line 83
    :cond_7
    iget-object v2, p0, Lcom/umeng/commonsdk/utils/FileLockUtil;->lockObject:Ljava/lang/Object;

    monitor-enter v2

    .line 84
    :try_start_a
    invoke-virtual {p1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v0

    invoke-static {v0}, Lcom/umeng/commonsdk/utils/FileLockUtil;->getFileLock(Ljava/lang/String;)Ljava/nio/channels/FileLock;
    :try_end_11
    .catchall {:try_start_a .. :try_end_11} :catchall_27

    move-result-object v1

    .line 85
    if-eqz v1, :cond_25

    .line 87
    :try_start_14
    invoke-virtual {p1}, Ljava/io/File;->getName()Ljava/lang/String;

    move-result-object v0

    invoke-interface {p2, v0}, Lcom/umeng/commonsdk/utils/FileLockCallback;->onFileLock(Ljava/lang/String;)Z
    :try_end_1b
    .catch Ljava/lang/Exception; {:try_start_14 .. :try_end_1b} :catch_2f
    .catchall {:try_start_14 .. :try_end_1b} :catchall_43

    .line 92
    :try_start_1b
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->release()V

    .line 93
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->channel()Ljava/nio/channels/FileChannel;

    move-result-object v0

    invoke-virtual {v0}, Ljava/nio/channels/FileChannel;->close()V
    :try_end_25
    .catch Ljava/io/IOException; {:try_start_1b .. :try_end_25} :catch_2a
    .catchall {:try_start_1b .. :try_end_25} :catchall_27

    .line 99
    :cond_25
    :goto_25
    :try_start_25
    monitor-exit v2

    goto :goto_6

    :catchall_27
    move-exception v0

    monitor-exit v2
    :try_end_29
    .catchall {:try_start_25 .. :try_end_29} :catchall_27

    throw v0

    .line 94
    :catch_2a
    move-exception v0

    .line 95
    :try_start_2b
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V
    :try_end_2e
    .catchall {:try_start_2b .. :try_end_2e} :catchall_27

    goto :goto_25

    .line 88
    :catch_2f
    move-exception v0

    .line 89
    :try_start_30
    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V
    :try_end_33
    .catchall {:try_start_30 .. :try_end_33} :catchall_43

    .line 92
    :try_start_33
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->release()V

    .line 93
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->channel()Ljava/nio/channels/FileChannel;

    move-result-object v0

    invoke-virtual {v0}, Ljava/nio/channels/FileChannel;->close()V
    :try_end_3d
    .catch Ljava/io/IOException; {:try_start_33 .. :try_end_3d} :catch_3e
    .catchall {:try_start_33 .. :try_end_3d} :catchall_27

    goto :goto_25

    .line 94
    :catch_3e
    move-exception v0

    .line 95
    :try_start_3f
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V
    :try_end_42
    .catchall {:try_start_3f .. :try_end_42} :catchall_27

    goto :goto_25

    .line 91
    :catchall_43
    move-exception v0

    .line 92
    :try_start_44
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->release()V

    .line 93
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->channel()Ljava/nio/channels/FileChannel;

    move-result-object v1

    invoke-virtual {v1}, Ljava/nio/channels/FileChannel;->close()V
    :try_end_4e
    .catch Ljava/io/IOException; {:try_start_44 .. :try_end_4e} :catch_4f
    .catchall {:try_start_44 .. :try_end_4e} :catchall_27

    .line 96
    :goto_4e
    :try_start_4e
    throw v0

    .line 94
    :catch_4f
    move-exception v1

    .line 95
    invoke-virtual {v1}, Ljava/io/IOException;->printStackTrace()V
    :try_end_53
    .catchall {:try_start_4e .. :try_end_53} :catchall_27

    goto :goto_4e
.end method

.method public doFileOperateion(Ljava/io/File;Lcom/umeng/commonsdk/utils/FileLockCallback;I)V
    .registers 7

    .prologue
    .line 50
    invoke-virtual {p1}, Ljava/io/File;->exists()Z

    move-result v0

    if-nez v0, :cond_7

    .line 71
    :goto_6
    return-void

    .line 53
    :cond_7
    iget-object v2, p0, Lcom/umeng/commonsdk/utils/FileLockUtil;->lockObject:Ljava/lang/Object;

    monitor-enter v2

    .line 54
    :try_start_a
    invoke-virtual {p1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v0

    invoke-static {v0}, Lcom/umeng/commonsdk/utils/FileLockUtil;->getFileLock(Ljava/lang/String;)Ljava/nio/channels/FileLock;
    :try_end_11
    .catchall {:try_start_a .. :try_end_11} :catchall_23

    move-result-object v1

    .line 55
    if-eqz v1, :cond_21

    .line 57
    :try_start_14
    invoke-interface {p2, p1, p3}, Lcom/umeng/commonsdk/utils/FileLockCallback;->onFileLock(Ljava/io/File;I)Z
    :try_end_17
    .catch Ljava/lang/Exception; {:try_start_14 .. :try_end_17} :catch_2b
    .catchall {:try_start_14 .. :try_end_17} :catchall_3f

    .line 62
    :try_start_17
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->release()V

    .line 63
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->channel()Ljava/nio/channels/FileChannel;

    move-result-object v0

    invoke-virtual {v0}, Ljava/nio/channels/FileChannel;->close()V
    :try_end_21
    .catch Ljava/lang/Throwable; {:try_start_17 .. :try_end_21} :catch_26
    .catchall {:try_start_17 .. :try_end_21} :catchall_23

    .line 70
    :cond_21
    :goto_21
    :try_start_21
    monitor-exit v2

    goto :goto_6

    :catchall_23
    move-exception v0

    monitor-exit v2
    :try_end_25
    .catchall {:try_start_21 .. :try_end_25} :catchall_23

    throw v0

    .line 64
    :catch_26
    move-exception v0

    .line 66
    :try_start_27
    invoke-virtual {v0}, Ljava/lang/Throwable;->printStackTrace()V
    :try_end_2a
    .catchall {:try_start_27 .. :try_end_2a} :catchall_23

    goto :goto_21

    .line 58
    :catch_2b
    move-exception v0

    .line 59
    :try_start_2c
    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V
    :try_end_2f
    .catchall {:try_start_2c .. :try_end_2f} :catchall_3f

    .line 62
    :try_start_2f
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->release()V

    .line 63
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->channel()Ljava/nio/channels/FileChannel;

    move-result-object v0

    invoke-virtual {v0}, Ljava/nio/channels/FileChannel;->close()V
    :try_end_39
    .catch Ljava/lang/Throwable; {:try_start_2f .. :try_end_39} :catch_3a
    .catchall {:try_start_2f .. :try_end_39} :catchall_23

    goto :goto_21

    .line 64
    :catch_3a
    move-exception v0

    .line 66
    :try_start_3b
    invoke-virtual {v0}, Ljava/lang/Throwable;->printStackTrace()V
    :try_end_3e
    .catchall {:try_start_3b .. :try_end_3e} :catchall_23

    goto :goto_21

    .line 61
    :catchall_3f
    move-exception v0

    .line 62
    :try_start_40
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->release()V

    .line 63
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->channel()Ljava/nio/channels/FileChannel;

    move-result-object v1

    invoke-virtual {v1}, Ljava/nio/channels/FileChannel;->close()V
    :try_end_4a
    .catch Ljava/lang/Throwable; {:try_start_40 .. :try_end_4a} :catch_4b
    .catchall {:try_start_40 .. :try_end_4a} :catchall_23

    .line 67
    :goto_4a
    :try_start_4a
    throw v0

    .line 64
    :catch_4b
    move-exception v1

    .line 66
    invoke-virtual {v1}, Ljava/lang/Throwable;->printStackTrace()V
    :try_end_4f
    .catchall {:try_start_4a .. :try_end_4f} :catchall_23

    goto :goto_4a
.end method

.method public doFileOperateion(Ljava/io/File;Lcom/umeng/commonsdk/utils/FileLockCallback;Ljava/lang/Object;)V
    .registers 7

    .prologue
    .line 27
    invoke-virtual {p1}, Ljava/io/File;->exists()Z

    move-result v0

    if-nez v0, :cond_7

    .line 47
    :goto_6
    return-void

    .line 30
    :cond_7
    iget-object v2, p0, Lcom/umeng/commonsdk/utils/FileLockUtil;->lockObject:Ljava/lang/Object;

    monitor-enter v2

    .line 31
    :try_start_a
    invoke-virtual {p1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v0

    invoke-static {v0}, Lcom/umeng/commonsdk/utils/FileLockUtil;->getFileLock(Ljava/lang/String;)Ljava/nio/channels/FileLock;
    :try_end_11
    .catchall {:try_start_a .. :try_end_11} :catchall_27

    move-result-object v1

    .line 32
    if-eqz v1, :cond_25

    .line 34
    :try_start_14
    invoke-virtual {p1}, Ljava/io/File;->getName()Ljava/lang/String;

    move-result-object v0

    invoke-interface {p2, v0, p3}, Lcom/umeng/commonsdk/utils/FileLockCallback;->onFileLock(Ljava/lang/String;Ljava/lang/Object;)Z
    :try_end_1b
    .catch Ljava/lang/Exception; {:try_start_14 .. :try_end_1b} :catch_2f
    .catchall {:try_start_14 .. :try_end_1b} :catchall_43

    .line 39
    :try_start_1b
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->release()V

    .line 40
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->channel()Ljava/nio/channels/FileChannel;

    move-result-object v0

    invoke-virtual {v0}, Ljava/nio/channels/FileChannel;->close()V
    :try_end_25
    .catch Ljava/io/IOException; {:try_start_1b .. :try_end_25} :catch_2a
    .catchall {:try_start_1b .. :try_end_25} :catchall_27

    .line 46
    :cond_25
    :goto_25
    :try_start_25
    monitor-exit v2

    goto :goto_6

    :catchall_27
    move-exception v0

    monitor-exit v2
    :try_end_29
    .catchall {:try_start_25 .. :try_end_29} :catchall_27

    throw v0

    .line 41
    :catch_2a
    move-exception v0

    .line 42
    :try_start_2b
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V
    :try_end_2e
    .catchall {:try_start_2b .. :try_end_2e} :catchall_27

    goto :goto_25

    .line 35
    :catch_2f
    move-exception v0

    .line 36
    :try_start_30
    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V
    :try_end_33
    .catchall {:try_start_30 .. :try_end_33} :catchall_43

    .line 39
    :try_start_33
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->release()V

    .line 40
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->channel()Ljava/nio/channels/FileChannel;

    move-result-object v0

    invoke-virtual {v0}, Ljava/nio/channels/FileChannel;->close()V
    :try_end_3d
    .catch Ljava/io/IOException; {:try_start_33 .. :try_end_3d} :catch_3e
    .catchall {:try_start_33 .. :try_end_3d} :catchall_27

    goto :goto_25

    .line 41
    :catch_3e
    move-exception v0

    .line 42
    :try_start_3f
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V
    :try_end_42
    .catchall {:try_start_3f .. :try_end_42} :catchall_27

    goto :goto_25

    .line 38
    :catchall_43
    move-exception v0

    .line 39
    :try_start_44
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->release()V

    .line 40
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->channel()Ljava/nio/channels/FileChannel;

    move-result-object v1

    invoke-virtual {v1}, Ljava/nio/channels/FileChannel;->close()V
    :try_end_4e
    .catch Ljava/io/IOException; {:try_start_44 .. :try_end_4e} :catch_4f
    .catchall {:try_start_44 .. :try_end_4e} :catchall_27

    .line 43
    :goto_4e
    :try_start_4e
    throw v0

    .line 41
    :catch_4f
    move-exception v1

    .line 42
    invoke-virtual {v1}, Ljava/io/IOException;->printStackTrace()V
    :try_end_53
    .catchall {:try_start_4e .. :try_end_53} :catchall_27

    goto :goto_4e
.end method

.method public doFileOperateion(Ljava/lang/String;Lcom/umeng/commonsdk/utils/FileLockCallback;)V
    .registers 6

    .prologue
    .line 109
    new-instance v0, Ljava/io/File;

    invoke-direct {v0, p1}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 110
    invoke-virtual {v0}, Ljava/io/File;->exists()Z

    move-result v1

    if-nez v1, :cond_c

    .line 130
    :goto_b
    return-void

    .line 113
    :cond_c
    iget-object v2, p0, Lcom/umeng/commonsdk/utils/FileLockUtil;->lockObject:Ljava/lang/Object;

    monitor-enter v2

    .line 114
    :try_start_f
    invoke-static {p1}, Lcom/umeng/commonsdk/utils/FileLockUtil;->getFileLock(Ljava/lang/String;)Ljava/nio/channels/FileLock;
    :try_end_12
    .catchall {:try_start_f .. :try_end_12} :catchall_28

    move-result-object v1

    .line 115
    if-eqz v1, :cond_26

    .line 117
    :try_start_15
    invoke-virtual {v0}, Ljava/io/File;->getName()Ljava/lang/String;

    move-result-object v0

    invoke-interface {p2, v0}, Lcom/umeng/commonsdk/utils/FileLockCallback;->onFileLock(Ljava/lang/String;)Z
    :try_end_1c
    .catch Ljava/lang/Exception; {:try_start_15 .. :try_end_1c} :catch_30
    .catchall {:try_start_15 .. :try_end_1c} :catchall_44

    .line 122
    :try_start_1c
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->release()V

    .line 123
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->channel()Ljava/nio/channels/FileChannel;

    move-result-object v0

    invoke-virtual {v0}, Ljava/nio/channels/FileChannel;->close()V
    :try_end_26
    .catch Ljava/io/IOException; {:try_start_1c .. :try_end_26} :catch_2b
    .catchall {:try_start_1c .. :try_end_26} :catchall_28

    .line 129
    :cond_26
    :goto_26
    :try_start_26
    monitor-exit v2

    goto :goto_b

    :catchall_28
    move-exception v0

    monitor-exit v2
    :try_end_2a
    .catchall {:try_start_26 .. :try_end_2a} :catchall_28

    throw v0

    .line 124
    :catch_2b
    move-exception v0

    .line 125
    :try_start_2c
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V
    :try_end_2f
    .catchall {:try_start_2c .. :try_end_2f} :catchall_28

    goto :goto_26

    .line 118
    :catch_30
    move-exception v0

    .line 119
    :try_start_31
    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V
    :try_end_34
    .catchall {:try_start_31 .. :try_end_34} :catchall_44

    .line 122
    :try_start_34
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->release()V

    .line 123
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->channel()Ljava/nio/channels/FileChannel;

    move-result-object v0

    invoke-virtual {v0}, Ljava/nio/channels/FileChannel;->close()V
    :try_end_3e
    .catch Ljava/io/IOException; {:try_start_34 .. :try_end_3e} :catch_3f
    .catchall {:try_start_34 .. :try_end_3e} :catchall_28

    goto :goto_26

    .line 124
    :catch_3f
    move-exception v0

    .line 125
    :try_start_40
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V
    :try_end_43
    .catchall {:try_start_40 .. :try_end_43} :catchall_28

    goto :goto_26

    .line 121
    :catchall_44
    move-exception v0

    .line 122
    :try_start_45
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->release()V

    .line 123
    invoke-virtual {v1}, Ljava/nio/channels/FileLock;->channel()Ljava/nio/channels/FileChannel;

    move-result-object v1

    invoke-virtual {v1}, Ljava/nio/channels/FileChannel;->close()V
    :try_end_4f
    .catch Ljava/io/IOException; {:try_start_45 .. :try_end_4f} :catch_50
    .catchall {:try_start_45 .. :try_end_4f} :catchall_28

    .line 126
    :goto_4f
    :try_start_4f
    throw v0

    .line 124
    :catch_50
    move-exception v1

    .line 125
    invoke-virtual {v1}, Ljava/io/IOException;->printStackTrace()V
    :try_end_54
    .catchall {:try_start_4f .. :try_end_54} :catchall_28

    goto :goto_4f
.end method