.class public Lcom/moji/httpdns/MJHttpDnsSdk;
.super Ljava/lang/Object;
.source "MJHttpDnsSdk.java"


# static fields
.field private static volatile a:Lcom/moji/httpdns/MJHttpDnsSdk;


# instance fields
.field private b:Lcom/moji/httpdns/cache/IDnsCache;

.field private c:Lcom/moji/httpdns/server/IDnsServer;

.field private d:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List<",
            "Lcom/moji/httpdns/DegradationFilter;",
            ">;"
        }
    .end annotation
.end field

.field private e:Ljava/util/concurrent/ConcurrentHashMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/concurrent/ConcurrentHashMap<",
            "Ljava/lang/String;",
            "Ljava/lang/Thread;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method static constructor <clinit>()V
    .locals 0

    return-void
.end method

.method private constructor <init>()V
    .locals 1

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

    const/4 v0, 0x0

    .line 30
    iput-object v0, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->b:Lcom/moji/httpdns/cache/IDnsCache;

    .line 33
    iput-object v0, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->c:Lcom/moji/httpdns/server/IDnsServer;

    .line 34
    new-instance v0, Ljava/util/ArrayList;

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

    invoke-static {v0}, Ljava/util/Collections;->synchronizedList(Ljava/util/List;)Ljava/util/List;

    move-result-object v0

    iput-object v0, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->d:Ljava/util/List;

    .line 134
    new-instance v0, Ljava/util/concurrent/ConcurrentHashMap;

    invoke-direct {v0}, Ljava/util/concurrent/ConcurrentHashMap;-><init>()V

    iput-object v0, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->e:Ljava/util/concurrent/ConcurrentHashMap;

    return-void
.end method

.method public static a()Lcom/moji/httpdns/MJHttpDnsSdk;
    .locals 2

    .line 40
    sget-object v0, Lcom/moji/httpdns/MJHttpDnsSdk;->a:Lcom/moji/httpdns/MJHttpDnsSdk;

    if-nez v0, :cond_1

    .line 41
    const-class v0, Lcom/moji/httpdns/MJHttpDnsSdk;

    monitor-enter v0

    .line 42
    :try_start_0
    sget-object v1, Lcom/moji/httpdns/MJHttpDnsSdk;->a:Lcom/moji/httpdns/MJHttpDnsSdk;

    if-nez v1, :cond_0

    .line 43
    new-instance v1, Lcom/moji/httpdns/MJHttpDnsSdk;

    invoke-direct {v1}, Lcom/moji/httpdns/MJHttpDnsSdk;-><init>()V

    sput-object v1, Lcom/moji/httpdns/MJHttpDnsSdk;->a:Lcom/moji/httpdns/MJHttpDnsSdk;

    .line 45
    :cond_0
    monitor-exit v0

    goto :goto_0

    :catchall_0
    move-exception v1

    monitor-exit v0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v1

    .line 47
    :cond_1
    :goto_0
    sget-object v0, Lcom/moji/httpdns/MJHttpDnsSdk;->a:Lcom/moji/httpdns/MJHttpDnsSdk;

    return-object v0
.end method

.method static synthetic a(Lcom/moji/httpdns/MJHttpDnsSdk;)Lcom/moji/httpdns/cache/IDnsCache;
    .locals 0

    .line 25
    iget-object p0, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->b:Lcom/moji/httpdns/cache/IDnsCache;

    return-object p0
.end method

.method static synthetic a(Lcom/moji/httpdns/MJHttpDnsSdk;Ljava/lang/String;)Z
    .locals 0

    .line 25
    invoke-direct {p0, p1}, Lcom/moji/httpdns/MJHttpDnsSdk;->d(Ljava/lang/String;)Z

    move-result p0

    return p0
.end method

