h.smali
.class public Lcom/huawei/updatesdk/sdk/service/download/h;
.super Ljava/lang/Object;
# annotations
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lcom/huawei/updatesdk/sdk/service/download/h$a;
}
.end annotation
# static fields
.field private static volatile a:Lcom/huawei/updatesdk/sdk/service/download/h;
# direct methods
.method static constructor <clinit>()V
.registers 1
const/4 v0, 0x0
sput-object v0, Lcom/huawei/updatesdk/sdk/service/download/h;->a:Lcom/huawei/updatesdk/sdk/service/download/h;
invoke-static {}, Lcom/huawei/updatesdk/sdk/service/download/h;->c()V
return-void
.end method
.method public constructor <init>()V
.registers 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method public static a(Ljava/lang/String;)J
.registers 6
const-wide/16 v0, -0x1
invoke-static {p0}, Lcom/huawei/updatesdk/sdk/a/c/f;->a(Ljava/lang/String;)Z
move-result v2
if-nez v2, :cond_3b
const-string v2, "bytes"
invoke-virtual {p0, v2}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
move-result v2
if-eqz v2, :cond_3b
const/16 v2, 0x2f
invoke-virtual {p0, v2}, Ljava/lang/String;->indexOf(I)I
move-result v2
const/4 v3, -0x1
if-eq v3, v2, :cond_45
add-int/lit8 v2, v2, 0x1
:try_start_1b
invoke-virtual {p0, v2}, Ljava/lang/String;->substring(I)Ljava/lang/String;
move-result-object v2
invoke-static {v2}, Ljava/lang/Long;->parseLong(Ljava/lang/String;)J
move-result-wide v0
const-string v2, "HiAppDownload"
new-instance v3, Ljava/lang/StringBuilder;
invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
const-string v4, "get new filelength by Content-Range:"
invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v3
invoke-virtual {v3, v0, v1}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
move-result-object v3
invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v3
invoke-static {v2, v3}, Lcom/huawei/updatesdk/sdk/a/b/a/a/a;->a(Ljava/lang/String;Ljava/lang/String;)V
:try_end_3b
.catch Ljava/lang/NumberFormatException; {:try_start_1b .. :try_end_3b} :catch_3c
:cond_3b
:goto_3b
return-wide v0
:catch_3c
move-exception v2
const-string v2, "HiAppDownload"
const-string v3, "getEntityLegth NumberFormatException"
invoke-static {v2, v3}, Lcom/huawei/updatesdk/sdk/a/b/a/a/a;->d(Ljava/lang/String;Ljava/lang/String;)V
goto :goto_3b
:cond_45
const-string v2, "HiAppDownload"
const-string v3, "getEntityLegth failed Content-Range"
invoke-static {v2, v3}, Lcom/huawei/updatesdk/sdk/a/b/a/a/a;->d(Ljava/lang/String;Ljava/lang/String;)V
goto :goto_3b
.end method
.method public static a(Lcom/huawei/updatesdk/sdk/service/download/bean/DownloadTask;Ljava/net/HttpURLConnection;Z)Lcom/huawei/updatesdk/sdk/service/download/h$a;
.registers 8
if-nez p1, :cond_4
const/4 v0, 0x0
:goto_3
return-object v0
:cond_4
invoke-static {}, Ljava/util/concurrent/Executors;->newSingleThreadExecutor()Ljava/util/concurrent/ExecutorService;
move-result-object v0
new-instance v1, Lcom/huawei/updatesdk/sdk/service/download/h$a;
invoke-direct {v1}, Lcom/huawei/updatesdk/sdk/service/download/h$a;-><init>()V
new-instance v2, Lcom/huawei/updatesdk/sdk/service/download/h$3;
invoke-direct {v2, p1}, Lcom/huawei/updatesdk/sdk/service/download/h$3;-><init>(Ljava/net/HttpURLConnection;)V
invoke-interface {v0, v2}, Ljava/util/concurrent/ExecutorService;->submit(Ljava/util/concurrent/Callable;)Ljava/util/concurrent/Future;
move-result-object v0
if-eqz p0, :cond_1d
if-eqz p2, :cond_1d
invoke-virtual {p0, v0}, Lcom/huawei/updatesdk/sdk/service/download/bean/DownloadTask;->b(Ljava/util/concurrent/Future;)V
:cond_1d
const-wide/16 v2, 0x1f40
:try_start_1f
sget-object v4, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;
invoke-interface {v0, v2, v3, v4}, Ljava/util/concurrent/Future;->get(JLjava/util/concurrent/TimeUnit;)Ljava/lang/Object;
move-result-object v0
check-cast v0, Lcom/huawei/updatesdk/sdk/service/download/h$a;
:try_end_27
.catch Ljava/util/concurrent/TimeoutException; {:try_start_1f .. :try_end_27} :catch_28
.catch Ljava/lang/Exception; {:try_start_1f .. :try_end_27} :catch_35
goto :goto_3
:catch_28
move-exception v0
new-instance v0, Ljava/net/SocketTimeoutException;
const-string v2, "connect timeout"
invoke-direct {v0, v2}, Ljava/net/SocketTimeoutException;-><init>(Ljava/lang/String;)V
invoke-virtual {v1, v0}, Lcom/huawei/updatesdk/sdk/service/download/h$a;->a(Ljava/lang/Exception;)V
move-object v0, v1
goto :goto_3
:catch_35
move-exception v0
invoke-virtual {v1, v0}, Lcom/huawei/updatesdk/sdk/service/download/h$a;->a(Ljava/lang/Exception;)V
move-object v0, v1
goto :goto_3
.end method
.method public static declared-synchronized a()Lcom/huawei/updatesdk/sdk/service/download/h;
.registers 2
const-class v1, Lcom/huawei/updatesdk/sdk/service/download/h;
monitor-enter v1
:try_start_3
sget-object v0, Lcom/huawei/updatesdk/sdk/service/download/h;->a:Lcom/huawei/updatesdk/sdk/service/download/h;
if-nez v0, :cond_e
new-instance v0, Lcom/huawei/updatesdk/sdk/service/download/h;
invoke-direct {v0}, Lcom/huawei/updatesdk/sdk/service/download/h;-><init>()V
sput-object v0, Lcom/huawei/updatesdk/sdk/service/download/h;->a:Lcom/huawei/updatesdk/sdk/service/download/h;
:cond_e
sget-object v0, Lcom/huawei/updatesdk/sdk/service/download/h;->a:Lcom/huawei/updatesdk/sdk/service/download/h;
:try_end_10
.catchall {:try_start_3 .. :try_end_10} :catchall_12
monitor-exit v1
return-object v0
:catchall_12
move-exception v0
monitor-exit v1
throw v0
.end method
.method private b()Ljava/net/Proxy;
.registers 2
invoke-static {}, Lcom/huawei/updatesdk/sdk/service/a/a;->a()Lcom/huawei/updatesdk/sdk/service/a/a;
move-result-object v0
invoke-virtual {v0}, Lcom/huawei/updatesdk/sdk/service/a/a;->b()Landroid/content/Context;
move-result-object v0
invoke-static {v0}, Lcom/huawei/updatesdk/sdk/a/c/c/b;->b(Landroid/content/Context;)Z
move-result v0
if-eqz v0, :cond_13
invoke-static {}, Lcom/huawei/updatesdk/sdk/a/c/c/b;->a()Ljava/net/Proxy;
move-result-object v0
:goto_12
return-object v0
:cond_13
const/4 v0, 0x0
goto :goto_12
.end method
.method private static c()V
.registers 4
const/4 v0, 0x1
new-array v0, v0, [Ljavax/net/ssl/TrustManager;
const/4 v1, 0x0
new-instance v2, Lcom/huawei/updatesdk/sdk/service/download/h$1;
invoke-direct {v2}, Lcom/huawei/updatesdk/sdk/service/download/h$1;-><init>()V
aput-object v2, v0, v1
:try_start_b
const-string v1, "TLS"
invoke-static {v1}, Ljavax/net/ssl/SSLContext;->getInstance(Ljava/lang/String;)Ljavax/net/ssl/SSLContext;
move-result-object v1
const/4 v2, 0x0
new-instance v3, Ljava/security/SecureRandom;
invoke-direct {v3}, Ljava/security/SecureRandom;-><init>()V
invoke-virtual {v1, v2, v0, v3}, Ljavax/net/ssl/SSLContext;->init([Ljavax/net/ssl/KeyManager;[Ljavax/net/ssl/TrustManager;Ljava/security/SecureRandom;)V
invoke-virtual {v1}, Ljavax/net/ssl/SSLContext;->getSocketFactory()Ljavax/net/ssl/SSLSocketFactory;
move-result-object v0
invoke-static {v0}, Ljavax/net/ssl/HttpsURLConnection;->setDefaultSSLSocketFactory(Ljavax/net/ssl/SSLSocketFactory;)V
:try_end_21
.catch Ljava/security/KeyManagementException; {:try_start_b .. :try_end_21} :catch_2a
.catch Ljava/security/NoSuchAlgorithmException; {:try_start_b .. :try_end_21} :catch_33
:goto_21
new-instance v0, Lcom/huawei/updatesdk/sdk/service/download/h$2;
invoke-direct {v0}, Lcom/huawei/updatesdk/sdk/service/download/h$2;-><init>()V
invoke-static {v0}, Ljavax/net/ssl/HttpsURLConnection;->setDefaultHostnameVerifier(Ljavax/net/ssl/HostnameVerifier;)V
return-void
:catch_2a
move-exception v0
const-string v1, "HiAppDownload"
const-string v2, "disableSSLCertificateChecking exception"
invoke-static {v1, v2, v0}, Lcom/huawei/updatesdk/sdk/a/b/a/a/a;->a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
goto :goto_21
:catch_33
move-exception v0
const-string v1, "HiAppDownload"
const-string v2, "disableSSLCertificateChecking exception"
invoke-static {v1, v2, v0}, Lcom/huawei/updatesdk/sdk/a/b/a/a/a;->a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
goto :goto_21
.end method
# virtual methods
.method public a(Ljava/lang/String;Z)Ljava/net/HttpURLConnection;
.registers 6
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
new-instance v0, Ljava/net/URL;
invoke-direct {v0, p1}, Ljava/net/URL;-><init>(Ljava/lang/String;)V
invoke-direct {p0}, Lcom/huawei/updatesdk/sdk/service/download/h;->b()Ljava/net/Proxy;
move-result-object v1
if-nez v1, :cond_2e
invoke-virtual {v0}, Ljava/net/URL;->openConnection()Ljava/net/URLConnection;
move-result-object v0
check-cast v0, Ljava/net/HttpURLConnection;
:goto_11
const/16 v1, 0x1b58
invoke-virtual {v0, v1}, Ljava/net/HttpURLConnection;->setConnectTimeout(I)V
const/16 v1, 0x2710
invoke-virtual {v0, v1}, Ljava/net/HttpURLConnection;->setReadTimeout(I)V
const/4 v1, 0x0
invoke-virtual {v0, v1}, Ljava/net/HttpURLConnection;->setUseCaches(Z)V
const/4 v1, 0x1
invoke-virtual {v0, v1}, Ljava/net/HttpURLConnection;->setDoInput(Z)V
const-string v1, "Accept-Encoding"
const-string v2, "identity"
invoke-virtual {v0, v1, v2}, Ljava/net/HttpURLConnection;->setRequestProperty(Ljava/lang/String;Ljava/lang/String;)V
invoke-virtual {v0, p2}, Ljava/net/HttpURLConnection;->setInstanceFollowRedirects(Z)V
return-object v0
:cond_2e
invoke-virtual {v0, v1}, Ljava/net/URL;->openConnection(Ljava/net/Proxy;)Ljava/net/URLConnection;
move-result-object v0
check-cast v0, Ljava/net/HttpURLConnection;
goto :goto_11
.end method