291 lines
6.8 KiB
Smali
291 lines
6.8 KiB
Smali
.class public final Lorg/apache/http/conn/MultihomePlainSocketFactory;
|
|
.super Ljava/lang/Object;
|
|
.source "MultihomePlainSocketFactory.java"
|
|
|
|
# interfaces
|
|
.implements Lorg/apache/http/conn/scheme/SocketFactory;
|
|
|
|
|
|
# annotations
|
|
.annotation build Lorg/apache/http/annotation/Immutable;
|
|
.end annotation
|
|
|
|
|
|
# static fields
|
|
.field private static final DEFAULT_FACTORY:Lorg/apache/http/conn/MultihomePlainSocketFactory;
|
|
|
|
|
|
# direct methods
|
|
.method public static constructor <clinit>()V
|
|
.locals 1
|
|
|
|
.line 1
|
|
new-instance v0, Lorg/apache/http/conn/MultihomePlainSocketFactory;
|
|
|
|
invoke-direct {v0}, Lorg/apache/http/conn/MultihomePlainSocketFactory;-><init>()V
|
|
|
|
sput-object v0, Lorg/apache/http/conn/MultihomePlainSocketFactory;->DEFAULT_FACTORY:Lorg/apache/http/conn/MultihomePlainSocketFactory;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method private constructor <init>()V
|
|
.locals 0
|
|
|
|
.line 1
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static getSocketFactory()Lorg/apache/http/conn/MultihomePlainSocketFactory;
|
|
.locals 1
|
|
|
|
.line 1
|
|
sget-object v0, Lorg/apache/http/conn/MultihomePlainSocketFactory;->DEFAULT_FACTORY:Lorg/apache/http/conn/MultihomePlainSocketFactory;
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public connectSocket(Ljava/net/Socket;Ljava/lang/String;ILjava/net/InetAddress;ILorg/apache/http/params/HttpParams;)Ljava/net/Socket;
|
|
.locals 1
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
if-eqz p2, :cond_7
|
|
|
|
if-eqz p6, :cond_6
|
|
|
|
if-nez p1, :cond_0
|
|
|
|
.line 1
|
|
invoke-virtual {p0}, Lorg/apache/http/conn/MultihomePlainSocketFactory;->createSocket()Ljava/net/Socket;
|
|
|
|
move-result-object p1
|
|
|
|
:cond_0
|
|
if-nez p4, :cond_1
|
|
|
|
if-lez p5, :cond_3
|
|
|
|
:cond_1
|
|
if-gez p5, :cond_2
|
|
|
|
const/4 p5, 0x0
|
|
|
|
.line 2
|
|
:cond_2
|
|
new-instance v0, Ljava/net/InetSocketAddress;
|
|
|
|
invoke-direct {v0, p4, p5}, Ljava/net/InetSocketAddress;-><init>(Ljava/net/InetAddress;I)V
|
|
|
|
.line 3
|
|
invoke-virtual {p1, v0}, Ljava/net/Socket;->bind(Ljava/net/SocketAddress;)V
|
|
|
|
.line 4
|
|
:cond_3
|
|
invoke-static {p6}, Lorg/apache/http/params/HttpConnectionParams;->getConnectionTimeout(Lorg/apache/http/params/HttpParams;)I
|
|
|
|
move-result p4
|
|
|
|
.line 5
|
|
invoke-static {p2}, Ljava/net/InetAddress;->getAllByName(Ljava/lang/String;)[Ljava/net/InetAddress;
|
|
|
|
move-result-object p2
|
|
|
|
.line 6
|
|
new-instance p5, Ljava/util/ArrayList;
|
|
|
|
array-length p6, p2
|
|
|
|
invoke-direct {p5, p6}, Ljava/util/ArrayList;-><init>(I)V
|
|
|
|
.line 7
|
|
invoke-static {p2}, Ljava/util/Arrays;->asList([Ljava/lang/Object;)Ljava/util/List;
|
|
|
|
move-result-object p2
|
|
|
|
invoke-virtual {p5, p2}, Ljava/util/ArrayList;->addAll(Ljava/util/Collection;)Z
|
|
|
|
.line 8
|
|
invoke-static {p5}, Ljava/util/Collections;->shuffle(Ljava/util/List;)V
|
|
|
|
const/4 p2, 0x0
|
|
|
|
.line 9
|
|
invoke-virtual {p5}, Ljava/util/ArrayList;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object p5
|
|
|
|
:goto_0
|
|
invoke-interface {p5}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result p6
|
|
|
|
if-eqz p6, :cond_4
|
|
|
|
invoke-interface {p5}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object p6
|
|
|
|
check-cast p6, Ljava/net/InetAddress;
|
|
|
|
.line 10
|
|
:try_start_0
|
|
new-instance v0, Ljava/net/InetSocketAddress;
|
|
|
|
invoke-direct {v0, p6, p3}, Ljava/net/InetSocketAddress;-><init>(Ljava/net/InetAddress;I)V
|
|
|
|
invoke-virtual {p1, v0, p4}, Ljava/net/Socket;->connect(Ljava/net/SocketAddress;I)V
|
|
:try_end_0
|
|
.catch Ljava/net/SocketTimeoutException; {:try_start_0 .. :try_end_0} :catch_1
|
|
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
goto :goto_1
|
|
|
|
:catch_0
|
|
move-exception p1
|
|
|
|
move-object p2, p1
|
|
|
|
.line 11
|
|
new-instance p1, Ljava/net/Socket;
|
|
|
|
invoke-direct {p1}, Ljava/net/Socket;-><init>()V
|
|
|
|
goto :goto_0
|
|
|
|
.line 12
|
|
:catch_1
|
|
new-instance p1, Lorg/apache/http/conn/ConnectTimeoutException;
|
|
|
|
new-instance p2, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {p2}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
const-string p3, "Connect to "
|
|
|
|
invoke-virtual {p2, p3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {p2, p6}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
|
|
|
|
const-string p3, " timed out"
|
|
|
|
invoke-virtual {p2, p3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {p2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object p2
|
|
|
|
invoke-direct {p1, p2}, Lorg/apache/http/conn/ConnectTimeoutException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p1
|
|
|
|
:cond_4
|
|
:goto_1
|
|
if-nez p2, :cond_5
|
|
|
|
return-object p1
|
|
|
|
.line 13
|
|
:cond_5
|
|
throw p2
|
|
|
|
.line 14
|
|
:cond_6
|
|
new-instance p1, Ljava/lang/IllegalArgumentException;
|
|
|
|
const-string p2, "Parameters may not be null."
|
|
|
|
invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p1
|
|
|
|
.line 15
|
|
:cond_7
|
|
new-instance p1, Ljava/lang/IllegalArgumentException;
|
|
|
|
const-string p2, "Target host may not be null."
|
|
|
|
invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p1
|
|
.end method
|
|
|
|
.method public createSocket()Ljava/net/Socket;
|
|
.locals 1
|
|
|
|
.line 1
|
|
new-instance v0, Ljava/net/Socket;
|
|
|
|
invoke-direct {v0}, Ljava/net/Socket;-><init>()V
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public final isSecure(Ljava/net/Socket;)Z
|
|
.locals 2
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/lang/IllegalArgumentException;
|
|
}
|
|
.end annotation
|
|
|
|
if-eqz p1, :cond_2
|
|
|
|
.line 1
|
|
invoke-virtual {p1}, Ljava/lang/Object;->getClass()Ljava/lang/Class;
|
|
|
|
move-result-object v0
|
|
|
|
const-class v1, Ljava/net/Socket;
|
|
|
|
if-ne v0, v1, :cond_1
|
|
|
|
.line 2
|
|
invoke-virtual {p1}, Ljava/net/Socket;->isClosed()Z
|
|
|
|
move-result p1
|
|
|
|
if-nez p1, :cond_0
|
|
|
|
const/4 p1, 0x0
|
|
|
|
return p1
|
|
|
|
.line 3
|
|
:cond_0
|
|
new-instance p1, Ljava/lang/IllegalArgumentException;
|
|
|
|
const-string v0, "Socket is closed."
|
|
|
|
invoke-direct {p1, v0}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p1
|
|
|
|
.line 4
|
|
:cond_1
|
|
new-instance p1, Ljava/lang/IllegalArgumentException;
|
|
|
|
const-string v0, "Socket not created by this factory."
|
|
|
|
invoke-direct {p1, v0}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p1
|
|
|
|
.line 5
|
|
:cond_2
|
|
new-instance p1, Ljava/lang/IllegalArgumentException;
|
|
|
|
const-string v0, "Socket may not be null."
|
|
|
|
invoke-direct {p1, v0}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw p1
|
|
.end method
|