.method private b(Ljava/lang/String;Z)Lcom/moji/httpdns/model/DnsResult;
    .locals 2

    .line 96
    iget-object v0, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->b:Lcom/moji/httpdns/cache/IDnsCache;

    const/4 v1, 0x0

    if-eqz v0, :cond_0

    .line 97
    iget-object v0, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->b:Lcom/moji/httpdns/cache/IDnsCache;

    invoke-interface {v0, p1}, Lcom/moji/httpdns/cache/IDnsCache;->a(Ljava/lang/String;)Lcom/moji/httpdns/model/DnsResult;

    move-result-object v0

    goto :goto_0

    :cond_0
    move-object v0, v1

    :goto_0
    if-eqz p2, :cond_3

    if-eqz v0, :cond_1

    .line 101
    invoke-virtual {v0}, Lcom/moji/httpdns/model/DnsResult;->needUpdate()Z

    move-result p2

    if-nez p2, :cond_2

    :cond_1
    if-nez v0, :cond_3

    .line 102
    :cond_2
    invoke-direct {p0, p1}, Lcom/moji/httpdns/MJHttpDnsSdk;->c(Ljava/lang/String;)V

    :cond_3
    if-eqz v0, :cond_4

    .line 106
    invoke-virtual {v0}, Lcom/moji/httpdns/model/DnsResult;->isUseAble()Z

    move-result p1

    if-nez p1, :cond_4

    move-object v0, v1

    :cond_4
    return-object v0
.end method

.method static synthetic b(Lcom/moji/httpdns/MJHttpDnsSdk;)Ljava/util/concurrent/ConcurrentHashMap;
    .locals 0

    .line 25
    iget-object p0, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->e:Ljava/util/concurrent/ConcurrentHashMap;

    return-object p0
.end method

.method private b(Ljava/lang/String;)Z
    .locals 2

    .line 84
    iget-object v0, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->d:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v0

    :cond_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v1

    if-eqz v1, :cond_1

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/moji/httpdns/DegradationFilter;

    .line 85
    invoke-interface {v1, p1}, Lcom/moji/httpdns/DegradationFilter;->a(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_0

    const/4 p1, 0x1

    return p1

    :cond_1
    const/4 p1, 0x0

    return p1
.end method

.method private c(Ljava/lang/String;)V
    .locals 3

    .line 138
    iget-object v0, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->e:Ljava/util/concurrent/ConcurrentHashMap;

    invoke-virtual {v0, p1}, Ljava/util/concurrent/ConcurrentHashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/Thread;

    if-nez v0, :cond_0

    .line 140
    new-instance v0, Ljava/lang/Thread;

    new-instance v1, Lcom/moji/httpdns/MJHttpDnsSdk$1;

    invoke-direct {v1, p0, p1}, Lcom/moji/httpdns/MJHttpDnsSdk$1;-><init>(Lcom/moji/httpdns/MJHttpDnsSdk;Ljava/lang/String;)V

    const-string v2, "mj_http_dns"

    invoke-direct {v0, v1, v2}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;Ljava/lang/String;)V

    .line 156
    invoke-virtual {v0}, Ljava/lang/Thread;->start()V

    .line 157
    iget-object v1, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->e:Ljava/util/concurrent/ConcurrentHashMap;

    invoke-virtual {v1, p1, v0}, Ljava/util/concurrent/ConcurrentHashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    :cond_0
    return-void
.end method

.method private d(Ljava/lang/String;)Z
    .locals 2
    .annotation build Landroid/support/annotation/WorkerThread;
    .end annotation

    const/4 v0, 0x0

    .line 164
    :try_start_0
    iget-object v1, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->c:Lcom/moji/httpdns/server/IDnsServer;

    if-nez v1, :cond_0

    const/4 p1, 0x0

    goto :goto_0

    :cond_0
    iget-object v1, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->c:Lcom/moji/httpdns/server/IDnsServer;

    invoke-interface {v1, p1}, Lcom/moji/httpdns/server/IDnsServer;->a(Ljava/lang/String;)Lcom/moji/httpdns/model/HttpDnsPack;

    move-result-object p1

    :goto_0
    if-eqz p1, :cond_1

    .line 165
    iget-object v1, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->b:Lcom/moji/httpdns/cache/IDnsCache;

    if-eqz v1, :cond_1

    iget-object v1, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->b:Lcom/moji/httpdns/cache/IDnsCache;

    invoke-interface {v1, p1}, Lcom/moji/httpdns/cache/IDnsCache;->a(Lcom/moji/httpdns/model/HttpDnsPack;)Z

    move-result p1
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    if-eqz p1, :cond_1

    const/4 v0, 0x1

    :cond_1
    return v0

    :catch_0
    move-exception p1

    .line 167
    invoke-virtual {p1}, Ljava/lang/Exception;->printStackTrace()V

    return v0
