apkfuckery/com.discord/smali/androidx/room/RoomOpenHelper.smali
2020-10-05 23:18:16 +00:00

545 lines
17 KiB
Smali

.class public Landroidx/room/RoomOpenHelper;
.super Landroidx/sqlite/db/SupportSQLiteOpenHelper$Callback;
.source "RoomOpenHelper.java"
# annotations
.annotation build Landroidx/annotation/RestrictTo;
value = {
.enum Landroidx/annotation/RestrictTo$Scope;->LIBRARY_GROUP_PREFIX:Landroidx/annotation/RestrictTo$Scope;
}
.end annotation
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Landroidx/room/RoomOpenHelper$ValidationResult;,
Landroidx/room/RoomOpenHelper$Delegate;
}
.end annotation
# instance fields
.field public mConfiguration:Landroidx/room/DatabaseConfiguration;
.annotation build Landroidx/annotation/Nullable;
.end annotation
.end field
.field public final mDelegate:Landroidx/room/RoomOpenHelper$Delegate;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end field
.field public final mIdentityHash:Ljava/lang/String;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end field
.field public final mLegacyHash:Ljava/lang/String;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end field
# direct methods
.method public constructor <init>(Landroidx/room/DatabaseConfiguration;Landroidx/room/RoomOpenHelper$Delegate;Ljava/lang/String;)V
.locals 1
.param p1 # Landroidx/room/DatabaseConfiguration;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
.param p2 # Landroidx/room/RoomOpenHelper$Delegate;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
.param p3 # Ljava/lang/String;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
const-string v0, ""
invoke-direct {p0, p1, p2, v0, p3}, Landroidx/room/RoomOpenHelper;-><init>(Landroidx/room/DatabaseConfiguration;Landroidx/room/RoomOpenHelper$Delegate;Ljava/lang/String;Ljava/lang/String;)V
return-void
.end method
.method public constructor <init>(Landroidx/room/DatabaseConfiguration;Landroidx/room/RoomOpenHelper$Delegate;Ljava/lang/String;Ljava/lang/String;)V
.locals 1
.param p1 # Landroidx/room/DatabaseConfiguration;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
.param p2 # Landroidx/room/RoomOpenHelper$Delegate;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
.param p3 # Ljava/lang/String;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
.param p4 # Ljava/lang/String;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
iget v0, p2, Landroidx/room/RoomOpenHelper$Delegate;->version:I
invoke-direct {p0, v0}, Landroidx/sqlite/db/SupportSQLiteOpenHelper$Callback;-><init>(I)V
iput-object p1, p0, Landroidx/room/RoomOpenHelper;->mConfiguration:Landroidx/room/DatabaseConfiguration;
iput-object p2, p0, Landroidx/room/RoomOpenHelper;->mDelegate:Landroidx/room/RoomOpenHelper$Delegate;
iput-object p3, p0, Landroidx/room/RoomOpenHelper;->mIdentityHash:Ljava/lang/String;
iput-object p4, p0, Landroidx/room/RoomOpenHelper;->mLegacyHash:Ljava/lang/String;
return-void
.end method
.method private checkIdentity(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
.locals 3
invoke-static {p1}, Landroidx/room/RoomOpenHelper;->hasRoomMasterTable(Landroidx/sqlite/db/SupportSQLiteDatabase;)Z
move-result v0
if-eqz v0, :cond_2
const/4 v0, 0x0
new-instance v1, Landroidx/sqlite/db/SimpleSQLiteQuery;
const-string v2, "SELECT identity_hash FROM room_master_table WHERE id = 42 LIMIT 1"
invoke-direct {v1, v2}, Landroidx/sqlite/db/SimpleSQLiteQuery;-><init>(Ljava/lang/String;)V
invoke-interface {p1, v1}, Landroidx/sqlite/db/SupportSQLiteDatabase;->query(Landroidx/sqlite/db/SupportSQLiteQuery;)Landroid/database/Cursor;
move-result-object p1
:try_start_0
invoke-interface {p1}, Landroid/database/Cursor;->moveToFirst()Z
move-result v1
if-eqz v1, :cond_0
const/4 v0, 0x0
invoke-interface {p1, v0}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;
move-result-object v0
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
:cond_0
invoke-interface {p1}, Landroid/database/Cursor;->close()V
iget-object p1, p0, Landroidx/room/RoomOpenHelper;->mIdentityHash:Ljava/lang/String;
invoke-virtual {p1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result p1
if-nez p1, :cond_3
iget-object p1, p0, Landroidx/room/RoomOpenHelper;->mLegacyHash:Ljava/lang/String;
invoke-virtual {p1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result p1
if-eqz p1, :cond_1
goto :goto_0
:cond_1
new-instance p1, Ljava/lang/IllegalStateException;
const-string v0, "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."
invoke-direct {p1, v0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p1
:catchall_0
move-exception v0
invoke-interface {p1}, Landroid/database/Cursor;->close()V
throw v0
:cond_2
iget-object v0, p0, Landroidx/room/RoomOpenHelper;->mDelegate:Landroidx/room/RoomOpenHelper$Delegate;
invoke-virtual {v0, p1}, Landroidx/room/RoomOpenHelper$Delegate;->onValidateSchema(Landroidx/sqlite/db/SupportSQLiteDatabase;)Landroidx/room/RoomOpenHelper$ValidationResult;
move-result-object v0
iget-boolean v1, v0, Landroidx/room/RoomOpenHelper$ValidationResult;->isValid:Z
if-eqz v1, :cond_4
iget-object v0, p0, Landroidx/room/RoomOpenHelper;->mDelegate:Landroidx/room/RoomOpenHelper$Delegate;
invoke-virtual {v0, p1}, Landroidx/room/RoomOpenHelper$Delegate;->onPostMigrate(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
invoke-direct {p0, p1}, Landroidx/room/RoomOpenHelper;->updateIdentity(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
:cond_3
:goto_0
return-void
:cond_4
new-instance p1, Ljava/lang/IllegalStateException;
const-string v1, "Pre-packaged database has an invalid schema: "
invoke-static {v1}, Lf/e/c/a/a;->E(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
iget-object v0, v0, Landroidx/room/RoomOpenHelper$ValidationResult;->expectedFoundMsg:Ljava/lang/String;
invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v0
invoke-direct {p1, v0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p1
.end method
.method private createMasterTableIfNotExists(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
.locals 1
const-string v0, "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)"
invoke-interface {p1, v0}, Landroidx/sqlite/db/SupportSQLiteDatabase;->execSQL(Ljava/lang/String;)V
return-void
.end method
.method public static hasEmptySchema(Landroidx/sqlite/db/SupportSQLiteDatabase;)Z
.locals 2
const-string v0, "SELECT count(*) FROM sqlite_master WHERE name != \'android_metadata\'"
invoke-interface {p0, v0}, Landroidx/sqlite/db/SupportSQLiteDatabase;->query(Ljava/lang/String;)Landroid/database/Cursor;
move-result-object p0
:try_start_0
invoke-interface {p0}, Landroid/database/Cursor;->moveToFirst()Z
move-result v0
const/4 v1, 0x0
if-eqz v0, :cond_0
invoke-interface {p0, v1}, Landroid/database/Cursor;->getInt(I)I
move-result v0
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
if-nez v0, :cond_0
const/4 v1, 0x1
:cond_0
invoke-interface {p0}, Landroid/database/Cursor;->close()V
return v1
:catchall_0
move-exception v0
invoke-interface {p0}, Landroid/database/Cursor;->close()V
throw v0
.end method
.method public static hasRoomMasterTable(Landroidx/sqlite/db/SupportSQLiteDatabase;)Z
.locals 2
const-string v0, "SELECT 1 FROM sqlite_master WHERE type = \'table\' AND name=\'room_master_table\'"
invoke-interface {p0, v0}, Landroidx/sqlite/db/SupportSQLiteDatabase;->query(Ljava/lang/String;)Landroid/database/Cursor;
move-result-object p0
:try_start_0
invoke-interface {p0}, Landroid/database/Cursor;->moveToFirst()Z
move-result v0
const/4 v1, 0x0
if-eqz v0, :cond_0
invoke-interface {p0, v1}, Landroid/database/Cursor;->getInt(I)I
move-result v0
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
if-eqz v0, :cond_0
const/4 v1, 0x1
:cond_0
invoke-interface {p0}, Landroid/database/Cursor;->close()V
return v1
:catchall_0
move-exception v0
invoke-interface {p0}, Landroid/database/Cursor;->close()V
throw v0
.end method
.method private updateIdentity(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
.locals 1
invoke-direct {p0, p1}, Landroidx/room/RoomOpenHelper;->createMasterTableIfNotExists(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
iget-object v0, p0, Landroidx/room/RoomOpenHelper;->mIdentityHash:Ljava/lang/String;
invoke-static {v0}, Landroidx/room/RoomMasterTable;->createInsertQuery(Ljava/lang/String;)Ljava/lang/String;
move-result-object v0
invoke-interface {p1, v0}, Landroidx/sqlite/db/SupportSQLiteDatabase;->execSQL(Ljava/lang/String;)V
return-void
.end method
# virtual methods
.method public onConfigure(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
.locals 0
invoke-super {p0, p1}, Landroidx/sqlite/db/SupportSQLiteOpenHelper$Callback;->onConfigure(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
return-void
.end method
.method public onCreate(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
.locals 2
invoke-static {p1}, Landroidx/room/RoomOpenHelper;->hasEmptySchema(Landroidx/sqlite/db/SupportSQLiteDatabase;)Z
move-result v0
iget-object v1, p0, Landroidx/room/RoomOpenHelper;->mDelegate:Landroidx/room/RoomOpenHelper$Delegate;
invoke-virtual {v1, p1}, Landroidx/room/RoomOpenHelper$Delegate;->createAllTables(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
if-nez v0, :cond_1
iget-object v0, p0, Landroidx/room/RoomOpenHelper;->mDelegate:Landroidx/room/RoomOpenHelper$Delegate;
invoke-virtual {v0, p1}, Landroidx/room/RoomOpenHelper$Delegate;->onValidateSchema(Landroidx/sqlite/db/SupportSQLiteDatabase;)Landroidx/room/RoomOpenHelper$ValidationResult;
move-result-object v0
iget-boolean v1, v0, Landroidx/room/RoomOpenHelper$ValidationResult;->isValid:Z
if-eqz v1, :cond_0
goto :goto_0
:cond_0
new-instance p1, Ljava/lang/IllegalStateException;
const-string v1, "Pre-packaged database has an invalid schema: "
invoke-static {v1}, Lf/e/c/a/a;->E(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
iget-object v0, v0, Landroidx/room/RoomOpenHelper$ValidationResult;->expectedFoundMsg:Ljava/lang/String;
invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v0
invoke-direct {p1, v0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p1
:cond_1
:goto_0
invoke-direct {p0, p1}, Landroidx/room/RoomOpenHelper;->updateIdentity(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
iget-object v0, p0, Landroidx/room/RoomOpenHelper;->mDelegate:Landroidx/room/RoomOpenHelper$Delegate;
invoke-virtual {v0, p1}, Landroidx/room/RoomOpenHelper$Delegate;->onCreate(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
return-void
.end method
.method public onDowngrade(Landroidx/sqlite/db/SupportSQLiteDatabase;II)V
.locals 0
invoke-virtual {p0, p1, p2, p3}, Landroidx/room/RoomOpenHelper;->onUpgrade(Landroidx/sqlite/db/SupportSQLiteDatabase;II)V
return-void
.end method
.method public onOpen(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
.locals 1
invoke-super {p0, p1}, Landroidx/sqlite/db/SupportSQLiteOpenHelper$Callback;->onOpen(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
invoke-direct {p0, p1}, Landroidx/room/RoomOpenHelper;->checkIdentity(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
iget-object v0, p0, Landroidx/room/RoomOpenHelper;->mDelegate:Landroidx/room/RoomOpenHelper$Delegate;
invoke-virtual {v0, p1}, Landroidx/room/RoomOpenHelper$Delegate;->onOpen(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
const/4 p1, 0x0
iput-object p1, p0, Landroidx/room/RoomOpenHelper;->mConfiguration:Landroidx/room/DatabaseConfiguration;
return-void
.end method
.method public onUpgrade(Landroidx/sqlite/db/SupportSQLiteDatabase;II)V
.locals 3
iget-object v0, p0, Landroidx/room/RoomOpenHelper;->mConfiguration:Landroidx/room/DatabaseConfiguration;
if-eqz v0, :cond_2
iget-object v0, v0, Landroidx/room/DatabaseConfiguration;->migrationContainer:Landroidx/room/RoomDatabase$MigrationContainer;
invoke-virtual {v0, p2, p3}, Landroidx/room/RoomDatabase$MigrationContainer;->findMigrationPath(II)Ljava/util/List;
move-result-object v0
if-eqz v0, :cond_2
iget-object v1, p0, Landroidx/room/RoomOpenHelper;->mDelegate:Landroidx/room/RoomOpenHelper$Delegate;
invoke-virtual {v1, p1}, Landroidx/room/RoomOpenHelper$Delegate;->onPreMigrate(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;
move-result-object v0
:goto_0
invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
move-result v1
if-eqz v1, :cond_0
invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v1
check-cast v1, Landroidx/room/migration/Migration;
invoke-virtual {v1, p1}, Landroidx/room/migration/Migration;->migrate(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
goto :goto_0
:cond_0
iget-object v0, p0, Landroidx/room/RoomOpenHelper;->mDelegate:Landroidx/room/RoomOpenHelper$Delegate;
invoke-virtual {v0, p1}, Landroidx/room/RoomOpenHelper$Delegate;->onValidateSchema(Landroidx/sqlite/db/SupportSQLiteDatabase;)Landroidx/room/RoomOpenHelper$ValidationResult;
move-result-object v0
iget-boolean v1, v0, Landroidx/room/RoomOpenHelper$ValidationResult;->isValid:Z
if-eqz v1, :cond_1
iget-object v0, p0, Landroidx/room/RoomOpenHelper;->mDelegate:Landroidx/room/RoomOpenHelper$Delegate;
invoke-virtual {v0, p1}, Landroidx/room/RoomOpenHelper$Delegate;->onPostMigrate(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
invoke-direct {p0, p1}, Landroidx/room/RoomOpenHelper;->updateIdentity(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
const/4 v0, 0x1
goto :goto_1
:cond_1
new-instance p1, Ljava/lang/IllegalStateException;
const-string p2, "Migration didn\'t properly handle: "
invoke-static {p2}, Lf/e/c/a/a;->E(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object p2
iget-object p3, v0, Landroidx/room/RoomOpenHelper$ValidationResult;->expectedFoundMsg:Ljava/lang/String;
invoke-virtual {p2, p3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {p2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p2
invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p1
:cond_2
const/4 v0, 0x0
:goto_1
if-nez v0, :cond_4
iget-object v0, p0, Landroidx/room/RoomOpenHelper;->mConfiguration:Landroidx/room/DatabaseConfiguration;
if-eqz v0, :cond_3
invoke-virtual {v0, p2, p3}, Landroidx/room/DatabaseConfiguration;->isMigrationRequired(II)Z
move-result v0
if-nez v0, :cond_3
iget-object p2, p0, Landroidx/room/RoomOpenHelper;->mDelegate:Landroidx/room/RoomOpenHelper$Delegate;
invoke-virtual {p2, p1}, Landroidx/room/RoomOpenHelper$Delegate;->dropAllTables(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
iget-object p2, p0, Landroidx/room/RoomOpenHelper;->mDelegate:Landroidx/room/RoomOpenHelper$Delegate;
invoke-virtual {p2, p1}, Landroidx/room/RoomOpenHelper$Delegate;->createAllTables(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
goto :goto_2
:cond_3
new-instance p1, Ljava/lang/IllegalStateException;
const-string v0, "A migration from "
const-string v1, " to "
const-string v2, " 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."
invoke-static {v0, p2, v1, p3, v2}, Lf/e/c/a/a;->l(Ljava/lang/String;ILjava/lang/String;ILjava/lang/String;)Ljava/lang/String;
move-result-object p2
invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p1
:cond_4
:goto_2
return-void
.end method