1164 lines
32 KiB
Smali
1164 lines
32 KiB
Smali
.class final Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;
|
|
.super Ljava/lang/Object;
|
|
.source "CachedContentIndex.java"
|
|
|
|
|
|
# static fields
|
|
.field public static final FILE_NAME:Ljava/lang/String; = "cached_content_index.exi"
|
|
|
|
.field private static final FLAG_ENCRYPTED_INDEX:I = 0x1
|
|
|
|
.field private static final TAG:Ljava/lang/String; = "CachedContentIndex"
|
|
|
|
.field private static final VERSION:I = 0x1
|
|
|
|
|
|
# instance fields
|
|
.field private final atomicFile:Lcom/google/android/exoplayer2/util/AtomicFile;
|
|
|
|
.field private bufferedOutputStream:Lcom/google/android/exoplayer2/util/ReusableBufferedOutputStream;
|
|
|
|
.field private changed:Z
|
|
|
|
.field private final cipher:Ljavax/crypto/Cipher;
|
|
|
|
.field private final idToKey:Landroid/util/SparseArray;
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"Landroid/util/SparseArray<",
|
|
"Ljava/lang/String;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
.end field
|
|
|
|
.field private final keyToContent:Ljava/util/HashMap;
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"Ljava/util/HashMap<",
|
|
"Ljava/lang/String;",
|
|
"Lcom/google/android/exoplayer2/upstream/cache/CachedContent;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
.end field
|
|
|
|
.field private final secretKeySpec:Ljavax/crypto/spec/SecretKeySpec;
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>(Ljava/io/File;)V
|
|
.locals 1
|
|
|
|
const/4 v0, 0x0
|
|
|
|
.line 1
|
|
invoke-direct {p0, p1, v0}, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;-><init>(Ljava/io/File;[B)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public constructor <init>(Ljava/io/File;[B)V
|
|
.locals 2
|
|
|
|
.line 2
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
if-eqz p2, :cond_1
|
|
|
|
.line 3
|
|
array-length v0, p2
|
|
|
|
const/16 v1, 0x10
|
|
|
|
if-ne v0, v1, :cond_0
|
|
|
|
const/4 v0, 0x1
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
const/4 v0, 0x0
|
|
|
|
:goto_0
|
|
invoke-static {v0}, Lcom/google/android/exoplayer2/util/Assertions;->checkArgument(Z)V
|
|
|
|
:try_start_0
|
|
const-string v0, "AES/CBC/PKCS5PADDING"
|
|
|
|
.line 4
|
|
invoke-static {v0}, Ljavax/crypto/Cipher;->getInstance(Ljava/lang/String;)Ljavax/crypto/Cipher;
|
|
|
|
move-result-object v0
|
|
|
|
iput-object v0, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->cipher:Ljavax/crypto/Cipher;
|
|
|
|
.line 5
|
|
new-instance v0, Ljavax/crypto/spec/SecretKeySpec;
|
|
|
|
const-string v1, "AES"
|
|
|
|
invoke-direct {v0, p2, v1}, Ljavax/crypto/spec/SecretKeySpec;-><init>([BLjava/lang/String;)V
|
|
|
|
iput-object v0, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->secretKeySpec:Ljavax/crypto/spec/SecretKeySpec;
|
|
:try_end_0
|
|
.catch Ljava/security/NoSuchAlgorithmException; {:try_start_0 .. :try_end_0} :catch_1
|
|
.catch Ljavax/crypto/NoSuchPaddingException; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
goto :goto_2
|
|
|
|
:catch_0
|
|
move-exception p1
|
|
|
|
goto :goto_1
|
|
|
|
:catch_1
|
|
move-exception p1
|
|
|
|
.line 6
|
|
:goto_1
|
|
new-instance p2, Ljava/lang/IllegalStateException;
|
|
|
|
invoke-direct {p2, p1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/Throwable;)V
|
|
|
|
throw p2
|
|
|
|
:cond_1
|
|
const/4 p2, 0x0
|
|
|
|
.line 7
|
|
iput-object p2, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->cipher:Ljavax/crypto/Cipher;
|
|
|
|
.line 8
|
|
iput-object p2, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->secretKeySpec:Ljavax/crypto/spec/SecretKeySpec;
|
|
|
|
.line 9
|
|
:goto_2
|
|
new-instance p2, Ljava/util/HashMap;
|
|
|
|
invoke-direct {p2}, Ljava/util/HashMap;-><init>()V
|
|
|
|
iput-object p2, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->keyToContent:Ljava/util/HashMap;
|
|
|
|
.line 10
|
|
new-instance p2, Landroid/util/SparseArray;
|
|
|
|
invoke-direct {p2}, Landroid/util/SparseArray;-><init>()V
|
|
|
|
iput-object p2, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->idToKey:Landroid/util/SparseArray;
|
|
|
|
.line 11
|
|
new-instance p2, Lcom/google/android/exoplayer2/util/AtomicFile;
|
|
|
|
new-instance v0, Ljava/io/File;
|
|
|
|
const-string v1, "cached_content_index.exi"
|
|
|
|
invoke-direct {v0, p1, v1}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V
|
|
|
|
invoke-direct {p2, v0}, Lcom/google/android/exoplayer2/util/AtomicFile;-><init>(Ljava/io/File;)V
|
|
|
|
iput-object p2, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->atomicFile:Lcom/google/android/exoplayer2/util/AtomicFile;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method private add(Lcom/google/android/exoplayer2/upstream/cache/CachedContent;)V
|
|
.locals 2
|
|
|
|
.line 3
|
|
iget-object v0, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->keyToContent:Ljava/util/HashMap;
|
|
|
|
iget-object v1, p1, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;->key:Ljava/lang/String;
|
|
|
|
invoke-virtual {v0, v1, p1}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
|
|
|
|
.line 4
|
|
iget-object v0, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->idToKey:Landroid/util/SparseArray;
|
|
|
|
iget v1, p1, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;->id:I
|
|
|
|
iget-object p1, p1, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;->key:Ljava/lang/String;
|
|
|
|
invoke-virtual {v0, v1, p1}, Landroid/util/SparseArray;->put(ILjava/lang/Object;)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method private addNew(Ljava/lang/String;J)Lcom/google/android/exoplayer2/upstream/cache/CachedContent;
|
|
.locals 2
|
|
|
|
.line 3
|
|
iget-object v0, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->idToKey:Landroid/util/SparseArray;
|
|
|
|
invoke-static {v0}, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->getNewId(Landroid/util/SparseArray;)I
|
|
|
|
move-result v0
|
|
|
|
.line 4
|
|
new-instance v1, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;
|
|
|
|
invoke-direct {v1, v0, p1, p2, p3}, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;-><init>(ILjava/lang/String;J)V
|
|
|
|
.line 5
|
|
invoke-virtual {p0, v1}, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->addNew(Lcom/google/android/exoplayer2/upstream/cache/CachedContent;)V
|
|
|
|
return-object v1
|
|
.end method
|
|
|
|
.method public static getNewId(Landroid/util/SparseArray;)I
|
|
.locals 3
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(",
|
|
"Landroid/util/SparseArray<",
|
|
"Ljava/lang/String;",
|
|
">;)I"
|
|
}
|
|
.end annotation
|
|
|
|
.line 1
|
|
invoke-virtual {p0}, Landroid/util/SparseArray;->size()I
|
|
|
|
move-result v0
|
|
|
|
const/4 v1, 0x0
|
|
|
|
if-nez v0, :cond_0
|
|
|
|
move v2, v1
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
add-int/lit8 v2, v0, -0x1
|
|
|
|
.line 2
|
|
invoke-virtual {p0, v2}, Landroid/util/SparseArray;->keyAt(I)I
|
|
|
|
move-result v2
|
|
|
|
add-int/lit8 v2, v2, 0x1
|
|
|
|
:goto_0
|
|
if-gez v2, :cond_3
|
|
|
|
:goto_1
|
|
if-ge v1, v0, :cond_2
|
|
|
|
.line 3
|
|
invoke-virtual {p0, v1}, Landroid/util/SparseArray;->keyAt(I)I
|
|
|
|
move-result v2
|
|
|
|
if-eq v1, v2, :cond_1
|
|
|
|
goto :goto_2
|
|
|
|
:cond_1
|
|
add-int/lit8 v1, v1, 0x1
|
|
|
|
goto :goto_1
|
|
|
|
:cond_2
|
|
:goto_2
|
|
move v2, v1
|
|
|
|
:cond_3
|
|
return v2
|
|
.end method
|
|
|
|
.method private readFile()Z
|
|
.locals 8
|
|
|
|
const/4 v0, 0x0
|
|
|
|
const/4 v1, 0x0
|
|
|
|
.line 1
|
|
:try_start_0
|
|
new-instance v2, Ljava/io/BufferedInputStream;
|
|
|
|
iget-object v3, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->atomicFile:Lcom/google/android/exoplayer2/util/AtomicFile;
|
|
|
|
invoke-virtual {v3}, Lcom/google/android/exoplayer2/util/AtomicFile;->openRead()Ljava/io/InputStream;
|
|
|
|
move-result-object v3
|
|
|
|
invoke-direct {v2, v3}, Ljava/io/BufferedInputStream;-><init>(Ljava/io/InputStream;)V
|
|
|
|
.line 2
|
|
new-instance v3, Ljava/io/DataInputStream;
|
|
|
|
invoke-direct {v3, v2}, Ljava/io/DataInputStream;-><init>(Ljava/io/InputStream;)V
|
|
:try_end_0
|
|
.catch Ljava/io/FileNotFoundException; {:try_start_0 .. :try_end_0} :catch_5
|
|
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_4
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
.line 3
|
|
:try_start_1
|
|
invoke-virtual {v3}, Ljava/io/DataInputStream;->readInt()I
|
|
|
|
move-result v1
|
|
:try_end_1
|
|
.catch Ljava/io/FileNotFoundException; {:try_start_1 .. :try_end_1} :catch_3
|
|
.catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_2
|
|
.catchall {:try_start_1 .. :try_end_1} :catchall_1
|
|
|
|
const/4 v4, 0x1
|
|
|
|
if-eq v1, v4, :cond_0
|
|
|
|
.line 4
|
|
invoke-static {v3}, Lcom/google/android/exoplayer2/util/Util;->closeQuietly(Ljava/io/Closeable;)V
|
|
|
|
return v0
|
|
|
|
.line 5
|
|
:cond_0
|
|
:try_start_2
|
|
invoke-virtual {v3}, Ljava/io/DataInputStream;->readInt()I
|
|
|
|
move-result v1
|
|
|
|
and-int/2addr v1, v4
|
|
|
|
if-eqz v1, :cond_2
|
|
|
|
.line 6
|
|
iget-object v1, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->cipher:Ljavax/crypto/Cipher;
|
|
:try_end_2
|
|
.catch Ljava/io/FileNotFoundException; {:try_start_2 .. :try_end_2} :catch_3
|
|
.catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_2
|
|
.catchall {:try_start_2 .. :try_end_2} :catchall_1
|
|
|
|
if-nez v1, :cond_1
|
|
|
|
.line 7
|
|
invoke-static {v3}, Lcom/google/android/exoplayer2/util/Util;->closeQuietly(Ljava/io/Closeable;)V
|
|
|
|
return v0
|
|
|
|
:cond_1
|
|
const/16 v1, 0x10
|
|
|
|
:try_start_3
|
|
new-array v1, v1, [B
|
|
|
|
.line 8
|
|
invoke-virtual {v3, v1}, Ljava/io/DataInputStream;->readFully([B)V
|
|
|
|
.line 9
|
|
new-instance v5, Ljavax/crypto/spec/IvParameterSpec;
|
|
|
|
invoke-direct {v5, v1}, Ljavax/crypto/spec/IvParameterSpec;-><init>([B)V
|
|
:try_end_3
|
|
.catch Ljava/io/FileNotFoundException; {:try_start_3 .. :try_end_3} :catch_3
|
|
.catch Ljava/io/IOException; {:try_start_3 .. :try_end_3} :catch_2
|
|
.catchall {:try_start_3 .. :try_end_3} :catchall_1
|
|
|
|
.line 10
|
|
:try_start_4
|
|
iget-object v1, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->cipher:Ljavax/crypto/Cipher;
|
|
|
|
const/4 v6, 0x2
|
|
|
|
iget-object v7, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->secretKeySpec:Ljavax/crypto/spec/SecretKeySpec;
|
|
|
|
invoke-virtual {v1, v6, v7, v5}, Ljavax/crypto/Cipher;->init(ILjava/security/Key;Ljava/security/spec/AlgorithmParameterSpec;)V
|
|
:try_end_4
|
|
.catch Ljava/security/InvalidKeyException; {:try_start_4 .. :try_end_4} :catch_1
|
|
.catch Ljava/security/InvalidAlgorithmParameterException; {:try_start_4 .. :try_end_4} :catch_0
|
|
.catch Ljava/io/FileNotFoundException; {:try_start_4 .. :try_end_4} :catch_3
|
|
.catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_2
|
|
.catchall {:try_start_4 .. :try_end_4} :catchall_1
|
|
|
|
.line 11
|
|
:try_start_5
|
|
new-instance v1, Ljava/io/DataInputStream;
|
|
|
|
new-instance v5, Ljavax/crypto/CipherInputStream;
|
|
|
|
iget-object v6, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->cipher:Ljavax/crypto/Cipher;
|
|
|
|
invoke-direct {v5, v2, v6}, Ljavax/crypto/CipherInputStream;-><init>(Ljava/io/InputStream;Ljavax/crypto/Cipher;)V
|
|
|
|
invoke-direct {v1, v5}, Ljava/io/DataInputStream;-><init>(Ljava/io/InputStream;)V
|
|
|
|
goto :goto_1
|
|
|
|
:catch_0
|
|
move-exception v1
|
|
|
|
goto :goto_0
|
|
|
|
:catch_1
|
|
move-exception v1
|
|
|
|
.line 12
|
|
:goto_0
|
|
new-instance v2, Ljava/lang/IllegalStateException;
|
|
|
|
invoke-direct {v2, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/Throwable;)V
|
|
|
|
throw v2
|
|
|
|
.line 13
|
|
:cond_2
|
|
iget-object v1, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->cipher:Ljavax/crypto/Cipher;
|
|
|
|
if-eqz v1, :cond_3
|
|
|
|
.line 14
|
|
iput-boolean v4, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->changed:Z
|
|
:try_end_5
|
|
.catch Ljava/io/FileNotFoundException; {:try_start_5 .. :try_end_5} :catch_3
|
|
.catch Ljava/io/IOException; {:try_start_5 .. :try_end_5} :catch_2
|
|
.catchall {:try_start_5 .. :try_end_5} :catchall_1
|
|
|
|
:cond_3
|
|
move-object v1, v3
|
|
|
|
.line 15
|
|
:goto_1
|
|
:try_start_6
|
|
invoke-virtual {v1}, Ljava/io/DataInputStream;->readInt()I
|
|
|
|
move-result v2
|
|
|
|
move v3, v0
|
|
|
|
move v5, v3
|
|
|
|
:goto_2
|
|
if-ge v3, v2, :cond_4
|
|
|
|
.line 16
|
|
new-instance v6, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;
|
|
|
|
invoke-direct {v6, v1}, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;-><init>(Ljava/io/DataInputStream;)V
|
|
|
|
.line 17
|
|
invoke-direct {p0, v6}, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->add(Lcom/google/android/exoplayer2/upstream/cache/CachedContent;)V
|
|
|
|
.line 18
|
|
invoke-virtual {v6}, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;->headerHashCode()I
|
|
|
|
move-result v6
|
|
|
|
add-int/2addr v5, v6
|
|
|
|
add-int/lit8 v3, v3, 0x1
|
|
|
|
goto :goto_2
|
|
|
|
.line 19
|
|
:cond_4
|
|
invoke-virtual {v1}, Ljava/io/DataInputStream;->readInt()I
|
|
|
|
move-result v2
|
|
:try_end_6
|
|
.catch Ljava/io/FileNotFoundException; {:try_start_6 .. :try_end_6} :catch_5
|
|
.catch Ljava/io/IOException; {:try_start_6 .. :try_end_6} :catch_4
|
|
.catchall {:try_start_6 .. :try_end_6} :catchall_0
|
|
|
|
if-eq v2, v5, :cond_5
|
|
|
|
.line 20
|
|
invoke-static {v1}, Lcom/google/android/exoplayer2/util/Util;->closeQuietly(Ljava/io/Closeable;)V
|
|
|
|
return v0
|
|
|
|
:cond_5
|
|
invoke-static {v1}, Lcom/google/android/exoplayer2/util/Util;->closeQuietly(Ljava/io/Closeable;)V
|
|
|
|
return v4
|
|
|
|
:catch_2
|
|
move-exception v1
|
|
|
|
goto :goto_3
|
|
|
|
:catch_3
|
|
move-object v1, v3
|
|
|
|
goto :goto_5
|
|
|
|
:catchall_0
|
|
move-exception v0
|
|
|
|
goto :goto_4
|
|
|
|
:catch_4
|
|
move-exception v2
|
|
|
|
move-object v3, v1
|
|
|
|
move-object v1, v2
|
|
|
|
:goto_3
|
|
:try_start_7
|
|
const-string v2, "CachedContentIndex"
|
|
|
|
const-string v4, "Error reading cache content index file."
|
|
|
|
.line 21
|
|
invoke-static {v2, v4, v1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
|
|
:try_end_7
|
|
.catchall {:try_start_7 .. :try_end_7} :catchall_1
|
|
|
|
if-eqz v3, :cond_6
|
|
|
|
.line 22
|
|
invoke-static {v3}, Lcom/google/android/exoplayer2/util/Util;->closeQuietly(Ljava/io/Closeable;)V
|
|
|
|
:cond_6
|
|
return v0
|
|
|
|
:catchall_1
|
|
move-exception v0
|
|
|
|
move-object v1, v3
|
|
|
|
:goto_4
|
|
if-eqz v1, :cond_7
|
|
|
|
invoke-static {v1}, Lcom/google/android/exoplayer2/util/Util;->closeQuietly(Ljava/io/Closeable;)V
|
|
|
|
:cond_7
|
|
throw v0
|
|
|
|
:catch_5
|
|
:goto_5
|
|
if-eqz v1, :cond_8
|
|
|
|
invoke-static {v1}, Lcom/google/android/exoplayer2/util/Util;->closeQuietly(Ljava/io/Closeable;)V
|
|
|
|
:cond_8
|
|
return v0
|
|
.end method
|
|
|
|
.method private writeFile()V
|
|
.locals 8
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Lcom/google/android/exoplayer2/upstream/cache/Cache$CacheException;
|
|
}
|
|
.end annotation
|
|
|
|
const/4 v0, 0x0
|
|
|
|
.line 1
|
|
:try_start_0
|
|
iget-object v1, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->atomicFile:Lcom/google/android/exoplayer2/util/AtomicFile;
|
|
|
|
invoke-virtual {v1}, Lcom/google/android/exoplayer2/util/AtomicFile;->startWrite()Ljava/io/OutputStream;
|
|
|
|
move-result-object v1
|
|
|
|
.line 2
|
|
iget-object v2, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->bufferedOutputStream:Lcom/google/android/exoplayer2/util/ReusableBufferedOutputStream;
|
|
|
|
if-nez v2, :cond_0
|
|
|
|
.line 3
|
|
new-instance v2, Lcom/google/android/exoplayer2/util/ReusableBufferedOutputStream;
|
|
|
|
invoke-direct {v2, v1}, Lcom/google/android/exoplayer2/util/ReusableBufferedOutputStream;-><init>(Ljava/io/OutputStream;)V
|
|
|
|
iput-object v2, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->bufferedOutputStream:Lcom/google/android/exoplayer2/util/ReusableBufferedOutputStream;
|
|
|
|
goto :goto_0
|
|
|
|
.line 4
|
|
:cond_0
|
|
invoke-virtual {v2, v1}, Lcom/google/android/exoplayer2/util/ReusableBufferedOutputStream;->reset(Ljava/io/OutputStream;)V
|
|
|
|
.line 5
|
|
:goto_0
|
|
new-instance v1, Ljava/io/DataOutputStream;
|
|
|
|
iget-object v2, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->bufferedOutputStream:Lcom/google/android/exoplayer2/util/ReusableBufferedOutputStream;
|
|
|
|
invoke-direct {v1, v2}, Ljava/io/DataOutputStream;-><init>(Ljava/io/OutputStream;)V
|
|
:try_end_0
|
|
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_3
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_1
|
|
|
|
const/4 v2, 0x1
|
|
|
|
.line 6
|
|
:try_start_1
|
|
invoke-virtual {v1, v2}, Ljava/io/DataOutputStream;->writeInt(I)V
|
|
|
|
.line 7
|
|
iget-object v3, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->cipher:Ljavax/crypto/Cipher;
|
|
|
|
const/4 v4, 0x0
|
|
|
|
if-eqz v3, :cond_1
|
|
|
|
move v3, v2
|
|
|
|
goto :goto_1
|
|
|
|
:cond_1
|
|
move v3, v4
|
|
|
|
.line 8
|
|
:goto_1
|
|
invoke-virtual {v1, v3}, Ljava/io/DataOutputStream;->writeInt(I)V
|
|
|
|
.line 9
|
|
iget-object v3, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->cipher:Ljavax/crypto/Cipher;
|
|
|
|
if-eqz v3, :cond_2
|
|
|
|
const/16 v3, 0x10
|
|
|
|
new-array v3, v3, [B
|
|
|
|
.line 10
|
|
new-instance v5, Ljava/util/Random;
|
|
|
|
invoke-direct {v5}, Ljava/util/Random;-><init>()V
|
|
|
|
invoke-virtual {v5, v3}, Ljava/util/Random;->nextBytes([B)V
|
|
|
|
.line 11
|
|
invoke-virtual {v1, v3}, Ljava/io/DataOutputStream;->write([B)V
|
|
|
|
.line 12
|
|
new-instance v5, Ljavax/crypto/spec/IvParameterSpec;
|
|
|
|
invoke-direct {v5, v3}, Ljavax/crypto/spec/IvParameterSpec;-><init>([B)V
|
|
:try_end_1
|
|
.catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_2
|
|
.catchall {:try_start_1 .. :try_end_1} :catchall_0
|
|
|
|
.line 13
|
|
:try_start_2
|
|
iget-object v3, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->cipher:Ljavax/crypto/Cipher;
|
|
|
|
iget-object v6, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->secretKeySpec:Ljavax/crypto/spec/SecretKeySpec;
|
|
|
|
invoke-virtual {v3, v2, v6, v5}, Ljavax/crypto/Cipher;->init(ILjava/security/Key;Ljava/security/spec/AlgorithmParameterSpec;)V
|
|
:try_end_2
|
|
.catch Ljava/security/InvalidKeyException; {:try_start_2 .. :try_end_2} :catch_1
|
|
.catch Ljava/security/InvalidAlgorithmParameterException; {:try_start_2 .. :try_end_2} :catch_0
|
|
.catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_2
|
|
.catchall {:try_start_2 .. :try_end_2} :catchall_0
|
|
|
|
.line 14
|
|
:try_start_3
|
|
invoke-virtual {v1}, Ljava/io/DataOutputStream;->flush()V
|
|
|
|
.line 15
|
|
new-instance v2, Ljava/io/DataOutputStream;
|
|
|
|
new-instance v3, Ljavax/crypto/CipherOutputStream;
|
|
|
|
iget-object v5, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->bufferedOutputStream:Lcom/google/android/exoplayer2/util/ReusableBufferedOutputStream;
|
|
|
|
iget-object v6, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->cipher:Ljavax/crypto/Cipher;
|
|
|
|
invoke-direct {v3, v5, v6}, Ljavax/crypto/CipherOutputStream;-><init>(Ljava/io/OutputStream;Ljavax/crypto/Cipher;)V
|
|
|
|
invoke-direct {v2, v3}, Ljava/io/DataOutputStream;-><init>(Ljava/io/OutputStream;)V
|
|
|
|
move-object v1, v2
|
|
|
|
goto :goto_3
|
|
|
|
:catch_0
|
|
move-exception v0
|
|
|
|
goto :goto_2
|
|
|
|
:catch_1
|
|
move-exception v0
|
|
|
|
.line 16
|
|
:goto_2
|
|
new-instance v2, Ljava/lang/IllegalStateException;
|
|
|
|
invoke-direct {v2, v0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/Throwable;)V
|
|
|
|
throw v2
|
|
|
|
.line 17
|
|
:cond_2
|
|
:goto_3
|
|
iget-object v2, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->keyToContent:Ljava/util/HashMap;
|
|
|
|
invoke-virtual {v2}, Ljava/util/HashMap;->size()I
|
|
|
|
move-result v2
|
|
|
|
invoke-virtual {v1, v2}, Ljava/io/DataOutputStream;->writeInt(I)V
|
|
|
|
.line 18
|
|
iget-object v2, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->keyToContent:Ljava/util/HashMap;
|
|
|
|
invoke-virtual {v2}, Ljava/util/HashMap;->values()Ljava/util/Collection;
|
|
|
|
move-result-object v2
|
|
|
|
invoke-interface {v2}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object v2
|
|
|
|
:goto_4
|
|
invoke-interface {v2}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v3
|
|
|
|
if-eqz v3, :cond_3
|
|
|
|
invoke-interface {v2}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v3
|
|
|
|
check-cast v3, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;
|
|
|
|
.line 19
|
|
invoke-virtual {v3, v1}, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;->writeToStream(Ljava/io/DataOutputStream;)V
|
|
|
|
.line 20
|
|
invoke-virtual {v3}, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;->headerHashCode()I
|
|
|
|
move-result v3
|
|
|
|
add-int/2addr v4, v3
|
|
|
|
goto :goto_4
|
|
|
|
.line 21
|
|
:cond_3
|
|
invoke-virtual {v1, v4}, Ljava/io/DataOutputStream;->writeInt(I)V
|
|
|
|
.line 22
|
|
iget-object v2, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->atomicFile:Lcom/google/android/exoplayer2/util/AtomicFile;
|
|
|
|
invoke-virtual {v2, v1}, Lcom/google/android/exoplayer2/util/AtomicFile;->endWrite(Ljava/io/OutputStream;)V
|
|
:try_end_3
|
|
.catch Ljava/io/IOException; {:try_start_3 .. :try_end_3} :catch_2
|
|
.catchall {:try_start_3 .. :try_end_3} :catchall_0
|
|
|
|
.line 23
|
|
invoke-static {v0}, Lcom/google/android/exoplayer2/util/Util;->closeQuietly(Ljava/io/Closeable;)V
|
|
|
|
return-void
|
|
|
|
:catchall_0
|
|
move-exception v0
|
|
|
|
move-object v7, v1
|
|
|
|
move-object v1, v0
|
|
|
|
move-object v0, v7
|
|
|
|
goto :goto_6
|
|
|
|
:catch_2
|
|
move-exception v0
|
|
|
|
move-object v7, v1
|
|
|
|
move-object v1, v0
|
|
|
|
move-object v0, v7
|
|
|
|
goto :goto_5
|
|
|
|
:catchall_1
|
|
move-exception v1
|
|
|
|
goto :goto_6
|
|
|
|
:catch_3
|
|
move-exception v1
|
|
|
|
.line 24
|
|
:goto_5
|
|
:try_start_4
|
|
new-instance v2, Lcom/google/android/exoplayer2/upstream/cache/Cache$CacheException;
|
|
|
|
invoke-direct {v2, v1}, Lcom/google/android/exoplayer2/upstream/cache/Cache$CacheException;-><init>(Ljava/io/IOException;)V
|
|
|
|
throw v2
|
|
:try_end_4
|
|
.catchall {:try_start_4 .. :try_end_4} :catchall_1
|
|
|
|
.line 25
|
|
:goto_6
|
|
invoke-static {v0}, Lcom/google/android/exoplayer2/util/Util;->closeQuietly(Ljava/io/Closeable;)V
|
|
|
|
throw v1
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public add(Ljava/lang/String;)Lcom/google/android/exoplayer2/upstream/cache/CachedContent;
|
|
.locals 2
|
|
|
|
.line 1
|
|
iget-object v0, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->keyToContent:Ljava/util/HashMap;
|
|
|
|
invoke-virtual {v0, p1}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;
|
|
|
|
move-result-object v0
|
|
|
|
check-cast v0, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;
|
|
|
|
if-nez v0, :cond_0
|
|
|
|
const-wide/16 v0, -0x1
|
|
|
|
.line 2
|
|
invoke-direct {p0, p1, v0, v1}, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->addNew(Ljava/lang/String;J)Lcom/google/android/exoplayer2/upstream/cache/CachedContent;
|
|
|
|
move-result-object v0
|
|
|
|
:cond_0
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public addNew(Lcom/google/android/exoplayer2/upstream/cache/CachedContent;)V
|
|
.locals 0
|
|
|
|
.line 1
|
|
invoke-direct {p0, p1}, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->add(Lcom/google/android/exoplayer2/upstream/cache/CachedContent;)V
|
|
|
|
const/4 p1, 0x1
|
|
|
|
.line 2
|
|
iput-boolean p1, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->changed:Z
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public assignIdForKey(Ljava/lang/String;)I
|
|
.locals 0
|
|
|
|
.line 1
|
|
invoke-virtual {p0, p1}, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->add(Ljava/lang/String;)Lcom/google/android/exoplayer2/upstream/cache/CachedContent;
|
|
|
|
move-result-object p1
|
|
|
|
iget p1, p1, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;->id:I
|
|
|
|
return p1
|
|
.end method
|
|
|
|
.method public get(Ljava/lang/String;)Lcom/google/android/exoplayer2/upstream/cache/CachedContent;
|
|
.locals 1
|
|
|
|
.line 1
|
|
iget-object v0, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->keyToContent:Ljava/util/HashMap;
|
|
|
|
invoke-virtual {v0, p1}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;
|
|
|
|
move-result-object p1
|
|
|
|
check-cast p1, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;
|
|
|
|
return-object p1
|
|
.end method
|
|
|
|
.method public getAll()Ljava/util/Collection;
|
|
.locals 1
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"()",
|
|
"Ljava/util/Collection<",
|
|
"Lcom/google/android/exoplayer2/upstream/cache/CachedContent;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
|
|
.line 1
|
|
iget-object v0, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->keyToContent:Ljava/util/HashMap;
|
|
|
|
invoke-virtual {v0}, Ljava/util/HashMap;->values()Ljava/util/Collection;
|
|
|
|
move-result-object v0
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public getContentLength(Ljava/lang/String;)J
|
|
.locals 2
|
|
|
|
.line 1
|
|
invoke-virtual {p0, p1}, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->get(Ljava/lang/String;)Lcom/google/android/exoplayer2/upstream/cache/CachedContent;
|
|
|
|
move-result-object p1
|
|
|
|
if-nez p1, :cond_0
|
|
|
|
const-wide/16 v0, -0x1
|
|
|
|
goto :goto_0
|
|
|
|
.line 2
|
|
:cond_0
|
|
invoke-virtual {p1}, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;->getLength()J
|
|
|
|
move-result-wide v0
|
|
|
|
:goto_0
|
|
return-wide v0
|
|
.end method
|
|
|
|
.method public getKeyForId(I)Ljava/lang/String;
|
|
.locals 1
|
|
|
|
.line 1
|
|
iget-object v0, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->idToKey:Landroid/util/SparseArray;
|
|
|
|
invoke-virtual {v0, p1}, Landroid/util/SparseArray;->get(I)Ljava/lang/Object;
|
|
|
|
move-result-object p1
|
|
|
|
check-cast p1, Ljava/lang/String;
|
|
|
|
return-object p1
|
|
.end method
|
|
|
|
.method public getKeys()Ljava/util/Set;
|
|
.locals 1
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"()",
|
|
"Ljava/util/Set<",
|
|
"Ljava/lang/String;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
|
|
.line 1
|
|
iget-object v0, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->keyToContent:Ljava/util/HashMap;
|
|
|
|
invoke-virtual {v0}, Ljava/util/HashMap;->keySet()Ljava/util/Set;
|
|
|
|
move-result-object v0
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public load()V
|
|
.locals 1
|
|
|
|
.line 1
|
|
iget-boolean v0, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->changed:Z
|
|
|
|
xor-int/lit8 v0, v0, 0x1
|
|
|
|
invoke-static {v0}, Lcom/google/android/exoplayer2/util/Assertions;->checkState(Z)V
|
|
|
|
.line 2
|
|
invoke-direct {p0}, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->readFile()Z
|
|
|
|
move-result v0
|
|
|
|
if-nez v0, :cond_0
|
|
|
|
.line 3
|
|
iget-object v0, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->atomicFile:Lcom/google/android/exoplayer2/util/AtomicFile;
|
|
|
|
invoke-virtual {v0}, Lcom/google/android/exoplayer2/util/AtomicFile;->delete()V
|
|
|
|
.line 4
|
|
iget-object v0, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->keyToContent:Ljava/util/HashMap;
|
|
|
|
invoke-virtual {v0}, Ljava/util/HashMap;->clear()V
|
|
|
|
.line 5
|
|
iget-object v0, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->idToKey:Landroid/util/SparseArray;
|
|
|
|
invoke-virtual {v0}, Landroid/util/SparseArray;->clear()V
|
|
|
|
:cond_0
|
|
return-void
|
|
.end method
|
|
|
|
.method public removeEmpty()V
|
|
.locals 4
|
|
|
|
.line 5
|
|
new-instance v0, Ljava/util/LinkedList;
|
|
|
|
invoke-direct {v0}, Ljava/util/LinkedList;-><init>()V
|
|
|
|
.line 6
|
|
iget-object v1, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->keyToContent:Ljava/util/HashMap;
|
|
|
|
invoke-virtual {v1}, Ljava/util/HashMap;->values()Ljava/util/Collection;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-interface {v1}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object v1
|
|
|
|
:cond_0
|
|
:goto_0
|
|
invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v2
|
|
|
|
if-eqz v2, :cond_1
|
|
|
|
invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v2
|
|
|
|
check-cast v2, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;
|
|
|
|
.line 7
|
|
invoke-virtual {v2}, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;->isEmpty()Z
|
|
|
|
move-result v3
|
|
|
|
if-eqz v3, :cond_0
|
|
|
|
.line 8
|
|
iget-object v2, v2, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;->key:Ljava/lang/String;
|
|
|
|
invoke-virtual {v0, v2}, Ljava/util/LinkedList;->add(Ljava/lang/Object;)Z
|
|
|
|
goto :goto_0
|
|
|
|
.line 9
|
|
:cond_1
|
|
invoke-virtual {v0}, Ljava/util/LinkedList;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object v0
|
|
|
|
:goto_1
|
|
invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v1
|
|
|
|
if-eqz v1, :cond_2
|
|
|
|
invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v1
|
|
|
|
check-cast v1, Ljava/lang/String;
|
|
|
|
.line 10
|
|
invoke-virtual {p0, v1}, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->removeEmpty(Ljava/lang/String;)V
|
|
|
|
goto :goto_1
|
|
|
|
:cond_2
|
|
return-void
|
|
.end method
|
|
|
|
.method public removeEmpty(Ljava/lang/String;)V
|
|
.locals 1
|
|
|
|
.line 1
|
|
iget-object v0, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->keyToContent:Ljava/util/HashMap;
|
|
|
|
invoke-virtual {v0, p1}, Ljava/util/HashMap;->remove(Ljava/lang/Object;)Ljava/lang/Object;
|
|
|
|
move-result-object p1
|
|
|
|
check-cast p1, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;
|
|
|
|
if-eqz p1, :cond_0
|
|
|
|
.line 2
|
|
invoke-virtual {p1}, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;->isEmpty()Z
|
|
|
|
move-result v0
|
|
|
|
invoke-static {v0}, Lcom/google/android/exoplayer2/util/Assertions;->checkState(Z)V
|
|
|
|
.line 3
|
|
iget-object v0, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->idToKey:Landroid/util/SparseArray;
|
|
|
|
iget p1, p1, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;->id:I
|
|
|
|
invoke-virtual {v0, p1}, Landroid/util/SparseArray;->remove(I)V
|
|
|
|
const/4 p1, 0x1
|
|
|
|
.line 4
|
|
iput-boolean p1, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->changed:Z
|
|
|
|
:cond_0
|
|
return-void
|
|
.end method
|
|
|
|
.method public setContentLength(Ljava/lang/String;J)V
|
|
.locals 3
|
|
|
|
.line 1
|
|
invoke-virtual {p0, p1}, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->get(Ljava/lang/String;)Lcom/google/android/exoplayer2/upstream/cache/CachedContent;
|
|
|
|
move-result-object v0
|
|
|
|
if-eqz v0, :cond_0
|
|
|
|
.line 2
|
|
invoke-virtual {v0}, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;->getLength()J
|
|
|
|
move-result-wide v1
|
|
|
|
cmp-long p1, v1, p2
|
|
|
|
if-eqz p1, :cond_1
|
|
|
|
.line 3
|
|
invoke-virtual {v0, p2, p3}, Lcom/google/android/exoplayer2/upstream/cache/CachedContent;->setLength(J)V
|
|
|
|
const/4 p1, 0x1
|
|
|
|
.line 4
|
|
iput-boolean p1, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->changed:Z
|
|
|
|
goto :goto_0
|
|
|
|
.line 5
|
|
:cond_0
|
|
invoke-direct {p0, p1, p2, p3}, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->addNew(Ljava/lang/String;J)Lcom/google/android/exoplayer2/upstream/cache/CachedContent;
|
|
|
|
:cond_1
|
|
:goto_0
|
|
return-void
|
|
.end method
|
|
|
|
.method public store()V
|
|
.locals 1
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Lcom/google/android/exoplayer2/upstream/cache/Cache$CacheException;
|
|
}
|
|
.end annotation
|
|
|
|
.line 1
|
|
iget-boolean v0, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->changed:Z
|
|
|
|
if-nez v0, :cond_0
|
|
|
|
return-void
|
|
|
|
.line 2
|
|
:cond_0
|
|
invoke-direct {p0}, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->writeFile()V
|
|
|
|
const/4 v0, 0x0
|
|
|
|
.line 3
|
|
iput-boolean v0, p0, Lcom/google/android/exoplayer2/upstream/cache/CachedContentIndex;->changed:Z
|
|
|
|
return-void
|
|
.end method
|