.end method


# virtual methods
.method public a(Ljava/lang/String;Z)Ljava/util/List;
    .locals 2
    .annotation build Landroid/support/annotation/Nullable;
    .end annotation

    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            "Z)",
            "Ljava/util/List<",
            "Ljava/net/InetAddress;",
            ">;"
        }
    .end annotation

    .line 123
    invoke-direct {p0, p1}, Lcom/moji/httpdns/MJHttpDnsSdk;->b(Ljava/lang/String;)Z

    move-result v0

    const/4 v1, 0x0

    if-eqz v0, :cond_0

    return-object v1

    .line 126
    :cond_0
    invoke-direct {p0, p1, p2}, Lcom/moji/httpdns/MJHttpDnsSdk;->b(Ljava/lang/String;Z)Lcom/moji/httpdns/model/DnsResult;

    move-result-object p1

    if-eqz p1, :cond_1

    .line 128
    invoke-virtual {p1}, Lcom/moji/httpdns/model/DnsResult;->getAddressList()Ljava/util/List;

    move-result-object p1

    return-object p1

    :cond_1
    return-object v1
.end method

.method public a(Landroid/content/Context;Lcom/moji/httpdns/config/HttpDnsConfig;)V
    .locals 2

    if-eqz p1, :cond_0

    .line 57
    invoke-virtual {p1}, Landroid/content/Context;->getApplicationContext()Landroid/content/Context;

    move-result-object p1

    .line 58
    invoke-static {p1}, Lcom/moji/httpdns/nettype/NetworkManager;->a(Landroid/content/Context;)Lcom/moji/httpdns/nettype/NetworkManager;

    .line 60
    new-instance v0, Lcom/moji/httpdns/cache/DnsCache;

    invoke-direct {v0, p1}, Lcom/moji/httpdns/cache/DnsCache;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->b:Lcom/moji/httpdns/cache/IDnsCache;

    .line 61
    new-instance p1, Lcom/moji/httpdns/server/DnsServer;

    invoke-direct {p1}, Lcom/moji/httpdns/server/DnsServer;-><init>()V

    iput-object p1, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->c:Lcom/moji/httpdns/server/IDnsServer;

    .line 62
    iget-object p1, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->d:Ljava/util/List;

    new-instance v0, Lcom/moji/httpdns/DefaultDegradationFilter;

    invoke-virtual {p2}, Lcom/moji/httpdns/config/HttpDnsConfig;->a()Ljava/util/Set;

    move-result-object v1

    invoke-direct {v0, v1}, Lcom/moji/httpdns/DefaultDegradationFilter;-><init>(Ljava/util/Set;)V

    invoke-interface {p1, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 63
    invoke-virtual {p2}, Lcom/moji/httpdns/config/HttpDnsConfig;->b()I

    move-result p1

    int-to-long v0, p1

    invoke-virtual {p2}, Lcom/moji/httpdns/config/HttpDnsConfig;->c()I

    move-result p1

    int-to-long p1, p1

    invoke-static {v0, v1, p1, p2}, Lcom/moji/httpdns/config/UpdateTimeConfig;->a(JJ)V

    return-void

    .line 55
    :cond_0
    new-instance p1, Ljava/lang/RuntimeException;

    const-string p2, "MJHttpDnsSdk init; context can not be null!!!"

    invoke-direct {p1, p2}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw p1
.end method

.method public a(Ljava/lang/String;)Z
    .locals 0

    .line 208
    invoke-direct {p0, p1}, Lcom/moji/httpdns/MJHttpDnsSdk;->b(Ljava/lang/String;)Z

    move-result p1

    xor-int/lit8 p1, p1, 0x1

    return p1
.end method

.method public b()V
    .locals 1

    .line 178
    iget-object v0, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->b:Lcom/moji/httpdns/cache/IDnsCache;

    if-eqz v0, :cond_0

    .line 179
    iget-object v0, p0, Lcom/moji/httpdns/MJHttpDnsSdk;->b:Lcom/moji/httpdns/cache/IDnsCache;

    invoke-interface {v0}, Lcom/moji/httpdns/cache/IDnsCache;->a()V

    :cond_0
    return-void
.end method
