Weather/smali_classes4/mtopsdk/a/c.smali
2021-05-10 10:13:34 +02:00

716 lines
16 KiB
Smali

.class public final Lmtopsdk/a/c;
.super Ljava/lang/Object;
# interfaces
.implements Lmtopsdk/a/a;
# instance fields
.field volatile a:Z
.field private b:Lmtopsdk/a/b/b;
.field private c:Ljava/util/concurrent/ExecutorService;
.field private d:Ljava/util/concurrent/Future;
# direct methods
.method public constructor <init>(Lmtopsdk/a/b/b;Ljava/util/concurrent/ExecutorService;)V
.locals 0
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
iput-object p1, p0, Lmtopsdk/a/c;->b:Lmtopsdk/a/b/b;
iput-object p2, p0, Lmtopsdk/a/c;->c:Ljava/util/concurrent/ExecutorService;
return-void
.end method
.method private static a(Ljava/lang/String;Ljava/util/Map;)V
.locals 3
if-eqz p0, :cond_3
if-nez p1, :cond_0
goto :goto_1
:cond_0
:try_start_0
invoke-interface {p1}, Ljava/util/Map;->entrySet()Ljava/util/Set;
move-result-object p1
invoke-interface {p1}, Ljava/util/Set;->iterator()Ljava/util/Iterator;
move-result-object p1
:cond_1
invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z
move-result v0
if-eqz v0, :cond_3
invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v0
check-cast v0, Ljava/util/Map$Entry;
invoke-interface {v0}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;
move-result-object v1
check-cast v1, Ljava/lang/String;
if-eqz v1, :cond_1
const-string v2, "Set-Cookie"
invoke-virtual {v1, v2}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
move-result v2
if-nez v2, :cond_2
const-string v2, "Set-Cookie2"
invoke-virtual {v1, v2}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
move-result v1
if-eqz v1, :cond_1
:cond_2
invoke-interface {v0}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;
move-result-object v0
check-cast v0, Ljava/util/List;
invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;
move-result-object v0
:goto_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, Ljava/lang/String;
invoke-static {p0, v1}, Lmtopsdk/a/a/a;->a(Ljava/lang/String;Ljava/lang/String;)V
:try_end_0
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
goto :goto_0
:catch_0
:cond_3
:goto_1
return-void
.end method
.method private static a(Ljava/net/HttpURLConnection;Lmtopsdk/a/b/b;)V
.locals 5
invoke-virtual {p1}, Lmtopsdk/a/b/b;->b()Ljava/lang/String;
move-result-object v0
invoke-virtual {p0, v0}, Ljava/net/HttpURLConnection;->setRequestMethod(Ljava/lang/String;)V
invoke-virtual {p1}, Lmtopsdk/a/b/b;->c()Ljava/util/Map;
move-result-object v0
invoke-interface {v0}, Ljava/util/Map;->entrySet()Ljava/util/Set;
move-result-object v0
invoke-interface {v0}, Ljava/util/Set;->iterator()Ljava/util/Iterator;
move-result-object v0
:cond_0
:goto_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, Ljava/util/Map$Entry;
invoke-interface {v1}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;
move-result-object v2
check-cast v2, Ljava/lang/String;
const-string v3, "Cookie"
invoke-virtual {v2, v3}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
move-result v2
if-nez v2, :cond_0
invoke-interface {v1}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;
move-result-object v2
check-cast v2, Ljava/lang/String;
invoke-interface {v1}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;
move-result-object v1
check-cast v1, Ljava/lang/String;
invoke-virtual {p0, v2, v1}, Ljava/net/HttpURLConnection;->addRequestProperty(Ljava/lang/String;Ljava/lang/String;)V
goto :goto_0
:cond_1
invoke-virtual {p1}, Lmtopsdk/a/b/b;->a()Ljava/lang/String;
move-result-object v0
invoke-static {v0}, Lmtopsdk/a/a/a;->a(Ljava/lang/String;)Ljava/lang/String;
move-result-object v0
invoke-static {v0}, Lmtopsdk/common/util/StringUtils;->isBlank(Ljava/lang/String;)Z
move-result v0
if-nez v0, :cond_2
const-string v0, "Cookie"
invoke-virtual {p1}, Lmtopsdk/a/b/b;->a()Ljava/lang/String;
move-result-object v1
invoke-static {v1}, Lmtopsdk/a/a/a;->a(Ljava/lang/String;)Ljava/lang/String;
move-result-object v1
invoke-virtual {p0, v0, v1}, Ljava/net/HttpURLConnection;->addRequestProperty(Ljava/lang/String;Ljava/lang/String;)V
:cond_2
const-string v0, "POST"
invoke-virtual {p1}, Lmtopsdk/a/b/b;->b()Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
move-result v0
const/4 v1, 0x1
if-eqz v0, :cond_3
invoke-virtual {p0, v1}, Ljava/net/HttpURLConnection;->setDoOutput(Z)V
:cond_3
invoke-virtual {p1}, Lmtopsdk/a/b/b;->d()Lmtopsdk/a/b/d;
move-result-object p1
if-eqz p1, :cond_5
invoke-virtual {p0, v1}, Ljava/net/HttpURLConnection;->setDoOutput(Z)V
const-string v0, "Content-Type"
invoke-virtual {p1}, Lmtopsdk/a/b/d;->contentType()Ljava/lang/String;
move-result-object v1
invoke-virtual {p0, v0, v1}, Ljava/net/HttpURLConnection;->addRequestProperty(Ljava/lang/String;Ljava/lang/String;)V
invoke-virtual {p1}, Lmtopsdk/a/b/d;->contentLength()J
move-result-wide v0
const-wide/16 v2, -0x1
cmp-long v4, v0, v2
if-eqz v4, :cond_4
long-to-int v2, v0
invoke-virtual {p0, v2}, Ljava/net/HttpURLConnection;->setFixedLengthStreamingMode(I)V
const-string v2, "Content-Length"
invoke-static {v0, v1}, Ljava/lang/String;->valueOf(J)Ljava/lang/String;
move-result-object v0
invoke-virtual {p0, v2, v0}, Ljava/net/HttpURLConnection;->addRequestProperty(Ljava/lang/String;Ljava/lang/String;)V
:cond_4
invoke-virtual {p0}, Ljava/net/HttpURLConnection;->getOutputStream()Ljava/io/OutputStream;
move-result-object p0
:try_start_0
invoke-virtual {p1, p0}, Lmtopsdk/a/b/d;->writeTo(Ljava/io/OutputStream;)V
:try_end_0
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
invoke-static {p0}, Lcom/taobao/tao/remotebusiness/listener/c;->a(Ljava/io/Closeable;)V
return-void
:catchall_0
move-exception p1
goto :goto_1
:catch_0
move-exception p1
:try_start_1
const-string v0, "mtopsdk.DefaultCallImpl"
const-string v1, "write outputstream error."
invoke-static {v0, v1, p1}, Lmtopsdk/common/util/TBSdkLog;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
:try_end_1
.catchall {:try_start_1 .. :try_end_1} :catchall_0
invoke-static {p0}, Lcom/taobao/tao/remotebusiness/listener/c;->a(Ljava/io/Closeable;)V
return-void
:goto_1
invoke-static {p0}, Lcom/taobao/tao/remotebusiness/listener/c;->a(Ljava/io/Closeable;)V
throw p1
:cond_5
return-void
.end method
# virtual methods
.method public final a()Lmtopsdk/a/b/b;
.locals 1
iget-object v0, p0, Lmtopsdk/a/c;->b:Lmtopsdk/a/b/b;
return-object v0
.end method
.method public final a(Lmtopsdk/a/f;)V
.locals 3
iget-object v0, p0, Lmtopsdk/a/c;->c:Ljava/util/concurrent/ExecutorService;
if-eqz v0, :cond_0
:try_start_0
iget-object v0, p0, Lmtopsdk/a/c;->c:Ljava/util/concurrent/ExecutorService;
new-instance v1, Lmtopsdk/a/e;
iget-object v2, p0, Lmtopsdk/a/c;->b:Lmtopsdk/a/b/b;
invoke-direct {v1, p0, v2, p1}, Lmtopsdk/a/e;-><init>(Lmtopsdk/a/c;Lmtopsdk/a/b/b;Lmtopsdk/a/f;)V
invoke-interface {v0, v1}, Ljava/util/concurrent/ExecutorService;->submit(Ljava/lang/Runnable;)Ljava/util/concurrent/Future;
move-result-object v0
iput-object v0, p0, Lmtopsdk/a/c;->d:Ljava/util/concurrent/Future;
:try_end_0
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
return-void
:catch_0
move-exception v0
invoke-interface {p1, p0, v0}, Lmtopsdk/a/f;->onFailure(Lmtopsdk/a/a;Ljava/lang/Exception;)V
return-void
:cond_0
new-instance v0, Ljava/lang/Exception;
const-string v1, "miss executorService in CallImpl "
invoke-direct {v0, v1}, Ljava/lang/Exception;-><init>(Ljava/lang/String;)V
invoke-interface {p1, p0, v0}, Lmtopsdk/a/f;->onFailure(Lmtopsdk/a/a;Ljava/lang/Exception;)V
return-void
.end method
.method public final b()Lmtopsdk/a/b/g;
.locals 13
iget-object v0, p0, Lmtopsdk/a/c;->b:Lmtopsdk/a/b/b;
const/4 v1, 0x0
const/4 v2, 0x0
move-object v4, v2
const/4 v3, 0x0
:goto_0
add-int/lit8 v5, v1, 0x1
invoke-virtual {v0}, Lmtopsdk/a/b/b;->g()I
move-result v6
if-ge v1, v6, :cond_5
:try_start_0
new-instance v1, Ljava/net/URL;
invoke-virtual {v0}, Lmtopsdk/a/b/b;->a()Ljava/lang/String;
move-result-object v6
invoke-direct {v1, v6}, Ljava/net/URL;-><init>(Ljava/lang/String;)V
invoke-virtual {v1}, Ljava/net/URL;->openConnection()Ljava/net/URLConnection;
move-result-object v1
check-cast v1, Ljava/net/HttpURLConnection;
invoke-virtual {v0}, Lmtopsdk/a/b/b;->e()I
move-result v6
invoke-virtual {v1, v6}, Ljava/net/HttpURLConnection;->setConnectTimeout(I)V
invoke-virtual {v0}, Lmtopsdk/a/b/b;->f()I
move-result v6
invoke-virtual {v1, v6}, Ljava/net/HttpURLConnection;->setReadTimeout(I)V
invoke-static {v1, v0}, Lmtopsdk/a/c;->a(Ljava/net/HttpURLConnection;Lmtopsdk/a/b/b;)V
invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;
move-result-object v6
invoke-virtual {v6}, Ljava/lang/Thread;->isInterrupted()Z
move-result v6
if-nez v6, :cond_4
invoke-virtual {v1}, Ljava/net/HttpURLConnection;->getResponseCode()I
move-result v6
invoke-virtual {v1}, Ljava/net/HttpURLConnection;->getResponseMessage()Ljava/lang/String;
move-result-object v7
if-nez v7, :cond_0
const-string v7, ""
:cond_0
invoke-virtual {v1}, Ljava/net/HttpURLConnection;->getHeaderFields()Ljava/util/Map;
move-result-object v8
invoke-virtual {v0}, Lmtopsdk/a/b/b;->a()Ljava/lang/String;
move-result-object v9
invoke-static {v9, v8}, Lmtopsdk/a/c;->a(Ljava/lang/String;Ljava/util/Map;)V
invoke-virtual {v1}, Ljava/net/HttpURLConnection;->getContentType()Ljava/lang/String;
move-result-object v9
invoke-virtual {v1}, Ljava/net/HttpURLConnection;->getContentLength()I
move-result v10
invoke-static {v8}, Lcom/taobao/tao/remotebusiness/listener/c;->a(Ljava/util/Map;)Z
move-result v11
const/16 v12, 0x190
if-lt v6, v12, :cond_1
invoke-virtual {v1}, Ljava/net/HttpURLConnection;->getErrorStream()Ljava/io/InputStream;
move-result-object v1
goto :goto_1
:cond_1
if-eqz v11, :cond_2
new-instance v11, Ljava/util/zip/GZIPInputStream;
invoke-virtual {v1}, Ljava/net/HttpURLConnection;->getInputStream()Ljava/io/InputStream;
move-result-object v1
invoke-direct {v11, v1}, Ljava/util/zip/GZIPInputStream;-><init>(Ljava/io/InputStream;)V
move-object v1, v11
goto :goto_1
:cond_2
invoke-virtual {v1}, Ljava/net/HttpURLConnection;->getInputStream()Ljava/io/InputStream;
move-result-object v1
:goto_1
new-instance v11, Lmtopsdk/a/d;
invoke-direct {v11, p0, v9, v10, v1}, Lmtopsdk/a/d;-><init>(Lmtopsdk/a/c;Ljava/lang/String;ILjava/io/InputStream;)V
invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/Thread;->isInterrupted()Z
move-result v1
if-nez v1, :cond_3
invoke-virtual {v11}, Lmtopsdk/a/b/i;->c()[B
new-instance v1, Lmtopsdk/a/b/h;
invoke-direct {v1}, Lmtopsdk/a/b/h;-><init>()V
invoke-virtual {v1, v0}, Lmtopsdk/a/b/h;->a(Lmtopsdk/a/b/b;)Lmtopsdk/a/b/h;
move-result-object v1
invoke-virtual {v1, v6}, Lmtopsdk/a/b/h;->a(I)Lmtopsdk/a/b/h;
move-result-object v1
invoke-virtual {v1, v7}, Lmtopsdk/a/b/h;->a(Ljava/lang/String;)Lmtopsdk/a/b/h;
move-result-object v1
invoke-virtual {v1, v8}, Lmtopsdk/a/b/h;->a(Ljava/util/Map;)Lmtopsdk/a/b/h;
move-result-object v1
invoke-virtual {v1, v11}, Lmtopsdk/a/b/h;->a(Lmtopsdk/a/b/i;)Lmtopsdk/a/b/h;
move-result-object v1
invoke-virtual {v1}, Lmtopsdk/a/b/h;->a()Lmtopsdk/a/b/g;
move-result-object v1
goto :goto_3
:cond_3
const-string v1, "mtopsdk.DefaultCallImpl"
const-string v3, "[readResponse]call task is canceled."
invoke-static {v1, v3}, Lmtopsdk/common/util/TBSdkLog;->d(Ljava/lang/String;Ljava/lang/String;)V
new-instance v1, Ljava/util/concurrent/CancellationException;
const-string v3, "call canceled"
invoke-direct {v1, v3}, Ljava/util/concurrent/CancellationException;-><init>(Ljava/lang/String;)V
throw v1
:cond_4
const-string v1, "mtopsdk.DefaultCallImpl"
const-string v3, "[readResponse]call task is canceled."
invoke-static {v1, v3}, Lmtopsdk/common/util/TBSdkLog;->d(Ljava/lang/String;Ljava/lang/String;)V
new-instance v1, Ljava/util/concurrent/CancellationException;
const-string v3, "call canceled"
invoke-direct {v1, v3}, Ljava/util/concurrent/CancellationException;-><init>(Ljava/lang/String;)V
throw v1
:try_end_0
.catch Ljava/net/UnknownHostException; {:try_start_0 .. :try_end_0} :catch_6
.catch Ljava/net/SocketTimeoutException; {:try_start_0 .. :try_end_0} :catch_5
.catch Lorg/apache/http/conn/ConnectTimeoutException; {:try_start_0 .. :try_end_0} :catch_4
.catch Ljavax/net/ssl/SSLHandshakeException; {:try_start_0 .. :try_end_0} :catch_3
.catch Ljavax/net/ssl/SSLException; {:try_start_0 .. :try_end_0} :catch_2
.catch Ljava/net/ConnectException; {:try_start_0 .. :try_end_0} :catch_1
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
:catch_0
move-exception v1
const/4 v3, -0x7
invoke-virtual {v1}, Ljava/lang/Exception;->getMessage()Ljava/lang/String;
move-result-object v4
goto :goto_2
:catch_1
move-exception v1
const/4 v3, -0x6
invoke-virtual {v1}, Ljava/net/ConnectException;->getMessage()Ljava/lang/String;
move-result-object v4
goto :goto_2
:catch_2
move-exception v1
const/4 v3, -0x5
invoke-virtual {v1}, Ljavax/net/ssl/SSLException;->getMessage()Ljava/lang/String;
move-result-object v4
goto :goto_2
:catch_3
move-exception v1
const/4 v3, -0x4
invoke-virtual {v1}, Ljavax/net/ssl/SSLHandshakeException;->getMessage()Ljava/lang/String;
move-result-object v4
goto :goto_2
:catch_4
move-exception v1
const/4 v3, -0x3
invoke-virtual {v1}, Lorg/apache/http/conn/ConnectTimeoutException;->getMessage()Ljava/lang/String;
move-result-object v4
goto :goto_2
:catch_5
move-exception v1
const/4 v3, -0x2
invoke-virtual {v1}, Ljava/net/SocketTimeoutException;->getMessage()Ljava/lang/String;
move-result-object v4
goto :goto_2
:catch_6
move-exception v1
const/4 v3, -0x1
invoke-virtual {v1}, Ljava/net/UnknownHostException;->getMessage()Ljava/lang/String;
move-result-object v4
:goto_2
move v1, v5
goto/16 :goto_0
:cond_5
move-object v1, v2
:goto_3
if-nez v1, :cond_6
new-instance v1, Lmtopsdk/a/b/h;
invoke-direct {v1}, Lmtopsdk/a/b/h;-><init>()V
invoke-virtual {v1, v0}, Lmtopsdk/a/b/h;->a(Lmtopsdk/a/b/b;)Lmtopsdk/a/b/h;
move-result-object v0
invoke-virtual {v0, v3}, Lmtopsdk/a/b/h;->a(I)Lmtopsdk/a/b/h;
move-result-object v0
invoke-virtual {v0, v4}, Lmtopsdk/a/b/h;->a(Ljava/lang/String;)Lmtopsdk/a/b/h;
move-result-object v0
invoke-virtual {v0}, Lmtopsdk/a/b/h;->a()Lmtopsdk/a/b/g;
move-result-object v1
:cond_6
return-object v1
.end method
.method public final c()V
.locals 2
const-string v0, "mtopsdk.DefaultCallImpl"
const-string v1, "try to cancel call"
invoke-static {v0, v1}, Lmtopsdk/common/util/TBSdkLog;->d(Ljava/lang/String;Ljava/lang/String;)V
const/4 v0, 0x1
iput-boolean v0, p0, Lmtopsdk/a/c;->a:Z
iget-object v1, p0, Lmtopsdk/a/c;->d:Ljava/util/concurrent/Future;
if-eqz v1, :cond_0
iget-object v1, p0, Lmtopsdk/a/c;->d:Ljava/util/concurrent/Future;
invoke-interface {v1, v0}, Ljava/util/concurrent/Future;->cancel(Z)Z
:cond_0
return-void
.end method