l.smali

.class public Lcom/fulishe/fs/newvideo/cache/l;
.super Ljava/lang/Object;
.source ""


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/fulishe/fs/newvideo/cache/l$a;
    }
.end annotation


# static fields
.field public static final a:Ljava/lang/String; = "j"


# instance fields
.field public final b:Ljava/util/concurrent/ExecutorService;

.field public final c:Ljava/lang/String;

.field public final d:I


# direct methods
.method public constructor <init>(Ljava/lang/String;I)V
    .registers 4

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

    invoke-static {}, Ljava/util/concurrent/Executors;->newSingleThreadExecutor()Ljava/util/concurrent/ExecutorService;

    move-result-object v0

    iput-object v0, p0, Lcom/fulishe/fs/newvideo/cache/l;->b:Ljava/util/concurrent/ExecutorService;

    invoke-static {p1}, Lcom/fulishe/fs/newvideo/cache/o;->a(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/String;

    iput-object v0, p0, Lcom/fulishe/fs/newvideo/cache/l;->c:Ljava/lang/String;

    iput p2, p0, Lcom/fulishe/fs/newvideo/cache/l;->d:I

    return-void
.end method

.method private a()Ljava/util/List;
    .registers 4
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/List",
            "<",
            "Ljava/net/Proxy;",
            ">;"
        }
    .end annotation

    :try_start_0
    invoke-static {}, Ljava/net/ProxySelector;->getDefault()Ljava/net/ProxySelector;

    move-result-object v0

    new-instance v1, Ljava/net/URI;

    invoke-direct {p0}, Lcom/fulishe/fs/newvideo/cache/l;->c()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v1, v2}, Ljava/net/URI;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0, v1}, Ljava/net/ProxySelector;->select(Ljava/net/URI;)Ljava/util/List;
    :try_end_10
    .catch Ljava/net/URISyntaxException; {:try_start_0 .. :try_end_10} :catch_12

    move-result-object v0

    return-object v0

    :catch_12
    move-exception v0

    new-instance v1, Ljava/lang/IllegalStateException;

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

    throw v1
.end method

.method public static synthetic a(Lcom/fulishe/fs/newvideo/cache/l;)Z
    .registers 2

    invoke-direct {p0}, Lcom/fulishe/fs/newvideo/cache/l;->b()Z

    move-result v0

    return v0
.end method

