- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
949 lines
42 KiB
Java
949 lines
42 KiB
Java
package androidx.room;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.database.Cursor;
|
|
import android.database.sqlite.SQLiteException;
|
|
import android.util.Log;
|
|
import androidx.annotation.GuardedBy;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.annotation.VisibleForTesting;
|
|
import androidx.annotation.WorkerThread;
|
|
import androidx.arch.core.internal.SafeIterableMap;
|
|
import androidx.lifecycle.LiveData;
|
|
import androidx.sqlite.db.SimpleSQLiteQuery;
|
|
import androidx.sqlite.db.SupportSQLiteDatabase;
|
|
import androidx.sqlite.db.SupportSQLiteStatement;
|
|
import java.lang.ref.WeakReference;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Iterator;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import java.util.concurrent.locks.Lock;
|
|
import kotlin.Unit;
|
|
import kotlin.collections.CollectionsKt___CollectionsKt;
|
|
import kotlin.collections.MapsKt__MapsKt;
|
|
import kotlin.collections.SetsKt__SetsJVMKt;
|
|
import kotlin.collections.SetsKt__SetsKt;
|
|
import kotlin.io.CloseableKt;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.jvm.internal.SourceDebugExtension;
|
|
import kotlin.text.StringsKt__StringsJVMKt;
|
|
import org.apache.http.client.methods.HttpDelete;
|
|
|
|
@SourceDebugExtension({"SMAP\nInvalidationTracker.kt\nKotlin\n*S Kotlin\n*F\n+ 1 InvalidationTracker.kt\nandroidx/room/InvalidationTracker\n+ 2 _Maps.kt\nkotlin/collections/MapsKt___MapsKt\n+ 3 _Arrays.kt\nkotlin/collections/ArraysKt___ArraysKt\n+ 4 ArraysJVM.kt\nkotlin/collections/ArraysKt__ArraysJVMKt\n+ 5 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n*L\n1#1,840:1\n215#2,2:841\n11335#3:843\n11670#3,3:844\n13579#3,2:847\n13579#3,2:849\n13674#3,3:855\n37#4,2:851\n1855#5,2:853\n*S KotlinDebug\n*F\n+ 1 InvalidationTracker.kt\nandroidx/room/InvalidationTracker\n*L\n102#1:841,2\n250#1:843\n250#1:844,3\n271#1:847,2\n287#1:849,2\n491#1:855,3\n294#1:851,2\n467#1:853,2\n*E\n"})
|
|
/* loaded from: classes.dex */
|
|
public class InvalidationTracker {
|
|
private static final String CREATE_TRACKING_TABLE_SQL = "CREATE TEMP TABLE room_table_modification_log (table_id INTEGER PRIMARY KEY, invalidated INTEGER NOT NULL DEFAULT 0)";
|
|
private static final String INVALIDATED_COLUMN_NAME = "invalidated";
|
|
public static final String RESET_UPDATED_TABLES_SQL = "UPDATE room_table_modification_log SET invalidated = 0 WHERE invalidated = 1";
|
|
public static final String SELECT_UPDATED_TABLES_SQL = "SELECT * FROM room_table_modification_log WHERE invalidated = 1;";
|
|
private static final String TABLE_ID_COLUMN_NAME = "table_id";
|
|
private static final String UPDATE_TABLE_NAME = "room_table_modification_log";
|
|
private AutoCloser autoCloser;
|
|
private volatile SupportSQLiteStatement cleanupStatement;
|
|
private final RoomDatabase database;
|
|
private volatile boolean initialized;
|
|
private final InvalidationLiveDataContainer invalidationLiveDataContainer;
|
|
private MultiInstanceInvalidationClient multiInstanceInvalidationClient;
|
|
private final ObservedTableTracker observedTableTracker;
|
|
|
|
@GuardedBy("observerMap")
|
|
private final SafeIterableMap<Observer, ObserverWrapper> observerMap;
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY})
|
|
private final AtomicBoolean pendingRefresh;
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY})
|
|
public final Runnable refreshRunnable;
|
|
private final Map<String, String> shadowTablesMap;
|
|
private final Object syncTriggersLock;
|
|
private final Map<String, Integer> tableIdLookup;
|
|
private final String[] tablesNames;
|
|
private final Object trackerLock;
|
|
private final Map<String, Set<String>> viewTables;
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final String[] TRIGGERS = {"UPDATE", HttpDelete.METHOD_NAME, "INSERT"};
|
|
|
|
@VisibleForTesting
|
|
public static /* synthetic */ void getRefreshRunnable$annotations() {
|
|
}
|
|
|
|
public final SupportSQLiteStatement getCleanupStatement$room_runtime_release() {
|
|
return this.cleanupStatement;
|
|
}
|
|
|
|
public final RoomDatabase getDatabase$room_runtime_release() {
|
|
return this.database;
|
|
}
|
|
|
|
public final SafeIterableMap<Observer, ObserverWrapper> getObserverMap$room_runtime_release() {
|
|
return this.observerMap;
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY})
|
|
public final AtomicBoolean getPendingRefresh() {
|
|
return this.pendingRefresh;
|
|
}
|
|
|
|
public final Map<String, Integer> getTableIdLookup$room_runtime_release() {
|
|
return this.tableIdLookup;
|
|
}
|
|
|
|
public final String[] getTablesNames$room_runtime_release() {
|
|
return this.tablesNames;
|
|
}
|
|
|
|
public final void setCleanupStatement$room_runtime_release(SupportSQLiteStatement supportSQLiteStatement) {
|
|
this.cleanupStatement = supportSQLiteStatement;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public InvalidationTracker(RoomDatabase database, Map<String, String> shadowTablesMap, Map<String, Set<String>> viewTables, String... tableNames) {
|
|
Object value;
|
|
String str;
|
|
Intrinsics.checkNotNullParameter(database, "database");
|
|
Intrinsics.checkNotNullParameter(shadowTablesMap, "shadowTablesMap");
|
|
Intrinsics.checkNotNullParameter(viewTables, "viewTables");
|
|
Intrinsics.checkNotNullParameter(tableNames, "tableNames");
|
|
this.database = database;
|
|
this.shadowTablesMap = shadowTablesMap;
|
|
this.viewTables = viewTables;
|
|
this.pendingRefresh = new AtomicBoolean(false);
|
|
this.observedTableTracker = new ObservedTableTracker(tableNames.length);
|
|
this.invalidationLiveDataContainer = new InvalidationLiveDataContainer(database);
|
|
this.observerMap = new SafeIterableMap<>();
|
|
this.syncTriggersLock = new Object();
|
|
this.trackerLock = new Object();
|
|
this.tableIdLookup = new LinkedHashMap();
|
|
int length = tableNames.length;
|
|
String[] strArr = new String[length];
|
|
for (int i = 0; i < length; i++) {
|
|
String str2 = tableNames[i];
|
|
Locale US = Locale.US;
|
|
Intrinsics.checkNotNullExpressionValue(US, "US");
|
|
String lowerCase = str2.toLowerCase(US);
|
|
Intrinsics.checkNotNullExpressionValue(lowerCase, "this as java.lang.String).toLowerCase(locale)");
|
|
this.tableIdLookup.put(lowerCase, Integer.valueOf(i));
|
|
String str3 = this.shadowTablesMap.get(tableNames[i]);
|
|
if (str3 != null) {
|
|
Intrinsics.checkNotNullExpressionValue(US, "US");
|
|
str = str3.toLowerCase(US);
|
|
Intrinsics.checkNotNullExpressionValue(str, "this as java.lang.String).toLowerCase(locale)");
|
|
} else {
|
|
str = null;
|
|
}
|
|
if (str != null) {
|
|
lowerCase = str;
|
|
}
|
|
strArr[i] = lowerCase;
|
|
}
|
|
this.tablesNames = strArr;
|
|
for (Map.Entry<String, String> entry : this.shadowTablesMap.entrySet()) {
|
|
String value2 = entry.getValue();
|
|
Locale US2 = Locale.US;
|
|
Intrinsics.checkNotNullExpressionValue(US2, "US");
|
|
String lowerCase2 = value2.toLowerCase(US2);
|
|
Intrinsics.checkNotNullExpressionValue(lowerCase2, "this as java.lang.String).toLowerCase(locale)");
|
|
if (this.tableIdLookup.containsKey(lowerCase2)) {
|
|
String key = entry.getKey();
|
|
Intrinsics.checkNotNullExpressionValue(US2, "US");
|
|
String lowerCase3 = key.toLowerCase(US2);
|
|
Intrinsics.checkNotNullExpressionValue(lowerCase3, "this as java.lang.String).toLowerCase(locale)");
|
|
Map<String, Integer> map = this.tableIdLookup;
|
|
value = MapsKt__MapsKt.getValue(map, lowerCase2);
|
|
map.put(lowerCase3, value);
|
|
}
|
|
}
|
|
this.refreshRunnable = new Runnable() { // from class: androidx.room.InvalidationTracker$refreshRunnable$1
|
|
/* JADX WARN: Code restructure failed: missing block: B:30:0x0080, code lost:
|
|
|
|
if (r0 != null) goto L26;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:31:0x0082, code lost:
|
|
|
|
r0.decrementCountAndScheduleClose();
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:33:0x00c5, code lost:
|
|
|
|
if ((!r3.isEmpty()) == false) goto L59;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:34:0x00c7, code lost:
|
|
|
|
r0 = r5.this$0.getObserverMap$room_runtime_release();
|
|
r1 = r5.this$0;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:35:0x00cf, code lost:
|
|
|
|
monitor-enter(r0);
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:37:0x00d0, code lost:
|
|
|
|
r1 = r1.getObserverMap$room_runtime_release().iterator();
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:39:0x00dc, code lost:
|
|
|
|
if (r1.hasNext() == false) goto L69;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:40:0x00de, code lost:
|
|
|
|
((androidx.room.InvalidationTracker.ObserverWrapper) ((java.util.Map.Entry) r1.next()).getValue()).notifyByTableInvalidStatus$room_runtime_release(r3);
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:42:0x00f0, code lost:
|
|
|
|
r1 = kotlin.Unit.INSTANCE;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:43:0x00f2, code lost:
|
|
|
|
monitor-exit(r0);
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:44:?, code lost:
|
|
|
|
return;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:46:0x00ee, code lost:
|
|
|
|
r1 = move-exception;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:48:0x00f5, code lost:
|
|
|
|
throw r1;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:49:0x00f6, code lost:
|
|
|
|
return;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:62:0x00a6, code lost:
|
|
|
|
if (r0 == null) goto L44;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:66:0x00bd, code lost:
|
|
|
|
if (r0 == null) goto L44;
|
|
*/
|
|
@Override // java.lang.Runnable
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public void run() {
|
|
/*
|
|
Method dump skipped, instructions count: 262
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.room.InvalidationTracker$refreshRunnable$1.run():void");
|
|
}
|
|
|
|
private final Set<Integer> checkUpdatedTable() {
|
|
Set createSetBuilder;
|
|
Set<Integer> build;
|
|
InvalidationTracker invalidationTracker = InvalidationTracker.this;
|
|
createSetBuilder = SetsKt__SetsJVMKt.createSetBuilder();
|
|
Cursor query$default = RoomDatabase.query$default(invalidationTracker.getDatabase$room_runtime_release(), new SimpleSQLiteQuery(InvalidationTracker.SELECT_UPDATED_TABLES_SQL), null, 2, null);
|
|
while (query$default.moveToNext()) {
|
|
try {
|
|
createSetBuilder.add(Integer.valueOf(query$default.getInt(0)));
|
|
} finally {
|
|
}
|
|
}
|
|
Unit unit = Unit.INSTANCE;
|
|
CloseableKt.closeFinally(query$default, null);
|
|
build = SetsKt__SetsJVMKt.build(createSetBuilder);
|
|
if (!build.isEmpty()) {
|
|
if (InvalidationTracker.this.getCleanupStatement$room_runtime_release() == null) {
|
|
throw new IllegalStateException("Required value was null.".toString());
|
|
}
|
|
SupportSQLiteStatement cleanupStatement$room_runtime_release = InvalidationTracker.this.getCleanupStatement$room_runtime_release();
|
|
if (cleanupStatement$room_runtime_release == null) {
|
|
throw new IllegalArgumentException("Required value was null.".toString());
|
|
}
|
|
cleanupStatement$room_runtime_release.executeUpdateDelete();
|
|
}
|
|
return build;
|
|
}
|
|
};
|
|
}
|
|
|
|
/* JADX WARN: Illegal instructions before constructor call */
|
|
@androidx.annotation.RestrictTo({androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public InvalidationTracker(androidx.room.RoomDatabase r4, java.lang.String... r5) {
|
|
/*
|
|
r3 = this;
|
|
java.lang.String r0 = "database"
|
|
kotlin.jvm.internal.Intrinsics.checkNotNullParameter(r4, r0)
|
|
java.lang.String r0 = "tableNames"
|
|
kotlin.jvm.internal.Intrinsics.checkNotNullParameter(r5, r0)
|
|
java.util.Map r0 = kotlin.collections.MapsKt.emptyMap()
|
|
java.util.Map r1 = kotlin.collections.MapsKt.emptyMap()
|
|
int r2 = r5.length
|
|
java.lang.Object[] r5 = java.util.Arrays.copyOf(r5, r2)
|
|
java.lang.String[] r5 = (java.lang.String[]) r5
|
|
r3.<init>(r4, r0, r1, r5)
|
|
return
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.room.InvalidationTracker.<init>(androidx.room.RoomDatabase, java.lang.String[]):void");
|
|
}
|
|
|
|
public final void setAutoCloser$room_runtime_release(AutoCloser autoCloser) {
|
|
Intrinsics.checkNotNullParameter(autoCloser, "autoCloser");
|
|
this.autoCloser = autoCloser;
|
|
autoCloser.setAutoCloseCallback(new Runnable() { // from class: androidx.room.InvalidationTracker$$ExternalSyntheticLambda0
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
InvalidationTracker.this.onAutoCloseCallback();
|
|
}
|
|
});
|
|
}
|
|
|
|
public final void internalInit$room_runtime_release(SupportSQLiteDatabase database) {
|
|
Intrinsics.checkNotNullParameter(database, "database");
|
|
synchronized (this.trackerLock) {
|
|
if (this.initialized) {
|
|
Log.e(Room.LOG_TAG, "Invalidation tracker is initialized twice :/.");
|
|
return;
|
|
}
|
|
database.execSQL("PRAGMA temp_store = MEMORY;");
|
|
database.execSQL("PRAGMA recursive_triggers='ON';");
|
|
database.execSQL(CREATE_TRACKING_TABLE_SQL);
|
|
syncTriggers$room_runtime_release(database);
|
|
this.cleanupStatement = database.compileStatement(RESET_UPDATED_TABLES_SQL);
|
|
this.initialized = true;
|
|
Unit unit = Unit.INSTANCE;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public final void onAutoCloseCallback() {
|
|
synchronized (this.trackerLock) {
|
|
this.initialized = false;
|
|
this.observedTableTracker.resetTriggerState();
|
|
SupportSQLiteStatement supportSQLiteStatement = this.cleanupStatement;
|
|
if (supportSQLiteStatement != null) {
|
|
supportSQLiteStatement.close();
|
|
Unit unit = Unit.INSTANCE;
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void startMultiInstanceInvalidation$room_runtime_release(Context context, String name, Intent serviceIntent) {
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
Intrinsics.checkNotNullParameter(name, "name");
|
|
Intrinsics.checkNotNullParameter(serviceIntent, "serviceIntent");
|
|
this.multiInstanceInvalidationClient = new MultiInstanceInvalidationClient(context, name, serviceIntent, this, this.database.getQueryExecutor());
|
|
}
|
|
|
|
public final void stopMultiInstanceInvalidation$room_runtime_release() {
|
|
MultiInstanceInvalidationClient multiInstanceInvalidationClient = this.multiInstanceInvalidationClient;
|
|
if (multiInstanceInvalidationClient != null) {
|
|
multiInstanceInvalidationClient.stop();
|
|
}
|
|
this.multiInstanceInvalidationClient = null;
|
|
}
|
|
|
|
private final void stopTrackingTable(SupportSQLiteDatabase supportSQLiteDatabase, int i) {
|
|
String str = this.tablesNames[i];
|
|
for (String str2 : TRIGGERS) {
|
|
String str3 = "DROP TRIGGER IF EXISTS " + Companion.getTriggerName$room_runtime_release(str, str2);
|
|
Intrinsics.checkNotNullExpressionValue(str3, "StringBuilder().apply(builderAction).toString()");
|
|
supportSQLiteDatabase.execSQL(str3);
|
|
}
|
|
}
|
|
|
|
private final void startTrackingTable(SupportSQLiteDatabase supportSQLiteDatabase, int i) {
|
|
supportSQLiteDatabase.execSQL("INSERT OR IGNORE INTO room_table_modification_log VALUES(" + i + ", 0)");
|
|
String str = this.tablesNames[i];
|
|
for (String str2 : TRIGGERS) {
|
|
String str3 = "CREATE TEMP TRIGGER IF NOT EXISTS " + Companion.getTriggerName$room_runtime_release(str, str2) + " AFTER " + str2 + " ON `" + str + "` BEGIN UPDATE " + UPDATE_TABLE_NAME + " SET " + INVALIDATED_COLUMN_NAME + " = 1 WHERE " + TABLE_ID_COLUMN_NAME + " = " + i + " AND " + INVALIDATED_COLUMN_NAME + " = 0; END";
|
|
Intrinsics.checkNotNullExpressionValue(str3, "StringBuilder().apply(builderAction).toString()");
|
|
supportSQLiteDatabase.execSQL(str3);
|
|
}
|
|
}
|
|
|
|
@SuppressLint({"RestrictedApi"})
|
|
@WorkerThread
|
|
public void addObserver(Observer observer) {
|
|
int[] intArray;
|
|
ObserverWrapper putIfAbsent;
|
|
Intrinsics.checkNotNullParameter(observer, "observer");
|
|
String[] resolveViews = resolveViews(observer.getTables$room_runtime_release());
|
|
ArrayList arrayList = new ArrayList(resolveViews.length);
|
|
for (String str : resolveViews) {
|
|
Map<String, Integer> map = this.tableIdLookup;
|
|
Locale US = Locale.US;
|
|
Intrinsics.checkNotNullExpressionValue(US, "US");
|
|
String lowerCase = str.toLowerCase(US);
|
|
Intrinsics.checkNotNullExpressionValue(lowerCase, "this as java.lang.String).toLowerCase(locale)");
|
|
Integer num = map.get(lowerCase);
|
|
if (num == null) {
|
|
throw new IllegalArgumentException("There is no table with name " + str);
|
|
}
|
|
arrayList.add(Integer.valueOf(num.intValue()));
|
|
}
|
|
intArray = CollectionsKt___CollectionsKt.toIntArray(arrayList);
|
|
ObserverWrapper observerWrapper = new ObserverWrapper(observer, intArray, resolveViews);
|
|
synchronized (this.observerMap) {
|
|
putIfAbsent = this.observerMap.putIfAbsent(observer, observerWrapper);
|
|
}
|
|
if (putIfAbsent == null && this.observedTableTracker.onAdded(Arrays.copyOf(intArray, intArray.length))) {
|
|
syncTriggers$room_runtime_release();
|
|
}
|
|
}
|
|
|
|
private final String[] validateAndResolveTableNames(String[] strArr) {
|
|
String[] resolveViews = resolveViews(strArr);
|
|
for (String str : resolveViews) {
|
|
Map<String, Integer> map = this.tableIdLookup;
|
|
Locale US = Locale.US;
|
|
Intrinsics.checkNotNullExpressionValue(US, "US");
|
|
String lowerCase = str.toLowerCase(US);
|
|
Intrinsics.checkNotNullExpressionValue(lowerCase, "this as java.lang.String).toLowerCase(locale)");
|
|
if (!map.containsKey(lowerCase)) {
|
|
throw new IllegalArgumentException(("There is no table with name " + str).toString());
|
|
}
|
|
}
|
|
return resolveViews;
|
|
}
|
|
|
|
private final String[] resolveViews(String[] strArr) {
|
|
Set createSetBuilder;
|
|
Set build;
|
|
createSetBuilder = SetsKt__SetsJVMKt.createSetBuilder();
|
|
for (String str : strArr) {
|
|
Map<String, Set<String>> map = this.viewTables;
|
|
Locale US = Locale.US;
|
|
Intrinsics.checkNotNullExpressionValue(US, "US");
|
|
String lowerCase = str.toLowerCase(US);
|
|
Intrinsics.checkNotNullExpressionValue(lowerCase, "this as java.lang.String).toLowerCase(locale)");
|
|
if (map.containsKey(lowerCase)) {
|
|
Map<String, Set<String>> map2 = this.viewTables;
|
|
Intrinsics.checkNotNullExpressionValue(US, "US");
|
|
String lowerCase2 = str.toLowerCase(US);
|
|
Intrinsics.checkNotNullExpressionValue(lowerCase2, "this as java.lang.String).toLowerCase(locale)");
|
|
Set<String> set = map2.get(lowerCase2);
|
|
Intrinsics.checkNotNull(set);
|
|
createSetBuilder.addAll(set);
|
|
} else {
|
|
createSetBuilder.add(str);
|
|
}
|
|
}
|
|
build = SetsKt__SetsJVMKt.build(createSetBuilder);
|
|
return (String[]) build.toArray(new String[0]);
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public void addWeakObserver(Observer observer) {
|
|
Intrinsics.checkNotNullParameter(observer, "observer");
|
|
addObserver(new WeakObserver(this, observer));
|
|
}
|
|
|
|
@SuppressLint({"RestrictedApi"})
|
|
@WorkerThread
|
|
public void removeObserver(Observer observer) {
|
|
ObserverWrapper remove;
|
|
Intrinsics.checkNotNullParameter(observer, "observer");
|
|
synchronized (this.observerMap) {
|
|
remove = this.observerMap.remove(observer);
|
|
}
|
|
if (remove != null) {
|
|
ObservedTableTracker observedTableTracker = this.observedTableTracker;
|
|
int[] tableIds$room_runtime_release = remove.getTableIds$room_runtime_release();
|
|
if (observedTableTracker.onRemoved(Arrays.copyOf(tableIds$room_runtime_release, tableIds$room_runtime_release.length))) {
|
|
syncTriggers$room_runtime_release();
|
|
}
|
|
}
|
|
}
|
|
|
|
public final boolean ensureInitialization$room_runtime_release() {
|
|
if (!this.database.isOpenInternal()) {
|
|
return false;
|
|
}
|
|
if (!this.initialized) {
|
|
this.database.getOpenHelper().getWritableDatabase();
|
|
}
|
|
if (this.initialized) {
|
|
return true;
|
|
}
|
|
Log.e(Room.LOG_TAG, "database is not initialized even though it is open");
|
|
return false;
|
|
}
|
|
|
|
public void refreshVersionsAsync() {
|
|
if (this.pendingRefresh.compareAndSet(false, true)) {
|
|
AutoCloser autoCloser = this.autoCloser;
|
|
if (autoCloser != null) {
|
|
autoCloser.incrementCountAndEnsureDbIsOpen();
|
|
}
|
|
this.database.getQueryExecutor().execute(this.refreshRunnable);
|
|
}
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
@WorkerThread
|
|
public void refreshVersionsSync() {
|
|
AutoCloser autoCloser = this.autoCloser;
|
|
if (autoCloser != null) {
|
|
autoCloser.incrementCountAndEnsureDbIsOpen();
|
|
}
|
|
syncTriggers$room_runtime_release();
|
|
this.refreshRunnable.run();
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY})
|
|
public final void notifyObserversByTableNames(String... tables) {
|
|
Intrinsics.checkNotNullParameter(tables, "tables");
|
|
synchronized (this.observerMap) {
|
|
try {
|
|
Iterator<Map.Entry<K, V>> it = this.observerMap.iterator();
|
|
while (it.hasNext()) {
|
|
Map.Entry entry = (Map.Entry) it.next();
|
|
Intrinsics.checkNotNullExpressionValue(entry, "(observer, wrapper)");
|
|
Observer observer = (Observer) entry.getKey();
|
|
ObserverWrapper observerWrapper = (ObserverWrapper) entry.getValue();
|
|
if (!observer.isRemote$room_runtime_release()) {
|
|
observerWrapper.notifyByTableNames$room_runtime_release(tables);
|
|
}
|
|
}
|
|
Unit unit = Unit.INSTANCE;
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void syncTriggers$room_runtime_release(SupportSQLiteDatabase database) {
|
|
Intrinsics.checkNotNullParameter(database, "database");
|
|
if (database.inTransaction()) {
|
|
return;
|
|
}
|
|
try {
|
|
Lock closeLock$room_runtime_release = this.database.getCloseLock$room_runtime_release();
|
|
closeLock$room_runtime_release.lock();
|
|
try {
|
|
synchronized (this.syncTriggersLock) {
|
|
int[] tablesToSync = this.observedTableTracker.getTablesToSync();
|
|
if (tablesToSync == null) {
|
|
return;
|
|
}
|
|
Companion.beginTransactionInternal$room_runtime_release(database);
|
|
try {
|
|
int length = tablesToSync.length;
|
|
int i = 0;
|
|
int i2 = 0;
|
|
while (i < length) {
|
|
int i3 = tablesToSync[i];
|
|
int i4 = i2 + 1;
|
|
if (i3 == 1) {
|
|
startTrackingTable(database, i2);
|
|
} else if (i3 == 2) {
|
|
stopTrackingTable(database, i2);
|
|
}
|
|
i++;
|
|
i2 = i4;
|
|
}
|
|
database.setTransactionSuccessful();
|
|
database.endTransaction();
|
|
Unit unit = Unit.INSTANCE;
|
|
} catch (Throwable th) {
|
|
database.endTransaction();
|
|
throw th;
|
|
}
|
|
}
|
|
} finally {
|
|
closeLock$room_runtime_release.unlock();
|
|
}
|
|
} catch (SQLiteException e) {
|
|
Log.e(Room.LOG_TAG, "Cannot run invalidation tracker. Is the db closed?", e);
|
|
} catch (IllegalStateException e2) {
|
|
Log.e(Room.LOG_TAG, "Cannot run invalidation tracker. Is the db closed?", e2);
|
|
}
|
|
}
|
|
|
|
public final void syncTriggers$room_runtime_release() {
|
|
if (this.database.isOpenInternal()) {
|
|
syncTriggers$room_runtime_release(this.database.getOpenHelper().getWritableDatabase());
|
|
}
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public <T> LiveData<T> createLiveData(String[] tableNames, Callable<T> computeFunction) {
|
|
Intrinsics.checkNotNullParameter(tableNames, "tableNames");
|
|
Intrinsics.checkNotNullParameter(computeFunction, "computeFunction");
|
|
return createLiveData(tableNames, false, computeFunction);
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public <T> LiveData<T> createLiveData(String[] tableNames, boolean z, Callable<T> computeFunction) {
|
|
Intrinsics.checkNotNullParameter(tableNames, "tableNames");
|
|
Intrinsics.checkNotNullParameter(computeFunction, "computeFunction");
|
|
return this.invalidationLiveDataContainer.create(validateAndResolveTableNames(tableNames), z, computeFunction);
|
|
}
|
|
|
|
@SourceDebugExtension({"SMAP\nInvalidationTracker.kt\nKotlin\n*S Kotlin\n*F\n+ 1 InvalidationTracker.kt\nandroidx/room/InvalidationTracker$ObserverWrapper\n+ 2 _Arrays.kt\nkotlin/collections/ArraysKt___ArraysKt\n*L\n1#1,840:1\n13674#2,3:841\n12744#2,2:844\n13579#2:846\n13579#2,2:847\n13580#2:849\n*S KotlinDebug\n*F\n+ 1 InvalidationTracker.kt\nandroidx/room/InvalidationTracker$ObserverWrapper\n*L\n612#1:841,3\n634#1:844,2\n640#1:846\n641#1:847,2\n640#1:849\n*E\n"})
|
|
public static final class ObserverWrapper {
|
|
private final Observer observer;
|
|
private final Set<String> singleTableSet;
|
|
private final int[] tableIds;
|
|
private final String[] tableNames;
|
|
|
|
public final Observer getObserver$room_runtime_release() {
|
|
return this.observer;
|
|
}
|
|
|
|
public final int[] getTableIds$room_runtime_release() {
|
|
return this.tableIds;
|
|
}
|
|
|
|
public ObserverWrapper(Observer observer, int[] tableIds, String[] tableNames) {
|
|
Set<String> emptySet;
|
|
Intrinsics.checkNotNullParameter(observer, "observer");
|
|
Intrinsics.checkNotNullParameter(tableIds, "tableIds");
|
|
Intrinsics.checkNotNullParameter(tableNames, "tableNames");
|
|
this.observer = observer;
|
|
this.tableIds = tableIds;
|
|
this.tableNames = tableNames;
|
|
if (!(tableNames.length == 0)) {
|
|
emptySet = SetsKt__SetsJVMKt.setOf(tableNames[0]);
|
|
} else {
|
|
emptySet = SetsKt__SetsKt.emptySet();
|
|
}
|
|
this.singleTableSet = emptySet;
|
|
if (tableIds.length != tableNames.length) {
|
|
throw new IllegalStateException("Check failed.".toString());
|
|
}
|
|
}
|
|
|
|
public final void notifyByTableInvalidStatus$room_runtime_release(Set<Integer> invalidatedTablesIds) {
|
|
Set<String> emptySet;
|
|
Set createSetBuilder;
|
|
Intrinsics.checkNotNullParameter(invalidatedTablesIds, "invalidatedTablesIds");
|
|
int[] iArr = this.tableIds;
|
|
int length = iArr.length;
|
|
if (length != 0) {
|
|
int i = 0;
|
|
if (length == 1) {
|
|
emptySet = invalidatedTablesIds.contains(Integer.valueOf(iArr[0])) ? this.singleTableSet : SetsKt__SetsKt.emptySet();
|
|
} else {
|
|
createSetBuilder = SetsKt__SetsJVMKt.createSetBuilder();
|
|
int[] iArr2 = this.tableIds;
|
|
int length2 = iArr2.length;
|
|
int i2 = 0;
|
|
while (i < length2) {
|
|
int i3 = i2 + 1;
|
|
if (invalidatedTablesIds.contains(Integer.valueOf(iArr2[i]))) {
|
|
createSetBuilder.add(this.tableNames[i2]);
|
|
}
|
|
i++;
|
|
i2 = i3;
|
|
}
|
|
emptySet = SetsKt__SetsJVMKt.build(createSetBuilder);
|
|
}
|
|
} else {
|
|
emptySet = SetsKt__SetsKt.emptySet();
|
|
}
|
|
if (!emptySet.isEmpty()) {
|
|
this.observer.onInvalidated(emptySet);
|
|
}
|
|
}
|
|
|
|
public final void notifyByTableNames$room_runtime_release(String[] tables) {
|
|
Set<String> emptySet;
|
|
boolean equals;
|
|
Set createSetBuilder;
|
|
boolean equals2;
|
|
Intrinsics.checkNotNullParameter(tables, "tables");
|
|
int length = this.tableNames.length;
|
|
if (length != 0) {
|
|
if (length != 1) {
|
|
createSetBuilder = SetsKt__SetsJVMKt.createSetBuilder();
|
|
for (String str : tables) {
|
|
for (String str2 : this.tableNames) {
|
|
equals2 = StringsKt__StringsJVMKt.equals(str2, str, true);
|
|
if (equals2) {
|
|
createSetBuilder.add(str2);
|
|
}
|
|
}
|
|
}
|
|
emptySet = SetsKt__SetsJVMKt.build(createSetBuilder);
|
|
} else {
|
|
int length2 = tables.length;
|
|
int i = 0;
|
|
while (true) {
|
|
if (i < length2) {
|
|
equals = StringsKt__StringsJVMKt.equals(tables[i], this.tableNames[0], true);
|
|
if (equals) {
|
|
emptySet = this.singleTableSet;
|
|
break;
|
|
}
|
|
i++;
|
|
} else {
|
|
emptySet = SetsKt__SetsKt.emptySet();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
emptySet = SetsKt__SetsKt.emptySet();
|
|
}
|
|
if (!emptySet.isEmpty()) {
|
|
this.observer.onInvalidated(emptySet);
|
|
}
|
|
}
|
|
}
|
|
|
|
@SourceDebugExtension({"SMAP\nInvalidationTracker.kt\nKotlin\n*S Kotlin\n*F\n+ 1 InvalidationTracker.kt\nandroidx/room/InvalidationTracker$Observer\n+ 2 ArraysJVM.kt\nkotlin/collections/ArraysKt__ArraysJVMKt\n*L\n1#1,840:1\n37#2,2:841\n*S KotlinDebug\n*F\n+ 1 InvalidationTracker.kt\nandroidx/room/InvalidationTracker$Observer\n*L\n670#1:841,2\n*E\n"})
|
|
public static abstract class Observer {
|
|
private final String[] tables;
|
|
|
|
public final String[] getTables$room_runtime_release() {
|
|
return this.tables;
|
|
}
|
|
|
|
public boolean isRemote$room_runtime_release() {
|
|
return false;
|
|
}
|
|
|
|
public abstract void onInvalidated(Set<String> set);
|
|
|
|
public Observer(String[] tables) {
|
|
Intrinsics.checkNotNullParameter(tables, "tables");
|
|
this.tables = tables;
|
|
}
|
|
|
|
/* JADX WARN: Illegal instructions before constructor call */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public Observer(java.lang.String r3, java.lang.String... r4) {
|
|
/*
|
|
r2 = this;
|
|
java.lang.String r0 = "firstTable"
|
|
kotlin.jvm.internal.Intrinsics.checkNotNullParameter(r3, r0)
|
|
java.lang.String r0 = "rest"
|
|
kotlin.jvm.internal.Intrinsics.checkNotNullParameter(r4, r0)
|
|
java.util.List r0 = kotlin.collections.CollectionsKt.createListBuilder()
|
|
r1 = r0
|
|
java.util.Collection r1 = (java.util.Collection) r1
|
|
kotlin.collections.CollectionsKt.addAll(r1, r4)
|
|
r0.add(r3)
|
|
java.util.List r3 = kotlin.collections.CollectionsKt.build(r0)
|
|
java.util.Collection r3 = (java.util.Collection) r3
|
|
r4 = 0
|
|
java.lang.String[] r4 = new java.lang.String[r4]
|
|
java.lang.Object[] r3 = r3.toArray(r4)
|
|
java.lang.String[] r3 = (java.lang.String[]) r3
|
|
r2.<init>(r3)
|
|
return
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.room.InvalidationTracker.Observer.<init>(java.lang.String, java.lang.String[]):void");
|
|
}
|
|
}
|
|
|
|
@SourceDebugExtension({"SMAP\nInvalidationTracker.kt\nKotlin\n*S Kotlin\n*F\n+ 1 InvalidationTracker.kt\nandroidx/room/InvalidationTracker$ObservedTableTracker\n+ 2 _Arrays.kt\nkotlin/collections/ArraysKt___ArraysKt\n*L\n1#1,840:1\n13600#2,2:841\n13600#2,2:843\n13684#2,3:845\n*S KotlinDebug\n*F\n+ 1 InvalidationTracker.kt\nandroidx/room/InvalidationTracker$ObservedTableTracker\n*L\n711#1:841,2\n729#1:843,2\n765#1:845,3\n*E\n"})
|
|
public static final class ObservedTableTracker {
|
|
public static final int ADD = 1;
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final int NO_OP = 0;
|
|
public static final int REMOVE = 2;
|
|
private boolean needsSync;
|
|
private final long[] tableObservers;
|
|
private final int[] triggerStateChanges;
|
|
private final boolean[] triggerStates;
|
|
|
|
public final boolean getNeedsSync() {
|
|
return this.needsSync;
|
|
}
|
|
|
|
public final long[] getTableObservers() {
|
|
return this.tableObservers;
|
|
}
|
|
|
|
public final void setNeedsSync(boolean z) {
|
|
this.needsSync = z;
|
|
}
|
|
|
|
public ObservedTableTracker(int i) {
|
|
this.tableObservers = new long[i];
|
|
this.triggerStates = new boolean[i];
|
|
this.triggerStateChanges = new int[i];
|
|
}
|
|
|
|
public final boolean onAdded(int... tableIds) {
|
|
boolean z;
|
|
Intrinsics.checkNotNullParameter(tableIds, "tableIds");
|
|
synchronized (this) {
|
|
try {
|
|
z = false;
|
|
for (int i : tableIds) {
|
|
long[] jArr = this.tableObservers;
|
|
long j = jArr[i];
|
|
jArr[i] = 1 + j;
|
|
if (j == 0) {
|
|
z = true;
|
|
this.needsSync = true;
|
|
}
|
|
}
|
|
Unit unit = Unit.INSTANCE;
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
return z;
|
|
}
|
|
|
|
public final boolean onRemoved(int... tableIds) {
|
|
boolean z;
|
|
Intrinsics.checkNotNullParameter(tableIds, "tableIds");
|
|
synchronized (this) {
|
|
try {
|
|
z = false;
|
|
for (int i : tableIds) {
|
|
long[] jArr = this.tableObservers;
|
|
long j = jArr[i];
|
|
jArr[i] = j - 1;
|
|
if (j == 1) {
|
|
z = true;
|
|
this.needsSync = true;
|
|
}
|
|
}
|
|
Unit unit = Unit.INSTANCE;
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
return z;
|
|
}
|
|
|
|
public final void resetTriggerState() {
|
|
synchronized (this) {
|
|
Arrays.fill(this.triggerStates, false);
|
|
this.needsSync = true;
|
|
Unit unit = Unit.INSTANCE;
|
|
}
|
|
}
|
|
|
|
@VisibleForTesting
|
|
public final int[] getTablesToSync() {
|
|
synchronized (this) {
|
|
try {
|
|
if (!this.needsSync) {
|
|
return null;
|
|
}
|
|
long[] jArr = this.tableObservers;
|
|
int length = jArr.length;
|
|
int i = 0;
|
|
int i2 = 0;
|
|
while (i < length) {
|
|
int i3 = i2 + 1;
|
|
int i4 = 1;
|
|
boolean z = jArr[i] > 0;
|
|
boolean[] zArr = this.triggerStates;
|
|
if (z != zArr[i2]) {
|
|
int[] iArr = this.triggerStateChanges;
|
|
if (!z) {
|
|
i4 = 2;
|
|
}
|
|
iArr[i2] = i4;
|
|
} else {
|
|
this.triggerStateChanges[i2] = 0;
|
|
}
|
|
zArr[i2] = z;
|
|
i++;
|
|
i2 = i3;
|
|
}
|
|
this.needsSync = false;
|
|
return (int[]) this.triggerStateChanges.clone();
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
}
|
|
|
|
public static final class Companion {
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
private Companion() {
|
|
}
|
|
}
|
|
}
|
|
|
|
public static final class WeakObserver extends Observer {
|
|
private final WeakReference<Observer> delegateRef;
|
|
private final InvalidationTracker tracker;
|
|
|
|
public final WeakReference<Observer> getDelegateRef() {
|
|
return this.delegateRef;
|
|
}
|
|
|
|
public final InvalidationTracker getTracker() {
|
|
return this.tracker;
|
|
}
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public WeakObserver(InvalidationTracker tracker, Observer delegate) {
|
|
super(delegate.getTables$room_runtime_release());
|
|
Intrinsics.checkNotNullParameter(tracker, "tracker");
|
|
Intrinsics.checkNotNullParameter(delegate, "delegate");
|
|
this.tracker = tracker;
|
|
this.delegateRef = new WeakReference<>(delegate);
|
|
}
|
|
|
|
@Override // androidx.room.InvalidationTracker.Observer
|
|
public void onInvalidated(Set<String> tables) {
|
|
Intrinsics.checkNotNullParameter(tables, "tables");
|
|
Observer observer = this.delegateRef.get();
|
|
if (observer == null) {
|
|
this.tracker.removeObserver(this);
|
|
} else {
|
|
observer.onInvalidated(tables);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static final class Companion {
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
@VisibleForTesting
|
|
public static /* synthetic */ void getRESET_UPDATED_TABLES_SQL$room_runtime_release$annotations() {
|
|
}
|
|
|
|
@VisibleForTesting
|
|
public static /* synthetic */ void getSELECT_UPDATED_TABLES_SQL$room_runtime_release$annotations() {
|
|
}
|
|
|
|
private Companion() {
|
|
}
|
|
|
|
public final String getTriggerName$room_runtime_release(String tableName, String triggerType) {
|
|
Intrinsics.checkNotNullParameter(tableName, "tableName");
|
|
Intrinsics.checkNotNullParameter(triggerType, "triggerType");
|
|
return "`room_table_modification_trigger_" + tableName + '_' + triggerType + '`';
|
|
}
|
|
|
|
public final void beginTransactionInternal$room_runtime_release(SupportSQLiteDatabase database) {
|
|
Intrinsics.checkNotNullParameter(database, "database");
|
|
if (database.isWriteAheadLoggingEnabled()) {
|
|
database.beginTransactionNonExclusive();
|
|
} else {
|
|
database.beginTransaction();
|
|
}
|
|
}
|
|
}
|
|
}
|