298 lines
7.4 KiB
Smali
298 lines
7.4 KiB
Smali
|
.class public Landroidx/room/util/DBUtil;
|
||
|
.super Ljava/lang/Object;
|
||
|
.source "DBUtil.java"
|
||
|
|
||
|
|
||
|
# annotations
|
||
|
.annotation build Landroidx/annotation/RestrictTo;
|
||
|
value = {
|
||
|
.enum Landroidx/annotation/RestrictTo$Scope;->LIBRARY_GROUP_PREFIX:Landroidx/annotation/RestrictTo$Scope;
|
||
|
}
|
||
|
.end annotation
|
||
|
|
||
|
|
||
|
# direct methods
|
||
|
.method public constructor <init>()V
|
||
|
.locals 0
|
||
|
|
||
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
||
|
|
||
|
return-void
|
||
|
.end method
|
||
|
|
||
|
.method public static createCancellationSignal()Landroid/os/CancellationSignal;
|
||
|
.locals 1
|
||
|
.annotation build Landroidx/annotation/Nullable;
|
||
|
.end annotation
|
||
|
|
||
|
new-instance v0, Landroid/os/CancellationSignal;
|
||
|
|
||
|
invoke-direct {v0}, Landroid/os/CancellationSignal;-><init>()V
|
||
|
|
||
|
return-object v0
|
||
|
.end method
|
||
|
|
||
|
.method public static dropFtsSyncTriggers(Landroidx/sqlite/db/SupportSQLiteDatabase;)V
|
||
|
.locals 4
|
||
|
|
||
|
new-instance v0, Ljava/util/ArrayList;
|
||
|
|
||
|
invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
|
||
|
|
||
|
const-string v1, "SELECT name FROM sqlite_master WHERE type = \'trigger\'"
|
||
|
|
||
|
invoke-interface {p0, v1}, Landroidx/sqlite/db/SupportSQLiteDatabase;->query(Ljava/lang/String;)Landroid/database/Cursor;
|
||
|
|
||
|
move-result-object v1
|
||
|
|
||
|
:goto_0
|
||
|
:try_start_0
|
||
|
invoke-interface {v1}, Landroid/database/Cursor;->moveToNext()Z
|
||
|
|
||
|
move-result v2
|
||
|
|
||
|
if-eqz v2, :cond_0
|
||
|
|
||
|
const/4 v2, 0x0
|
||
|
|
||
|
invoke-interface {v1, v2}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;
|
||
|
|
||
|
move-result-object v2
|
||
|
|
||
|
invoke-virtual {v0, v2}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
|
||
|
:try_end_0
|
||
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
||
|
|
||
|
goto :goto_0
|
||
|
|
||
|
:cond_0
|
||
|
invoke-interface {v1}, Landroid/database/Cursor;->close()V
|
||
|
|
||
|
invoke-virtual {v0}, Ljava/util/ArrayList;->iterator()Ljava/util/Iterator;
|
||
|
|
||
|
move-result-object v0
|
||
|
|
||
|
:cond_1
|
||
|
:goto_1
|
||
|
invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
|
||
|
|
||
|
move-result v1
|
||
|
|
||
|
if-eqz v1, :cond_2
|
||
|
|
||
|
invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
||
|
|
||
|
move-result-object v1
|
||
|
|
||
|
check-cast v1, Ljava/lang/String;
|
||
|
|
||
|
const-string v2, "room_fts_content_sync_"
|
||
|
|
||
|
invoke-virtual {v1, v2}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
|
||
|
|
||
|
move-result v2
|
||
|
|
||
|
if-eqz v2, :cond_1
|
||
|
|
||
|
new-instance v2, Ljava/lang/StringBuilder;
|
||
|
|
||
|
invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
|
||
|
|
||
|
const-string v3, "DROP TRIGGER IF EXISTS "
|
||
|
|
||
|
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
||
|
|
||
|
invoke-virtual {v2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
||
|
|
||
|
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
||
|
|
||
|
move-result-object v1
|
||
|
|
||
|
invoke-interface {p0, v1}, Landroidx/sqlite/db/SupportSQLiteDatabase;->execSQL(Ljava/lang/String;)V
|
||
|
|
||
|
goto :goto_1
|
||
|
|
||
|
:cond_2
|
||
|
return-void
|
||
|
|
||
|
:catchall_0
|
||
|
move-exception p0
|
||
|
|
||
|
invoke-interface {v1}, Landroid/database/Cursor;->close()V
|
||
|
|
||
|
throw p0
|
||
|
.end method
|
||
|
|
||
|
.method public static query(Landroidx/room/RoomDatabase;Landroidx/sqlite/db/SupportSQLiteQuery;Z)Landroid/database/Cursor;
|
||
|
.locals 1
|
||
|
.annotation build Landroidx/annotation/NonNull;
|
||
|
.end annotation
|
||
|
|
||
|
.annotation runtime Ljava/lang/Deprecated;
|
||
|
.end annotation
|
||
|
|
||
|
const/4 v0, 0x0
|
||
|
|
||
|
invoke-static {p0, p1, p2, v0}, Landroidx/room/util/DBUtil;->query(Landroidx/room/RoomDatabase;Landroidx/sqlite/db/SupportSQLiteQuery;ZLandroid/os/CancellationSignal;)Landroid/database/Cursor;
|
||
|
|
||
|
move-result-object p0
|
||
|
|
||
|
return-object p0
|
||
|
.end method
|
||
|
|
||
|
.method public static query(Landroidx/room/RoomDatabase;Landroidx/sqlite/db/SupportSQLiteQuery;ZLandroid/os/CancellationSignal;)Landroid/database/Cursor;
|
||
|
.locals 2
|
||
|
.param p0 # Landroidx/room/RoomDatabase;
|
||
|
.annotation build Landroidx/annotation/NonNull;
|
||
|
.end annotation
|
||
|
.end param
|
||
|
.param p1 # Landroidx/sqlite/db/SupportSQLiteQuery;
|
||
|
.annotation build Landroidx/annotation/NonNull;
|
||
|
.end annotation
|
||
|
.end param
|
||
|
.param p3 # Landroid/os/CancellationSignal;
|
||
|
.annotation build Landroidx/annotation/Nullable;
|
||
|
.end annotation
|
||
|
.end param
|
||
|
.annotation build Landroidx/annotation/NonNull;
|
||
|
.end annotation
|
||
|
|
||
|
invoke-virtual {p0, p1, p3}, Landroidx/room/RoomDatabase;->query(Landroidx/sqlite/db/SupportSQLiteQuery;Landroid/os/CancellationSignal;)Landroid/database/Cursor;
|
||
|
|
||
|
move-result-object p0
|
||
|
|
||
|
if-eqz p2, :cond_2
|
||
|
|
||
|
instance-of p1, p0, Landroid/database/AbstractWindowedCursor;
|
||
|
|
||
|
if-eqz p1, :cond_2
|
||
|
|
||
|
move-object p1, p0
|
||
|
|
||
|
check-cast p1, Landroid/database/AbstractWindowedCursor;
|
||
|
|
||
|
invoke-virtual {p1}, Landroid/database/AbstractWindowedCursor;->getCount()I
|
||
|
|
||
|
move-result p2
|
||
|
|
||
|
invoke-virtual {p1}, Landroid/database/AbstractWindowedCursor;->hasWindow()Z
|
||
|
|
||
|
move-result p3
|
||
|
|
||
|
if-eqz p3, :cond_0
|
||
|
|
||
|
invoke-virtual {p1}, Landroid/database/AbstractWindowedCursor;->getWindow()Landroid/database/CursorWindow;
|
||
|
|
||
|
move-result-object p3
|
||
|
|
||
|
invoke-virtual {p3}, Landroid/database/CursorWindow;->getNumRows()I
|
||
|
|
||
|
move-result p3
|
||
|
|
||
|
goto :goto_0
|
||
|
|
||
|
:cond_0
|
||
|
move p3, p2
|
||
|
|
||
|
:goto_0
|
||
|
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
|
||
|
|
||
|
const/16 v1, 0x17
|
||
|
|
||
|
if-lt v0, v1, :cond_1
|
||
|
|
||
|
if-ge p3, p2, :cond_2
|
||
|
|
||
|
:cond_1
|
||
|
invoke-static {p1}, Landroidx/room/util/CursorUtil;->copyAndClose(Landroid/database/Cursor;)Landroid/database/Cursor;
|
||
|
|
||
|
move-result-object p0
|
||
|
|
||
|
:cond_2
|
||
|
return-object p0
|
||
|
.end method
|
||
|
|
||
|
.method public static readVersion(Ljava/io/File;)I
|
||
|
.locals 10
|
||
|
.param p0 # Ljava/io/File;
|
||
|
.annotation build Landroidx/annotation/NonNull;
|
||
|
.end annotation
|
||
|
.end param
|
||
|
.annotation system Ldalvik/annotation/Throws;
|
||
|
value = {
|
||
|
Ljava/io/IOException;
|
||
|
}
|
||
|
.end annotation
|
||
|
|
||
|
const/4 v0, 0x4
|
||
|
|
||
|
const/4 v1, 0x0
|
||
|
|
||
|
:try_start_0
|
||
|
invoke-static {v0}, Ljava/nio/ByteBuffer;->allocate(I)Ljava/nio/ByteBuffer;
|
||
|
|
||
|
move-result-object v2
|
||
|
|
||
|
new-instance v3, Ljava/io/FileInputStream;
|
||
|
|
||
|
invoke-direct {v3, p0}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V
|
||
|
|
||
|
invoke-virtual {v3}, Ljava/io/FileInputStream;->getChannel()Ljava/nio/channels/FileChannel;
|
||
|
|
||
|
move-result-object v1
|
||
|
|
||
|
const-wide/16 v5, 0x3c
|
||
|
|
||
|
const-wide/16 v7, 0x4
|
||
|
|
||
|
const/4 v9, 0x1
|
||
|
|
||
|
move-object v4, v1
|
||
|
|
||
|
invoke-virtual/range {v4 .. v9}, Ljava/nio/channels/FileChannel;->tryLock(JJZ)Ljava/nio/channels/FileLock;
|
||
|
|
||
|
const-wide/16 v3, 0x3c
|
||
|
|
||
|
invoke-virtual {v1, v3, v4}, Ljava/nio/channels/FileChannel;->position(J)Ljava/nio/channels/FileChannel;
|
||
|
|
||
|
invoke-virtual {v1, v2}, Ljava/nio/channels/FileChannel;->read(Ljava/nio/ByteBuffer;)I
|
||
|
|
||
|
move-result p0
|
||
|
|
||
|
if-ne p0, v0, :cond_0
|
||
|
|
||
|
invoke-virtual {v2}, Ljava/nio/ByteBuffer;->rewind()Ljava/nio/Buffer;
|
||
|
|
||
|
invoke-virtual {v2}, Ljava/nio/ByteBuffer;->getInt()I
|
||
|
|
||
|
move-result p0
|
||
|
:try_end_0
|
||
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
||
|
|
||
|
invoke-virtual {v1}, Ljava/nio/channels/FileChannel;->close()V
|
||
|
|
||
|
return p0
|
||
|
|
||
|
:cond_0
|
||
|
:try_start_1
|
||
|
new-instance p0, Ljava/io/IOException;
|
||
|
|
||
|
const-string v0, "Bad database header, unable to read 4 bytes at offset 60"
|
||
|
|
||
|
invoke-direct {p0, v0}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
|
||
|
|
||
|
throw p0
|
||
|
:try_end_1
|
||
|
.catchall {:try_start_1 .. :try_end_1} :catchall_0
|
||
|
|
||
|
:catchall_0
|
||
|
move-exception p0
|
||
|
|
||
|
if-eqz v1, :cond_1
|
||
|
|
||
|
invoke-virtual {v1}, Ljava/nio/channels/FileChannel;->close()V
|
||
|
|
||
|
:cond_1
|
||
|
throw p0
|
||
|
.end method
|