.method private b()Z
    .registers 7

    invoke-direct {p0}, Lcom/fulishe/fs/newvideo/cache/l;->c()Ljava/lang/String;

    move-result-object v0

    new-instance v1, Lcom/fulishe/fs/newvideo/cache/j;

    invoke-direct {v1, v0}, Lcom/fulishe/fs/newvideo/cache/j;-><init>(Ljava/lang/String;)V

    :try_start_9
    const-string v0, "ping ok"

    invoke-virtual {v0}, Ljava/lang/String;->getBytes()[B

    move-result-object v0

    const-wide/16 v2, 0x0

    invoke-virtual {v1, v2, v3}, Lcom/fulishe/fs/newvideo/cache/j;->a(J)V

    array-length v2, v0

    new-array v2, v2, [B

    invoke-virtual {v1, v2}, Lcom/fulishe/fs/newvideo/cache/j;->a([B)I

    invoke-static {v0, v2}, Ljava/util/Arrays;->equals([B[B)Z

    move-result v0

    sget-object v3, Lcom/fulishe/fs/newvideo/cache/l;->a:Ljava/lang/String;

    new-instance v4, Ljava/lang/StringBuilder;

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

    const-string v5, "Ping response: `"

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

    move-result-object v4

    new-instance v5, Ljava/lang/String;

    invoke-direct {v5, v2}, Ljava/lang/String;-><init>([B)V

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

    move-result-object v2

    const-string v4, "`, pinged? "

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

    move-result-object v2

    invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    move-result-object v2

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

    move-result-object v2

    invoke-static {v3, v2}, Lcom/fulishe/shadow/base/p;->a(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_45
    .catchall {:try_start_9 .. :try_end_45} :catchall_49

    invoke-virtual {v1}, Lcom/fulishe/fs/newvideo/cache/j;->b()V

    :goto_48
    return v0

    :catchall_49
    move-exception v0

    :try_start_4a
    sget-object v2, Lcom/fulishe/fs/newvideo/cache/l;->a:Ljava/lang/String;

    const-string v3, "Error reading ping response"

    invoke-static {v2, v3, v0}, Lcom/fulishe/shadow/base/p;->a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    :try_end_51
    .catchall {:try_start_4a .. :try_end_51} :catchall_56

    invoke-virtual {v1}, Lcom/fulishe/fs/newvideo/cache/j;->b()V

    const/4 v0, 0x0

    goto :goto_48

    :catchall_56
    move-exception v0

    invoke-virtual {v1}, Lcom/fulishe/fs/newvideo/cache/j;->b()V

    throw v0
.end method

.method private c()Ljava/lang/String;
    .registers 5

    sget-object v0, Ljava/util/Locale;->US:Ljava/util/Locale;

    const/4 v1, 0x3

    new-array v1, v1, [Ljava/lang/Object;

    iget-object v2, p0, Lcom/fulishe/fs/newvideo/cache/l;->c:Ljava/lang/String;

    const/4 v3, 0x0

    aput-object v2, v1, v3

    iget v2, p0, Lcom/fulishe/fs/newvideo/cache/l;->d:I

    invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v2

    const/4 v3, 0x1

    aput-object v2, v1, v3

    const/4 v2, 0x2

    const-string v3, "ping"

    aput-object v3, v1, v2

    const-string v2, "http://%s:%d/%s"

    invoke-static {v0, v2, v1}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method


# virtual methods
.method public a(Ljava/net/Socket;)V
    .registers 4

    invoke-virtual {p1}, Ljava/net/Socket;->getOutputStream()Ljava/io/OutputStream;

    move-result-object v0

    const-string v1, "HTTP/1.1 200 OK\n\n"

    invoke-virtual {v1}, Ljava/lang/String;->getBytes()[B

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/io/OutputStream;->write([B)V

    const-string v1, "ping ok"

    invoke-virtual {v1}, Ljava/lang/String;->getBytes()[B

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/io/OutputStream;->write([B)V

    return-void
.end method

.method public a(II)Z
    .registers 10

    const/4 v1, 0x1

    const/4 v2, 0x0

    if-lt p1, v1, :cond_2d

    move v0, v1

    :goto_5
    invoke-static {v0}, Lcom/fulishe/fs/newvideo/cache/o;->a(Z)V

    if-lez p2, :cond_2f

    move v0, v1

    :goto_b
    invoke-static {v0}, Lcom/fulishe/fs/newvideo/cache/o;->a(Z)V

    move v3, v2

    :goto_f
    if-ge v3, p1, :cond_69

    :try_start_11
    iget-object v0, p0, Lcom/fulishe/fs/newvideo/cache/l;->b:Ljava/util/concurrent/ExecutorService;

    new-instance v4, Lcom/fulishe/fs/newvideo/cache/l$a;

    const/4 v5, 0x0

    invoke-direct {v4, p0, v5}, Lcom/fulishe/fs/newvideo/cache/l$a;-><init>(Lcom/fulishe/fs/newvideo/cache/l;Lcom/fulishe/fs/newvideo/cache/n;)V

    invoke-interface {v0, v4}, Ljava/util/concurrent/ExecutorService;->submit(Ljava/util/concurrent/Callable;)Ljava/util/concurrent/Future;

    move-result-object v0

    int-to-long v4, p2

    sget-object v6, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;

    invoke-interface {v0, v4, v5, v6}, Ljava/util/concurrent/Future;->get(JLjava/util/concurrent/TimeUnit;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/Boolean;

    invoke-virtual {v0}, Ljava/lang/Boolean;->booleanValue()Z
    :try_end_29
    .catch Ljava/util/concurrent/TimeoutException; {:try_start_11 .. :try_end_29} :catch_3f
    .catch Ljava/lang/InterruptedException; {:try_start_11 .. :try_end_29} :catch_31
    .catch Ljava/util/concurrent/ExecutionException; {:try_start_11 .. :try_end_29} :catch_95

    move-result v0

    if-eqz v0, :cond_39

    :goto_2c
    return v1

    :cond_2d
    move v0, v2

    goto :goto_5

    :cond_2f
    move v0, v2

    goto :goto_b

    :catch_31
    move-exception v0

    :goto_32
    sget-object v4, Lcom/fulishe/fs/newvideo/cache/l;->a:Ljava/lang/String;

    const-string v5, "Error pinging server due to unexpected error"

    invoke-static {v4, v5, v0}, Lcom/fulishe/shadow/base/p;->a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V

    :cond_39
    :goto_39
    mul-int/lit8 p2, p2, 0x2

    add-int/lit8 v0, v3, 0x1

    move v3, v0

    goto :goto_f

    :catch_3f
    move-exception v0

    sget-object v0, Lcom/fulishe/fs/newvideo/cache/l;->a:Ljava/lang/String;

    new-instance v4, Ljava/lang/StringBuilder;

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

    const-string v5, "Error pinging server (attempt: "

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

    move-result-object v4

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

    move-result-object v4

    const-string v5, ", timeout: "

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

    move-result-object v4

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

    move-result-object v4

    const-string v5, "). "

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

    move-result-object v4

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

    move-result-object v4

    invoke-static {v0, v4}, Lcom/fulishe/shadow/base/p;->a(Ljava/lang/String;Ljava/lang/String;)V

    goto :goto_39

    :cond_69
    sget-object v0, Ljava/util/Locale;->US:Ljava/util/Locale;

    const/4 v4, 0x3

    new-array v4, v4, [Ljava/lang/Object;

    invoke-static {v3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v3

    aput-object v3, v4, v2

    div-int/lit8 v3, p2, 0x2

    invoke-static {v3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v3

    aput-object v3, v4, v1

    invoke-direct {p0}, Lcom/fulishe/fs/newvideo/cache/l;->a()Ljava/util/List;

    move-result-object v1

    const/4 v3, 0x2

    aput-object v1, v4, v3

    const-string v1, "Error pinging server (attempts: %d, max timeout: %d). If you see this message, please, report at https://github.com/danikula/AndroidVideoCache/issues/134. Default proxies are: %s"

    invoke-static {v0, v1, v4}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v0

    sget-object v1, Lcom/fulishe/fs/newvideo/cache/l;->a:Ljava/lang/String;

    new-instance v3, Lcom/fulishe/fs/newvideo/cache/m;

    invoke-direct {v3, v0}, Lcom/fulishe/fs/newvideo/cache/m;-><init>(Ljava/lang/String;)V

    invoke-static {v1, v0, v3}, Lcom/fulishe/shadow/base/p;->a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V

    move v1, v2

    goto :goto_2c

    :catch_95
    move-exception v0

    goto :goto_32
.end method

.method public a(Ljava/lang/String;)Z
    .registers 3

    const-string v0, "ping"

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

    move-result v0

    return v0
.end method