SSZVideoCacheOkHttpService.smali
.class public Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;
.super Ljava/lang/Object;
.source "SourceFile"
# static fields
.field private static final CONNECTION_ERROR:I = -0x2
.field private static final CONNECTION_ERROR_CODE:I = -0x3
.field private static final CONTENT_RANGE_HEADER:Ljava/util/regex/Pattern;
.field private static final HTTP_DISCONNECT:I = -0x2
.field private static final MAX_BYTES_TO_DRAIN:J = 0x800L
.field private static final REQUEST_GET_METHOD:Ljava/lang/String; = "GET"
.field private static final TAG:Ljava/lang/String; = "VideoCacheOkHttpService"
.field private static final skipBufferReference:Ljava/util/concurrent/atomic/AtomicReference;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/concurrent/atomic/AtomicReference<",
"[B>;"
}
.end annotation
.end field
# instance fields
.field private allowGzip:Z
.field private bytesSkipped:J
.field public bytesToSkip:J
.field private connectTimeoutMillis:I
.field public connection:Ljava/net/HttpURLConnection;
.field private inputStream:Ljava/io/InputStream;
.field private isOpened:Z
.field private readTimeoutMillis:I
.field private responseCode:I
# direct methods
.method public static constructor <clinit>()V
.registers 1
const-string v0, "^bytes (\\d+)-(\\d+)/(\\d+)$"
.line 1
invoke-static {v0}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;
move-result-object v0
sput-object v0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->CONTENT_RANGE_HEADER:Ljava/util/regex/Pattern;
.line 2
new-instance v0, Ljava/util/concurrent/atomic/AtomicReference;
invoke-direct {v0}, Ljava/util/concurrent/atomic/AtomicReference;-><init>()V
sput-object v0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->skipBufferReference:Ljava/util/concurrent/atomic/AtomicReference;
return-void
.end method
.method public constructor <init>()V
.registers 2
.line 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
const/16 v0, 0x3a98
.line 2
iput v0, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->connectTimeoutMillis:I
.line 3
iput v0, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->readTimeoutMillis:I
const/4 v0, 0x0
.line 4
iput-boolean v0, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->allowGzip:Z
return-void
.end method
.method private closeConnectionQuietly()V
.registers 2
.line 1
iget-object v0, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->connection:Ljava/net/HttpURLConnection;
if-eqz v0, :cond_f
.line 2
:try_start_4
invoke-virtual {v0}, Ljava/net/HttpURLConnection;->disconnect()V
:try_end_7
.catch Ljava/lang/Exception; {:try_start_4 .. :try_end_7} :catch_8
goto :goto_c
:catch_8
move-exception v0
.line 3
invoke-virtual {v0}, Ljava/lang/Object;->toString()Ljava/lang/String;
:goto_c
const/4 v0, 0x0
.line 4
iput-object v0, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->connection:Ljava/net/HttpURLConnection;
:cond_f
return-void
.end method
.method public static createInstance()Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;
.registers 1
new-instance v0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;
invoke-direct {v0}, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;-><init>()V
return-object v0
.end method
.method private static getContentLength(Ljava/net/HttpURLConnection;)J
.registers 7
const-string v0, "Content-Length"
.line 1
invoke-virtual {p0, v0}, Ljava/net/URLConnection;->getHeaderField(Ljava/lang/String;)Ljava/lang/String;
move-result-object v0
.line 2
invoke-static {v0}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z
move-result v1
if-nez v1, :cond_11
.line 3
:try_start_c
invoke-static {v0}, Ljava/lang/Long;->parseLong(Ljava/lang/String;)J
move-result-wide v0
:try_end_10
.catch Ljava/lang/NumberFormatException; {:try_start_c .. :try_end_10} :catch_11
goto :goto_13
:catch_11
:cond_11
const-wide/16 v0, -0x1
:goto_13
const-string v2, "Content-Range"
.line 4
invoke-virtual {p0, v2}, Ljava/net/URLConnection;->getHeaderField(Ljava/lang/String;)Ljava/lang/String;
move-result-object p0
.line 5
invoke-static {p0}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z
move-result v2
if-nez v2, :cond_51
.line 6
sget-object v2, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->CONTENT_RANGE_HEADER:Ljava/util/regex/Pattern;
invoke-virtual {v2, p0}, Ljava/util/regex/Pattern;->matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;
move-result-object p0
.line 7
invoke-virtual {p0}, Ljava/util/regex/Matcher;->find()Z
move-result v2
if-eqz v2, :cond_51
const/4 v2, 0x2
.line 8
:try_start_2c
invoke-virtual {p0, v2}, Ljava/util/regex/Matcher;->group(I)Ljava/lang/String;
move-result-object v2
invoke-static {v2}, Ljava/lang/Long;->parseLong(Ljava/lang/String;)J
move-result-wide v2
const/4 v4, 0x1
invoke-virtual {p0, v4}, Ljava/util/regex/Matcher;->group(I)Ljava/lang/String;
move-result-object p0
invoke-static {p0}, Ljava/lang/Long;->parseLong(Ljava/lang/String;)J
move-result-wide v4
sub-long/2addr v2, v4
const-wide/16 v4, 0x1
add-long/2addr v2, v4
const-wide/16 v4, 0x0
cmp-long p0, v0, v4
if-gez p0, :cond_49
move-wide v0, v2
goto :goto_51
:cond_49
cmp-long p0, v0, v2
if-eqz p0, :cond_51
.line 9
invoke-static {v0, v1, v2, v3}, Ljava/lang/Math;->max(JJ)J
move-result-wide v0
:try_end_51
.catch Ljava/lang/NumberFormatException; {:try_start_2c .. :try_end_51} :catch_51
:catch_51
:cond_51
:goto_51
return-wide v0
.end method
.method private makeConnection(Ljava/net/URL;J)Ljava/net/HttpURLConnection;
.registers 7
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 1
invoke-virtual {p1}, Ljava/net/URL;->openConnection()Ljava/net/URLConnection;
move-result-object p1
invoke-static {p1}, Lcom/google/firebase/perf/network/FirebasePerfUrlConnection;->instrument(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object p1
check-cast p1, Ljava/net/URLConnection;
check-cast p1, Ljava/net/HttpURLConnection;
.line 2
iget v0, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->connectTimeoutMillis:I
invoke-virtual {p1, v0}, Ljava/net/URLConnection;->setConnectTimeout(I)V
.line 3
iget v0, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->readTimeoutMillis:I
invoke-virtual {p1, v0}, Ljava/net/URLConnection;->setReadTimeout(I)V
const-wide/16 v0, 0x0
cmp-long v2, p2, v0
if-eqz v2, :cond_29
const-string v0, "bytes="
const-string v1, "-"
.line 4
invoke-static {v0, p2, p3, v1}, Landroidx/appcompat/g;->e(Ljava/lang/String;JLjava/lang/String;)Ljava/lang/String;
move-result-object p2
const-string p3, "Range"
.line 5
invoke-virtual {p1, p3, p2}, Ljava/net/URLConnection;->setRequestProperty(Ljava/lang/String;Ljava/lang/String;)V
:cond_29
const-string p2, "Accept-Encoding"
const-string p3, "identity"
.line 6
invoke-virtual {p1, p2, p3}, Ljava/net/URLConnection;->setRequestProperty(Ljava/lang/String;Ljava/lang/String;)V
const-string p2, "Icy-MetaData"
const-string p3, "1"
.line 7
invoke-virtual {p1, p2, p3}, Ljava/net/URLConnection;->setRequestProperty(Ljava/lang/String;Ljava/lang/String;)V
const/4 p2, 0x1
.line 8
invoke-virtual {p1, p2}, Ljava/net/HttpURLConnection;->setInstanceFollowRedirects(Z)V
const/4 p2, 0x0
.line 9
invoke-virtual {p1, p2}, Ljava/net/URLConnection;->setDoOutput(Z)V
const-string p2, "GET"
.line 10
invoke-virtual {p1, p2}, Ljava/net/HttpURLConnection;->setRequestMethod(Ljava/lang/String;)V
.line 11
invoke-virtual {p1}, Ljava/net/URLConnection;->connect()V
return-object p1
.end method
.method private static maybeTerminateInputStream(Ljava/net/HttpURLConnection;J)V
.registers 3
return-void
.end method
.method private skipInternal()V
.registers 7
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 1
iget-wide v0, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->bytesSkipped:J
iget-wide v2, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->bytesToSkip:J
cmp-long v4, v0, v2
if-nez v4, :cond_9
return-void
.line 2
:cond_9
sget-object v0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->skipBufferReference:Ljava/util/concurrent/atomic/AtomicReference;
const/4 v1, 0x0
invoke-virtual {v0, v1}, Ljava/util/concurrent/atomic/AtomicReference;->getAndSet(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object v0
check-cast v0, [B
if-nez v0, :cond_18
const/16 v0, 0x1000
new-array v0, v0, [B
.line 3
:cond_18
:goto_18
iget-wide v1, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->bytesSkipped:J
iget-wide v3, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->bytesToSkip:J
cmp-long v5, v1, v3
if-gez v5, :cond_4f
sub-long/2addr v3, v1
.line 4
array-length v1, v0
int-to-long v1, v1
invoke-static {v3, v4, v1, v2}, Ljava/lang/Math;->min(JJ)J
move-result-wide v1
long-to-int v2, v1
.line 5
iget-object v1, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->inputStream:Ljava/io/InputStream;
const/4 v3, 0x0
invoke-virtual {v1, v0, v3, v2}, Ljava/io/InputStream;->read([BII)I
move-result v1
.line 6
invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;
move-result-object v2
invoke-virtual {v2}, Ljava/lang/Thread;->isInterrupted()Z
move-result v2
if-nez v2, :cond_49
const/4 v2, -0x1
if-eq v1, v2, :cond_43
.line 7
iget-wide v2, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->bytesSkipped:J
int-to-long v4, v1
add-long/2addr v2, v4
iput-wide v2, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->bytesSkipped:J
goto :goto_18
.line 8
:cond_43
new-instance v0, Ljava/io/EOFException;
invoke-direct {v0}, Ljava/io/EOFException;-><init>()V
throw v0
.line 9
:cond_49
new-instance v0, Ljava/io/InterruptedIOException;
invoke-direct {v0}, Ljava/io/InterruptedIOException;-><init>()V
throw v0
.line 10
:cond_4f
sget-object v1, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->skipBufferReference:Ljava/util/concurrent/atomic/AtomicReference;
invoke-virtual {v1, v0}, Ljava/util/concurrent/atomic/AtomicReference;->set(Ljava/lang/Object;)V
return-void
.end method
# virtual methods
.method public close(J)V
.registers 6
const/4 v0, 0x0
const/4 v1, 0x0
.line 1
:try_start_2
iget-object v2, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->inputStream:Ljava/io/InputStream;
if-eqz v2, :cond_15
.line 2
iget-object v2, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->connection:Ljava/net/HttpURLConnection;
invoke-static {v2, p1, p2}, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->maybeTerminateInputStream(Ljava/net/HttpURLConnection;J)V
:try_end_b
.catchall {:try_start_2 .. :try_end_b} :catchall_21
.line 3
:try_start_b
iget-object p1, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->inputStream:Ljava/io/InputStream;
invoke-virtual {p1}, Ljava/io/InputStream;->close()V
:try_end_10
.catch Ljava/io/IOException; {:try_start_b .. :try_end_10} :catch_11
.catchall {:try_start_b .. :try_end_10} :catchall_21
goto :goto_15
:catch_11
move-exception p1
.line 4
:try_start_12
invoke-virtual {p1}, Ljava/lang/Object;->toString()Ljava/lang/String;
:try_end_15
.catchall {:try_start_12 .. :try_end_15} :catchall_21
.line 5
:cond_15
:goto_15
iput-object v1, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->inputStream:Ljava/io/InputStream;
.line 6
invoke-direct {p0}, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->closeConnectionQuietly()V
.line 7
iget-boolean p1, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->isOpened:Z
if-eqz p1, :cond_20
.line 8
iput-boolean v0, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->isOpened:Z
:cond_20
return-void
:catchall_21
move-exception p1
.line 9
iput-object v1, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->inputStream:Ljava/io/InputStream;
.line 10
invoke-direct {p0}, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->closeConnectionQuietly()V
.line 11
iget-boolean p2, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->isOpened:Z
if-eqz p2, :cond_2d
.line 12
iput-boolean v0, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->isOpened:Z
.line 13
:cond_2d
throw p1
.end method
.method public open(Ljava/lang/String;J)J
.registers 9
const-wide/16 v0, -0x2
.line 1
:try_start_2
new-instance v2, Ljava/net/URL;
invoke-direct {v2, p1}, Ljava/net/URL;-><init>(Ljava/lang/String;)V
.line 2
invoke-direct {p0, v2, p2, p3}, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->makeConnection(Ljava/net/URL;J)Ljava/net/HttpURLConnection;
move-result-object p1
iput-object p1, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->connection:Ljava/net/HttpURLConnection;
:try_end_d
.catch Ljava/io/IOException; {:try_start_2 .. :try_end_d} :catch_56
.line 3
:try_start_d
invoke-virtual {p1}, Ljava/net/HttpURLConnection;->getResponseCode()I
move-result p1
iput p1, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->responseCode:I
:try_end_13
.catch Ljava/io/IOException; {:try_start_d .. :try_end_13} :catch_52
const/16 v2, 0xc8
if-lt p1, v2, :cond_4c
const/16 v3, 0x12b
if-le p1, v3, :cond_1c
goto :goto_4c
:cond_1c
const-wide/16 v3, 0x0
if-ne p1, v2, :cond_25
cmp-long p1, p2, v3
if-eqz p1, :cond_25
goto :goto_26
:cond_25
move-wide p2, v3
.line 4
:goto_26
iput-wide p2, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->bytesToSkip:J
.line 5
iget-object p1, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->connection:Ljava/net/HttpURLConnection;
invoke-static {p1}, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->getContentLength(Ljava/net/HttpURLConnection;)J
move-result-wide p1
const-wide/16 v2, -0x1
cmp-long p3, p1, v2
if-eqz p3, :cond_38
.line 6
iget-wide v2, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->bytesToSkip:J
sub-long v2, p1, v2
.line 7
:cond_38
:try_start_38
iget-object p1, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->connection:Ljava/net/HttpURLConnection;
invoke-virtual {p1}, Ljava/net/URLConnection;->getInputStream()Ljava/io/InputStream;
move-result-object p1
iput-object p1, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->inputStream:Ljava/io/InputStream;
:try_end_40
.catch Ljava/io/IOException; {:try_start_38 .. :try_end_40} :catch_44
const/4 p1, 0x1
.line 8
iput-boolean p1, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->isOpened:Z
return-wide v2
:catch_44
move-exception p1
.line 9
invoke-direct {p0}, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->closeConnectionQuietly()V
.line 10
invoke-virtual {p1}, Ljava/lang/Object;->toString()Ljava/lang/String;
return-wide v0
.line 11
:cond_4c
:goto_4c
invoke-direct {p0}, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->closeConnectionQuietly()V
const-wide/16 p1, -0x3
return-wide p1
.line 12
:catch_52
invoke-direct {p0}, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->closeConnectionQuietly()V
return-wide v0
:catch_56
move-exception p1
.line 13
invoke-virtual {p1}, Ljava/lang/Object;->toString()Ljava/lang/String;
return-wide v0
.end method
.method public read([BII)I
.registers 5
.line 1
:try_start_0
invoke-direct {p0}, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->skipInternal()V
.line 2
iget-object v0, p0, Lcom/mmc/player/videocache/SSZVideoCacheOkHttpService;->inputStream:Ljava/io/InputStream;
invoke-virtual {v0, p1, p2, p3}, Ljava/io/InputStream;->read([BII)I
move-result p1
:try_end_9
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_9} :catch_a
return p1
:catch_a
move-exception p1
.line 3
invoke-virtual {p1}, Ljava/lang/Object;->toString()Ljava/lang/String;
const/4 p1, -0x2
return p1
.end method