546 lines
14 KiB
Smali
546 lines
14 KiB
Smali
.class public Le/d/a/v/c;
|
|
.super Ljava/lang/Object;
|
|
.source "NetworkFetcher.java"
|
|
|
|
|
|
# instance fields
|
|
.field public final a:Landroid/content/Context;
|
|
|
|
.field public final b:Ljava/lang/String;
|
|
|
|
.field public final c:Le/d/a/v/b;
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>(Landroid/content/Context;Ljava/lang/String;)V
|
|
.locals 1
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
invoke-virtual {p1}, Landroid/content/Context;->getApplicationContext()Landroid/content/Context;
|
|
|
|
move-result-object p1
|
|
|
|
iput-object p1, p0, Le/d/a/v/c;->a:Landroid/content/Context;
|
|
|
|
iput-object p2, p0, Le/d/a/v/c;->b:Ljava/lang/String;
|
|
|
|
new-instance p1, Le/d/a/v/b;
|
|
|
|
iget-object v0, p0, Le/d/a/v/c;->a:Landroid/content/Context;
|
|
|
|
invoke-direct {p1, v0, p2}, Le/d/a/v/b;-><init>(Landroid/content/Context;Ljava/lang/String;)V
|
|
|
|
iput-object p1, p0, Le/d/a/v/c;->c:Le/d/a/v/b;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public final a()Le/d/a/l;
|
|
.locals 6
|
|
.annotation build Landroidx/annotation/WorkerThread;
|
|
.end annotation
|
|
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
const-string v0, "Fetching "
|
|
|
|
invoke-static {v0}, Le/e/b/a/a;->a(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
move-result-object v0
|
|
|
|
iget-object v1, p0, Le/d/a/v/c;->b:Ljava/lang/String;
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-static {v0}, Le/d/a/x/c;->a(Ljava/lang/String;)V
|
|
|
|
new-instance v0, Ljava/net/URL;
|
|
|
|
iget-object v1, p0, Le/d/a/v/c;->b:Ljava/lang/String;
|
|
|
|
invoke-direct {v0, v1}, Ljava/net/URL;-><init>(Ljava/lang/String;)V
|
|
|
|
invoke-virtual {v0}, Ljava/net/URL;->openConnection()Ljava/net/URLConnection;
|
|
|
|
move-result-object v0
|
|
|
|
check-cast v0, Ljava/net/HttpURLConnection;
|
|
|
|
const-string v1, "GET"
|
|
|
|
invoke-virtual {v0, v1}, Ljava/net/HttpURLConnection;->setRequestMethod(Ljava/lang/String;)V
|
|
|
|
:try_start_0
|
|
invoke-virtual {v0}, Ljava/net/HttpURLConnection;->connect()V
|
|
|
|
invoke-virtual {v0}, Ljava/net/HttpURLConnection;->getErrorStream()Ljava/io/InputStream;
|
|
|
|
move-result-object v1
|
|
|
|
if-nez v1, :cond_2
|
|
|
|
invoke-virtual {v0}, Ljava/net/HttpURLConnection;->getResponseCode()I
|
|
|
|
move-result v1
|
|
|
|
const/16 v2, 0xc8
|
|
|
|
if-eq v1, v2, :cond_0
|
|
|
|
goto :goto_1
|
|
|
|
:cond_0
|
|
invoke-virtual {p0, v0}, Le/d/a/v/c;->b(Ljava/net/HttpURLConnection;)Le/d/a/l;
|
|
|
|
move-result-object v1
|
|
|
|
new-instance v2, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
const-string v3, "Completed fetch from network. Success: "
|
|
|
|
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
iget-object v3, v1, Le/d/a/l;->a:Ljava/lang/Object;
|
|
|
|
if-eqz v3, :cond_1
|
|
|
|
const/4 v3, 0x1
|
|
|
|
goto :goto_0
|
|
|
|
:cond_1
|
|
const/4 v3, 0x0
|
|
|
|
:goto_0
|
|
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v2
|
|
|
|
invoke-static {v2}, Le/d/a/x/c;->a(Ljava/lang/String;)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-virtual {v0}, Ljava/net/HttpURLConnection;->disconnect()V
|
|
|
|
return-object v1
|
|
|
|
:cond_2
|
|
:goto_1
|
|
:try_start_1
|
|
invoke-virtual {p0, v0}, Le/d/a/v/c;->a(Ljava/net/HttpURLConnection;)Ljava/lang/String;
|
|
|
|
move-result-object v1
|
|
|
|
new-instance v2, Le/d/a/l;
|
|
|
|
new-instance v3, Ljava/lang/IllegalArgumentException;
|
|
|
|
new-instance v4, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
const-string v5, "Unable to fetch "
|
|
|
|
invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
iget-object v5, p0, Le/d/a/v/c;->b:Ljava/lang/String;
|
|
|
|
invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
const-string v5, ". Failed with "
|
|
|
|
invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v0}, Ljava/net/HttpURLConnection;->getResponseCode()I
|
|
|
|
move-result v5
|
|
|
|
invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
|
|
|
|
const-string v5, "\n"
|
|
|
|
invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v4, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-direct {v3, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
|
|
|
|
invoke-direct {v2, v3}, Le/d/a/l;-><init>(Ljava/lang/Throwable;)V
|
|
:try_end_1
|
|
.catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0
|
|
.catchall {:try_start_1 .. :try_end_1} :catchall_0
|
|
|
|
invoke-virtual {v0}, Ljava/net/HttpURLConnection;->disconnect()V
|
|
|
|
return-object v2
|
|
|
|
:catchall_0
|
|
move-exception v1
|
|
|
|
goto :goto_2
|
|
|
|
:catch_0
|
|
move-exception v1
|
|
|
|
:try_start_2
|
|
new-instance v2, Le/d/a/l;
|
|
|
|
invoke-direct {v2, v1}, Le/d/a/l;-><init>(Ljava/lang/Throwable;)V
|
|
:try_end_2
|
|
.catchall {:try_start_2 .. :try_end_2} :catchall_0
|
|
|
|
invoke-virtual {v0}, Ljava/net/HttpURLConnection;->disconnect()V
|
|
|
|
return-object v2
|
|
|
|
:goto_2
|
|
invoke-virtual {v0}, Ljava/net/HttpURLConnection;->disconnect()V
|
|
|
|
throw v1
|
|
.end method
|
|
|
|
.method public final a(Ljava/net/HttpURLConnection;)Ljava/lang/String;
|
|
.locals 2
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
invoke-virtual {p1}, Ljava/net/HttpURLConnection;->getResponseCode()I
|
|
|
|
new-instance v0, Ljava/io/BufferedReader;
|
|
|
|
new-instance v1, Ljava/io/InputStreamReader;
|
|
|
|
invoke-virtual {p1}, Ljava/net/HttpURLConnection;->getErrorStream()Ljava/io/InputStream;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-direct {v1, p1}, Ljava/io/InputStreamReader;-><init>(Ljava/io/InputStream;)V
|
|
|
|
invoke-direct {v0, v1}, Ljava/io/BufferedReader;-><init>(Ljava/io/Reader;)V
|
|
|
|
new-instance p1, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {p1}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
:goto_0
|
|
:try_start_0
|
|
invoke-virtual {v0}, Ljava/io/BufferedReader;->readLine()Ljava/lang/String;
|
|
|
|
move-result-object v1
|
|
|
|
if-eqz v1, :cond_0
|
|
|
|
invoke-virtual {p1, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
const/16 v1, 0xa
|
|
|
|
invoke-virtual {p1, v1}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;
|
|
:try_end_0
|
|
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_1
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
:try_start_1
|
|
invoke-virtual {v0}, Ljava/io/BufferedReader;->close()V
|
|
:try_end_1
|
|
.catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0
|
|
|
|
:catch_0
|
|
invoke-virtual {p1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
return-object p1
|
|
|
|
:catchall_0
|
|
move-exception p1
|
|
|
|
goto :goto_1
|
|
|
|
:catch_1
|
|
move-exception p1
|
|
|
|
:try_start_2
|
|
throw p1
|
|
:try_end_2
|
|
.catchall {:try_start_2 .. :try_end_2} :catchall_0
|
|
|
|
:goto_1
|
|
:try_start_3
|
|
invoke-virtual {v0}, Ljava/io/BufferedReader;->close()V
|
|
:try_end_3
|
|
.catch Ljava/lang/Exception; {:try_start_3 .. :try_end_3} :catch_2
|
|
|
|
:catch_2
|
|
throw p1
|
|
.end method
|
|
|
|
.method public final b(Ljava/net/HttpURLConnection;)Le/d/a/l;
|
|
.locals 6
|
|
.annotation build Landroidx/annotation/Nullable;
|
|
.end annotation
|
|
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(",
|
|
"Ljava/net/HttpURLConnection;",
|
|
")",
|
|
"Le/d/a/l<",
|
|
"Le/d/a/d;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
invoke-virtual {p1}, Ljava/net/HttpURLConnection;->getContentType()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "application/json"
|
|
|
|
if-nez v0, :cond_0
|
|
|
|
move-object v0, v1
|
|
|
|
:cond_0
|
|
const/4 v2, -0x1
|
|
|
|
invoke-virtual {v0}, Ljava/lang/String;->hashCode()I
|
|
|
|
move-result v3
|
|
|
|
const v4, -0x4a67ee1e
|
|
|
|
const/4 v5, 0x1
|
|
|
|
if-eq v3, v4, :cond_2
|
|
|
|
const v4, -0x29cf5b9
|
|
|
|
if-eq v3, v4, :cond_1
|
|
|
|
goto :goto_0
|
|
|
|
:cond_1
|
|
invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
|
|
|
|
move-result v0
|
|
|
|
if-eqz v0, :cond_3
|
|
|
|
const/4 v2, 0x1
|
|
|
|
goto :goto_0
|
|
|
|
:cond_2
|
|
const-string v1, "application/zip"
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
|
|
|
|
move-result v0
|
|
|
|
if-eqz v0, :cond_3
|
|
|
|
const/4 v2, 0x0
|
|
|
|
:cond_3
|
|
:goto_0
|
|
if-eqz v2, :cond_4
|
|
|
|
const-string v0, "Received json response."
|
|
|
|
invoke-static {v0}, Le/d/a/x/c;->a(Ljava/lang/String;)V
|
|
|
|
sget-object v0, Le/d/a/v/a;->d:Le/d/a/v/a;
|
|
|
|
iget-object v1, p0, Le/d/a/v/c;->c:Le/d/a/v/b;
|
|
|
|
invoke-virtual {p1}, Ljava/net/HttpURLConnection;->getInputStream()Ljava/io/InputStream;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-virtual {v1, p1, v0}, Le/d/a/v/b;->a(Ljava/io/InputStream;Le/d/a/v/a;)Ljava/io/File;
|
|
|
|
move-result-object p1
|
|
|
|
new-instance v1, Ljava/io/FileInputStream;
|
|
|
|
new-instance v2, Ljava/io/File;
|
|
|
|
invoke-virtual {p1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-direct {v2, p1}, Ljava/io/File;-><init>(Ljava/lang/String;)V
|
|
|
|
invoke-direct {v1, v2}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V
|
|
|
|
iget-object p1, p0, Le/d/a/v/c;->b:Ljava/lang/String;
|
|
|
|
invoke-static {v1, p1}, Le/d/a/e;->a(Ljava/io/InputStream;Ljava/lang/String;)Le/d/a/l;
|
|
|
|
move-result-object p1
|
|
|
|
goto :goto_1
|
|
|
|
:cond_4
|
|
const-string v0, "Handling zip response."
|
|
|
|
invoke-static {v0}, Le/d/a/x/c;->a(Ljava/lang/String;)V
|
|
|
|
sget-object v0, Le/d/a/v/a;->e:Le/d/a/v/a;
|
|
|
|
iget-object v1, p0, Le/d/a/v/c;->c:Le/d/a/v/b;
|
|
|
|
invoke-virtual {p1}, Ljava/net/HttpURLConnection;->getInputStream()Ljava/io/InputStream;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-virtual {v1, p1, v0}, Le/d/a/v/b;->a(Ljava/io/InputStream;Le/d/a/v/a;)Ljava/io/File;
|
|
|
|
move-result-object p1
|
|
|
|
new-instance v1, Ljava/util/zip/ZipInputStream;
|
|
|
|
new-instance v2, Ljava/io/FileInputStream;
|
|
|
|
invoke-direct {v2, p1}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V
|
|
|
|
invoke-direct {v1, v2}, Ljava/util/zip/ZipInputStream;-><init>(Ljava/io/InputStream;)V
|
|
|
|
iget-object p1, p0, Le/d/a/v/c;->b:Ljava/lang/String;
|
|
|
|
invoke-static {v1, p1}, Le/d/a/e;->a(Ljava/util/zip/ZipInputStream;Ljava/lang/String;)Le/d/a/l;
|
|
|
|
move-result-object p1
|
|
|
|
:goto_1
|
|
iget-object v1, p1, Le/d/a/l;->a:Ljava/lang/Object;
|
|
|
|
if-eqz v1, :cond_5
|
|
|
|
iget-object v1, p0, Le/d/a/v/c;->c:Le/d/a/v/b;
|
|
|
|
iget-object v2, v1, Le/d/a/v/b;->b:Ljava/lang/String;
|
|
|
|
invoke-static {v2, v0, v5}, Le/d/a/v/b;->a(Ljava/lang/String;Le/d/a/v/a;Z)Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
new-instance v2, Ljava/io/File;
|
|
|
|
iget-object v1, v1, Le/d/a/v/b;->a:Landroid/content/Context;
|
|
|
|
invoke-virtual {v1}, Landroid/content/Context;->getCacheDir()Ljava/io/File;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-direct {v2, v1, v0}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V
|
|
|
|
invoke-virtual {v2}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, ".temp"
|
|
|
|
const-string v3, ""
|
|
|
|
invoke-virtual {v0, v1, v3}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
new-instance v1, Ljava/io/File;
|
|
|
|
invoke-direct {v1, v0}, Ljava/io/File;-><init>(Ljava/lang/String;)V
|
|
|
|
invoke-virtual {v2, v1}, Ljava/io/File;->renameTo(Ljava/io/File;)Z
|
|
|
|
move-result v0
|
|
|
|
new-instance v3, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
const-string v4, "Copying temp file to real file ("
|
|
|
|
invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
|
|
|
|
const-string v4, ")"
|
|
|
|
invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v3
|
|
|
|
invoke-static {v3}, Le/d/a/x/c;->a(Ljava/lang/String;)V
|
|
|
|
if-nez v0, :cond_5
|
|
|
|
const-string v0, "Unable to rename cache file "
|
|
|
|
invoke-static {v0}, Le/e/b/a/a;->a(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v2}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;
|
|
|
|
move-result-object v2
|
|
|
|
invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
const-string v2, " to "
|
|
|
|
invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
const-string v1, "."
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-static {v0}, Le/d/a/x/c;->b(Ljava/lang/String;)V
|
|
|
|
:cond_5
|
|
return-object p1
|
|
.end method
|