.class public final Lz5/xr1;
.super Lz5/a3;
.source ""


# instance fields
.field public A:Z

.field public final v:Landroid/content/ContentResolver;

.field public w:Landroid/net/Uri;

.field public x:Landroid/content/res/AssetFileDescriptor;

.field public y:Ljava/io/FileInputStream;

.field public z:J


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .registers 3

    const/4 v0, 0x0

    invoke-direct {p0, v0}, Lz5/a3;-><init>(Z)V

    invoke-virtual {p1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object p1

    iput-object p1, p0, Lz5/xr1;->v:Landroid/content/ContentResolver;

    return-void
.end method


# virtual methods
.method public final a([BII)I
    .registers 12

    if-nez p3, :cond_4

    const/4 p1, 0x0

    return p1

    :cond_4
    iget-wide v0, p0, Lz5/xr1;->z:J

    const-wide/16 v2, 0x0

    cmp-long v2, v0, v2

    const/4 v3, -0x1

    if-eqz v2, :cond_3b

    const-wide/16 v4, -0x1

    cmp-long v2, v0, v4

    if-eqz v2, :cond_19

    int-to-long v6, p3

    :try_start_14
    invoke-static {v0, v1, v6, v7}, Ljava/lang/Math;->min(JJ)J

    move-result-wide v0

    long-to-int p3, v0

    :cond_19
    iget-object v0, p0, Lz5/xr1;->y:Ljava/io/FileInputStream;

    sget v1, Lz5/r7;->a:I

    invoke-virtual {v0, p1, p2, p3}, Ljava/io/FileInputStream;->read([BII)I

    move-result p1
    :try_end_21
    .catch Ljava/io/IOException; {:try_start_14 .. :try_end_21} :catch_32

    if-ne p1, v3, :cond_24

    return v3

    :cond_24
    iget-wide p2, p0, Lz5/xr1;->z:J

    cmp-long v0, p2, v4

    if-eqz v0, :cond_2e

    int-to-long v0, p1

    sub-long/2addr p2, v0

    iput-wide p2, p0, Lz5/xr1;->z:J

    :cond_2e
    invoke-virtual {p0, p1}, Lz5/a3;->m(I)V

    return p1

    :catch_32
    move-exception p1

    new-instance p2, Lz5/wr1;

    const/16 p3, 0x7d0

    invoke-direct {p2, p1, p3}, Lz5/wr1;-><init>(Ljava/io/IOException;I)V

    throw p2

    :cond_3b
    return v3
.end method

.method public final h(Lz5/a8;)J
    .registers 17

    move-object v1, p0

    move-object/from16 v0, p1

    :try_start_3
    iget-object v4, v0, Lz5/a8;->a:Landroid/net/Uri;

    iput-object v4, v1, Lz5/xr1;->w:Landroid/net/Uri;

    invoke-virtual/range {p0 .. p1}, Lz5/a3;->c(Lz5/a8;)V

    const-string v5, "content"

    iget-object v6, v0, Lz5/a8;->a:Landroid/net/Uri;

    invoke-virtual {v6}, Landroid/net/Uri;->getScheme()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v5, v6}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v5

    if-eqz v5, :cond_2f

    new-instance v5, Landroid/os/Bundle;

    invoke-direct {v5}, Landroid/os/Bundle;-><init>()V

    sget v6, Lz5/r7;->a:I

    const/16 v7, 0x1f

    if-lt v6, v7, :cond_26

    invoke-static {v5}, Lz5/vr1;->a(Landroid/os/Bundle;)V

    :cond_26
    iget-object v6, v1, Lz5/xr1;->v:Landroid/content/ContentResolver;

    const-string v7, "*/*"

    invoke-virtual {v6, v4, v7, v5}, Landroid/content/ContentResolver;->openTypedAssetFileDescriptor(Landroid/net/Uri;Ljava/lang/String;Landroid/os/Bundle;)Landroid/content/res/AssetFileDescriptor;

    move-result-object v5

    goto :goto_37

    :cond_2f
    iget-object v5, v1, Lz5/xr1;->v:Landroid/content/ContentResolver;

    const-string v6, "r"

    invoke-virtual {v5, v4, v6}, Landroid/content/ContentResolver;->openAssetFileDescriptor(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/res/AssetFileDescriptor;

    move-result-object v5

    :goto_37
    iput-object v5, v1, Lz5/xr1;->x:Landroid/content/res/AssetFileDescriptor;

    if-eqz v5, :cond_cc

    invoke-virtual {v5}, Landroid/content/res/AssetFileDescriptor;->getLength()J

    move-result-wide v6

    new-instance v4, Ljava/io/FileInputStream;

    invoke-virtual {v5}, Landroid/content/res/AssetFileDescriptor;->getFileDescriptor()Ljava/io/FileDescriptor;

    move-result-object v8

    invoke-direct {v4, v8}, Ljava/io/FileInputStream;-><init>(Ljava/io/FileDescriptor;)V

    iput-object v4, v1, Lz5/xr1;->y:Ljava/io/FileInputStream;

    const-wide/16 v8, -0x1

    cmp-long v10, v6, v8

    const/16 v11, 0x7d8

    const/4 v12, 0x0

    if-eqz v10, :cond_60

    iget-wide v13, v0, Lz5/a8;->d:J

    cmp-long v13, v13, v6

    if-gtz v13, :cond_5a

    goto :goto_60

    :cond_5a
    new-instance v0, Lz5/wr1;

    invoke-direct {v0, v12, v11}, Lz5/wr1;-><init>(Ljava/io/IOException;I)V

    throw v0

    :cond_60
    :goto_60
    invoke-virtual {v5}, Landroid/content/res/AssetFileDescriptor;->getStartOffset()J

    move-result-wide v13

    iget-wide v2, v0, Lz5/a8;->d:J

    add-long/2addr v2, v13

    invoke-virtual {v4, v2, v3}, Ljava/io/FileInputStream;->skip(J)J

    move-result-wide v2

    sub-long/2addr v2, v13

    iget-wide v13, v0, Lz5/a8;->d:J

    cmp-long v13, v2, v13

    if-nez v13, :cond_c6

    const-wide/16 v13, 0x0

    if-nez v10, :cond_98

    invoke-virtual {v4}, Ljava/io/FileInputStream;->getChannel()Ljava/nio/channels/FileChannel;

    move-result-object v2

    invoke-virtual {v2}, Ljava/nio/channels/FileChannel;->size()J

    move-result-wide v3

    cmp-long v6, v3, v13

    if-nez v6, :cond_86

    iput-wide v8, v1, Lz5/xr1;->z:J

    move-wide v3, v8

    goto :goto_a0

    :cond_86
    invoke-virtual {v2}, Ljava/nio/channels/FileChannel;->position()J

    move-result-wide v6

    sub-long/2addr v3, v6

    iput-wide v3, v1, Lz5/xr1;->z:J

    cmp-long v2, v3, v13

    if-ltz v2, :cond_92

    goto :goto_a0

    :cond_92
    new-instance v0, Lz5/wr1;

    invoke-direct {v0, v12, v11}, Lz5/wr1;-><init>(Ljava/io/IOException;I)V

    throw v0

    :cond_98
    sub-long v3, v6, v2

    iput-wide v3, v1, Lz5/xr1;->z:J
    :try_end_9c
    .catch Lz5/wr1; {:try_start_3 .. :try_end_9c} :catch_107
    .catch Ljava/io/IOException; {:try_start_3 .. :try_end_9c} :catch_f6

    cmp-long v2, v3, v13

    if-ltz v2, :cond_c0

    :goto_a0
    iget-wide v5, v0, Lz5/a8;->e:J

    cmp-long v2, v5, v8

    if-eqz v2, :cond_b0

    cmp-long v2, v3, v8

    if-eqz v2, :cond_ae

    invoke-static {v3, v4, v5, v6}, Ljava/lang/Math;->min(JJ)J

    move-result-wide v5

    :cond_ae
    iput-wide v5, v1, Lz5/xr1;->z:J

    :cond_b0
    const/4 v2, 0x1

    iput-boolean v2, v1, Lz5/xr1;->A:Z

    invoke-virtual/range {p0 .. p1}, Lz5/a3;->i(Lz5/a8;)V

    iget-wide v2, v0, Lz5/a8;->e:J

    cmp-long v0, v2, v8

    if-eqz v0, :cond_bd

    return-wide v2

    :cond_bd
    iget-wide v2, v1, Lz5/xr1;->z:J

    return-wide v2

    :cond_c0
    :try_start_c0
    new-instance v0, Lz5/wr1;

    invoke-direct {v0, v12, v11}, Lz5/wr1;-><init>(Ljava/io/IOException;I)V

    throw v0

    :cond_c6
    new-instance v0, Lz5/wr1;

    invoke-direct {v0, v12, v11}, Lz5/wr1;-><init>(Ljava/io/IOException;I)V

    throw v0

    :cond_cc
    new-instance v0, Lz5/wr1;

    new-instance v2, Ljava/io/IOException;

    invoke-static {v4}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/String;->length()I

    move-result v4

    add-int/lit8 v4, v4, 0x24

    new-instance v6, Ljava/lang/StringBuilder;

    invoke-direct {v6, v4}, Ljava/lang/StringBuilder;-><init>(I)V

    const-string v4, "Could not open file descriptor for: "

    invoke-virtual {v6, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v6, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
    :try_end_ee
    .catch Lz5/wr1; {:try_start_c0 .. :try_end_ee} :catch_107
    .catch Ljava/io/IOException; {:try_start_c0 .. :try_end_ee} :catch_f6

    const/16 v3, 0x7d0

    :try_start_f0
    invoke-direct {v0, v2, v3}, Lz5/wr1;-><init>(Ljava/io/IOException;I)V

    throw v0
    :try_end_f4
    .catch Lz5/wr1; {:try_start_f0 .. :try_end_f4} :catch_107
    .catch Ljava/io/IOException; {:try_start_f0 .. :try_end_f4} :catch_f4

    :catch_f4
    move-exception v0

    goto :goto_f9

    :catch_f6
    move-exception v0

    const/16 v3, 0x7d0

    :goto_f9
    new-instance v2, Lz5/wr1;

    instance-of v4, v0, Ljava/io/FileNotFoundException;

    const/4 v5, 0x1

    if-eq v5, v4, :cond_101

    goto :goto_103

    :cond_101
    const/16 v3, 0x7d5

    :goto_103
    invoke-direct {v2, v0, v3}, Lz5/wr1;-><init>(Ljava/io/IOException;I)V

    throw v2

    :catch_107
    move-exception v0

    throw v0
.end method

.method public final zzi()Landroid/net/Uri;
    .registers 2

    iget-object v0, p0, Lz5/xr1;->w:Landroid/net/Uri;

    return-object v0
.end method

.method public final zzj()V
    .registers 6

    const/4 v0, 0x0

    iput-object v0, p0, Lz5/xr1;->w:Landroid/net/Uri;

    const/16 v1, 0x7d0

    const/4 v2, 0x0

    :try_start_6
    iget-object v3, p0, Lz5/xr1;->y:Ljava/io/FileInputStream;

    if-eqz v3, :cond_d

    invoke-virtual {v3}, Ljava/io/FileInputStream;->close()V
    :try_end_d
    .catch Ljava/io/IOException; {:try_start_6 .. :try_end_d} :catch_39
    .catchall {:try_start_6 .. :try_end_d} :catchall_37

    :cond_d
    iput-object v0, p0, Lz5/xr1;->y:Ljava/io/FileInputStream;

    :try_start_f
    iget-object v3, p0, Lz5/xr1;->x:Landroid/content/res/AssetFileDescriptor;

    if-eqz v3, :cond_16

    invoke-virtual {v3}, Landroid/content/res/AssetFileDescriptor;->close()V
    :try_end_16
    .catch Ljava/io/IOException; {:try_start_f .. :try_end_16} :catch_24
    .catchall {:try_start_f .. :try_end_16} :catchall_22

    :cond_16
    iput-object v0, p0, Lz5/xr1;->x:Landroid/content/res/AssetFileDescriptor;

    iget-boolean v0, p0, Lz5/xr1;->A:Z

    if-eqz v0, :cond_21

    iput-boolean v2, p0, Lz5/xr1;->A:Z

    invoke-virtual {p0}, Lz5/a3;->n()V

    :cond_21
    return-void

    :catchall_22
    move-exception v1

    goto :goto_2b

    :catch_24
    move-exception v3

    :try_start_25
    new-instance v4, Lz5/wr1;

    invoke-direct {v4, v3, v1}, Lz5/wr1;-><init>(Ljava/io/IOException;I)V

    throw v4
    :try_end_2b
    .catchall {:try_start_25 .. :try_end_2b} :catchall_22

    :goto_2b
    iput-object v0, p0, Lz5/xr1;->x:Landroid/content/res/AssetFileDescriptor;

    iget-boolean v0, p0, Lz5/xr1;->A:Z

    if-eqz v0, :cond_36

    iput-boolean v2, p0, Lz5/xr1;->A:Z

    invoke-virtual {p0}, Lz5/a3;->n()V

    :cond_36
    throw v1

    :catchall_37
    move-exception v3

    goto :goto_40

    :catch_39
    move-exception v3

    :try_start_3a
    new-instance v4, Lz5/wr1;

    invoke-direct {v4, v3, v1}, Lz5/wr1;-><init>(Ljava/io/IOException;I)V

    throw v4
    :try_end_40
    .catchall {:try_start_3a .. :try_end_40} :catchall_37

    :goto_40
    iput-object v0, p0, Lz5/xr1;->y:Ljava/io/FileInputStream;

    :try_start_42
    iget-object v4, p0, Lz5/xr1;->x:Landroid/content/res/AssetFileDescriptor;

    if-eqz v4, :cond_49

    invoke-virtual {v4}, Landroid/content/res/AssetFileDescriptor;->close()V
    :try_end_49
    .catch Ljava/io/IOException; {:try_start_42 .. :try_end_49} :catch_57
    .catchall {:try_start_42 .. :try_end_49} :catchall_55

    :cond_49
    iput-object v0, p0, Lz5/xr1;->x:Landroid/content/res/AssetFileDescriptor;

    iget-boolean v0, p0, Lz5/xr1;->A:Z

    if-eqz v0, :cond_54

    iput-boolean v2, p0, Lz5/xr1;->A:Z

    invoke-virtual {p0}, Lz5/a3;->n()V

    :cond_54
    throw v3

    :catchall_55
    move-exception v1

    goto :goto_5e

    :catch_57
    move-exception v3

    :try_start_58
    new-instance v4, Lz5/wr1;

    invoke-direct {v4, v3, v1}, Lz5/wr1;-><init>(Ljava/io/IOException;I)V

    throw v4
    :try_end_5e
    .catchall {:try_start_58 .. :try_end_5e} :catchall_55

    :goto_5e
    iput-object v0, p0, Lz5/xr1;->x:Landroid/content/res/AssetFileDescriptor;

    iget-boolean v0, p0, Lz5/xr1;->A:Z

    if-nez v0, :cond_65

    goto :goto_6a

    :cond_65
    iput-boolean v2, p0, Lz5/xr1;->A:Z

    invoke-virtual {p0}, Lz5/a3;->n()V

    :goto_6a
    throw v1
.end method
