tmap/smali_classes3/com/google/firebase/database/android/SqlPersistenceStorageEngine.smali
2022-06-10 21:38:30 +09:00

4906 lines
134 KiB
Smali

.class public Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;
.super Ljava/lang/Object;
.source "SqlPersistenceStorageEngine.java"
# interfaces
.implements Lcom/google/firebase/database/core/persistence/PersistenceStorageEngine;
# annotations
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lcom/google/firebase/database/android/SqlPersistenceStorageEngine$PersistentCacheOpenHelper;
}
.end annotation
# static fields
.field private static final CHILDREN_NODE_SPLIT_SIZE_THRESHOLD:I = 0x4000
.field private static final CREATE_SERVER_CACHE:Ljava/lang/String; = "CREATE TABLE serverCache (path TEXT PRIMARY KEY, value BLOB);"
.field private static final CREATE_TRACKED_KEYS:Ljava/lang/String; = "CREATE TABLE trackedKeys (id INTEGER, key TEXT);"
.field private static final CREATE_TRACKED_QUERIES:Ljava/lang/String; = "CREATE TABLE trackedQueries (id INTEGER PRIMARY KEY, path TEXT, queryParams TEXT, lastUse INTEGER, complete INTEGER, active INTEGER);"
.field private static final CREATE_WRITES:Ljava/lang/String; = "CREATE TABLE writes (id INTEGER, path TEXT, type TEXT, part INTEGER, node BLOB, UNIQUE (id, part));"
.field private static final FIRST_PART_KEY:Ljava/lang/String; = ".part-0000"
.field private static final LOGGER_COMPONENT:Ljava/lang/String; = "Persistence"
.field private static final PART_KEY_FORMAT:Ljava/lang/String; = ".part-%04d"
.field private static final PART_KEY_PREFIX:Ljava/lang/String; = ".part-"
.field private static final PATH_COLUMN_NAME:Ljava/lang/String; = "path"
.field private static final ROW_ID_COLUMN_NAME:Ljava/lang/String; = "rowid"
.field private static final ROW_SPLIT_SIZE:I = 0x40000
.field private static final SERVER_CACHE_TABLE:Ljava/lang/String; = "serverCache"
.field private static final TRACKED_KEYS_ID_COLUMN_NAME:Ljava/lang/String; = "id"
.field private static final TRACKED_KEYS_KEY_COLUMN_NAME:Ljava/lang/String; = "key"
.field private static final TRACKED_KEYS_TABLE:Ljava/lang/String; = "trackedKeys"
.field private static final TRACKED_QUERY_ACTIVE_COLUMN_NAME:Ljava/lang/String; = "active"
.field private static final TRACKED_QUERY_COMPLETE_COLUMN_NAME:Ljava/lang/String; = "complete"
.field private static final TRACKED_QUERY_ID_COLUMN_NAME:Ljava/lang/String; = "id"
.field private static final TRACKED_QUERY_LAST_USE_COLUMN_NAME:Ljava/lang/String; = "lastUse"
.field private static final TRACKED_QUERY_PARAMS_COLUMN_NAME:Ljava/lang/String; = "queryParams"
.field private static final TRACKED_QUERY_PATH_COLUMN_NAME:Ljava/lang/String; = "path"
.field private static final TRACKED_QUERY_TABLE:Ljava/lang/String; = "trackedQueries"
.field private static final UTF8_CHARSET:Ljava/nio/charset/Charset;
.field private static final VALUE_COLUMN_NAME:Ljava/lang/String; = "value"
.field private static final WRITES_TABLE:Ljava/lang/String; = "writes"
.field private static final WRITE_ID_COLUMN_NAME:Ljava/lang/String; = "id"
.field private static final WRITE_NODE_COLUMN_NAME:Ljava/lang/String; = "node"
.field private static final WRITE_PART_COLUMN_NAME:Ljava/lang/String; = "part"
.field private static final WRITE_TYPE_COLUMN_NAME:Ljava/lang/String; = "type"
.field private static final WRITE_TYPE_MERGE:Ljava/lang/String; = "m"
.field private static final WRITE_TYPE_OVERWRITE:Ljava/lang/String; = "o"
# instance fields
.field private final database:Landroid/database/sqlite/SQLiteDatabase;
.field private insideTransaction:Z
.field private final logger:Lcom/google/firebase/database/logging/LogWrapper;
.field private transactionStart:J
# direct methods
.method public static constructor <clinit>()V
.locals 1
const-string v0, "UTF-8"
.line 1
invoke-static {v0}, Ljava/nio/charset/Charset;->forName(Ljava/lang/String;)Ljava/nio/charset/Charset;
move-result-object v0
sput-object v0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->UTF8_CHARSET:Ljava/nio/charset/Charset;
return-void
.end method
.method public constructor <init>(Landroid/content/Context;Lcom/google/firebase/database/core/Context;Ljava/lang/String;)V
.locals 2
.line 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
const-wide/16 v0, 0x0
.line 2
iput-wide v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->transactionStart:J
:try_start_0
const-string v0, "utf-8"
.line 3
invoke-static {p3, v0}, Ljava/net/URLEncoder;->encode(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
move-result-object p3
:try_end_0
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
const-string v0, "Persistence"
.line 4
invoke-virtual {p2, v0}, Lcom/google/firebase/database/core/Context;->getLogger(Ljava/lang/String;)Lcom/google/firebase/database/logging/LogWrapper;
move-result-object p2
iput-object p2, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
.line 5
invoke-direct {p0, p1, p3}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->openDatabase(Landroid/content/Context;Ljava/lang/String;)Landroid/database/sqlite/SQLiteDatabase;
move-result-object p1
iput-object p1, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
return-void
:catch_0
move-exception p1
.line 6
new-instance p2, Ljava/lang/RuntimeException;
invoke-direct {p2, p1}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/Throwable;)V
throw p2
.end method
.method private static buildAncestorWhereClause(Lcom/google/firebase/database/core/Path;[Ljava/lang/String;)Ljava/lang/String;
.locals 4
.line 1
array-length v0, p1
invoke-virtual {p0}, Lcom/google/firebase/database/core/Path;->size()I
move-result v1
const/4 v2, 0x1
add-int/2addr v1, v2
const/4 v3, 0x0
if-lt v0, v1, :cond_0
goto :goto_0
:cond_0
move v2, v3
:goto_0
invoke-static {v2}, Lcom/google/firebase/database/core/utilities/Utilities;->hardAssert(Z)V
.line 2
new-instance v0, Ljava/lang/StringBuilder;
const-string v1, "("
invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
.line 3
:goto_1
invoke-virtual {p0}, Lcom/google/firebase/database/core/Path;->isEmpty()Z
move-result v1
const-string v2, "path"
if-nez v1, :cond_1
.line 4
invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string v1, " = ? OR "
.line 5
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
.line 6
invoke-static {p0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->pathToKey(Lcom/google/firebase/database/core/Path;)Ljava/lang/String;
move-result-object v1
aput-object v1, p1, v3
.line 7
invoke-virtual {p0}, Lcom/google/firebase/database/core/Path;->getParent()Lcom/google/firebase/database/core/Path;
move-result-object p0
add-int/lit8 v3, v3, 0x1
goto :goto_1
.line 8
:cond_1
invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string p0, " = ?)"
.line 9
invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
.line 10
invoke-static {}, Lcom/google/firebase/database/core/Path;->getEmptyPath()Lcom/google/firebase/database/core/Path;
move-result-object p0
invoke-static {p0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->pathToKey(Lcom/google/firebase/database/core/Path;)Ljava/lang/String;
move-result-object p0
aput-object p0, p1, v3
.line 11
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p0
return-object p0
.end method
.method private commaSeparatedList(Ljava/util/Collection;)Ljava/lang/String;
.locals 4
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Ljava/util/Collection<",
"Ljava/lang/Long;",
">;)",
"Ljava/lang/String;"
}
.end annotation
.line 1
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
.line 2
invoke-interface {p1}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;
move-result-object p1
const/4 v1, 0x1
:goto_0
invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z
move-result v2
if-eqz v2, :cond_1
invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v2
check-cast v2, Ljava/lang/Long;
invoke-virtual {v2}, Ljava/lang/Long;->longValue()J
move-result-wide v2
if-nez v1, :cond_0
const-string v1, ","
.line 3
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
:cond_0
const/4 v1, 0x0
.line 4
invoke-virtual {v0, v2, v3}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
goto :goto_0
.line 5
:cond_1
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p1
return-object p1
.end method
.method private deserializeNode([B)Lcom/google/firebase/database/snapshot/Node;
.locals 3
.line 1
:try_start_0
new-instance v0, Ljava/lang/String;
sget-object v1, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->UTF8_CHARSET:Ljava/nio/charset/Charset;
invoke-direct {v0, p1, v1}, Ljava/lang/String;-><init>([BLjava/nio/charset/Charset;)V
invoke-static {v0}, Lcom/google/firebase/database/util/JsonMapper;->parseJsonValue(Ljava/lang/String;)Ljava/lang/Object;
move-result-object v0
.line 2
invoke-static {v0}, Lcom/google/firebase/database/snapshot/NodeUtilities;->NodeFromJSON(Ljava/lang/Object;)Lcom/google/firebase/database/snapshot/Node;
move-result-object p1
:try_end_0
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
return-object p1
:catch_0
move-exception v0
.line 3
new-instance v1, Ljava/lang/String;
sget-object v2, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->UTF8_CHARSET:Ljava/nio/charset/Charset;
invoke-direct {v1, p1, v2}, Ljava/lang/String;-><init>([BLjava/nio/charset/Charset;)V
.line 4
new-instance p1, Ljava/lang/RuntimeException;
const-string v2, "Could not deserialize node: "
invoke-static {v2, v1}, Lc/g;->a(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
move-result-object v1
invoke-direct {p1, v1, v0}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
throw p1
.end method
.method private joinBytes(Ljava/util/List;)[B
.locals 5
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Ljava/util/List<",
"[B>;)[B"
}
.end annotation
.line 1
invoke-interface {p1}, Ljava/util/List;->iterator()Ljava/util/Iterator;
move-result-object v0
const/4 v1, 0x0
move v2, v1
:goto_0
invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
move-result v3
if-eqz v3, :cond_0
invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v3
check-cast v3, [B
.line 2
array-length v3, v3
add-int/2addr v2, v3
goto :goto_0
.line 3
:cond_0
new-array v0, v2, [B
.line 4
invoke-interface {p1}, Ljava/util/List;->iterator()Ljava/util/Iterator;
move-result-object p1
move v2, v1
:goto_1
invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z
move-result v3
if-eqz v3, :cond_1
invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v3
check-cast v3, [B
.line 5
array-length v4, v3
invoke-static {v3, v1, v0, v2, v4}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
.line 6
array-length v3, v3
add-int/2addr v2, v3
goto :goto_1
:cond_1
return-object v0
.end method
.method private loadNested(Lcom/google/firebase/database/core/Path;)Lcom/google/firebase/database/snapshot/Node;
.locals 21
move-object/from16 v1, p0
move-object/from16 v0, p1
.line 1
new-instance v2, Ljava/util/ArrayList;
invoke-direct {v2}, Ljava/util/ArrayList;-><init>()V
.line 2
new-instance v3, Ljava/util/ArrayList;
invoke-direct {v3}, Ljava/util/ArrayList;-><init>()V
.line 3
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v4
const-string v6, "path"
const-string v7, "value"
.line 4
filled-new-array {v6, v7}, [Ljava/lang/String;
move-result-object v6
invoke-direct {v1, v0, v6}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->loadNestedQuery(Lcom/google/firebase/database/core/Path;[Ljava/lang/String;)Landroid/database/Cursor;
move-result-object v6
.line 5
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v7
sub-long/2addr v7, v4
.line 6
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v9
.line 7
:goto_0
:try_start_0
invoke-interface {v6}, Landroid/database/Cursor;->moveToNext()Z
move-result v11
const/4 v12, 0x1
const/4 v13, 0x0
if-eqz v11, :cond_0
.line 8
invoke-interface {v6, v13}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;
move-result-object v11
invoke-virtual {v2, v11}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
.line 9
invoke-interface {v6, v12}, Landroid/database/Cursor;->getBlob(I)[B
move-result-object v11
invoke-virtual {v3, v11}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
goto :goto_0
.line 10
:cond_0
invoke-interface {v6}, Landroid/database/Cursor;->close()V
.line 11
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v11
sub-long/2addr v11, v9
.line 12
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v9
.line 13
invoke-static {}, Lcom/google/firebase/database/snapshot/EmptyNode;->Empty()Lcom/google/firebase/database/snapshot/EmptyNode;
move-result-object v6
.line 14
new-instance v14, Ljava/util/HashMap;
invoke-direct {v14}, Ljava/util/HashMap;-><init>()V
move-wide/from16 v16, v11
move v15, v13
.line 15
:goto_1
invoke-virtual {v3}, Ljava/util/ArrayList;->size()I
move-result v11
if-ge v13, v11, :cond_6
.line 16
invoke-virtual {v2, v13}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;
move-result-object v11
check-cast v11, Ljava/lang/String;
const-string v12, ".part-0000"
invoke-virtual {v11, v12}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z
move-result v11
if-eqz v11, :cond_2
.line 17
invoke-virtual {v2, v13}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;
move-result-object v11
check-cast v11, Ljava/lang/String;
.line 18
new-instance v12, Lcom/google/firebase/database/core/Path;
.line 19
invoke-virtual {v11}, Ljava/lang/String;->length()I
move-result v18
move-wide/from16 v19, v7
add-int/lit8 v7, v18, -0xa
const/4 v8, 0x0
invoke-virtual {v11, v8, v7}, Ljava/lang/String;->substring(II)Ljava/lang/String;
move-result-object v7
invoke-direct {v12, v7}, Lcom/google/firebase/database/core/Path;-><init>(Ljava/lang/String;)V
.line 20
invoke-direct {v1, v12, v2, v13}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->splitNodeRunLength(Lcom/google/firebase/database/core/Path;Ljava/util/List;I)I
move-result v7
.line 21
iget-object v8, v1, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {v8}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result v8
if-eqz v8, :cond_1
.line 22
iget-object v8, v1, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
const-string v11, "Loading split node with "
move-object/from16 v18, v12
const-string v12, " parts."
invoke-static {v11, v7, v12}, Landroidx/camera/core/impl/utils/f;->a(Ljava/lang/String;ILjava/lang/String;)Ljava/lang/String;
move-result-object v11
const/4 v12, 0x0
new-array v12, v12, [Ljava/lang/Object;
invoke-virtual {v8, v11, v12}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
goto :goto_2
:cond_1
move-object/from16 v18, v12
:goto_2
add-int/2addr v7, v13
.line 23
invoke-virtual {v3, v13, v7}, Ljava/util/ArrayList;->subList(II)Ljava/util/List;
move-result-object v8
invoke-direct {v1, v8}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->joinBytes(Ljava/util/List;)[B
move-result-object v8
invoke-direct {v1, v8}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->deserializeNode([B)Lcom/google/firebase/database/snapshot/Node;
move-result-object v8
add-int/lit8 v13, v7, -0x1
move-object/from16 v12, v18
goto :goto_3
:cond_2
move-wide/from16 v19, v7
.line 24
invoke-virtual {v3, v13}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;
move-result-object v7
check-cast v7, [B
invoke-direct {v1, v7}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->deserializeNode([B)Lcom/google/firebase/database/snapshot/Node;
move-result-object v8
.line 25
new-instance v12, Lcom/google/firebase/database/core/Path;
invoke-virtual {v2, v13}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;
move-result-object v7
check-cast v7, Ljava/lang/String;
invoke-direct {v12, v7}, Lcom/google/firebase/database/core/Path;-><init>(Ljava/lang/String;)V
.line 26
:goto_3
invoke-virtual {v12}, Lcom/google/firebase/database/core/Path;->getBack()Lcom/google/firebase/database/snapshot/ChildKey;
move-result-object v7
if-eqz v7, :cond_3
invoke-virtual {v12}, Lcom/google/firebase/database/core/Path;->getBack()Lcom/google/firebase/database/snapshot/ChildKey;
move-result-object v7
invoke-virtual {v7}, Lcom/google/firebase/database/snapshot/ChildKey;->isPriorityChildName()Z
move-result v7
if-eqz v7, :cond_3
.line 27
invoke-virtual {v14, v12, v8}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
goto :goto_4
.line 28
:cond_3
invoke-virtual {v12, v0}, Lcom/google/firebase/database/core/Path;->contains(Lcom/google/firebase/database/core/Path;)Z
move-result v7
if-eqz v7, :cond_4
xor-int/lit8 v6, v15, 0x1
const-string v7, "Descendants of path must come after ancestors."
.line 29
invoke-static {v6, v7}, Lcom/google/firebase/database/core/utilities/Utilities;->hardAssert(ZLjava/lang/String;)V
.line 30
invoke-static {v12, v0}, Lcom/google/firebase/database/core/Path;->getRelative(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/core/Path;)Lcom/google/firebase/database/core/Path;
move-result-object v6
invoke-interface {v8, v6}, Lcom/google/firebase/database/snapshot/Node;->getChild(Lcom/google/firebase/database/core/Path;)Lcom/google/firebase/database/snapshot/Node;
move-result-object v6
:goto_4
const/4 v7, 0x1
goto :goto_5
.line 31
:cond_4
invoke-virtual {v0, v12}, Lcom/google/firebase/database/core/Path;->contains(Lcom/google/firebase/database/core/Path;)Z
move-result v7
if-eqz v7, :cond_5
.line 32
invoke-static {v0, v12}, Lcom/google/firebase/database/core/Path;->getRelative(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/core/Path;)Lcom/google/firebase/database/core/Path;
move-result-object v7
.line 33
invoke-interface {v6, v7, v8}, Lcom/google/firebase/database/snapshot/Node;->updateChild(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;)Lcom/google/firebase/database/snapshot/Node;
move-result-object v6
const/4 v7, 0x1
const/4 v8, 0x1
move v15, v8
:goto_5
add-int/2addr v13, v7
move-wide/from16 v7, v19
goto/16 :goto_1
:cond_5
const/4 v2, 0x1
.line 34
new-instance v3, Ljava/lang/IllegalStateException;
const/4 v4, 0x2
new-array v4, v4, [Ljava/lang/Object;
const/4 v5, 0x0
aput-object v12, v4, v5
aput-object v0, v4, v2
const-string v0, "Loading an unrelated row with path %s for %s"
.line 35
invoke-static {v0, v4}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v0
invoke-direct {v3, v0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw v3
:cond_6
move-wide/from16 v19, v7
.line 36
invoke-virtual {v14}, Ljava/util/HashMap;->entrySet()Ljava/util/Set;
move-result-object v2
invoke-interface {v2}, Ljava/util/Set;->iterator()Ljava/util/Iterator;
move-result-object v2
:goto_6
invoke-interface {v2}, Ljava/util/Iterator;->hasNext()Z
move-result v7
if-eqz v7, :cond_7
invoke-interface {v2}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v7
check-cast v7, Ljava/util/Map$Entry;
.line 37
invoke-interface {v7}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;
move-result-object v8
check-cast v8, Lcom/google/firebase/database/core/Path;
.line 38
invoke-static {v0, v8}, Lcom/google/firebase/database/core/Path;->getRelative(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/core/Path;)Lcom/google/firebase/database/core/Path;
move-result-object v8
invoke-interface {v7}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;
move-result-object v7
check-cast v7, Lcom/google/firebase/database/snapshot/Node;
invoke-interface {v6, v8, v7}, Lcom/google/firebase/database/snapshot/Node;->updateChild(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;)Lcom/google/firebase/database/snapshot/Node;
move-result-object v6
goto :goto_6
.line 39
:cond_7
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v7
sub-long/2addr v7, v9
.line 40
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v9
sub-long/2addr v9, v4
.line 41
iget-object v2, v1, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {v2}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result v2
if-eqz v2, :cond_8
.line 42
iget-object v2, v1, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
sget-object v4, Ljava/util/Locale;->US:Ljava/util/Locale;
const/4 v5, 0x7
new-array v5, v5, [Ljava/lang/Object;
.line 43
invoke-virtual {v3}, Ljava/util/ArrayList;->size()I
move-result v3
invoke-static {v3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v3
const/4 v11, 0x0
aput-object v3, v5, v11
.line 44
invoke-static {v6}, Lcom/google/firebase/database/core/utilities/NodeSizeEstimator;->nodeCount(Lcom/google/firebase/database/snapshot/Node;)I
move-result v3
invoke-static {v3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v3
const/4 v11, 0x1
aput-object v3, v5, v11
const/4 v3, 0x2
aput-object v0, v5, v3
const/4 v0, 0x3
.line 45
invoke-static {v9, v10}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v3
aput-object v3, v5, v0
const/4 v0, 0x4
.line 46
invoke-static/range {v19 .. v20}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v3
aput-object v3, v5, v0
const/4 v0, 0x5
.line 47
invoke-static/range {v16 .. v17}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v3
aput-object v3, v5, v0
const/4 v0, 0x6
.line 48
invoke-static {v7, v8}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v3
aput-object v3, v5, v0
const-string v0, "Loaded a total of %d rows for a total of %d nodes at %s in %dms (Query: %dms, Loading: %dms, Serializing: %dms)"
.line 49
invoke-static {v4, v0, v5}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v0
const/4 v3, 0x0
new-array v3, v3, [Ljava/lang/Object;
.line 50
invoke-virtual {v2, v0, v3}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
:cond_8
return-object v6
:catchall_0
move-exception v0
.line 51
invoke-interface {v6}, Landroid/database/Cursor;->close()V
.line 52
throw v0
.end method
.method private loadNestedQuery(Lcom/google/firebase/database/core/Path;[Ljava/lang/String;)Landroid/database/Cursor;
.locals 11
.line 1
invoke-static {p1}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->pathToKey(Lcom/google/firebase/database/core/Path;)Ljava/lang/String;
move-result-object v0
.line 2
invoke-static {v0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->pathPrefixStartToPrefixEnd(Ljava/lang/String;)Ljava/lang/String;
move-result-object v1
.line 3
invoke-virtual {p1}, Lcom/google/firebase/database/core/Path;->size()I
move-result v2
add-int/lit8 v2, v2, 0x3
new-array v7, v2, [Ljava/lang/String;
.line 4
invoke-static {p1, v7}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->buildAncestorWhereClause(Lcom/google/firebase/database/core/Path;[Ljava/lang/String;)Ljava/lang/String;
move-result-object v2
const-string v3, " OR (path > ? AND path < ?)"
.line 5
invoke-static {v2, v3}, Lc/g;->a(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
move-result-object v6
.line 6
invoke-virtual {p1}, Lcom/google/firebase/database/core/Path;->size()I
move-result v2
add-int/lit8 v2, v2, 0x1
aput-object v0, v7, v2
.line 7
invoke-virtual {p1}, Lcom/google/firebase/database/core/Path;->size()I
move-result p1
add-int/lit8 p1, p1, 0x2
aput-object v1, v7, p1
.line 8
iget-object v3, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const-string v4, "serverCache"
const/4 v8, 0x0
const/4 v9, 0x0
const-string v10, "path"
move-object v5, p2
invoke-virtual/range {v3 .. v10}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;
move-result-object p1
return-object p1
.end method
.method private openDatabase(Landroid/content/Context;Ljava/lang/String;)Landroid/database/sqlite/SQLiteDatabase;
.locals 1
.line 1
new-instance v0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine$PersistentCacheOpenHelper;
invoke-direct {v0, p1, p2}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine$PersistentCacheOpenHelper;-><init>(Landroid/content/Context;Ljava/lang/String;)V
.line 2
:try_start_0
invoke-virtual {v0}, Landroid/database/sqlite/SQLiteOpenHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;
move-result-object p1
const-string p2, "PRAGMA locking_mode = EXCLUSIVE"
const/4 v0, 0x0
.line 3
invoke-virtual {p1, p2, v0}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;
move-result-object p2
invoke-interface {p2}, Landroid/database/Cursor;->close()V
.line 4
invoke-virtual {p1}, Landroid/database/sqlite/SQLiteDatabase;->beginTransaction()V
.line 5
invoke-virtual {p1}, Landroid/database/sqlite/SQLiteDatabase;->endTransaction()V
:try_end_0
.catch Landroid/database/sqlite/SQLiteException; {:try_start_0 .. :try_end_0} :catch_0
return-object p1
:catch_0
move-exception p1
.line 6
instance-of p2, p1, Landroid/database/sqlite/SQLiteDatabaseLockedException;
if-eqz p2, :cond_0
.line 7
new-instance p2, Lcom/google/firebase/database/DatabaseException;
const-string v0, "Failed to gain exclusive lock to Firebase Database\'s offline persistence. This generally means you are using Firebase Database from multiple processes in your app. Keep in mind that multi-process Android apps execute the code in your Application class in all processes, so you may need to avoid initializing FirebaseDatabase in your Application class. If you are intentionally using Firebase Database from multiple processes, you can only enable offline persistence (i.e. call setPersistenceEnabled(true)) in one of them."
invoke-direct {p2, v0, p1}, Lcom/google/firebase/database/DatabaseException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
throw p2
.line 8
:cond_0
throw p1
.end method
.method private partKey(Lcom/google/firebase/database/core/Path;I)Ljava/lang/String;
.locals 3
.line 1
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
invoke-static {p1}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->pathToKey(Lcom/google/firebase/database/core/Path;)Ljava/lang/String;
move-result-object p1
invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
sget-object p1, Ljava/util/Locale;->US:Ljava/util/Locale;
const/4 v1, 0x1
new-array v1, v1, [Ljava/lang/Object;
invoke-static {p2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object p2
const/4 v2, 0x0
aput-object p2, v1, v2
const-string p2, ".part-%04d"
invoke-static {p1, p2, v1}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object p1
invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p1
return-object p1
.end method
.method private static pathPrefixStartToPrefixEnd(Ljava/lang/String;)Ljava/lang/String;
.locals 3
const-string v0, "/"
.line 1
invoke-virtual {p0, v0}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z
move-result v0
const-string v1, "Path keys must end with a \'/\'"
invoke-static {v0, v1}, Lcom/google/firebase/database/core/utilities/Utilities;->hardAssert(ZLjava/lang/String;)V
.line 2
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
invoke-virtual {p0}, Ljava/lang/String;->length()I
move-result v1
add-int/lit8 v1, v1, -0x1
const/4 v2, 0x0
invoke-virtual {p0, v2, v1}, Ljava/lang/String;->substring(II)Ljava/lang/String;
move-result-object p0
invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const/16 p0, 0x30
invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p0
return-object p0
.end method
.method private static pathToKey(Lcom/google/firebase/database/core/Path;)Ljava/lang/String;
.locals 2
.line 1
invoke-virtual {p0}, Lcom/google/firebase/database/core/Path;->isEmpty()Z
move-result v0
const-string v1, "/"
if-eqz v0, :cond_0
return-object v1
.line 2
:cond_0
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
invoke-virtual {p0}, Lcom/google/firebase/database/core/Path;->toString()Ljava/lang/String;
move-result-object p0
invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p0
return-object p0
.end method
.method private pruneTreeRecursive(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/core/utilities/ImmutableTree;Lcom/google/firebase/database/core/utilities/ImmutableTree;Lcom/google/firebase/database/core/persistence/PruneForest;Ljava/util/List;)V
.locals 12
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/google/firebase/database/core/Path;",
"Lcom/google/firebase/database/core/Path;",
"Lcom/google/firebase/database/core/utilities/ImmutableTree<",
"Ljava/lang/Long;",
">;",
"Lcom/google/firebase/database/core/utilities/ImmutableTree<",
"Ljava/lang/Long;",
">;",
"Lcom/google/firebase/database/core/persistence/PruneForest;",
"Ljava/util/List<",
"Lcom/google/firebase/database/core/utilities/Pair<",
"Lcom/google/firebase/database/core/Path;",
"Lcom/google/firebase/database/snapshot/Node;",
">;>;)V"
}
.end annotation
move-object v7, p0
move-object/from16 v8, p4
move-object/from16 v9, p5
.line 1
invoke-virtual {p3}, Lcom/google/firebase/database/core/utilities/ImmutableTree;->getValue()Ljava/lang/Object;
move-result-object v0
if-eqz v0, :cond_1
const/4 v0, 0x0
.line 2
invoke-static {v0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v1
new-instance v2, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine$1;
invoke-direct {v2, p0, v8}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine$1;-><init>(Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;Lcom/google/firebase/database/core/utilities/ImmutableTree;)V
.line 3
invoke-virtual {v9, v1, v2}, Lcom/google/firebase/database/core/persistence/PruneForest;->foldKeptNodes(Ljava/lang/Object;Lcom/google/firebase/database/core/utilities/ImmutableTree$TreeVisitor;)Ljava/lang/Object;
move-result-object v1
check-cast v1, Ljava/lang/Integer;
invoke-virtual {v1}, Ljava/lang/Integer;->intValue()I
move-result v1
if-lez v1, :cond_2
.line 4
invoke-virtual {p1, p2}, Lcom/google/firebase/database/core/Path;->child(Lcom/google/firebase/database/core/Path;)Lcom/google/firebase/database/core/Path;
move-result-object v2
.line 5
iget-object v3, v7, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {v3}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result v3
if-eqz v3, :cond_0
.line 6
iget-object v3, v7, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
sget-object v4, Ljava/util/Locale;->US:Ljava/util/Locale;
const/4 v5, 0x2
new-array v5, v5, [Ljava/lang/Object;
.line 7
invoke-static {v1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v1
aput-object v1, v5, v0
const/4 v1, 0x1
aput-object v2, v5, v1
const-string v1, "Need to rewrite %d nodes below path %s"
.line 8
invoke-static {v4, v1, v5}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v1
new-array v0, v0, [Ljava/lang/Object;
.line 9
invoke-virtual {v3, v1, v0}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
.line 10
:cond_0
invoke-direct {p0, v2}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->loadNested(Lcom/google/firebase/database/core/Path;)Lcom/google/firebase/database/snapshot/Node;
move-result-object v5
const/4 v6, 0x0
.line 11
new-instance v10, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine$2;
move-object v0, v10
move-object v1, p0
move-object/from16 v2, p4
move-object/from16 v3, p6
move-object v4, p2
invoke-direct/range {v0 .. v5}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine$2;-><init>(Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;Lcom/google/firebase/database/core/utilities/ImmutableTree;Ljava/util/List;Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;)V
invoke-virtual {v9, v6, v10}, Lcom/google/firebase/database/core/persistence/PruneForest;->foldKeptNodes(Ljava/lang/Object;Lcom/google/firebase/database/core/utilities/ImmutableTree$TreeVisitor;)Ljava/lang/Object;
goto :goto_1
.line 12
:cond_1
invoke-virtual {p3}, Lcom/google/firebase/database/core/utilities/ImmutableTree;->getChildren()Lcom/google/firebase/database/collection/ImmutableSortedMap;
move-result-object v0
invoke-virtual {v0}, Lcom/google/firebase/database/collection/ImmutableSortedMap;->iterator()Ljava/util/Iterator;
move-result-object v10
:goto_0
invoke-interface {v10}, Ljava/util/Iterator;->hasNext()Z
move-result v0
if-eqz v0, :cond_2
invoke-interface {v10}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v0
check-cast v0, Ljava/util/Map$Entry;
.line 13
invoke-interface {v0}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;
move-result-object v1
check-cast v1, Lcom/google/firebase/database/snapshot/ChildKey;
.line 14
invoke-interface {v0}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;
move-result-object v2
check-cast v2, Lcom/google/firebase/database/snapshot/ChildKey;
invoke-virtual {v9, v2}, Lcom/google/firebase/database/core/persistence/PruneForest;->child(Lcom/google/firebase/database/snapshot/ChildKey;)Lcom/google/firebase/database/core/persistence/PruneForest;
move-result-object v5
move-object v11, p2
.line 15
invoke-virtual {p2, v1}, Lcom/google/firebase/database/core/Path;->child(Lcom/google/firebase/database/snapshot/ChildKey;)Lcom/google/firebase/database/core/Path;
move-result-object v2
.line 16
invoke-interface {v0}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;
move-result-object v0
move-object v3, v0
check-cast v3, Lcom/google/firebase/database/core/utilities/ImmutableTree;
.line 17
invoke-virtual {v8, v1}, Lcom/google/firebase/database/core/utilities/ImmutableTree;->getChild(Lcom/google/firebase/database/snapshot/ChildKey;)Lcom/google/firebase/database/core/utilities/ImmutableTree;
move-result-object v4
move-object v0, p0
move-object v1, p1
move-object/from16 v6, p6
.line 18
invoke-direct/range {v0 .. v6}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->pruneTreeRecursive(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/core/utilities/ImmutableTree;Lcom/google/firebase/database/core/utilities/ImmutableTree;Lcom/google/firebase/database/core/persistence/PruneForest;Ljava/util/List;)V
goto :goto_0
:cond_2
:goto_1
return-void
.end method
.method private removeNested(Ljava/lang/String;Lcom/google/firebase/database/core/Path;)I
.locals 4
.line 1
invoke-static {p2}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->pathToKey(Lcom/google/firebase/database/core/Path;)Ljava/lang/String;
move-result-object p2
.line 2
invoke-static {p2}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->pathPrefixStartToPrefixEnd(Ljava/lang/String;)Ljava/lang/String;
move-result-object v0
.line 3
iget-object v1, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const/4 v2, 0x2
new-array v2, v2, [Ljava/lang/String;
const/4 v3, 0x0
aput-object p2, v2, v3
const/4 p2, 0x1
aput-object v0, v2, p2
const-string p2, "path >= ? AND path < ?"
invoke-virtual {v1, p1, p2, v2}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I
move-result p1
return p1
.end method
.method private saveNested(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;)I
.locals 7
.line 1
invoke-static {p2}, Lcom/google/firebase/database/core/utilities/NodeSizeEstimator;->estimateSerializedNodeSize(Lcom/google/firebase/database/snapshot/Node;)J
move-result-wide v0
.line 2
instance-of v2, p2, Lcom/google/firebase/database/snapshot/ChildrenNode;
const/4 v3, 0x1
if-eqz v2, :cond_3
const-wide/16 v4, 0x4000
cmp-long v2, v0, v4
if-lez v2, :cond_3
.line 3
iget-object v2, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {v2}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result v2
const/4 v4, 0x0
if-eqz v2, :cond_0
.line 4
iget-object v2, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
sget-object v5, Ljava/util/Locale;->US:Ljava/util/Locale;
const/4 v6, 0x3
new-array v6, v6, [Ljava/lang/Object;
aput-object p1, v6, v4
.line 5
invoke-static {v0, v1}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v0
aput-object v0, v6, v3
const/4 v0, 0x2
const/16 v1, 0x4000
.line 6
invoke-static {v1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v1
aput-object v1, v6, v0
const-string v0, "Node estimated serialized size at path %s of %d bytes exceeds limit of %d bytes. Splitting up."
.line 7
invoke-static {v5, v0, v6}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v0
new-array v1, v4, [Ljava/lang/Object;
.line 8
invoke-virtual {v2, v0, v1}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
.line 9
:cond_0
invoke-interface {p2}, Ljava/lang/Iterable;->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_1
invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v1
check-cast v1, Lcom/google/firebase/database/snapshot/NamedNode;
.line 10
invoke-virtual {v1}, Lcom/google/firebase/database/snapshot/NamedNode;->getName()Lcom/google/firebase/database/snapshot/ChildKey;
move-result-object v2
invoke-virtual {p1, v2}, Lcom/google/firebase/database/core/Path;->child(Lcom/google/firebase/database/snapshot/ChildKey;)Lcom/google/firebase/database/core/Path;
move-result-object v2
invoke-virtual {v1}, Lcom/google/firebase/database/snapshot/NamedNode;->getNode()Lcom/google/firebase/database/snapshot/Node;
move-result-object v1
invoke-direct {p0, v2, v1}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->saveNested(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;)I
move-result v1
add-int/2addr v4, v1
goto :goto_0
.line 11
:cond_1
invoke-interface {p2}, Lcom/google/firebase/database/snapshot/Node;->getPriority()Lcom/google/firebase/database/snapshot/Node;
move-result-object v0
invoke-interface {v0}, Lcom/google/firebase/database/snapshot/Node;->isEmpty()Z
move-result v0
if-nez v0, :cond_2
.line 12
invoke-static {}, Lcom/google/firebase/database/snapshot/ChildKey;->getPriorityKey()Lcom/google/firebase/database/snapshot/ChildKey;
move-result-object v0
invoke-virtual {p1, v0}, Lcom/google/firebase/database/core/Path;->child(Lcom/google/firebase/database/snapshot/ChildKey;)Lcom/google/firebase/database/core/Path;
move-result-object v0
invoke-interface {p2}, Lcom/google/firebase/database/snapshot/Node;->getPriority()Lcom/google/firebase/database/snapshot/Node;
move-result-object p2
invoke-direct {p0, v0, p2}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->saveNode(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;)V
add-int/lit8 v4, v4, 0x1
.line 13
:cond_2
invoke-static {}, Lcom/google/firebase/database/snapshot/EmptyNode;->Empty()Lcom/google/firebase/database/snapshot/EmptyNode;
move-result-object p2
invoke-direct {p0, p1, p2}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->saveNode(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;)V
add-int/2addr v4, v3
return v4
.line 14
:cond_3
invoke-direct {p0, p1, p2}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->saveNode(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;)V
return v3
.end method
.method private saveNode(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;)V
.locals 9
const/4 v0, 0x1
.line 1
invoke-interface {p2, v0}, Lcom/google/firebase/database/snapshot/Node;->getValue(Z)Ljava/lang/Object;
move-result-object p2
invoke-direct {p0, p2}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->serializeObject(Ljava/lang/Object;)[B
move-result-object p2
.line 2
array-length v0, p2
const/4 v1, 0x5
const/4 v2, 0x0
const-string v3, "serverCache"
const-string v4, "value"
const-string v5, "path"
const/high16 v6, 0x40000
if-lt v0, v6, :cond_1
.line 3
invoke-static {p2, v6}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->splitBytes([BI)Ljava/util/List;
move-result-object p2
.line 4
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {v0}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result v0
const/4 v6, 0x0
if-eqz v0, :cond_0
.line 5
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
const-string v7, "Saving huge leaf node with "
invoke-static {v7}, Landroid/support/v4/media/d;->a(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v7
invoke-interface {p2}, Ljava/util/List;->size()I
move-result v8
invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
const-string v8, " parts."
invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v7}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v7
new-array v8, v6, [Ljava/lang/Object;
invoke-virtual {v0, v7, v8}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
.line 6
:cond_0
:goto_0
invoke-interface {p2}, Ljava/util/List;->size()I
move-result v0
if-ge v6, v0, :cond_2
.line 7
new-instance v0, Landroid/content/ContentValues;
invoke-direct {v0}, Landroid/content/ContentValues;-><init>()V
.line 8
invoke-direct {p0, p1, v6}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->partKey(Lcom/google/firebase/database/core/Path;I)Ljava/lang/String;
move-result-object v7
invoke-virtual {v0, v5, v7}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V
.line 9
invoke-interface {p2, v6}, Ljava/util/List;->get(I)Ljava/lang/Object;
move-result-object v7
check-cast v7, [B
invoke-virtual {v0, v4, v7}, Landroid/content/ContentValues;->put(Ljava/lang/String;[B)V
.line 10
iget-object v7, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
invoke-virtual {v7, v3, v2, v0, v1}, Landroid/database/sqlite/SQLiteDatabase;->insertWithOnConflict(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;I)J
add-int/lit8 v6, v6, 0x1
goto :goto_0
.line 11
:cond_1
new-instance v0, Landroid/content/ContentValues;
invoke-direct {v0}, Landroid/content/ContentValues;-><init>()V
.line 12
invoke-static {p1}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->pathToKey(Lcom/google/firebase/database/core/Path;)Ljava/lang/String;
move-result-object p1
invoke-virtual {v0, v5, p1}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V
.line 13
invoke-virtual {v0, v4, p2}, Landroid/content/ContentValues;->put(Ljava/lang/String;[B)V
.line 14
iget-object p1, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
invoke-virtual {p1, v3, v2, v0, v1}, Landroid/database/sqlite/SQLiteDatabase;->insertWithOnConflict(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;I)J
:cond_2
return-void
.end method
.method private saveWrite(Lcom/google/firebase/database/core/Path;JLjava/lang/String;[B)V
.locals 14
move-object v0, p0
move-object/from16 v1, p4
move-object/from16 v2, p5
.line 1
invoke-direct {p0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->verifyInsideTransaction()V
.line 2
iget-object v3, v0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const/4 v4, 0x1
new-array v4, v4, [Ljava/lang/String;
.line 3
invoke-static/range {p2 .. p3}, Ljava/lang/String;->valueOf(J)Ljava/lang/String;
move-result-object v5
const/4 v6, 0x0
aput-object v5, v4, v6
const-string v5, "writes"
const-string v7, "id = ?"
.line 4
invoke-virtual {v3, v5, v7, v4}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I
.line 5
array-length v3, v2
const/4 v4, 0x5
const-string v7, "node"
const-string v8, "part"
const-string v9, "type"
const-string v10, "path"
const-string v11, "id"
const/high16 v12, 0x40000
const/4 v13, 0x0
if-lt v3, v12, :cond_0
.line 6
invoke-static {v2, v12}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->splitBytes([BI)Ljava/util/List;
move-result-object v2
.line 7
:goto_0
invoke-interface {v2}, Ljava/util/List;->size()I
move-result v3
if-ge v6, v3, :cond_1
.line 8
new-instance v3, Landroid/content/ContentValues;
invoke-direct {v3}, Landroid/content/ContentValues;-><init>()V
.line 9
invoke-static/range {p2 .. p3}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v12
invoke-virtual {v3, v11, v12}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Long;)V
.line 10
invoke-static {p1}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->pathToKey(Lcom/google/firebase/database/core/Path;)Ljava/lang/String;
move-result-object v12
invoke-virtual {v3, v10, v12}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V
.line 11
invoke-virtual {v3, v9, v1}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V
.line 12
invoke-static {v6}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v12
invoke-virtual {v3, v8, v12}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Integer;)V
.line 13
invoke-interface {v2, v6}, Ljava/util/List;->get(I)Ljava/lang/Object;
move-result-object v12
check-cast v12, [B
invoke-virtual {v3, v7, v12}, Landroid/content/ContentValues;->put(Ljava/lang/String;[B)V
.line 14
iget-object v12, v0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
invoke-virtual {v12, v5, v13, v3, v4}, Landroid/database/sqlite/SQLiteDatabase;->insertWithOnConflict(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;I)J
add-int/lit8 v6, v6, 0x1
goto :goto_0
.line 15
:cond_0
new-instance v3, Landroid/content/ContentValues;
invoke-direct {v3}, Landroid/content/ContentValues;-><init>()V
.line 16
invoke-static/range {p2 .. p3}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v6
invoke-virtual {v3, v11, v6}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Long;)V
.line 17
invoke-static {p1}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->pathToKey(Lcom/google/firebase/database/core/Path;)Ljava/lang/String;
move-result-object v6
invoke-virtual {v3, v10, v6}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V
.line 18
invoke-virtual {v3, v9, v1}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V
.line 19
invoke-virtual {v3, v8, v13}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Integer;)V
.line 20
invoke-virtual {v3, v7, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;[B)V
.line 21
iget-object v1, v0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
invoke-virtual {v1, v5, v13, v3, v4}, Landroid/database/sqlite/SQLiteDatabase;->insertWithOnConflict(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;I)J
:cond_1
return-void
.end method
.method private serializeObject(Ljava/lang/Object;)[B
.locals 2
.line 1
:try_start_0
invoke-static {p1}, Lcom/google/firebase/database/util/JsonMapper;->serializeJsonValue(Ljava/lang/Object;)Ljava/lang/String;
move-result-object p1
sget-object v0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->UTF8_CHARSET:Ljava/nio/charset/Charset;
invoke-virtual {p1, v0}, Ljava/lang/String;->getBytes(Ljava/nio/charset/Charset;)[B
move-result-object p1
:try_end_0
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
return-object p1
:catch_0
move-exception p1
.line 2
new-instance v0, Ljava/lang/RuntimeException;
const-string v1, "Could not serialize leaf node"
invoke-direct {v0, v1, p1}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
throw v0
.end method
.method private static splitBytes([BI)Ljava/util/List;
.locals 7
.annotation system Ldalvik/annotation/Signature;
value = {
"([BI)",
"Ljava/util/List<",
"[B>;"
}
.end annotation
.line 1
array-length v0, p0
add-int/lit8 v0, v0, -0x1
div-int/2addr v0, p1
add-int/lit8 v0, v0, 0x1
.line 2
new-instance v1, Ljava/util/ArrayList;
invoke-direct {v1, v0}, Ljava/util/ArrayList;-><init>(I)V
const/4 v2, 0x0
move v3, v2
:goto_0
if-ge v3, v0, :cond_0
.line 3
array-length v4, p0
mul-int v5, v3, p1
sub-int/2addr v4, v5
invoke-static {p1, v4}, Ljava/lang/Math;->min(II)I
move-result v4
.line 4
new-array v6, v4, [B
.line 5
invoke-static {p0, v5, v6, v2, v4}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
.line 6
invoke-virtual {v1, v6}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
add-int/lit8 v3, v3, 0x1
goto :goto_0
:cond_0
return-object v1
.end method
.method private splitNodeRunLength(Lcom/google/firebase/database/core/Path;Ljava/util/List;I)I
.locals 4
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/google/firebase/database/core/Path;",
"Ljava/util/List<",
"Ljava/lang/String;",
">;I)I"
}
.end annotation
add-int/lit8 v0, p3, 0x1
.line 1
invoke-static {p1}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->pathToKey(Lcom/google/firebase/database/core/Path;)Ljava/lang/String;
move-result-object v1
.line 2
invoke-interface {p2, p3}, Ljava/util/List;->get(I)Ljava/lang/Object;
move-result-object v2
check-cast v2, Ljava/lang/String;
invoke-virtual {v2, v1}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
move-result v2
if-eqz v2, :cond_3
.line 3
:goto_0
invoke-interface {p2}, Ljava/util/List;->size()I
move-result v2
if-ge v0, v2, :cond_0
.line 4
invoke-interface {p2, v0}, Ljava/util/List;->get(I)Ljava/lang/Object;
move-result-object v2
check-cast v2, Ljava/lang/String;
sub-int v3, v0, p3
invoke-direct {p0, p1, v3}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->partKey(Lcom/google/firebase/database/core/Path;I)Ljava/lang/String;
move-result-object v3
invoke-virtual {v2, v3}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v2
if-eqz v2, :cond_0
add-int/lit8 v0, v0, 0x1
goto :goto_0
.line 5
:cond_0
invoke-interface {p2}, Ljava/util/List;->size()I
move-result p1
if-ge v0, p1, :cond_2
.line 6
invoke-interface {p2, v0}, Ljava/util/List;->get(I)Ljava/lang/Object;
move-result-object p1
check-cast p1, Ljava/lang/String;
new-instance p2, Ljava/lang/StringBuilder;
invoke-direct {p2}, Ljava/lang/StringBuilder;-><init>()V
invoke-virtual {p2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string v1, ".part-"
invoke-virtual {p2, v1}, 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-virtual {p1, p2}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
move-result p1
if-nez p1, :cond_1
goto :goto_1
.line 7
:cond_1
new-instance p1, Ljava/lang/IllegalStateException;
const-string p2, "Run did not finish with all parts"
invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p1
:cond_2
:goto_1
sub-int/2addr v0, p3
return v0
.line 8
:cond_3
new-instance p1, Ljava/lang/IllegalStateException;
const-string p2, "Extracting split nodes needs to start with path prefix"
invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p1
.end method
.method private updateServerCache(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;Z)V
.locals 7
.line 1
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v0
const-string v2, "serverCache"
const/4 v3, 0x0
if-nez p3, :cond_0
.line 2
invoke-direct {p0, v2, p1}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->removeNested(Ljava/lang/String;Lcom/google/firebase/database/core/Path;)I
move-result p3
.line 3
invoke-direct {p0, p1, p2}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->saveNested(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;)I
move-result p2
goto :goto_1
.line 4
:cond_0
invoke-interface {p2}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;
move-result-object p2
move p3, v3
move v4, p3
:goto_0
invoke-interface {p2}, Ljava/util/Iterator;->hasNext()Z
move-result v5
if-eqz v5, :cond_1
invoke-interface {p2}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v5
check-cast v5, Lcom/google/firebase/database/snapshot/NamedNode;
.line 5
invoke-virtual {v5}, Lcom/google/firebase/database/snapshot/NamedNode;->getName()Lcom/google/firebase/database/snapshot/ChildKey;
move-result-object v6
invoke-virtual {p1, v6}, Lcom/google/firebase/database/core/Path;->child(Lcom/google/firebase/database/snapshot/ChildKey;)Lcom/google/firebase/database/core/Path;
move-result-object v6
invoke-direct {p0, v2, v6}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->removeNested(Ljava/lang/String;Lcom/google/firebase/database/core/Path;)I
move-result v6
add-int/2addr v4, v6
.line 6
invoke-virtual {v5}, Lcom/google/firebase/database/snapshot/NamedNode;->getName()Lcom/google/firebase/database/snapshot/ChildKey;
move-result-object v6
invoke-virtual {p1, v6}, Lcom/google/firebase/database/core/Path;->child(Lcom/google/firebase/database/snapshot/ChildKey;)Lcom/google/firebase/database/core/Path;
move-result-object v6
invoke-virtual {v5}, Lcom/google/firebase/database/snapshot/NamedNode;->getNode()Lcom/google/firebase/database/snapshot/Node;
move-result-object v5
invoke-direct {p0, v6, v5}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->saveNested(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;)I
move-result v5
add-int/2addr p3, v5
goto :goto_0
:cond_1
move p2, p3
move p3, v4
.line 7
:goto_1
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v4
sub-long/2addr v4, v0
.line 8
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {v0}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result v0
if-eqz v0, :cond_2
.line 9
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
sget-object v1, Ljava/util/Locale;->US:Ljava/util/Locale;
const/4 v2, 0x4
new-array v2, v2, [Ljava/lang/Object;
.line 10
invoke-static {p2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object p2
aput-object p2, v2, v3
const/4 p2, 0x1
.line 11
invoke-static {p3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object p3
aput-object p3, v2, p2
const/4 p2, 0x2
.line 12
invoke-virtual {p1}, Lcom/google/firebase/database/core/Path;->toString()Ljava/lang/String;
move-result-object p1
aput-object p1, v2, p2
const/4 p1, 0x3
.line 13
invoke-static {v4, v5}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object p2
aput-object p2, v2, p1
const-string p1, "Persisted a total of %d rows and deleted %d rows for a set at %s in %dms"
.line 14
invoke-static {v1, p1, v2}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object p1
new-array p2, v3, [Ljava/lang/Object;
.line 15
invoke-virtual {v0, p1, p2}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
:cond_2
return-void
.end method
.method private verifyInsideTransaction()V
.locals 2
.line 1
iget-boolean v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->insideTransaction:Z
const-string v1, "Transaction expected to already be in progress."
invoke-static {v0, v1}, Lcom/google/firebase/database/core/utilities/Utilities;->hardAssert(ZLjava/lang/String;)V
return-void
.end method
# virtual methods
.method public beginTransaction()V
.locals 4
.line 1
iget-boolean v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->insideTransaction:Z
const/4 v1, 0x1
xor-int/2addr v0, v1
const-string v2, "runInTransaction called when an existing transaction is already in progress."
invoke-static {v0, v2}, Lcom/google/firebase/database/core/utilities/Utilities;->hardAssert(ZLjava/lang/String;)V
.line 2
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {v0}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result v0
if-eqz v0, :cond_0
.line 3
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
const/4 v2, 0x0
new-array v2, v2, [Ljava/lang/Object;
const-string v3, "Starting transaction."
invoke-virtual {v0, v3, v2}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
.line 4
:cond_0
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->beginTransaction()V
.line 5
iput-boolean v1, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->insideTransaction:Z
.line 6
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v0
iput-wide v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->transactionStart:J
return-void
.end method
.method public close()V
.locals 1
.line 1
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->close()V
return-void
.end method
.method public deleteTrackedQuery(J)V
.locals 5
.line 1
invoke-direct {p0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->verifyInsideTransaction()V
.line 2
invoke-static {p1, p2}, Ljava/lang/String;->valueOf(J)Ljava/lang/String;
move-result-object p1
.line 3
iget-object p2, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const/4 v0, 0x1
new-array v1, v0, [Ljava/lang/String;
const/4 v2, 0x0
aput-object p1, v1, v2
const-string v3, "trackedQueries"
const-string v4, "id = ?"
invoke-virtual {p2, v3, v4, v1}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I
.line 4
iget-object p2, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
new-array v0, v0, [Ljava/lang/String;
aput-object p1, v0, v2
const-string p1, "trackedKeys"
invoke-virtual {p2, p1, v4, v0}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I
return-void
.end method
.method public endTransaction()V
.locals 6
.line 1
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->endTransaction()V
const/4 v0, 0x0
.line 2
iput-boolean v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->insideTransaction:Z
.line 3
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v1
iget-wide v3, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->transactionStart:J
sub-long/2addr v1, v3
.line 4
iget-object v3, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {v3}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result v3
if-eqz v3, :cond_0
.line 5
iget-object v3, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
sget-object v4, Ljava/util/Locale;->US:Ljava/util/Locale;
const/4 v5, 0x1
new-array v5, v5, [Ljava/lang/Object;
invoke-static {v1, v2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v1
aput-object v1, v5, v0
const-string v1, "Transaction completed. Elapsed: %dms"
invoke-static {v4, v1, v5}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v1
new-array v0, v0, [Ljava/lang/Object;
invoke-virtual {v3, v1, v0}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
:cond_0
return-void
.end method
.method public loadTrackedQueries()Ljava/util/List;
.locals 17
.annotation system Ldalvik/annotation/Signature;
value = {
"()",
"Ljava/util/List<",
"Lcom/google/firebase/database/core/persistence/TrackedQuery;",
">;"
}
.end annotation
move-object/from16 v1, p0
const-string v2, "id"
const-string v3, "path"
const-string v4, "queryParams"
const-string v5, "lastUse"
const-string v6, "complete"
const-string v7, "active"
.line 1
filled-new-array/range {v2 .. v7}, [Ljava/lang/String;
move-result-object v10
.line 2
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v2
.line 3
iget-object v8, v1, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const-string v9, "trackedQueries"
const/4 v11, 0x0
const/4 v12, 0x0
const/4 v13, 0x0
const/4 v14, 0x0
const-string v15, "id"
.line 4
invoke-virtual/range {v8 .. v15}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;
move-result-object v4
.line 5
new-instance v0, Ljava/util/ArrayList;
invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
.line 6
:goto_0
:try_start_0
invoke-interface {v4}, Landroid/database/Cursor;->moveToNext()Z
move-result v5
const/4 v6, 0x2
const/4 v7, 0x1
const/4 v8, 0x0
if-eqz v5, :cond_2
.line 7
invoke-interface {v4, v8}, Landroid/database/Cursor;->getLong(I)J
move-result-wide v10
.line 8
new-instance v5, Lcom/google/firebase/database/core/Path;
invoke-interface {v4, v7}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;
move-result-object v9
invoke-direct {v5, v9}, Lcom/google/firebase/database/core/Path;-><init>(Ljava/lang/String;)V
.line 9
invoke-interface {v4, v6}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;
move-result-object v6
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
.line 10
:try_start_1
invoke-static {v6}, Lcom/google/firebase/database/util/JsonMapper;->parseJson(Ljava/lang/String;)Ljava/util/Map;
move-result-object v6
:try_end_1
.catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_0
.catchall {:try_start_1 .. :try_end_1} :catchall_0
.line 11
:try_start_2
invoke-static {v5, v6}, Lcom/google/firebase/database/core/view/QuerySpec;->fromPathAndQueryObject(Lcom/google/firebase/database/core/Path;Ljava/util/Map;)Lcom/google/firebase/database/core/view/QuerySpec;
move-result-object v12
const/4 v5, 0x3
.line 12
invoke-interface {v4, v5}, Landroid/database/Cursor;->getLong(I)J
move-result-wide v13
const/4 v5, 0x4
.line 13
invoke-interface {v4, v5}, Landroid/database/Cursor;->getInt(I)I
move-result v5
if-eqz v5, :cond_0
move v15, v7
goto :goto_1
:cond_0
move v15, v8
:goto_1
const/4 v5, 0x5
.line 14
invoke-interface {v4, v5}, Landroid/database/Cursor;->getInt(I)I
move-result v5
if-eqz v5, :cond_1
move/from16 v16, v7
goto :goto_2
:cond_1
move/from16 v16, v8
.line 15
:goto_2
new-instance v5, Lcom/google/firebase/database/core/persistence/TrackedQuery;
move-object v9, v5
invoke-direct/range {v9 .. v16}, Lcom/google/firebase/database/core/persistence/TrackedQuery;-><init>(JLcom/google/firebase/database/core/view/QuerySpec;JZZ)V
.line 16
invoke-virtual {v0, v5}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
goto :goto_0
:catch_0
move-exception v0
move-object v2, v0
.line 17
new-instance v0, Ljava/lang/RuntimeException;
invoke-direct {v0, v2}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/Throwable;)V
throw v0
.line 18
:cond_2
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v9
sub-long/2addr v9, v2
.line 19
iget-object v2, v1, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {v2}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result v2
if-eqz v2, :cond_3
.line 20
iget-object v2, v1, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
sget-object v3, Ljava/util/Locale;->US:Ljava/util/Locale;
const-string v5, "Loaded %d tracked queries in %dms"
new-array v6, v6, [Ljava/lang/Object;
.line 21
invoke-virtual {v0}, Ljava/util/ArrayList;->size()I
move-result v11
invoke-static {v11}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v11
aput-object v11, v6, v8
invoke-static {v9, v10}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v9
aput-object v9, v6, v7
.line 22
invoke-static {v3, v5, v6}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v3
new-array v5, v8, [Ljava/lang/Object;
.line 23
invoke-virtual {v2, v3, v5}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
:try_end_2
.catchall {:try_start_2 .. :try_end_2} :catchall_0
.line 24
:cond_3
invoke-interface {v4}, Landroid/database/Cursor;->close()V
return-object v0
:catchall_0
move-exception v0
invoke-interface {v4}, Landroid/database/Cursor;->close()V
.line 25
throw v0
.end method
.method public loadTrackedQueryKeys(J)Ljava/util/Set;
.locals 0
.annotation system Ldalvik/annotation/Signature;
value = {
"(J)",
"Ljava/util/Set<",
"Lcom/google/firebase/database/snapshot/ChildKey;",
">;"
}
.end annotation
.line 1
invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object p1
invoke-static {p1}, Ljava/util/Collections;->singleton(Ljava/lang/Object;)Ljava/util/Set;
move-result-object p1
invoke-virtual {p0, p1}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->loadTrackedQueryKeys(Ljava/util/Set;)Ljava/util/Set;
move-result-object p1
return-object p1
.end method
.method public loadTrackedQueryKeys(Ljava/util/Set;)Ljava/util/Set;
.locals 13
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Ljava/util/Set<",
"Ljava/lang/Long;",
">;)",
"Ljava/util/Set<",
"Lcom/google/firebase/database/snapshot/ChildKey;",
">;"
}
.end annotation
const-string v0, "key"
.line 2
filled-new-array {v0}, [Ljava/lang/String;
move-result-object v4
.line 3
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v11
const-string v0, "id IN ("
.line 4
invoke-static {v0}, Landroid/support/v4/media/d;->a(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v0
.line 5
invoke-direct {p0, p1}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->commaSeparatedList(Ljava/util/Collection;)Ljava/lang/String;
move-result-object v1
const-string v2, ")"
invoke-static {v0, v1, v2}, Landroidx/camera/camera2/internal/b;->a(Ljava/lang/StringBuilder;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
move-result-object v5
.line 6
iget-object v1, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const/4 v2, 0x1
const-string v3, "trackedKeys"
const/4 v6, 0x0
const/4 v7, 0x0
const/4 v8, 0x0
const/4 v9, 0x0
const/4 v10, 0x0
.line 7
invoke-virtual/range {v1 .. v10}, Landroid/database/sqlite/SQLiteDatabase;->query(ZLjava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;
move-result-object v0
.line 8
new-instance v1, Ljava/util/HashSet;
invoke-direct {v1}, Ljava/util/HashSet;-><init>()V
.line 9
:goto_0
:try_start_0
invoke-interface {v0}, Landroid/database/Cursor;->moveToNext()Z
move-result v2
const/4 v3, 0x0
if-eqz v2, :cond_0
.line 10
invoke-interface {v0, v3}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;
move-result-object v2
.line 11
invoke-static {v2}, Lcom/google/firebase/database/snapshot/ChildKey;->fromString(Ljava/lang/String;)Lcom/google/firebase/database/snapshot/ChildKey;
move-result-object v2
invoke-virtual {v1, v2}, Ljava/util/HashSet;->add(Ljava/lang/Object;)Z
goto :goto_0
.line 12
:cond_0
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v4
sub-long/2addr v4, v11
.line 13
iget-object v2, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {v2}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result v2
if-eqz v2, :cond_1
.line 14
iget-object v2, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
sget-object v6, Ljava/util/Locale;->US:Ljava/util/Locale;
const-string v7, "Loaded %d tracked queries keys for tracked queries %s in %dms"
const/4 v8, 0x3
new-array v8, v8, [Ljava/lang/Object;
.line 15
invoke-virtual {v1}, Ljava/util/HashSet;->size()I
move-result v9
invoke-static {v9}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v9
aput-object v9, v8, v3
const/4 v9, 0x1
.line 16
invoke-virtual {p1}, Ljava/lang/Object;->toString()Ljava/lang/String;
move-result-object p1
aput-object p1, v8, v9
const/4 p1, 0x2
.line 17
invoke-static {v4, v5}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v4
aput-object v4, v8, p1
.line 18
invoke-static {v6, v7, v8}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object p1
new-array v3, v3, [Ljava/lang/Object;
.line 19
invoke-virtual {v2, p1, v3}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
.line 20
:cond_1
invoke-interface {v0}, Landroid/database/Cursor;->close()V
return-object v1
:catchall_0
move-exception p1
invoke-interface {v0}, Landroid/database/Cursor;->close()V
.line 21
throw p1
.end method
.method public loadUserWrites()Ljava/util/List;
.locals 14
.annotation system Ldalvik/annotation/Signature;
value = {
"()",
"Ljava/util/List<",
"Lcom/google/firebase/database/core/UserWriteRecord;",
">;"
}
.end annotation
const-string v0, "id"
const-string v1, "path"
const-string v2, "type"
const-string v3, "part"
const-string v4, "node"
.line 1
filled-new-array {v0, v1, v2, v3, v4}, [Ljava/lang/String;
move-result-object v7
.line 2
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v0
.line 3
iget-object v5, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const-string v6, "writes"
const/4 v8, 0x0
const/4 v9, 0x0
const/4 v10, 0x0
const/4 v11, 0x0
const-string v12, "id, part"
.line 4
invoke-virtual/range {v5 .. v12}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;
move-result-object v2
.line 5
new-instance v3, Ljava/util/ArrayList;
invoke-direct {v3}, Ljava/util/ArrayList;-><init>()V
.line 6
:goto_0
:try_start_0
invoke-interface {v2}, Landroid/database/Cursor;->moveToNext()Z
move-result v4
const/4 v5, 0x2
const/4 v6, 0x1
const/4 v7, 0x0
if-eqz v4, :cond_5
.line 7
invoke-interface {v2, v7}, Landroid/database/Cursor;->getLong(I)J
move-result-wide v9
.line 8
new-instance v11, Lcom/google/firebase/database/core/Path;
invoke-interface {v2, v6}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;
move-result-object v4
invoke-direct {v11, v4}, Lcom/google/firebase/database/core/Path;-><init>(Ljava/lang/String;)V
.line 9
invoke-interface {v2, v5}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;
move-result-object v4
const/4 v5, 0x3
.line 10
invoke-interface {v2, v5}, Landroid/database/Cursor;->isNull(I)Z
move-result v5
const/4 v6, 0x4
if-eqz v5, :cond_0
.line 11
invoke-interface {v2, v6}, Landroid/database/Cursor;->getBlob(I)[B
move-result-object v5
goto :goto_1
.line 12
:cond_0
new-instance v5, Ljava/util/ArrayList;
invoke-direct {v5}, Ljava/util/ArrayList;-><init>()V
.line 13
:cond_1
invoke-interface {v2, v6}, Landroid/database/Cursor;->getBlob(I)[B
move-result-object v8
invoke-virtual {v5, v8}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
.line 14
invoke-interface {v2}, Landroid/database/Cursor;->moveToNext()Z
move-result v8
if-eqz v8, :cond_2
invoke-interface {v2, v7}, Landroid/database/Cursor;->getLong(I)J
move-result-wide v12
cmp-long v8, v12, v9
if-eqz v8, :cond_1
.line 15
:cond_2
invoke-interface {v2}, Landroid/database/Cursor;->moveToPrevious()Z
.line 16
invoke-direct {p0, v5}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->joinBytes(Ljava/util/List;)[B
move-result-object v5
.line 17
:goto_1
new-instance v6, Ljava/lang/String;
sget-object v7, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->UTF8_CHARSET:Ljava/nio/charset/Charset;
invoke-direct {v6, v5, v7}, Ljava/lang/String;-><init>([BLjava/nio/charset/Charset;)V
.line 18
invoke-static {v6}, Lcom/google/firebase/database/util/JsonMapper;->parseJsonValue(Ljava/lang/String;)Ljava/lang/Object;
move-result-object v5
const-string v6, "o"
.line 19
invoke-virtual {v6, v4}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v6
if-eqz v6, :cond_3
.line 20
invoke-static {v5}, Lcom/google/firebase/database/snapshot/NodeUtilities;->NodeFromJSON(Ljava/lang/Object;)Lcom/google/firebase/database/snapshot/Node;
move-result-object v12
.line 21
new-instance v4, Lcom/google/firebase/database/core/UserWriteRecord;
const/4 v13, 0x1
move-object v8, v4
invoke-direct/range {v8 .. v13}, Lcom/google/firebase/database/core/UserWriteRecord;-><init>(JLcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;Z)V
goto :goto_2
:cond_3
const-string v6, "m"
.line 22
invoke-virtual {v6, v4}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v6
if-eqz v6, :cond_4
.line 23
check-cast v5, Ljava/util/Map;
invoke-static {v5}, Lcom/google/firebase/database/core/CompoundWrite;->fromValue(Ljava/util/Map;)Lcom/google/firebase/database/core/CompoundWrite;
move-result-object v4
.line 24
new-instance v5, Lcom/google/firebase/database/core/UserWriteRecord;
invoke-direct {v5, v9, v10, v11, v4}, Lcom/google/firebase/database/core/UserWriteRecord;-><init>(JLcom/google/firebase/database/core/Path;Lcom/google/firebase/database/core/CompoundWrite;)V
move-object v4, v5
.line 25
:goto_2
invoke-virtual {v3, v4}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
goto :goto_0
.line 26
:cond_4
new-instance v0, Ljava/lang/IllegalStateException;
new-instance v1, Ljava/lang/StringBuilder;
invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
const-string v3, "Got invalid write type: "
invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v1, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw v0
.line 27
:cond_5
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v8
sub-long/2addr v8, v0
.line 28
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {v0}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result v0
if-eqz v0, :cond_6
.line 29
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
sget-object v1, Ljava/util/Locale;->US:Ljava/util/Locale;
const-string v4, "Loaded %d writes in %dms"
new-array v5, v5, [Ljava/lang/Object;
invoke-virtual {v3}, Ljava/util/ArrayList;->size()I
move-result v10
invoke-static {v10}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v10
aput-object v10, v5, v7
invoke-static {v8, v9}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v8
aput-object v8, v5, v6
invoke-static {v1, v4, v5}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v1
new-array v4, v7, [Ljava/lang/Object;
invoke-virtual {v0, v1, v4}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
:try_end_0
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
.line 30
:cond_6
invoke-interface {v2}, Landroid/database/Cursor;->close()V
return-object v3
:catchall_0
move-exception v0
goto :goto_3
:catch_0
move-exception v0
.line 31
:try_start_1
new-instance v1, Ljava/lang/RuntimeException;
const-string v3, "Failed to load writes"
invoke-direct {v1, v3, v0}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
throw v1
:try_end_1
.catchall {:try_start_1 .. :try_end_1} :catchall_0
.line 32
:goto_3
invoke-interface {v2}, Landroid/database/Cursor;->close()V
.line 33
throw v0
.end method
.method public mergeIntoServerCache(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/core/CompoundWrite;)V
.locals 8
.line 3
invoke-direct {p0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->verifyInsideTransaction()V
.line 4
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v0
.line 5
invoke-virtual {p2}, Lcom/google/firebase/database/core/CompoundWrite;->iterator()Ljava/util/Iterator;
move-result-object p2
const/4 v2, 0x0
move v3, v2
move v4, v3
:goto_0
invoke-interface {p2}, Ljava/util/Iterator;->hasNext()Z
move-result v5
if-eqz v5, :cond_0
invoke-interface {p2}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v5
check-cast v5, Ljava/util/Map$Entry;
.line 6
invoke-interface {v5}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;
move-result-object v6
check-cast v6, Lcom/google/firebase/database/core/Path;
invoke-virtual {p1, v6}, Lcom/google/firebase/database/core/Path;->child(Lcom/google/firebase/database/core/Path;)Lcom/google/firebase/database/core/Path;
move-result-object v6
const-string v7, "serverCache"
invoke-direct {p0, v7, v6}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->removeNested(Ljava/lang/String;Lcom/google/firebase/database/core/Path;)I
move-result v6
add-int/2addr v3, v6
.line 7
invoke-interface {v5}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;
move-result-object v6
check-cast v6, Lcom/google/firebase/database/core/Path;
invoke-virtual {p1, v6}, Lcom/google/firebase/database/core/Path;->child(Lcom/google/firebase/database/core/Path;)Lcom/google/firebase/database/core/Path;
move-result-object v6
invoke-interface {v5}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;
move-result-object v5
check-cast v5, Lcom/google/firebase/database/snapshot/Node;
invoke-direct {p0, v6, v5}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->saveNested(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;)I
move-result v5
add-int/2addr v4, v5
goto :goto_0
.line 8
:cond_0
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v5
sub-long/2addr v5, v0
.line 9
iget-object p2, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {p2}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result p2
if-eqz p2, :cond_1
.line 10
iget-object p2, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
sget-object v0, Ljava/util/Locale;->US:Ljava/util/Locale;
const/4 v1, 0x4
new-array v1, v1, [Ljava/lang/Object;
.line 11
invoke-static {v4}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v4
aput-object v4, v1, v2
const/4 v4, 0x1
.line 12
invoke-static {v3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v3
aput-object v3, v1, v4
const/4 v3, 0x2
.line 13
invoke-virtual {p1}, Lcom/google/firebase/database/core/Path;->toString()Ljava/lang/String;
move-result-object p1
aput-object p1, v1, v3
const/4 p1, 0x3
.line 14
invoke-static {v5, v6}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v3
aput-object v3, v1, p1
const-string p1, "Persisted a total of %d rows and deleted %d rows for a merge at %s in %dms"
.line 15
invoke-static {v0, p1, v1}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object p1
new-array v0, v2, [Ljava/lang/Object;
.line 16
invoke-virtual {p2, p1, v0}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
:cond_1
return-void
.end method
.method public mergeIntoServerCache(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;)V
.locals 1
.line 1
invoke-direct {p0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->verifyInsideTransaction()V
const/4 v0, 0x1
.line 2
invoke-direct {p0, p1, p2, v0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->updateServerCache(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;Z)V
return-void
.end method
.method public overwriteServerCache(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;)V
.locals 1
.line 1
invoke-direct {p0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->verifyInsideTransaction()V
const/4 v0, 0x0
.line 2
invoke-direct {p0, p1, p2, v0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->updateServerCache(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;Z)V
return-void
.end method
.method public pruneCache(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/core/persistence/PruneForest;)V
.locals 16
move-object/from16 v7, p0
move-object/from16 v8, p1
move-object/from16 v5, p2
.line 1
invoke-virtual/range {p2 .. p2}, Lcom/google/firebase/database/core/persistence/PruneForest;->prunesAnything()Z
move-result v0
if-nez v0, :cond_0
return-void
.line 2
:cond_0
invoke-direct/range {p0 .. p0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->verifyInsideTransaction()V
.line 3
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v9
const-string v0, "rowid"
const-string v1, "path"
.line 4
filled-new-array {v0, v1}, [Ljava/lang/String;
move-result-object v0
invoke-direct {v7, v8, v0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->loadNestedQuery(Lcom/google/firebase/database/core/Path;[Ljava/lang/String;)Landroid/database/Cursor;
move-result-object v0
.line 5
new-instance v1, Lcom/google/firebase/database/core/utilities/ImmutableTree;
const/4 v11, 0x0
invoke-direct {v1, v11}, Lcom/google/firebase/database/core/utilities/ImmutableTree;-><init>(Ljava/lang/Object;)V
.line 6
new-instance v2, Lcom/google/firebase/database/core/utilities/ImmutableTree;
invoke-direct {v2, v11}, Lcom/google/firebase/database/core/utilities/ImmutableTree;-><init>(Ljava/lang/Object;)V
move-object v12, v1
move-object v4, v2
.line 7
:goto_0
invoke-interface {v0}, Landroid/database/Cursor;->moveToNext()Z
move-result v1
const/4 v13, 0x1
const/4 v14, 0x0
if-eqz v1, :cond_4
.line 8
invoke-interface {v0, v14}, Landroid/database/Cursor;->getLong(I)J
move-result-wide v1
.line 9
new-instance v3, Lcom/google/firebase/database/core/Path;
invoke-interface {v0, v13}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;
move-result-object v6
invoke-direct {v3, v6}, Lcom/google/firebase/database/core/Path;-><init>(Ljava/lang/String;)V
.line 10
invoke-virtual {v8, v3}, Lcom/google/firebase/database/core/Path;->contains(Lcom/google/firebase/database/core/Path;)Z
move-result v6
const-string v13, "We are pruning at "
if-nez v6, :cond_1
.line 11
iget-object v1, v7, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
new-instance v2, Ljava/lang/StringBuilder;
invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
invoke-virtual {v2, v13}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v2, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
const-string v6, " but we have data stored higher up at "
invoke-virtual {v2, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
const-string v3, ". Ignoring."
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v2
invoke-virtual {v1, v2}, Lcom/google/firebase/database/logging/LogWrapper;->warn(Ljava/lang/String;)V
goto :goto_0
.line 12
:cond_1
invoke-static {v8, v3}, Lcom/google/firebase/database/core/Path;->getRelative(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/core/Path;)Lcom/google/firebase/database/core/Path;
move-result-object v6
.line 13
invoke-virtual {v5, v6}, Lcom/google/firebase/database/core/persistence/PruneForest;->shouldPruneUnkeptDescendants(Lcom/google/firebase/database/core/Path;)Z
move-result v14
if-eqz v14, :cond_2
.line 14
invoke-static {v1, v2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v1
invoke-virtual {v12, v6, v1}, Lcom/google/firebase/database/core/utilities/ImmutableTree;->set(Lcom/google/firebase/database/core/Path;Ljava/lang/Object;)Lcom/google/firebase/database/core/utilities/ImmutableTree;
move-result-object v12
goto :goto_0
.line 15
:cond_2
invoke-virtual {v5, v6}, Lcom/google/firebase/database/core/persistence/PruneForest;->shouldKeep(Lcom/google/firebase/database/core/Path;)Z
move-result v14
if-eqz v14, :cond_3
.line 16
invoke-static {v1, v2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v1
invoke-virtual {v4, v6, v1}, Lcom/google/firebase/database/core/utilities/ImmutableTree;->set(Lcom/google/firebase/database/core/Path;Ljava/lang/Object;)Lcom/google/firebase/database/core/utilities/ImmutableTree;
move-result-object v4
goto :goto_0
.line 17
:cond_3
iget-object v1, v7, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
new-instance v2, Ljava/lang/StringBuilder;
invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
invoke-virtual {v2, v13}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v2, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
const-string v6, " and have data at "
invoke-virtual {v2, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
const-string v3, " that isn\'t marked for pruning or keeping. Ignoring."
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v2
invoke-virtual {v1, v2}, Lcom/google/firebase/database/logging/LogWrapper;->warn(Ljava/lang/String;)V
goto/16 :goto_0
.line 18
:cond_4
invoke-virtual {v12}, Lcom/google/firebase/database/core/utilities/ImmutableTree;->isEmpty()Z
move-result v0
if-nez v0, :cond_6
.line 19
new-instance v15, Ljava/util/ArrayList;
invoke-direct {v15}, Ljava/util/ArrayList;-><init>()V
.line 20
invoke-static {}, Lcom/google/firebase/database/core/Path;->getEmptyPath()Lcom/google/firebase/database/core/Path;
move-result-object v2
move-object/from16 v0, p0
move-object/from16 v1, p1
move-object v3, v12
move-object/from16 v5, p2
move-object v6, v15
.line 21
invoke-direct/range {v0 .. v6}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->pruneTreeRecursive(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/core/utilities/ImmutableTree;Lcom/google/firebase/database/core/utilities/ImmutableTree;Lcom/google/firebase/database/core/persistence/PruneForest;Ljava/util/List;)V
.line 22
invoke-virtual {v12}, Lcom/google/firebase/database/core/utilities/ImmutableTree;->values()Ljava/util/Collection;
move-result-object v0
const-string v1, "rowid IN ("
.line 23
invoke-static {v1}, Landroid/support/v4/media/d;->a(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v1
invoke-direct {v7, v0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->commaSeparatedList(Ljava/util/Collection;)Ljava/lang/String;
move-result-object v2
const-string v3, ")"
invoke-static {v1, v2, v3}, Landroidx/camera/camera2/internal/b;->a(Ljava/lang/StringBuilder;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
move-result-object v1
.line 24
iget-object v2, v7, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const-string v3, "serverCache"
invoke-virtual {v2, v3, v1, v11}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I
.line 25
invoke-virtual {v15}, Ljava/util/ArrayList;->iterator()Ljava/util/Iterator;
move-result-object v1
:goto_1
invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z
move-result v2
if-eqz v2, :cond_5
invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v2
check-cast v2, Lcom/google/firebase/database/core/utilities/Pair;
.line 26
invoke-virtual {v2}, Lcom/google/firebase/database/core/utilities/Pair;->getFirst()Ljava/lang/Object;
move-result-object v3
check-cast v3, Lcom/google/firebase/database/core/Path;
invoke-virtual {v8, v3}, Lcom/google/firebase/database/core/Path;->child(Lcom/google/firebase/database/core/Path;)Lcom/google/firebase/database/core/Path;
move-result-object v3
invoke-virtual {v2}, Lcom/google/firebase/database/core/utilities/Pair;->getSecond()Ljava/lang/Object;
move-result-object v2
check-cast v2, Lcom/google/firebase/database/snapshot/Node;
invoke-direct {v7, v3, v2}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->saveNested(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;)I
goto :goto_1
.line 27
:cond_5
invoke-interface {v0}, Ljava/util/Collection;->size()I
move-result v0
.line 28
invoke-virtual {v15}, Ljava/util/ArrayList;->size()I
move-result v1
goto :goto_2
:cond_6
move v0, v14
move v1, v0
.line 29
:goto_2
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v2
sub-long/2addr v2, v9
.line 30
iget-object v4, v7, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {v4}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result v4
if-eqz v4, :cond_7
.line 31
iget-object v4, v7, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
sget-object v5, Ljava/util/Locale;->US:Ljava/util/Locale;
const/4 v6, 0x3
new-array v6, v6, [Ljava/lang/Object;
.line 32
invoke-static {v0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v0
aput-object v0, v6, v14
.line 33
invoke-static {v1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v0
aput-object v0, v6, v13
const/4 v0, 0x2
.line 34
invoke-static {v2, v3}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v1
aput-object v1, v6, v0
const-string v0, "Pruned %d rows with %d nodes resaved in %dms"
.line 35
invoke-static {v5, v0, v6}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v0
new-array v1, v14, [Ljava/lang/Object;
.line 36
invoke-virtual {v4, v0, v1}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
:cond_7
return-void
.end method
.method public purgeCache()V
.locals 3
.line 1
invoke-direct {p0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->verifyInsideTransaction()V
.line 2
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const-string v1, "serverCache"
const/4 v2, 0x0
invoke-virtual {v0, v1, v2, v2}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I
.line 3
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const-string v1, "writes"
invoke-virtual {v0, v1, v2, v2}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I
.line 4
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const-string v1, "trackedQueries"
invoke-virtual {v0, v1, v2, v2}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I
.line 5
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const-string v1, "trackedKeys"
invoke-virtual {v0, v1, v2, v2}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I
return-void
.end method
.method public removeAllUserWrites()V
.locals 7
.line 1
invoke-direct {p0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->verifyInsideTransaction()V
.line 2
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v0
.line 3
iget-object v2, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const-string v3, "writes"
const/4 v4, 0x0
invoke-virtual {v2, v3, v4, v4}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I
move-result v2
.line 4
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v3
sub-long/2addr v3, v0
.line 5
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {v0}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result v0
if-eqz v0, :cond_0
.line 6
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
sget-object v1, Ljava/util/Locale;->US:Ljava/util/Locale;
const/4 v5, 0x2
new-array v5, v5, [Ljava/lang/Object;
invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v2
const/4 v6, 0x0
aput-object v2, v5, v6
const/4 v2, 0x1
invoke-static {v3, v4}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v3
aput-object v3, v5, v2
const-string v2, "Deleted %d (all) write(s) in %dms"
invoke-static {v1, v2, v5}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v1
new-array v2, v6, [Ljava/lang/Object;
invoke-virtual {v0, v1, v2}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
:cond_0
return-void
.end method
.method public removeUserWrite(J)V
.locals 8
.line 1
invoke-direct {p0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->verifyInsideTransaction()V
.line 2
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v0
.line 3
iget-object v2, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const/4 v3, 0x1
new-array v4, v3, [Ljava/lang/String;
invoke-static {p1, p2}, Ljava/lang/String;->valueOf(J)Ljava/lang/String;
move-result-object v5
const/4 v6, 0x0
aput-object v5, v4, v6
const-string v5, "writes"
const-string v7, "id = ?"
invoke-virtual {v2, v5, v7, v4}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I
move-result v2
.line 4
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v4
sub-long/2addr v4, v0
.line 5
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {v0}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result v0
if-eqz v0, :cond_0
.line 6
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
sget-object v1, Ljava/util/Locale;->US:Ljava/util/Locale;
const/4 v7, 0x3
new-array v7, v7, [Ljava/lang/Object;
.line 7
invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v2
aput-object v2, v7, v6
invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object p1
aput-object p1, v7, v3
const/4 p1, 0x2
invoke-static {v4, v5}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object p2
aput-object p2, v7, p1
const-string p1, "Deleted %d write(s) with writeId %d in %dms"
.line 8
invoke-static {v1, p1, v7}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object p1
new-array p2, v6, [Ljava/lang/Object;
.line 9
invoke-virtual {v0, p1, p2}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
:cond_0
return-void
.end method
.method public resetPreviouslyActiveTrackedQueries(J)V
.locals 8
.line 1
invoke-direct {p0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->verifyInsideTransaction()V
.line 2
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v0
.line 3
new-instance v4, Landroid/content/ContentValues;
invoke-direct {v4}, Landroid/content/ContentValues;-><init>()V
.line 4
sget-object v2, Ljava/lang/Boolean;->FALSE:Ljava/lang/Boolean;
const-string v3, "active"
invoke-virtual {v4, v3, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Boolean;)V
.line 5
invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object p1
const-string p2, "lastUse"
invoke-virtual {v4, p2, p1}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Long;)V
.line 6
iget-object v2, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const/4 p1, 0x0
new-array v6, p1, [Ljava/lang/String;
const-string v3, "trackedQueries"
const-string v5, "active = 1"
const/4 v7, 0x5
invoke-virtual/range {v2 .. v7}, Landroid/database/sqlite/SQLiteDatabase;->updateWithOnConflict(Ljava/lang/String;Landroid/content/ContentValues;Ljava/lang/String;[Ljava/lang/String;I)I
.line 7
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v2
sub-long/2addr v2, v0
.line 8
iget-object p2, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {p2}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result p2
if-eqz p2, :cond_0
.line 9
iget-object p2, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
sget-object v0, Ljava/util/Locale;->US:Ljava/util/Locale;
const/4 v1, 0x1
new-array v1, v1, [Ljava/lang/Object;
invoke-static {v2, v3}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v2
aput-object v2, v1, p1
const-string v2, "Reset active tracked queries in %dms"
invoke-static {v0, v2, v1}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v0
new-array p1, p1, [Ljava/lang/Object;
invoke-virtual {p2, v0, p1}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
:cond_0
return-void
.end method
.method public saveTrackedQuery(Lcom/google/firebase/database/core/persistence/TrackedQuery;)V
.locals 6
.line 1
invoke-direct {p0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->verifyInsideTransaction()V
.line 2
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v0
.line 3
new-instance v2, Landroid/content/ContentValues;
invoke-direct {v2}, Landroid/content/ContentValues;-><init>()V
.line 4
iget-wide v3, p1, Lcom/google/firebase/database/core/persistence/TrackedQuery;->id:J
invoke-static {v3, v4}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v3
const-string v4, "id"
invoke-virtual {v2, v4, v3}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Long;)V
.line 5
iget-object v3, p1, Lcom/google/firebase/database/core/persistence/TrackedQuery;->querySpec:Lcom/google/firebase/database/core/view/QuerySpec;
invoke-virtual {v3}, Lcom/google/firebase/database/core/view/QuerySpec;->getPath()Lcom/google/firebase/database/core/Path;
move-result-object v3
invoke-static {v3}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->pathToKey(Lcom/google/firebase/database/core/Path;)Ljava/lang/String;
move-result-object v3
const-string v4, "path"
invoke-virtual {v2, v4, v3}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V
.line 6
iget-object v3, p1, Lcom/google/firebase/database/core/persistence/TrackedQuery;->querySpec:Lcom/google/firebase/database/core/view/QuerySpec;
invoke-virtual {v3}, Lcom/google/firebase/database/core/view/QuerySpec;->getParams()Lcom/google/firebase/database/core/view/QueryParams;
move-result-object v3
invoke-virtual {v3}, Lcom/google/firebase/database/core/view/QueryParams;->toJSON()Ljava/lang/String;
move-result-object v3
const-string v4, "queryParams"
invoke-virtual {v2, v4, v3}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V
.line 7
iget-wide v3, p1, Lcom/google/firebase/database/core/persistence/TrackedQuery;->lastUse:J
invoke-static {v3, v4}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v3
const-string v4, "lastUse"
invoke-virtual {v2, v4, v3}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Long;)V
.line 8
iget-boolean v3, p1, Lcom/google/firebase/database/core/persistence/TrackedQuery;->complete:Z
invoke-static {v3}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
move-result-object v3
const-string v4, "complete"
invoke-virtual {v2, v4, v3}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Boolean;)V
.line 9
iget-boolean p1, p1, Lcom/google/firebase/database/core/persistence/TrackedQuery;->active:Z
invoke-static {p1}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
move-result-object p1
const-string v3, "active"
invoke-virtual {v2, v3, p1}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Boolean;)V
.line 10
iget-object p1, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const-string v3, "trackedQueries"
const/4 v4, 0x0
const/4 v5, 0x5
invoke-virtual {p1, v3, v4, v2, v5}, Landroid/database/sqlite/SQLiteDatabase;->insertWithOnConflict(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;I)J
.line 11
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v2
sub-long/2addr v2, v0
.line 12
iget-object p1, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {p1}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result p1
if-eqz p1, :cond_0
.line 13
iget-object p1, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
sget-object v0, Ljava/util/Locale;->US:Ljava/util/Locale;
const/4 v1, 0x1
new-array v1, v1, [Ljava/lang/Object;
invoke-static {v2, v3}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v2
const/4 v3, 0x0
aput-object v2, v1, v3
const-string v2, "Saved new tracked query in %dms"
invoke-static {v0, v2, v1}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v0
new-array v1, v3, [Ljava/lang/Object;
invoke-virtual {p1, v0, v1}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
:cond_0
return-void
.end method
.method public saveTrackedQueryKeys(JLjava/util/Set;)V
.locals 10
.annotation system Ldalvik/annotation/Signature;
value = {
"(J",
"Ljava/util/Set<",
"Lcom/google/firebase/database/snapshot/ChildKey;",
">;)V"
}
.end annotation
.line 1
invoke-direct {p0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->verifyInsideTransaction()V
.line 2
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v0
.line 3
invoke-static {p1, p2}, Ljava/lang/String;->valueOf(J)Ljava/lang/String;
move-result-object v2
.line 4
iget-object v3, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const/4 v4, 0x1
new-array v5, v4, [Ljava/lang/String;
const/4 v6, 0x0
aput-object v2, v5, v6
const-string v2, "trackedKeys"
const-string v7, "id = ?"
invoke-virtual {v3, v2, v7, v5}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I
.line 5
invoke-interface {p3}, Ljava/util/Set;->iterator()Ljava/util/Iterator;
move-result-object v3
:goto_0
invoke-interface {v3}, Ljava/util/Iterator;->hasNext()Z
move-result v5
if-eqz v5, :cond_0
invoke-interface {v3}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v5
check-cast v5, Lcom/google/firebase/database/snapshot/ChildKey;
.line 6
new-instance v7, Landroid/content/ContentValues;
invoke-direct {v7}, Landroid/content/ContentValues;-><init>()V
.line 7
invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v8
const-string v9, "id"
invoke-virtual {v7, v9, v8}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Long;)V
.line 8
invoke-virtual {v5}, Lcom/google/firebase/database/snapshot/ChildKey;->asString()Ljava/lang/String;
move-result-object v5
const-string v8, "key"
invoke-virtual {v7, v8, v5}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V
.line 9
iget-object v5, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const/4 v8, 0x0
const/4 v9, 0x5
invoke-virtual {v5, v2, v8, v7, v9}, Landroid/database/sqlite/SQLiteDatabase;->insertWithOnConflict(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;I)J
goto :goto_0
.line 10
:cond_0
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v2
sub-long/2addr v2, v0
.line 11
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {v0}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result v0
if-eqz v0, :cond_1
.line 12
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
sget-object v1, Ljava/util/Locale;->US:Ljava/util/Locale;
const/4 v5, 0x3
new-array v5, v5, [Ljava/lang/Object;
.line 13
invoke-interface {p3}, Ljava/util/Set;->size()I
move-result p3
invoke-static {p3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object p3
aput-object p3, v5, v6
.line 14
invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object p1
aput-object p1, v5, v4
const/4 p1, 0x2
.line 15
invoke-static {v2, v3}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object p2
aput-object p2, v5, p1
const-string p1, "Set %d tracked query keys for tracked query %d in %dms"
.line 16
invoke-static {v1, p1, v5}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object p1
new-array p2, v6, [Ljava/lang/Object;
.line 17
invoke-virtual {v0, p1, p2}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
:cond_1
return-void
.end method
.method public saveUserMerge(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/core/CompoundWrite;J)V
.locals 9
.line 1
invoke-direct {p0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->verifyInsideTransaction()V
.line 2
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v0
const/4 v2, 0x1
.line 3
invoke-virtual {p2, v2}, Lcom/google/firebase/database/core/CompoundWrite;->getValue(Z)Ljava/util/Map;
move-result-object p2
invoke-direct {p0, p2}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->serializeObject(Ljava/lang/Object;)[B
move-result-object v8
const-string v7, "m"
move-object v3, p0
move-object v4, p1
move-wide v5, p3
.line 4
invoke-direct/range {v3 .. v8}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->saveWrite(Lcom/google/firebase/database/core/Path;JLjava/lang/String;[B)V
.line 5
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide p1
sub-long/2addr p1, v0
.line 6
iget-object p3, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {p3}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result p3
if-eqz p3, :cond_0
.line 7
iget-object p3, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
sget-object p4, Ljava/util/Locale;->US:Ljava/util/Locale;
new-array v0, v2, [Ljava/lang/Object;
invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object p1
const/4 p2, 0x0
aput-object p1, v0, p2
const-string p1, "Persisted user merge in %dms"
invoke-static {p4, p1, v0}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object p1
new-array p2, p2, [Ljava/lang/Object;
invoke-virtual {p3, p1, p2}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
:cond_0
return-void
.end method
.method public saveUserOverwrite(Lcom/google/firebase/database/core/Path;Lcom/google/firebase/database/snapshot/Node;J)V
.locals 9
.line 1
invoke-direct {p0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->verifyInsideTransaction()V
.line 2
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v0
const/4 v2, 0x1
.line 3
invoke-interface {p2, v2}, Lcom/google/firebase/database/snapshot/Node;->getValue(Z)Ljava/lang/Object;
move-result-object p2
invoke-direct {p0, p2}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->serializeObject(Ljava/lang/Object;)[B
move-result-object v8
const-string v7, "o"
move-object v3, p0
move-object v4, p1
move-wide v5, p3
.line 4
invoke-direct/range {v3 .. v8}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->saveWrite(Lcom/google/firebase/database/core/Path;JLjava/lang/String;[B)V
.line 5
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide p1
sub-long/2addr p1, v0
.line 6
iget-object p3, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {p3}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result p3
if-eqz p3, :cond_0
.line 7
iget-object p3, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
sget-object p4, Ljava/util/Locale;->US:Ljava/util/Locale;
new-array v0, v2, [Ljava/lang/Object;
invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object p1
const/4 p2, 0x0
aput-object p1, v0, p2
const-string p1, "Persisted user overwrite in %dms"
invoke-static {p4, p1, v0}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object p1
new-array p2, p2, [Ljava/lang/Object;
invoke-virtual {p3, p1, p2}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
:cond_0
return-void
.end method
.method public serverCache(Lcom/google/firebase/database/core/Path;)Lcom/google/firebase/database/snapshot/Node;
.locals 0
.line 1
invoke-direct {p0, p1}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->loadNested(Lcom/google/firebase/database/core/Path;)Lcom/google/firebase/database/snapshot/Node;
move-result-object p1
return-object p1
.end method
.method public serverCacheEstimatedSizeInBytes()J
.locals 4
const/4 v0, 0x3
new-array v0, v0, [Ljava/lang/Object;
const-string v1, "value"
const/4 v2, 0x0
aput-object v1, v0, v2
const/4 v1, 0x1
const-string v3, "path"
aput-object v3, v0, v1
const/4 v1, 0x2
const-string v3, "serverCache"
aput-object v3, v0, v1
const-string v1, "SELECT sum(length(%s) + length(%s)) FROM %s"
.line 1
invoke-static {v1, v0}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v0
.line 2
iget-object v1, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const/4 v3, 0x0
invoke-virtual {v1, v0, v3}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;
move-result-object v0
.line 3
:try_start_0
invoke-interface {v0}, Landroid/database/Cursor;->moveToFirst()Z
move-result v1
if-eqz v1, :cond_0
.line 4
invoke-interface {v0, v2}, Landroid/database/Cursor;->getLong(I)J
move-result-wide v1
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
.line 5
invoke-interface {v0}, Landroid/database/Cursor;->close()V
return-wide v1
.line 6
:cond_0
:try_start_1
new-instance v1, Ljava/lang/IllegalStateException;
const-string v2, "Couldn\'t read database result!"
invoke-direct {v1, v2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw v1
:try_end_1
.catchall {:try_start_1 .. :try_end_1} :catchall_0
:catchall_0
move-exception v1
.line 7
invoke-interface {v0}, Landroid/database/Cursor;->close()V
.line 8
throw v1
.end method
.method public setTransactionSuccessful()V
.locals 1
.line 1
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->setTransactionSuccessful()V
return-void
.end method
.method public updateTrackedQueryKeys(JLjava/util/Set;Ljava/util/Set;)V
.locals 11
.annotation system Ldalvik/annotation/Signature;
value = {
"(J",
"Ljava/util/Set<",
"Lcom/google/firebase/database/snapshot/ChildKey;",
">;",
"Ljava/util/Set<",
"Lcom/google/firebase/database/snapshot/ChildKey;",
">;)V"
}
.end annotation
.line 1
invoke-direct {p0}, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->verifyInsideTransaction()V
.line 2
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v0
.line 3
invoke-static {p1, p2}, Ljava/lang/String;->valueOf(J)Ljava/lang/String;
move-result-object v2
.line 4
invoke-interface {p4}, Ljava/util/Set;->iterator()Ljava/util/Iterator;
move-result-object v3
:goto_0
invoke-interface {v3}, Ljava/util/Iterator;->hasNext()Z
move-result v4
const/4 v5, 0x1
const/4 v6, 0x2
const-string v7, "trackedKeys"
const/4 v8, 0x0
if-eqz v4, :cond_0
invoke-interface {v3}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v4
check-cast v4, Lcom/google/firebase/database/snapshot/ChildKey;
.line 5
iget-object v9, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
new-array v6, v6, [Ljava/lang/String;
aput-object v2, v6, v8
.line 6
invoke-virtual {v4}, Lcom/google/firebase/database/snapshot/ChildKey;->asString()Ljava/lang/String;
move-result-object v4
aput-object v4, v6, v5
const-string v4, "id = ? AND key = ?"
.line 7
invoke-virtual {v9, v7, v4, v6}, Landroid/database/sqlite/SQLiteDatabase;->delete(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)I
goto :goto_0
.line 8
:cond_0
invoke-interface {p3}, Ljava/util/Set;->iterator()Ljava/util/Iterator;
move-result-object v2
:goto_1
invoke-interface {v2}, Ljava/util/Iterator;->hasNext()Z
move-result v3
if-eqz v3, :cond_1
invoke-interface {v2}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v3
check-cast v3, Lcom/google/firebase/database/snapshot/ChildKey;
.line 9
new-instance v4, Landroid/content/ContentValues;
invoke-direct {v4}, Landroid/content/ContentValues;-><init>()V
.line 10
invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object v9
const-string v10, "id"
invoke-virtual {v4, v10, v9}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/Long;)V
.line 11
invoke-virtual {v3}, Lcom/google/firebase/database/snapshot/ChildKey;->asString()Ljava/lang/String;
move-result-object v3
const-string v9, "key"
invoke-virtual {v4, v9, v3}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V
.line 12
iget-object v3, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->database:Landroid/database/sqlite/SQLiteDatabase;
const/4 v9, 0x0
const/4 v10, 0x5
invoke-virtual {v3, v7, v9, v4, v10}, Landroid/database/sqlite/SQLiteDatabase;->insertWithOnConflict(Ljava/lang/String;Ljava/lang/String;Landroid/content/ContentValues;I)J
goto :goto_1
.line 13
:cond_1
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v2
sub-long/2addr v2, v0
.line 14
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
invoke-virtual {v0}, Lcom/google/firebase/database/logging/LogWrapper;->logsDebug()Z
move-result v0
if-eqz v0, :cond_2
.line 15
iget-object v0, p0, Lcom/google/firebase/database/android/SqlPersistenceStorageEngine;->logger:Lcom/google/firebase/database/logging/LogWrapper;
sget-object v1, Ljava/util/Locale;->US:Ljava/util/Locale;
const/4 v4, 0x4
new-array v4, v4, [Ljava/lang/Object;
.line 16
invoke-interface {p3}, Ljava/util/Set;->size()I
move-result p3
invoke-static {p3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object p3
aput-object p3, v4, v8
.line 17
invoke-interface {p4}, Ljava/util/Set;->size()I
move-result p3
invoke-static {p3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object p3
aput-object p3, v4, v5
.line 18
invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object p1
aput-object p1, v4, v6
const/4 p1, 0x3
.line 19
invoke-static {v2, v3}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
move-result-object p2
aput-object p2, v4, p1
const-string p1, "Updated tracked query keys (%d added, %d removed) for tracked query id %d in %dms"
.line 20
invoke-static {v1, p1, v4}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object p1
new-array p2, v8, [Ljava/lang/Object;
.line 21
invoke-virtual {v0, p1, p2}, Lcom/google/firebase/database/logging/LogWrapper;->debug(Ljava/lang/String;[Ljava/lang/Object;)V
:cond_2
return-void
.end method