Networking.smali
.class public Lcom/mopub/network/Networking;
.super Ljava/lang/Object;
.source "SourceFile"
# static fields
.field static final CACHE_DIRECTORY_NAME:Ljava/lang/String; = "mopub-volley-cache"
.field private static final DEFAULT_USER_AGENT:Ljava/lang/String;
.field private static volatile sMaxWidthImageLoader:Lcom/mopub/network/MaxWidthImageLoader;
.field private static volatile sRequestQueue:Lcom/mopub/network/MoPubRequestQueue;
.field private static sUrlRewriter:Lcom/mopub/volley/toolbox/HurlStack$UrlRewriter;
.field private static sUseHttps:Z
.field private static volatile sUserAgent:Ljava/lang/String;
# direct methods
.method static constructor <clinit>()V
.registers 1
const-string v0, "http.agent"
.line 37
invoke-static {v0}, Ljava/lang/System;->getProperty(Ljava/lang/String;)Ljava/lang/String;
move-result-object v0
sput-object v0, Lcom/mopub/network/Networking;->DEFAULT_USER_AGENT:Ljava/lang/String;
const/4 v0, 0x0
.line 45
sput-boolean v0, Lcom/mopub/network/Networking;->sUseHttps:Z
return-void
.end method
.method public constructor <init>()V
.registers 1
.line 34
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method public static declared-synchronized clearForTesting()V
.registers 2
const-class v0, Lcom/mopub/network/Networking;
monitor-enter v0
const/4 v1, 0x0
.line 192
:try_start_4
sput-object v1, Lcom/mopub/network/Networking;->sRequestQueue:Lcom/mopub/network/MoPubRequestQueue;
.line 193
sput-object v1, Lcom/mopub/network/Networking;->sMaxWidthImageLoader:Lcom/mopub/network/MaxWidthImageLoader;
.line 194
sput-object v1, Lcom/mopub/network/Networking;->sUserAgent:Ljava/lang/String;
:try_end_a
.catchall {:try_start_4 .. :try_end_a} :catchall_c
.line 195
monitor-exit v0
return-void
:catchall_c
move-exception v1
monitor-exit v0
throw v1
.end method
.method public static getBaseUrlScheme()Ljava/lang/String;
.registers 1
.line 241
invoke-static {}, Lcom/mopub/network/Networking;->shouldUseHttps()Z
move-result v0
if-eqz v0, :cond_9
const-string v0, "https"
return-object v0
:cond_9
const-string v0, "http"
return-object v0
.end method
.method public static getCachedUserAgent()Ljava/lang/String;
.registers 1
.line 183
sget-object v0, Lcom/mopub/network/Networking;->sUserAgent:Ljava/lang/String;
if-nez v0, :cond_6
.line 185
sget-object v0, Lcom/mopub/network/Networking;->DEFAULT_USER_AGENT:Ljava/lang/String;
:cond_6
return-object v0
.end method
.method public static getImageLoader(Landroid/content/Context;)Lcom/mopub/volley/toolbox/ImageLoader;
.registers 6
.line 97
sget-object v0, Lcom/mopub/network/Networking;->sMaxWidthImageLoader:Lcom/mopub/network/MaxWidthImageLoader;
if-nez v0, :cond_2a
.line 100
const-class v1, Lcom/mopub/network/Networking;
monitor-enter v1
.line 101
:try_start_7
sget-object v0, Lcom/mopub/network/Networking;->sMaxWidthImageLoader:Lcom/mopub/network/MaxWidthImageLoader;
if-nez v0, :cond_25
.line 103
invoke-static {p0}, Lcom/mopub/network/Networking;->getRequestQueue(Landroid/content/Context;)Lcom/mopub/network/MoPubRequestQueue;
move-result-object v0
.line 104
invoke-static {p0}, Lcom/mopub/common/util/DeviceUtils;->memoryCacheSizeBytes(Landroid/content/Context;)I
move-result v2
.line 105
new-instance v3, Lcom/mopub/network/Networking$1;
invoke-direct {v3, v2}, Lcom/mopub/network/Networking$1;-><init>(I)V
.line 115
new-instance v2, Lcom/mopub/network/MaxWidthImageLoader;
new-instance v4, Lcom/mopub/network/Networking$2;
invoke-direct {v4, v3}, Lcom/mopub/network/Networking$2;-><init>(Landroidx/collection/LruCache;)V
invoke-direct {v2, v0, p0, v4}, Lcom/mopub/network/MaxWidthImageLoader;-><init>(Lcom/mopub/volley/RequestQueue;Landroid/content/Context;Lcom/mopub/volley/toolbox/ImageLoader$ImageCache;)V
.line 126
sput-object v2, Lcom/mopub/network/Networking;->sMaxWidthImageLoader:Lcom/mopub/network/MaxWidthImageLoader;
move-object v0, v2
.line 128
:cond_25
monitor-exit v1
goto :goto_2a
:catchall_27
move-exception p0
monitor-exit v1
:try_end_29
.catchall {:try_start_7 .. :try_end_29} :catchall_27
throw p0
:cond_2a
:goto_2a
return-object v0
.end method
.method public static getRequestQueue()Lcom/mopub/network/MoPubRequestQueue;
.registers 1
.line 50
sget-object v0, Lcom/mopub/network/Networking;->sRequestQueue:Lcom/mopub/network/MoPubRequestQueue;
return-object v0
.end method
.method public static getRequestQueue(Landroid/content/Context;)Lcom/mopub/network/MoPubRequestQueue;
.registers 6
.line 66
sget-object v0, Lcom/mopub/network/Networking;->sRequestQueue:Lcom/mopub/network/MoPubRequestQueue;
if-nez v0, :cond_67
.line 69
const-class v1, Lcom/mopub/network/Networking;
monitor-enter v1
.line 70
:try_start_7
sget-object v0, Lcom/mopub/network/Networking;->sRequestQueue:Lcom/mopub/network/MoPubRequestQueue;
if-nez v0, :cond_62
const/16 v0, 0x2710
.line 73
invoke-static {v0}, Lcom/mopub/network/CustomSSLSocketFactory;->getDefault(I)Lcom/mopub/network/CustomSSLSocketFactory;
move-result-object v0
.line 76
invoke-virtual {p0}, Landroid/content/Context;->getApplicationContext()Landroid/content/Context;
move-result-object v2
.line 75
invoke-static {v2}, Lcom/mopub/network/Networking;->getUserAgent(Landroid/content/Context;)Ljava/lang/String;
move-result-object v2
.line 77
new-instance v3, Lcom/mopub/network/RequestQueueHttpStack;
.line 78
invoke-static {p0}, Lcom/mopub/network/Networking;->getUrlRewriter(Landroid/content/Context;)Lcom/mopub/volley/toolbox/HurlStack$UrlRewriter;
move-result-object v4
invoke-direct {v3, v2, v4, v0}, Lcom/mopub/network/RequestQueueHttpStack;-><init>(Ljava/lang/String;Lcom/mopub/volley/toolbox/HurlStack$UrlRewriter;Ljavax/net/ssl/SSLSocketFactory;)V
.line 80
new-instance v0, Lcom/mopub/volley/toolbox/BasicNetwork;
invoke-direct {v0, v3}, Lcom/mopub/volley/toolbox/BasicNetwork;-><init>(Lcom/mopub/volley/toolbox/BaseHttpStack;)V
.line 81
new-instance v2, Ljava/io/File;
new-instance v3, Ljava/lang/StringBuilder;
invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
invoke-virtual {p0}, Landroid/content/Context;->getCacheDir()Ljava/io/File;
move-result-object p0
invoke-virtual {p0}, Ljava/io/File;->getPath()Ljava/lang/String;
move-result-object p0
invoke-virtual {v3, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
sget-object p0, Ljava/io/File;->separator:Ljava/lang/String;
invoke-virtual {v3, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string p0, "mopub-volley-cache"
invoke-virtual {v3, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p0
invoke-direct {v2, p0}, Ljava/io/File;-><init>(Ljava/lang/String;)V
.line 83
new-instance p0, Lcom/mopub/volley/toolbox/DiskBasedCache;
const-wide/32 v3, 0xa00000
.line 84
invoke-static {v2, v3, v4}, Lcom/mopub/common/util/DeviceUtils;->diskCacheSizeBytes(Ljava/io/File;J)J
move-result-wide v3
long-to-int v4, v3
invoke-direct {p0, v2, v4}, Lcom/mopub/volley/toolbox/DiskBasedCache;-><init>(Ljava/io/File;I)V
.line 85
new-instance v2, Lcom/mopub/network/MoPubRequestQueue;
invoke-direct {v2, p0, v0}, Lcom/mopub/network/MoPubRequestQueue;-><init>(Lcom/mopub/volley/Cache;Lcom/mopub/volley/Network;)V
.line 86
sput-object v2, Lcom/mopub/network/Networking;->sRequestQueue:Lcom/mopub/network/MoPubRequestQueue;
.line 87
invoke-virtual {v2}, Lcom/mopub/network/MoPubRequestQueue;->start()V
move-object v0, v2
.line 89
:cond_62
monitor-exit v1
goto :goto_67
:catchall_64
move-exception p0
monitor-exit v1
:try_end_66
.catchall {:try_start_7 .. :try_end_66} :catchall_64
throw p0
:cond_67
:goto_67
return-object v0
.end method
.method public static getScheme()Ljava/lang/String;
.registers 1
const-string v0, "https"
return-object v0
.end method
.method public static getUrlRewriter(Landroid/content/Context;)Lcom/mopub/volley/toolbox/HurlStack$UrlRewriter;
.registers 1
.line 55
invoke-static {p0}, Lcom/mopub/common/Preconditions;->checkNotNull(Ljava/lang/Object;)V
.line 58
sget-object p0, Lcom/mopub/network/Networking;->sUrlRewriter:Lcom/mopub/volley/toolbox/HurlStack$UrlRewriter;
if-nez p0, :cond_e
.line 59
new-instance p0, Lcom/mopub/network/PlayServicesUrlRewriter;
invoke-direct {p0}, Lcom/mopub/network/PlayServicesUrlRewriter;-><init>()V
sput-object p0, Lcom/mopub/network/Networking;->sUrlRewriter:Lcom/mopub/volley/toolbox/HurlStack$UrlRewriter;
.line 61
:cond_e
sget-object p0, Lcom/mopub/network/Networking;->sUrlRewriter:Lcom/mopub/volley/toolbox/HurlStack$UrlRewriter;
return-object p0
.end method
.method public static getUserAgent(Landroid/content/Context;)Ljava/lang/String;
.registers 4
.line 140
invoke-static {p0}, Lcom/mopub/common/Preconditions;->checkNotNull(Ljava/lang/Object;)V
.line 142
sget-object v0, Lcom/mopub/network/Networking;->sUserAgent:Ljava/lang/String;
if-nez v0, :cond_3f
.line 144
const-class v1, Lcom/mopub/network/Networking;
monitor-enter v1
.line 145
:try_start_a
sget-object v0, Lcom/mopub/network/Networking;->sUserAgent:Ljava/lang/String;
:try_end_c
.catchall {:try_start_a .. :try_end_c} :catchall_3c
if-nez v0, :cond_3a
.line 150
:try_start_e
invoke-static {}, Landroid/os/Looper;->myLooper()Landroid/os/Looper;
move-result-object v0
invoke-static {}, Landroid/os/Looper;->getMainLooper()Landroid/os/Looper;
move-result-object v2
if-ne v0, v2, :cond_31
.line 151
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
const/16 v2, 0x11
if-lt v0, v2, :cond_23
.line 152
invoke-static {p0}, Landroid/webkit/WebSettings;->getDefaultUserAgent(Landroid/content/Context;)Ljava/lang/String;
move-result-object p0
goto :goto_37
.line 154
:cond_23
new-instance v0, Landroid/webkit/WebView;
invoke-direct {v0, p0}, Landroid/webkit/WebView;-><init>(Landroid/content/Context;)V
invoke-virtual {v0}, Landroid/webkit/WebView;->getSettings()Landroid/webkit/WebSettings;
move-result-object p0
invoke-virtual {p0}, Landroid/webkit/WebSettings;->getUserAgentString()Ljava/lang/String;
move-result-object p0
goto :goto_37
.line 160
:cond_31
sget-object p0, Lcom/mopub/network/Networking;->DEFAULT_USER_AGENT:Ljava/lang/String;
:try_end_33
.catch Ljava/lang/Exception; {:try_start_e .. :try_end_33} :catch_35
.catchall {:try_start_e .. :try_end_33} :catchall_3c
:try_start_33
monitor-exit v1
return-object p0
.line 165
:catch_35
sget-object p0, Lcom/mopub/network/Networking;->DEFAULT_USER_AGENT:Ljava/lang/String;
.line 167
:goto_37
sput-object p0, Lcom/mopub/network/Networking;->sUserAgent:Ljava/lang/String;
move-object v0, p0
.line 169
:cond_3a
monitor-exit v1
goto :goto_3f
:catchall_3c
move-exception p0
monitor-exit v1
:try_end_3e
.catchall {:try_start_33 .. :try_end_3e} :catchall_3c
throw p0
:cond_3f
:goto_3f
return-object v0
.end method
.method public static declared-synchronized setImageLoaderForTesting(Lcom/mopub/network/MaxWidthImageLoader;)V
.registers 2
const-class v0, Lcom/mopub/network/Networking;
monitor-enter v0
.line 204
:try_start_3
sput-object p0, Lcom/mopub/network/Networking;->sMaxWidthImageLoader:Lcom/mopub/network/MaxWidthImageLoader;
:try_end_5
.catchall {:try_start_3 .. :try_end_5} :catchall_7
.line 205
monitor-exit v0
return-void
:catchall_7
move-exception p0
monitor-exit v0
throw p0
.end method
.method public static declared-synchronized setRequestQueueForTesting(Lcom/mopub/network/MoPubRequestQueue;)V
.registers 2
const-class v0, Lcom/mopub/network/Networking;
monitor-enter v0
.line 199
:try_start_3
sput-object p0, Lcom/mopub/network/Networking;->sRequestQueue:Lcom/mopub/network/MoPubRequestQueue;
:try_end_5
.catchall {:try_start_3 .. :try_end_5} :catchall_7
.line 200
monitor-exit v0
return-void
:catchall_7
move-exception p0
monitor-exit v0
throw p0
.end method
.method public static declared-synchronized setUserAgentForTesting(Ljava/lang/String;)V
.registers 2
const-class v0, Lcom/mopub/network/Networking;
monitor-enter v0
.line 209
:try_start_3
sput-object p0, Lcom/mopub/network/Networking;->sUserAgent:Ljava/lang/String;
:try_end_5
.catchall {:try_start_3 .. :try_end_5} :catchall_7
.line 210
monitor-exit v0
return-void
:catchall_7
move-exception p0
monitor-exit v0
throw p0
.end method
.method public static shouldUseHttps()Z
.registers 1
.line 220
sget-boolean v0, Lcom/mopub/network/Networking;->sUseHttps:Z
return v0
.end method
.method public static useHttps(Z)V
.registers 1
.line 216
sput-boolean p0, Lcom/mopub/network/Networking;->sUseHttps:Z
return-void
.end method