mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-14 18:07:16 +01:00
286 lines
17 KiB
Java
286 lines
17 KiB
Java
package androidx.sqlite.db;
|
|
|
|
import android.content.Context;
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
import android.database.sqlite.SQLiteException;
|
|
import android.util.Log;
|
|
import android.util.Pair;
|
|
import androidx.core.app.AppLaunchChecker$$ExternalSyntheticOutline0;
|
|
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
|
|
import defpackage.a$$ExternalSyntheticOutline0;
|
|
import java.io.Closeable;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import kotlin.Metadata;
|
|
import kotlin.jvm.JvmField;
|
|
import kotlin.jvm.JvmStatic;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.jvm.internal.SourceDebugExtension;
|
|
import kotlin.text.StringsKt;
|
|
import net.zetetic.database.sqlcipher.SQLiteDatabaseConfiguration;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
import rx.Single$$ExternalSyntheticBUOutline0;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@Metadata(d1 = {"\u0000&\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\t\bf\u0018\u00002\u00020\u0001:\u0003\u0011\u0012\u0013J\u0010\u0010\u0006\u001a\u00020\u00072\u0006\u0010\b\u001a\u00020\tH&J\b\u0010\u0010\u001a\u00020\u0007H&R\u0014\u0010\u0002\u001a\u0004\u0018\u00010\u0003X¦\u0004¢\u0006\u0006\u001a\u0004\b\u0004\u0010\u0005R\u0012\u0010\n\u001a\u00020\u000bX¦\u0004¢\u0006\u0006\u001a\u0004\b\f\u0010\rR\u0012\u0010\u000e\u001a\u00020\u000bX¦\u0004¢\u0006\u0006\u001a\u0004\b\u000f\u0010\rø\u0001\u0000\u0082\u0002\u0006\n\u0004\b!0\u0001¨\u0006\u0014À\u0006\u0001"}, d2 = {"Landroidx/sqlite/db/SupportSQLiteOpenHelper;", "Ljava/io/Closeable;", "databaseName", "", "getDatabaseName", "()Ljava/lang/String;", "setWriteAheadLoggingEnabled", "", "enabled", "", "writableDatabase", "Landroidx/sqlite/db/SupportSQLiteDatabase;", "getWritableDatabase", "()Landroidx/sqlite/db/SupportSQLiteDatabase;", "readableDatabase", "getReadableDatabase", "close", "Callback", "Configuration", "Factory", "sqlite_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
|
|
/* loaded from: classes14.dex */
|
|
public interface SupportSQLiteOpenHelper extends Closeable {
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@Metadata(d1 = {"\u0000(\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0010\u000e\n\u0002\b\u0002\b&\u0018\u0000 \u00142\u00020\u0001:\u0001\u0014B\u000f\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0004\b\u0004\u0010\u0005J\u0010\u0010\u0006\u001a\u00020\u00072\u0006\u0010\b\u001a\u00020\tH\u0016J\u0010\u0010\n\u001a\u00020\u00072\u0006\u0010\b\u001a\u00020\tH&J \u0010\u000b\u001a\u00020\u00072\u0006\u0010\b\u001a\u00020\t2\u0006\u0010\f\u001a\u00020\u00032\u0006\u0010\r\u001a\u00020\u0003H&J \u0010\u000e\u001a\u00020\u00072\u0006\u0010\b\u001a\u00020\t2\u0006\u0010\f\u001a\u00020\u00032\u0006\u0010\r\u001a\u00020\u0003H\u0016J\u0010\u0010\u000f\u001a\u00020\u00072\u0006\u0010\b\u001a\u00020\tH\u0016J\u0010\u0010\u0010\u001a\u00020\u00072\u0006\u0010\b\u001a\u00020\tH\u0016J\u0010\u0010\u0011\u001a\u00020\u00072\u0006\u0010\u0012\u001a\u00020\u0013H\u0002R\u0010\u0010\u0002\u001a\u00020\u00038\u0006X\u0087\u0004¢\u0006\u0002\n\u0000¨\u0006\u0015"}, d2 = {"Landroidx/sqlite/db/SupportSQLiteOpenHelper$Callback;", "", "version", "", "<init>", "(I)V", "onConfigure", "", "db", "Landroidx/sqlite/db/SupportSQLiteDatabase;", "onCreate", "onUpgrade", "oldVersion", "newVersion", "onDowngrade", "onOpen", "onCorruption", "deleteDatabaseFile", "fileName", "", "Companion", "sqlite_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
|
|
@SourceDebugExtension({"SMAP\nSupportSQLiteOpenHelper.android.kt\nKotlin\n*S Kotlin\n*F\n+ 1 SupportSQLiteOpenHelper.android.kt\nandroidx/sqlite/db/SupportSQLiteOpenHelper$Callback\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n+ 3 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n+ 4 Strings.kt\nkotlin/text/StringsKt__StringsKt\n*L\n1#1,366:1\n1#2:367\n1863#3,2:368\n108#4:370\n80#4,22:371\n*S KotlinDebug\n*F\n+ 1 SupportSQLiteOpenHelper.android.kt\nandroidx/sqlite/db/SupportSQLiteOpenHelper$Callback\n*L\n220#1:368,2\n228#1:370\n228#1:371,22\n*E\n"})
|
|
public static abstract class Callback {
|
|
|
|
@NotNull
|
|
private static final String TAG = "SupportSQLite";
|
|
|
|
@JvmField
|
|
public final int version;
|
|
|
|
public Callback(int i) {
|
|
this.version = i;
|
|
}
|
|
|
|
private final void deleteDatabaseFile(String fileName) {
|
|
if (StringsKt.equals(fileName, SQLiteDatabaseConfiguration.MEMORY_DB_PATH, true)) {
|
|
return;
|
|
}
|
|
int length = fileName.length() - 1;
|
|
int i = 0;
|
|
boolean z = false;
|
|
while (i <= length) {
|
|
boolean z2 = Intrinsics.compare((int) fileName.charAt(!z ? i : length), 32) <= 0;
|
|
if (z) {
|
|
if (!z2) {
|
|
break;
|
|
} else {
|
|
length--;
|
|
}
|
|
} else if (z2) {
|
|
i++;
|
|
} else {
|
|
z = true;
|
|
}
|
|
}
|
|
if (fileName.subSequence(i, length + 1).toString().length() == 0) {
|
|
return;
|
|
}
|
|
AppLaunchChecker$$ExternalSyntheticOutline0.m("deleting the database file: ", fileName, TAG);
|
|
try {
|
|
SQLiteDatabase.deleteDatabase(new File(fileName));
|
|
} catch (Exception e) {
|
|
Log.w(TAG, "delete failed: ", e);
|
|
}
|
|
}
|
|
|
|
public void onConfigure(@NotNull SupportSQLiteDatabase db) {
|
|
db.getClass();
|
|
}
|
|
|
|
public void onCorruption(@NotNull SupportSQLiteDatabase db) {
|
|
db.getClass();
|
|
Log.e(TAG, "Corruption reported by sqlite on database: " + db + ".path");
|
|
if (!db.isOpen()) {
|
|
String path = db.getPath();
|
|
if (path != null) {
|
|
deleteDatabaseFile(path);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
List<Pair<String, String>> list = null;
|
|
try {
|
|
try {
|
|
list = db.getAttachedDbs();
|
|
} finally {
|
|
if (list != null) {
|
|
Iterator<T> it2 = list.iterator();
|
|
while (it2.hasNext()) {
|
|
Object obj = ((Pair) it2.next()).second;
|
|
obj.getClass();
|
|
deleteDatabaseFile((String) obj);
|
|
}
|
|
} else {
|
|
String path2 = db.getPath();
|
|
if (path2 != null) {
|
|
deleteDatabaseFile(path2);
|
|
}
|
|
}
|
|
}
|
|
} catch (SQLiteException unused) {
|
|
}
|
|
try {
|
|
db.close();
|
|
} catch (IOException unused2) {
|
|
}
|
|
if (list != null) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
public abstract void onCreate(@NotNull SupportSQLiteDatabase db);
|
|
|
|
public void onDowngrade(@NotNull SupportSQLiteDatabase db, int oldVersion, int newVersion) {
|
|
db.getClass();
|
|
throw new SQLiteException(a$$ExternalSyntheticOutline0.m("Can't downgrade database from version ", oldVersion, " to ", newVersion));
|
|
}
|
|
|
|
public void onOpen(@NotNull SupportSQLiteDatabase db) {
|
|
db.getClass();
|
|
}
|
|
|
|
public abstract void onUpgrade(@NotNull SupportSQLiteDatabase db, int oldVersion, int newVersion);
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@Metadata(d1 = {"\u0000\u0016\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\bæ\u0080\u0001\u0018\u00002\u00020\u0001J\u0010\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u0005H&ø\u0001\u0000\u0082\u0002\u0006\n\u0004\b!0\u0001¨\u0006\u0006À\u0006\u0001"}, d2 = {"Landroidx/sqlite/db/SupportSQLiteOpenHelper$Factory;", "", "create", "Landroidx/sqlite/db/SupportSQLiteOpenHelper;", "configuration", "Landroidx/sqlite/db/SupportSQLiteOpenHelper$Configuration;", "sqlite_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
|
|
public interface Factory {
|
|
@NotNull
|
|
SupportSQLiteOpenHelper create(@NotNull Configuration configuration);
|
|
}
|
|
|
|
@Override // java.io.Closeable, java.lang.AutoCloseable
|
|
void close();
|
|
|
|
@Nullable
|
|
String getDatabaseName();
|
|
|
|
@NotNull
|
|
SupportSQLiteDatabase getReadableDatabase();
|
|
|
|
@NotNull
|
|
SupportSQLiteDatabase getWritableDatabase();
|
|
|
|
void setWriteAheadLoggingEnabled(boolean enabled);
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@Metadata(d1 = {"\u0000$\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0006\u0018\u0000 \u000e2\u00020\u0001:\u0002\r\u000eB5\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\b\u0010\u0004\u001a\u0004\u0018\u00010\u0005\u0012\u0006\u0010\u0006\u001a\u00020\u0007\u0012\b\b\u0002\u0010\b\u001a\u00020\t\u0012\b\b\u0002\u0010\n\u001a\u00020\t¢\u0006\u0004\b\u000b\u0010\fR\u0010\u0010\u0002\u001a\u00020\u00038\u0006X\u0087\u0004¢\u0006\u0002\n\u0000R\u0012\u0010\u0004\u001a\u0004\u0018\u00010\u00058\u0006X\u0087\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u0006\u001a\u00020\u00078\u0006X\u0087\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\b\u001a\u00020\t8\u0006X\u0087\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\n\u001a\u00020\t8\u0006X\u0087\u0004¢\u0006\u0002\n\u0000¨\u0006\u000f"}, d2 = {"Landroidx/sqlite/db/SupportSQLiteOpenHelper$Configuration;", "", "context", "Landroid/content/Context;", "name", "", "callback", "Landroidx/sqlite/db/SupportSQLiteOpenHelper$Callback;", "useNoBackupDirectory", "", "allowDataLossOnRecovery", "<init>", "(Landroid/content/Context;Ljava/lang/String;Landroidx/sqlite/db/SupportSQLiteOpenHelper$Callback;ZZ)V", "Builder", "Companion", "sqlite_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
|
|
public static final class Configuration {
|
|
|
|
/* renamed from: Companion, reason: from kotlin metadata */
|
|
@NotNull
|
|
public static final Companion INSTANCE = new Companion(null);
|
|
|
|
@JvmField
|
|
public final boolean allowDataLossOnRecovery;
|
|
|
|
@JvmField
|
|
@NotNull
|
|
public final Callback callback;
|
|
|
|
@JvmField
|
|
@NotNull
|
|
public final Context context;
|
|
|
|
@JvmField
|
|
@Nullable
|
|
public final String name;
|
|
|
|
@JvmField
|
|
public final boolean useNoBackupDirectory;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@Metadata(d1 = {"\u0000.\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0016\u0018\u00002\u00020\u0001B\u0011\b\u0000\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0004\b\u0004\u0010\u0005J\b\u0010\r\u001a\u00020\u000eH\u0016J\u0012\u0010\u0006\u001a\u00020\u00002\b\u0010\u0006\u001a\u0004\u0018\u00010\u0007H\u0016J\u0010\u0010\b\u001a\u00020\u00002\u0006\u0010\b\u001a\u00020\tH\u0016J\u0010\u0010\u000f\u001a\u00020\u00002\u0006\u0010\n\u001a\u00020\u000bH\u0016J\u0010\u0010\f\u001a\u00020\u00002\u0006\u0010\f\u001a\u00020\u000bH\u0016R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u0006\u001a\u0004\u0018\u00010\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\b\u001a\u0004\u0018\u00010\tX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\u000bX\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006\u0010"}, d2 = {"Landroidx/sqlite/db/SupportSQLiteOpenHelper$Configuration$Builder;", "", "context", "Landroid/content/Context;", "<init>", "(Landroid/content/Context;)V", "name", "", "callback", "Landroidx/sqlite/db/SupportSQLiteOpenHelper$Callback;", "useNoBackupDirectory", "", "allowDataLossOnRecovery", JsonPOJOBuilder.DEFAULT_BUILD_METHOD, "Landroidx/sqlite/db/SupportSQLiteOpenHelper$Configuration;", "noBackupDirectory", "sqlite_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
|
|
@SourceDebugExtension({"SMAP\nSupportSQLiteOpenHelper.android.kt\nKotlin\n*S Kotlin\n*F\n+ 1 SupportSQLiteOpenHelper.android.kt\nandroidx/sqlite/db/SupportSQLiteOpenHelper$Configuration$Builder\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n*L\n1#1,366:1\n1#2:367\n*E\n"})
|
|
public static class Builder {
|
|
private boolean allowDataLossOnRecovery;
|
|
|
|
@Nullable
|
|
private Callback callback;
|
|
|
|
@NotNull
|
|
private final Context context;
|
|
|
|
@Nullable
|
|
private String name;
|
|
private boolean useNoBackupDirectory;
|
|
|
|
public Builder(@NotNull Context context) {
|
|
context.getClass();
|
|
this.context = context;
|
|
}
|
|
|
|
@NotNull
|
|
public Builder allowDataLossOnRecovery(boolean allowDataLossOnRecovery) {
|
|
this.allowDataLossOnRecovery = allowDataLossOnRecovery;
|
|
return this;
|
|
}
|
|
|
|
@NotNull
|
|
public Configuration build() {
|
|
String str;
|
|
Callback callback = this.callback;
|
|
if (callback == null) {
|
|
Single$$ExternalSyntheticBUOutline0.m$3("Must set a callback to create the configuration.");
|
|
return null;
|
|
}
|
|
if (!this.useNoBackupDirectory || ((str = this.name) != null && str.length() != 0)) {
|
|
return new Configuration(this.context, this.name, callback, this.useNoBackupDirectory, this.allowDataLossOnRecovery);
|
|
}
|
|
Single$$ExternalSyntheticBUOutline0.m$3("Must set a non-null database name to a configuration that uses the no backup directory.");
|
|
return null;
|
|
}
|
|
|
|
@NotNull
|
|
public Builder callback(@NotNull Callback callback) {
|
|
callback.getClass();
|
|
this.callback = callback;
|
|
return this;
|
|
}
|
|
|
|
@NotNull
|
|
public Builder name(@Nullable String name) {
|
|
this.name = name;
|
|
return this;
|
|
}
|
|
|
|
@NotNull
|
|
public Builder noBackupDirectory(boolean useNoBackupDirectory) {
|
|
this.useNoBackupDirectory = useNoBackupDirectory;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
public Configuration(@NotNull Context context, @Nullable String str, @NotNull Callback callback, boolean z, boolean z2) {
|
|
context.getClass();
|
|
callback.getClass();
|
|
this.context = context;
|
|
this.name = str;
|
|
this.callback = callback;
|
|
this.useNoBackupDirectory = z;
|
|
this.allowDataLossOnRecovery = z2;
|
|
}
|
|
|
|
@JvmStatic
|
|
@NotNull
|
|
public static final Builder builder(@NotNull Context context) {
|
|
return INSTANCE.builder(context);
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003J\u0010\u0010\u0004\u001a\u00020\u00052\u0006\u0010\u0006\u001a\u00020\u0007H\u0007¨\u0006\b"}, d2 = {"Landroidx/sqlite/db/SupportSQLiteOpenHelper$Configuration$Companion;", "", "<init>", "()V", "builder", "Landroidx/sqlite/db/SupportSQLiteOpenHelper$Configuration$Builder;", "context", "Landroid/content/Context;", "sqlite_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
|
|
public static final class Companion {
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
@JvmStatic
|
|
@NotNull
|
|
public final Builder builder(@NotNull Context context) {
|
|
context.getClass();
|
|
return new Builder(context);
|
|
}
|
|
|
|
private Companion() {
|
|
}
|
|
}
|
|
|
|
public /* synthetic */ Configuration(Context context, String str, Callback callback, boolean z, boolean z2, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(context, str, callback, (i & 8) != 0 ? false : z, (i & 16) != 0 ? false : z2);
|
|
}
|
|
}
|
|
}
|