Files
rr3-apk/decompiled-community/sources/androidx/room/RoomOpenHelper.java
Daniel Elliott c080f0d97f Add Discord community version (64-bit only)
- Added realracing3-community.apk (71.57 MB)
- Removed 32-bit support (armeabi-v7a)
- Only includes arm64-v8a libraries
- Decompiled source code included
- Added README-community.md with analysis
2026-02-18 15:48:36 -08:00

238 lines
11 KiB
Java

package androidx.room;
import android.database.Cursor;
import androidx.annotation.RestrictTo;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SimpleSQLiteQuery;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.sqlite.db.SupportSQLiteOpenHelper;
import java.util.Iterator;
import java.util.List;
import kotlin.io.CloseableKt;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
@SourceDebugExtension({"SMAP\nRoomOpenHelper.kt\nKotlin\n*S Kotlin\n*F\n+ 1 RoomOpenHelper.kt\nandroidx/room/RoomOpenHelper\n+ 2 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n+ 3 CursorUtil.kt\nandroidx/room/util/CursorUtil\n*L\n1#1,245:1\n1855#2,2:246\n145#3,7:248\n*S KotlinDebug\n*F\n+ 1 RoomOpenHelper.kt\nandroidx/room/RoomOpenHelper\n*L\n90#1:246,2\n137#1:248,7\n*E\n"})
/* loaded from: classes.dex */
public class RoomOpenHelper extends SupportSQLiteOpenHelper.Callback {
public static final Companion Companion = new Companion(null);
private DatabaseConfiguration configuration;
private final Delegate delegate;
private final String identityHash;
private final String legacyHash;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public RoomOpenHelper(DatabaseConfiguration configuration, Delegate delegate, String identityHash, String legacyHash) {
super(delegate.version);
Intrinsics.checkNotNullParameter(configuration, "configuration");
Intrinsics.checkNotNullParameter(delegate, "delegate");
Intrinsics.checkNotNullParameter(identityHash, "identityHash");
Intrinsics.checkNotNullParameter(legacyHash, "legacyHash");
this.configuration = configuration;
this.delegate = delegate;
this.identityHash = identityHash;
this.legacyHash = legacyHash;
}
/* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
public RoomOpenHelper(DatabaseConfiguration configuration, Delegate delegate, String legacyHash) {
this(configuration, delegate, "", legacyHash);
Intrinsics.checkNotNullParameter(configuration, "configuration");
Intrinsics.checkNotNullParameter(delegate, "delegate");
Intrinsics.checkNotNullParameter(legacyHash, "legacyHash");
}
@Override // androidx.sqlite.db.SupportSQLiteOpenHelper.Callback
public void onConfigure(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
super.onConfigure(db);
}
@Override // androidx.sqlite.db.SupportSQLiteOpenHelper.Callback
public void onCreate(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
boolean hasEmptySchema$room_runtime_release = Companion.hasEmptySchema$room_runtime_release(db);
this.delegate.createAllTables(db);
if (!hasEmptySchema$room_runtime_release) {
ValidationResult onValidateSchema = this.delegate.onValidateSchema(db);
if (!onValidateSchema.isValid) {
throw new IllegalStateException("Pre-packaged database has an invalid schema: " + onValidateSchema.expectedFoundMsg);
}
}
updateIdentity(db);
this.delegate.onCreate(db);
}
@Override // androidx.sqlite.db.SupportSQLiteOpenHelper.Callback
public void onUpgrade(SupportSQLiteDatabase db, int i, int i2) {
List<Migration> findMigrationPath;
Intrinsics.checkNotNullParameter(db, "db");
DatabaseConfiguration databaseConfiguration = this.configuration;
if (databaseConfiguration != null && (findMigrationPath = databaseConfiguration.migrationContainer.findMigrationPath(i, i2)) != null) {
this.delegate.onPreMigrate(db);
Iterator<T> it = findMigrationPath.iterator();
while (it.hasNext()) {
((Migration) it.next()).migrate(db);
}
ValidationResult onValidateSchema = this.delegate.onValidateSchema(db);
if (!onValidateSchema.isValid) {
throw new IllegalStateException("Migration didn't properly handle: " + onValidateSchema.expectedFoundMsg);
}
this.delegate.onPostMigrate(db);
updateIdentity(db);
return;
}
DatabaseConfiguration databaseConfiguration2 = this.configuration;
if (databaseConfiguration2 != null && !databaseConfiguration2.isMigrationRequired(i, i2)) {
this.delegate.dropAllTables(db);
this.delegate.createAllTables(db);
return;
}
throw new IllegalStateException("A migration from " + i + " to " + i2 + " was required but not found. Please provide the necessary Migration path via RoomDatabase.Builder.addMigration(Migration ...) or allow for destructive migrations via one of the RoomDatabase.Builder.fallbackToDestructiveMigration* methods.");
}
@Override // androidx.sqlite.db.SupportSQLiteOpenHelper.Callback
public void onDowngrade(SupportSQLiteDatabase db, int i, int i2) {
Intrinsics.checkNotNullParameter(db, "db");
onUpgrade(db, i, i2);
}
@Override // androidx.sqlite.db.SupportSQLiteOpenHelper.Callback
public void onOpen(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
super.onOpen(db);
checkIdentity(db);
this.delegate.onOpen(db);
this.configuration = null;
}
private final void checkIdentity(SupportSQLiteDatabase supportSQLiteDatabase) {
if (!Companion.hasRoomMasterTable$room_runtime_release(supportSQLiteDatabase)) {
ValidationResult onValidateSchema = this.delegate.onValidateSchema(supportSQLiteDatabase);
if (onValidateSchema.isValid) {
this.delegate.onPostMigrate(supportSQLiteDatabase);
updateIdentity(supportSQLiteDatabase);
return;
} else {
throw new IllegalStateException("Pre-packaged database has an invalid schema: " + onValidateSchema.expectedFoundMsg);
}
}
Cursor query = supportSQLiteDatabase.query(new SimpleSQLiteQuery(RoomMasterTable.READ_QUERY));
try {
String string = query.moveToFirst() ? query.getString(0) : null;
CloseableKt.closeFinally(query, null);
if (Intrinsics.areEqual(this.identityHash, string) || Intrinsics.areEqual(this.legacyHash, string)) {
return;
}
throw new IllegalStateException("Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number. Expected identity hash: " + this.identityHash + ", found: " + string);
} catch (Throwable th) {
try {
throw th;
} catch (Throwable th2) {
CloseableKt.closeFinally(query, th);
throw th2;
}
}
}
private final void updateIdentity(SupportSQLiteDatabase supportSQLiteDatabase) {
createMasterTableIfNotExists(supportSQLiteDatabase);
supportSQLiteDatabase.execSQL(RoomMasterTable.createInsertQuery(this.identityHash));
}
private final void createMasterTableIfNotExists(SupportSQLiteDatabase supportSQLiteDatabase) {
supportSQLiteDatabase.execSQL(RoomMasterTable.CREATE_QUERY);
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public static abstract class Delegate {
public final int version;
public abstract void createAllTables(SupportSQLiteDatabase supportSQLiteDatabase);
public abstract void dropAllTables(SupportSQLiteDatabase supportSQLiteDatabase);
public abstract void onCreate(SupportSQLiteDatabase supportSQLiteDatabase);
public abstract void onOpen(SupportSQLiteDatabase supportSQLiteDatabase);
public void onPostMigrate(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
}
public void onPreMigrate(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
}
public Delegate(int i) {
this.version = i;
}
public void validateMigration(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
throw new UnsupportedOperationException("validateMigration is deprecated");
}
public ValidationResult onValidateSchema(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
validateMigration(db);
return new ValidationResult(true, null);
}
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public static class ValidationResult {
public final String expectedFoundMsg;
public final boolean isValid;
public ValidationResult(boolean z, String str) {
this.isValid = z;
this.expectedFoundMsg = str;
}
}
@SourceDebugExtension({"SMAP\nRoomOpenHelper.kt\nKotlin\n*S Kotlin\n*F\n+ 1 RoomOpenHelper.kt\nandroidx/room/RoomOpenHelper$Companion\n+ 2 CursorUtil.kt\nandroidx/room/util/CursorUtil\n*L\n1#1,245:1\n145#2,7:246\n145#2,7:253\n*S KotlinDebug\n*F\n+ 1 RoomOpenHelper.kt\nandroidx/room/RoomOpenHelper$Companion\n*L\n231#1:246,7\n239#1:253,7\n*E\n"})
public static final class Companion {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
public final boolean hasRoomMasterTable$room_runtime_release(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
Cursor query = db.query("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name='room_master_table'");
try {
boolean z = false;
if (query.moveToFirst()) {
if (query.getInt(0) != 0) {
z = true;
}
}
CloseableKt.closeFinally(query, null);
return z;
} finally {
}
}
public final boolean hasEmptySchema$room_runtime_release(SupportSQLiteDatabase db) {
Intrinsics.checkNotNullParameter(db, "db");
Cursor query = db.query("SELECT count(*) FROM sqlite_master WHERE name != 'android_metadata'");
try {
boolean z = false;
if (query.moveToFirst()) {
if (query.getInt(0) == 0) {
z = true;
}
}
CloseableKt.closeFinally(query, null);
return z;
} finally {
}
}
}
}