AndroidDnsServer.smali
.class public final Lcom/qiniu/android/dns/local/AndroidDnsServer;
.super Ljava/lang/Object;
.source "AndroidDnsServer.java"
# annotations
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lcom/qiniu/android/dns/local/AndroidDnsServer$AndroidResolver;
}
.end annotation
# direct methods
.method static constructor <clinit>()V
.registers 1
return-void
.end method
.method public constructor <init>()V
.registers 1
.line 32
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method public static defaultResolver(Landroid/content/Context;)Lcom/qiniu/android/dns/IResolver;
.registers 2
.param p0, "context" # Landroid/content/Context;
.line 214
new-instance v0, Lcom/qiniu/android/dns/local/AndroidDnsServer$AndroidResolver;
invoke-direct {v0, p0}, Lcom/qiniu/android/dns/local/AndroidDnsServer$AndroidResolver;-><init>(Landroid/content/Context;)V
return-object v0
.end method
.method public static getByCommand()Ljava/util/List;
.registers 10
.annotation system Ldalvik/annotation/Signature;
value = {
"()",
"Ljava/util/List<",
"Ljava/net/InetAddress;",
">;"
}
.end annotation
.line 131
:try_start_0
invoke-static {}, Ljava/lang/Runtime;->getRuntime()Ljava/lang/Runtime;
move-result-object v0
const-string v1, "getprop"
invoke-virtual {v0, v1}, Ljava/lang/Runtime;->exec(Ljava/lang/String;)Ljava/lang/Process;
move-result-object v0
.line 132
.local v0, "process":Ljava/lang/Process;
invoke-virtual {v0}, Ljava/lang/Process;->getInputStream()Ljava/io/InputStream;
move-result-object v1
.line 133
.local v1, "inputStream":Ljava/io/InputStream;
new-instance v2, Ljava/io/LineNumberReader;
new-instance v3, Ljava/io/InputStreamReader;
invoke-direct {v3, v1}, Ljava/io/InputStreamReader;-><init>(Ljava/io/InputStream;)V
invoke-direct {v2, v3}, Ljava/io/LineNumberReader;-><init>(Ljava/io/Reader;)V
.line 135
.local v2, "lnr":Ljava/io/LineNumberReader;
const/4 v3, 0x0
.line 136
.local v3, "line":Ljava/lang/String;
new-instance v4, Ljava/util/ArrayList;
const/4 v5, 0x5
invoke-direct {v4, v5}, Ljava/util/ArrayList;-><init>(I)V
.line 137
.local v4, "servers":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Ljava/net/InetAddress;>;"
:cond_1f
:goto_1f
invoke-virtual {v2}, Ljava/io/LineNumberReader;->readLine()Ljava/lang/String;
move-result-object v5
move-object v3, v5
if-eqz v5, :cond_8a
.line 138
const-string v5, "]: ["
invoke-virtual {v3, v5}, Ljava/lang/String;->indexOf(Ljava/lang/String;)I
move-result v5
.line 139
.local v5, "split":I
const/4 v6, 0x1
if-le v5, v6, :cond_1f
invoke-virtual {v3}, Ljava/lang/String;->length()I
move-result v7
sub-int/2addr v7, v6
add-int/lit8 v8, v5, 0x4
if-gt v7, v8, :cond_39
.line 140
goto :goto_1f
.line 142
:cond_39
invoke-virtual {v3, v6, v5}, Ljava/lang/String;->substring(II)Ljava/lang/String;
move-result-object v7
.line 143
.local v7, "property":Ljava/lang/String;
add-int/lit8 v8, v5, 0x4
invoke-virtual {v3}, Ljava/lang/String;->length()I
move-result v9
sub-int/2addr v9, v6
invoke-virtual {v3, v8, v9}, Ljava/lang/String;->substring(II)Ljava/lang/String;
move-result-object v6
.line 144
.local v6, "value":Ljava/lang/String;
const-string v8, ".dns"
invoke-virtual {v7, v8}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z
move-result v8
if-nez v8, :cond_70
const-string v8, ".dns1"
invoke-virtual {v7, v8}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z
move-result v8
if-nez v8, :cond_70
const-string v8, ".dns2"
.line 145
invoke-virtual {v7, v8}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z
move-result v8
if-nez v8, :cond_70
const-string v8, ".dns3"
invoke-virtual {v7, v8}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z
move-result v8
if-nez v8, :cond_70
const-string v8, ".dns4"
.line 146
invoke-virtual {v7, v8}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z
move-result v8
if-eqz v8, :cond_89
.line 150
:cond_70
invoke-static {v6}, Ljava/net/InetAddress;->getByName(Ljava/lang/String;)Ljava/net/InetAddress;
move-result-object v8
.line 152
.local v8, "ip":Ljava/net/InetAddress;
if-nez v8, :cond_77
goto :goto_1f
.line 154
:cond_77
invoke-virtual {v8}, Ljava/net/InetAddress;->getHostAddress()Ljava/lang/String;
move-result-object v9
move-object v6, v9
.line 156
if-nez v6, :cond_7f
goto :goto_1f
.line 157
:cond_7f
invoke-virtual {v6}, Ljava/lang/String;->length()I
move-result v9
if-nez v9, :cond_86
goto :goto_1f
.line 159
:cond_86
invoke-virtual {v4, v8}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
.line 161
.end local v5 # "split":I
.end local v6 # "value":Ljava/lang/String;
.end local v7 # "property":Ljava/lang/String;
.end local v8 # "ip":Ljava/net/InetAddress;
:cond_89
goto :goto_1f
.line 162
:cond_8a
invoke-virtual {v4}, Ljava/util/ArrayList;->size()I
move-result v5
:try_end_8e
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_8e} :catch_92
if-lez v5, :cond_91
.line 163
return-object v4
.line 167
.end local v0 # "process":Ljava/lang/Process;
.end local v1 # "inputStream":Ljava/io/InputStream;
.end local v2 # "lnr":Ljava/io/LineNumberReader;
.end local v3 # "line":Ljava/lang/String;
.end local v4 # "servers":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Ljava/net/InetAddress;>;"
:cond_91
goto :goto_a0
.line 165
:catch_92
move-exception v0
.line 166
.local v0, "e":Ljava/io/IOException;
const-string v1, "AndroidDnsServer"
invoke-static {v1}, Ljava/util/logging/Logger;->getLogger(Ljava/lang/String;)Ljava/util/logging/Logger;
move-result-object v1
sget-object v2, Ljava/util/logging/Level;->WARNING:Ljava/util/logging/Level;
const-string v3, "Exception in findDNSByExec"
invoke-virtual {v1, v2, v3, v0}, Ljava/util/logging/Logger;->log(Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
.line 168
.end local v0 # "e":Ljava/io/IOException;
:goto_a0
const/4 v0, 0x0
return-object v0
.end method
.method public static getByReflection()Ljava/util/List;
.registers 13
.annotation system Ldalvik/annotation/Signature;
value = {
"()",
"Ljava/util/List<",
"Ljava/net/InetAddress;",
">;"
}
.end annotation
.line 175
const/4 v0, 0x0
:try_start_1
const-string v1, "android.os.SystemProperties"
.line 176
invoke-static {v1}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;
move-result-object v1
.line 177
.local v1, "SystemProperties":Ljava/lang/Class;, "Ljava/lang/Class<*>;"
const-string v2, "get"
const/4 v3, 0x1
new-array v4, v3, [Ljava/lang/Class;
const-class v5, Ljava/lang/String;
const/4 v6, 0x0
aput-object v5, v4, v6
invoke-virtual {v1, v2, v4}, Ljava/lang/Class;->getMethod(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
move-result-object v2
.line 179
.local v2, "method":Ljava/lang/reflect/Method;
new-instance v4, Ljava/util/ArrayList;
const/4 v5, 0x5
invoke-direct {v4, v5}, Ljava/util/ArrayList;-><init>(I)V
.line 181
.local v4, "servers":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Ljava/net/InetAddress;>;"
const/4 v5, 0x4
const-string v7, "net.dns1"
const-string v8, "net.dns2"
const-string v9, "net.dns3"
const-string v10, "net.dns4"
filled-new-array {v7, v8, v9, v10}, [Ljava/lang/String;
move-result-object v7
const/4 v8, 0x0
:goto_29
if-ge v8, v5, :cond_64
aget-object v9, v7, v8
.line 184
.local v9, "propKey":Ljava/lang/String;
new-array v10, v3, [Ljava/lang/Object;
aput-object v9, v10, v6
invoke-virtual {v2, v0, v10}, Ljava/lang/reflect/Method;->invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
move-result-object v10
check-cast v10, Ljava/lang/String;
.line 186
.local v10, "value":Ljava/lang/String;
if-nez v10, :cond_3a
goto :goto_61
.line 187
:cond_3a
invoke-virtual {v10}, Ljava/lang/String;->length()I
move-result v11
if-nez v11, :cond_41
goto :goto_61
.line 189
:cond_41
invoke-static {v10}, Ljava/net/InetAddress;->getByName(Ljava/lang/String;)Ljava/net/InetAddress;
move-result-object v11
.line 191
.local v11, "ip":Ljava/net/InetAddress;
if-nez v11, :cond_48
goto :goto_61
.line 193
:cond_48
invoke-virtual {v11}, Ljava/net/InetAddress;->getHostAddress()Ljava/lang/String;
move-result-object v12
move-object v10, v12
.line 195
if-nez v10, :cond_50
goto :goto_61
.line 196
:cond_50
invoke-virtual {v10}, Ljava/lang/String;->length()I
move-result v12
if-nez v12, :cond_57
goto :goto_61
.line 197
:cond_57
invoke-virtual {v4, v11}, Ljava/util/ArrayList;->contains(Ljava/lang/Object;)Z
move-result v12
if-eqz v12, :cond_5e
goto :goto_61
.line 199
:cond_5e
invoke-virtual {v4, v11}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
.line 181
.end local v9 # "propKey":Ljava/lang/String;
.end local v10 # "value":Ljava/lang/String;
.end local v11 # "ip":Ljava/net/InetAddress;
:goto_61
add-int/lit8 v8, v8, 0x1
goto :goto_29
.line 202
:cond_64
invoke-virtual {v4}, Ljava/util/ArrayList;->size()I
move-result v3
:try_end_68
.catch Ljava/lang/Exception; {:try_start_1 .. :try_end_68} :catch_6c
if-lez v3, :cond_6b
.line 203
return-object v4
.line 208
.end local v1 # "SystemProperties":Ljava/lang/Class;, "Ljava/lang/Class<*>;"
.end local v2 # "method":Ljava/lang/reflect/Method;
.end local v4 # "servers":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Ljava/net/InetAddress;>;"
:cond_6b
goto :goto_7a
.line 205
:catch_6c
move-exception v1
.line 207
.local v1, "e":Ljava/lang/Exception;
const-string v2, "AndroidDnsServer"
invoke-static {v2}, Ljava/util/logging/Logger;->getLogger(Ljava/lang/String;)Ljava/util/logging/Logger;
move-result-object v2
sget-object v3, Ljava/util/logging/Level;->WARNING:Ljava/util/logging/Level;
const-string v4, "Exception in findDNSByReflection"
invoke-virtual {v2, v3, v4, v1}, Ljava/util/logging/Logger;->log(Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
.line 209
.end local v1 # "e":Ljava/lang/Exception;
:goto_7a
return-object v0
.end method