120 lines
4.5 KiB
Java
120 lines
4.5 KiB
Java
package c.i.a.c.h2.y;
|
|
|
|
import android.content.ContentValues;
|
|
import android.database.Cursor;
|
|
import android.database.SQLException;
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
import androidx.annotation.WorkerThread;
|
|
import c.i.a.c.w1.a;
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
import com.google.android.exoplayer2.database.DatabaseIOException;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
import java.util.Set;
|
|
/* compiled from: CacheFileMetadataIndex */
|
|
public final class f {
|
|
public static final String[] a = {"name", "length", "last_touch_timestamp"};
|
|
public final a b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public String f895c;
|
|
|
|
public f(a aVar) {
|
|
this.b = aVar;
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:12:0x0045, code lost:
|
|
r2 = move-exception;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:13:0x0046, code lost:
|
|
if (r0 != null) goto L_0x0048;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:15:?, code lost:
|
|
r0.close();
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:16:0x004c, code lost:
|
|
r0 = move-exception;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:17:0x004d, code lost:
|
|
r1.addSuppressed(r0);
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:18:0x0050, code lost:
|
|
throw r2;
|
|
*/
|
|
@WorkerThread
|
|
public Map<String, e> a() throws DatabaseIOException {
|
|
try {
|
|
Objects.requireNonNull(this.f895c);
|
|
Cursor query = this.b.getReadableDatabase().query(this.f895c, a, null, null, null, null, null);
|
|
HashMap hashMap = new HashMap(query.getCount());
|
|
while (query.moveToNext()) {
|
|
hashMap.put(query.getString(0), new e(query.getLong(1), query.getLong(2)));
|
|
}
|
|
query.close();
|
|
return hashMap;
|
|
} catch (SQLException e) {
|
|
throw new DatabaseIOException(e);
|
|
}
|
|
}
|
|
|
|
@WorkerThread
|
|
public void b(long j) throws DatabaseIOException {
|
|
try {
|
|
String hexString = Long.toHexString(j);
|
|
this.f895c = "ExoPlayerCacheFileMetadata" + hexString;
|
|
if (AnimatableValueParser.Q0(this.b.getReadableDatabase(), 2, hexString) != 1) {
|
|
SQLiteDatabase writableDatabase = this.b.getWritableDatabase();
|
|
writableDatabase.beginTransactionNonExclusive();
|
|
try {
|
|
AnimatableValueParser.A2(writableDatabase, 2, hexString, 1);
|
|
String str = this.f895c;
|
|
writableDatabase.execSQL("DROP TABLE IF EXISTS " + str);
|
|
writableDatabase.execSQL("CREATE TABLE " + this.f895c + " (name TEXT PRIMARY KEY NOT NULL,length INTEGER NOT NULL,last_touch_timestamp INTEGER NOT NULL)");
|
|
writableDatabase.setTransactionSuccessful();
|
|
} finally {
|
|
writableDatabase.endTransaction();
|
|
}
|
|
}
|
|
} catch (SQLException e) {
|
|
throw new DatabaseIOException(e);
|
|
}
|
|
}
|
|
|
|
@WorkerThread
|
|
public void c(Set<String> set) throws DatabaseIOException {
|
|
Objects.requireNonNull(this.f895c);
|
|
try {
|
|
SQLiteDatabase writableDatabase = this.b.getWritableDatabase();
|
|
writableDatabase.beginTransactionNonExclusive();
|
|
try {
|
|
Iterator<String> it = set.iterator();
|
|
while (it.hasNext()) {
|
|
writableDatabase.delete(this.f895c, "name = ?", new String[]{it.next()});
|
|
}
|
|
writableDatabase.setTransactionSuccessful();
|
|
} finally {
|
|
writableDatabase.endTransaction();
|
|
}
|
|
} catch (SQLException e) {
|
|
throw new DatabaseIOException(e);
|
|
}
|
|
}
|
|
|
|
@WorkerThread
|
|
public void d(String str, long j, long j2) throws DatabaseIOException {
|
|
Objects.requireNonNull(this.f895c);
|
|
try {
|
|
SQLiteDatabase writableDatabase = this.b.getWritableDatabase();
|
|
ContentValues contentValues = new ContentValues();
|
|
contentValues.put("name", str);
|
|
contentValues.put("length", Long.valueOf(j));
|
|
contentValues.put("last_touch_timestamp", Long.valueOf(j2));
|
|
writableDatabase.replaceOrThrow(this.f895c, null, contentValues);
|
|
} catch (SQLException e) {
|
|
throw new DatabaseIOException(e);
|
|
}
|
|
}
|
|
}
|