forked from Juby210/discord-jadx
187 lines
7.2 KiB
Java
187 lines
7.2 KiB
Java
package androidx.sqlite.db;
|
|
|
|
import android.content.Context;
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
import android.database.sqlite.SQLiteException;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
import android.util.Pair;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RequiresApi;
|
|
import c.d.b.a.a;
|
|
import java.io.Closeable;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.util.List;
|
|
public interface SupportSQLiteOpenHelper extends Closeable {
|
|
|
|
public static abstract class Callback {
|
|
private static final String TAG = "SupportSQLite";
|
|
public final int version;
|
|
|
|
public Callback(int i) {
|
|
this.version = i;
|
|
}
|
|
|
|
private void deleteDatabaseFile(String str) {
|
|
if (!str.equalsIgnoreCase(":memory:") && str.trim().length() != 0) {
|
|
a.h0("deleting the database file: ", str, "SupportSQLite");
|
|
try {
|
|
SQLiteDatabase.deleteDatabase(new File(str));
|
|
} catch (Exception e) {
|
|
Log.w("SupportSQLite", "delete failed: ", e);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void onConfigure(@NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:11:0x0030, code lost:
|
|
if (r0 != null) goto L_0x0032;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:12:0x0032, code lost:
|
|
r3 = r0.iterator();
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:14:0x003a, code lost:
|
|
if (r3.hasNext() != false) goto L_0x003c;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:15:0x003c, code lost:
|
|
deleteDatabaseFile((java.lang.String) r3.next().second);
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:16:0x004a, code lost:
|
|
deleteDatabaseFile(r3.getPath());
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:17:0x0051, code lost:
|
|
throw r1;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:7:0x002a, code lost:
|
|
r1 = move-exception;
|
|
*/
|
|
/* JADX WARNING: Failed to process nested try/catch */
|
|
/* JADX WARNING: Removed duplicated region for block: B:7:0x002a A[ExcHandler: all (r1v2 'th' java.lang.Throwable A[CUSTOM_DECLARE]), PHI: r0
|
|
PHI: (r0v12 java.util.List<android.util.Pair<java.lang.String, java.lang.String>>) = (r0v4 java.util.List<android.util.Pair<java.lang.String, java.lang.String>>), (r0v6 java.util.List<android.util.Pair<java.lang.String, java.lang.String>>), (r0v6 java.util.List<android.util.Pair<java.lang.String, java.lang.String>>) binds: [B:5:0x0025, B:8:0x002c, B:10:?] A[DONT_GENERATE, DONT_INLINE], Splitter:B:5:0x0025] */
|
|
public void onCorruption(@NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
|
|
StringBuilder L = a.L("Corruption reported by sqlite on database: ");
|
|
L.append(supportSQLiteDatabase.getPath());
|
|
Log.e("SupportSQLite", L.toString());
|
|
if (!supportSQLiteDatabase.isOpen()) {
|
|
deleteDatabaseFile(supportSQLiteDatabase.getPath());
|
|
return;
|
|
}
|
|
List<Pair<String, String>> list = null;
|
|
try {
|
|
list = supportSQLiteDatabase.getAttachedDbs();
|
|
supportSQLiteDatabase.close();
|
|
} catch (IOException unused) {
|
|
} catch (Throwable th) {
|
|
}
|
|
if (list != null) {
|
|
for (Pair<String, String> pair : list) {
|
|
deleteDatabaseFile((String) pair.second);
|
|
}
|
|
return;
|
|
}
|
|
deleteDatabaseFile(supportSQLiteDatabase.getPath());
|
|
}
|
|
|
|
public abstract void onCreate(@NonNull SupportSQLiteDatabase supportSQLiteDatabase);
|
|
|
|
public void onDowngrade(@NonNull SupportSQLiteDatabase supportSQLiteDatabase, int i, int i2) {
|
|
throw new SQLiteException(a.n("Can't downgrade database from version ", i, " to ", i2));
|
|
}
|
|
|
|
public void onOpen(@NonNull SupportSQLiteDatabase supportSQLiteDatabase) {
|
|
}
|
|
|
|
public abstract void onUpgrade(@NonNull SupportSQLiteDatabase supportSQLiteDatabase, int i, int i2);
|
|
}
|
|
|
|
public static class Configuration {
|
|
@NonNull
|
|
public final Callback callback;
|
|
@NonNull
|
|
public final Context context;
|
|
@Nullable
|
|
public final String name;
|
|
public final boolean useNoBackupDirectory;
|
|
|
|
public static class Builder {
|
|
public Callback mCallback;
|
|
public Context mContext;
|
|
public String mName;
|
|
public boolean mUseNoBackUpDirectory;
|
|
|
|
public Builder(@NonNull Context context) {
|
|
this.mContext = context;
|
|
}
|
|
|
|
@NonNull
|
|
public Configuration build() {
|
|
if (this.mCallback == null) {
|
|
throw new IllegalArgumentException("Must set a callback to create the configuration.");
|
|
} else if (this.mContext == null) {
|
|
throw new IllegalArgumentException("Must set a non-null context to create the configuration.");
|
|
} else if (!this.mUseNoBackUpDirectory || !TextUtils.isEmpty(this.mName)) {
|
|
return new Configuration(this.mContext, this.mName, this.mCallback, this.mUseNoBackUpDirectory);
|
|
} else {
|
|
throw new IllegalArgumentException("Must set a non-null database name to a configuration that uses the no backup directory.");
|
|
}
|
|
}
|
|
|
|
@NonNull
|
|
public Builder callback(@NonNull Callback callback) {
|
|
this.mCallback = callback;
|
|
return this;
|
|
}
|
|
|
|
@NonNull
|
|
public Builder name(@Nullable String str) {
|
|
this.mName = str;
|
|
return this;
|
|
}
|
|
|
|
@NonNull
|
|
public Builder noBackupDirectory(boolean z2) {
|
|
this.mUseNoBackUpDirectory = z2;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
public Configuration(@NonNull Context context, @Nullable String str, @NonNull Callback callback) {
|
|
this(context, str, callback, false);
|
|
}
|
|
|
|
public Configuration(@NonNull Context context, @Nullable String str, @NonNull Callback callback, boolean z2) {
|
|
this.context = context;
|
|
this.name = str;
|
|
this.callback = callback;
|
|
this.useNoBackupDirectory = z2;
|
|
}
|
|
|
|
@NonNull
|
|
public static Builder builder(@NonNull Context context) {
|
|
return new Builder(context);
|
|
}
|
|
}
|
|
|
|
public interface Factory {
|
|
@NonNull
|
|
SupportSQLiteOpenHelper create(@NonNull Configuration configuration);
|
|
}
|
|
|
|
@Override // java.io.Closeable, java.lang.AutoCloseable
|
|
void close();
|
|
|
|
@Nullable
|
|
String getDatabaseName();
|
|
|
|
SupportSQLiteDatabase getReadableDatabase();
|
|
|
|
SupportSQLiteDatabase getWritableDatabase();
|
|
|
|
@RequiresApi(api = 16)
|
|
void setWriteAheadLoggingEnabled(boolean z2);
|
|
}
|