Updated AndroidX

pull/194/merge
M66B 3 years ago
parent 3bc1c1aa20
commit 9a69f4809e

@ -316,12 +316,12 @@ dependencies {
def startup_version = "1.1.0" def startup_version = "1.1.0"
def annotation_version_experimental = "1.2.0" def annotation_version_experimental = "1.2.0"
def core_version = "1.7.0" // 1.8.0-alpha03 def core_version = "1.7.0" // 1.8.0-alpha05 / 1.9.0-alpha01
def shortcuts_version = "1.0.0" def shortcuts_version = "1.0.0"
def appcompat_version = "1.4.1" def appcompat_version = "1.4.1" // 1.6.0-alpha01
def emoji_version = "1.1.0-beta01" def emoji_version = "1.1.0" // 1.2.0-alpha01
def activity_version = "1.4.0" // 1.5.0-alpha01 def activity_version = "1.4.0" // 1.5.0-alpha03
def fragment_version = "1.4.1" // 1.5.0-alpha01 def fragment_version = "1.4.1" // 1.5.0-alpha03
def webkit_version = "1.4.0" def webkit_version = "1.4.0"
def recyclerview_version = "1.2.1" def recyclerview_version = "1.2.1"
def coordinatorlayout_version = "1.2.0" def coordinatorlayout_version = "1.2.0"
@ -331,10 +331,10 @@ dependencies {
def lbm_version = "1.1.0" def lbm_version = "1.1.0"
def swiperefresh_version = "1.2.0-alpha01" def swiperefresh_version = "1.2.0-alpha01"
def documentfile_version = "1.1.0-alpha01" def documentfile_version = "1.1.0-alpha01"
def lifecycle_version = "2.4.0" // 2.5.0-alpha01 def lifecycle_version = "2.4.0" // 2.5.0-alpha03
def lifecycle_extensions_version = "2.2.0" def lifecycle_extensions_version = "2.2.0"
def room_version = "2.4.1" def room_version = "2.4.2" // 2.5.0-alpha01
def sqlite_version = "2.2.0" def sqlite_version = "2.2.0" // 2.3.0-alpha01
def requery_version = "3.36.0" def requery_version = "3.36.0"
def paging_version = "2.1.2" // 3.1.0 def paging_version = "2.1.2" // 3.1.0
def preference_version = "1.2.0" def preference_version = "1.2.0"

@ -104,7 +104,7 @@ public class InvalidationTracker {
@SuppressWarnings("WeakerAccess") /* synthetic access */ @SuppressWarnings("WeakerAccess") /* synthetic access */
volatile SupportSQLiteStatement mCleanupStatement; volatile SupportSQLiteStatement mCleanupStatement;
private ObservedTableTracker mObservedTableTracker; private final ObservedTableTracker mObservedTableTracker;
private final InvalidationLiveDataContainer mInvalidationLiveDataContainer; private final InvalidationLiveDataContainer mInvalidationLiveDataContainer;
@ -115,6 +115,8 @@ public class InvalidationTracker {
private MultiInstanceInvalidationClient mMultiInstanceInvalidationClient; private MultiInstanceInvalidationClient mMultiInstanceInvalidationClient;
private final Object mSyncTriggersLock = new Object();
/** /**
* Used by the generated code. * Used by the generated code.
* *
@ -537,14 +539,13 @@ public class InvalidationTracker {
return; return;
} }
try { try {
// This method runs in a while loop because while changes are synced to db, another
// runnable may be skipped. If we cause it to skip, we need to do its work.
while (true) {
Lock closeLock = mDatabase.getCloseLock(); Lock closeLock = mDatabase.getCloseLock();
closeLock.lock(); closeLock.lock();
try { try {
// there is a potential race condition where another mSyncTriggers runnable // Serialize adding and removing table trackers, this is specifically important
// can start running right after we get the tables list to sync. // to avoid missing invalidation before a transaction starts but there are
// pending (possibly concurrent) observer changes.
synchronized (mSyncTriggersLock) {
final int[] tablesToSync = mObservedTableTracker.getTablesToSync(); final int[] tablesToSync = mObservedTableTracker.getTablesToSync();
if (tablesToSync == null) { if (tablesToSync == null) {
return; return;
@ -566,11 +567,10 @@ public class InvalidationTracker {
} finally { } finally {
database.endTransaction(); database.endTransaction();
} }
mObservedTableTracker.onSyncCompleted(); }
} finally { } finally {
closeLock.unlock(); closeLock.unlock();
} }
}
} catch (IllegalStateException | SQLiteException exception) { } catch (IllegalStateException | SQLiteException exception) {
// may happen if db is closed. just log. // may happen if db is closed. just log.
Log.e(Room.LOG_TAG, "Cannot run invalidation tracker. Is the db closed?", Log.e(Room.LOG_TAG, "Cannot run invalidation tracker. Is the db closed?",
@ -789,13 +789,6 @@ public class InvalidationTracker {
boolean mNeedsSync; boolean mNeedsSync;
/**
* After we return non-null value from getTablesToSync, we expect a onSyncCompleted before
* returning any non-null value from getTablesToSync.
* This allows us to workaround any multi-threaded state syncing issues.
*/
boolean mPendingSync;
ObservedTableTracker(int tableCount) { ObservedTableTracker(int tableCount) {
mTableObservers = new long[tableCount]; mTableObservers = new long[tableCount];
mTriggerStates = new boolean[tableCount]; mTriggerStates = new boolean[tableCount];
@ -852,7 +845,7 @@ public class InvalidationTracker {
} }
/** /**
* If this returns non-null, you must call onSyncCompleted. * If this returns non-null there are no pending sync operations.
* *
* @return int[] An int array where the index for each tableId has the action for that * @return int[] An int array where the index for each tableId has the action for that
* table. * table.
@ -860,7 +853,7 @@ public class InvalidationTracker {
@Nullable @Nullable
int[] getTablesToSync() { int[] getTablesToSync() {
synchronized (this) { synchronized (this) {
if (!mNeedsSync || mPendingSync) { if (!mNeedsSync) {
return null; return null;
} }
final int tableCount = mTableObservers.length; final int tableCount = mTableObservers.length;
@ -873,19 +866,8 @@ public class InvalidationTracker {
} }
mTriggerStates[i] = newState; mTriggerStates[i] = newState;
} }
mPendingSync = true;
mNeedsSync = false; mNeedsSync = false;
return mTriggerStateChanges; return mTriggerStateChanges.clone();
}
}
/**
* if getTablesToSync returned non-null, the called should call onSyncCompleted once it
* is done.
*/
void onSyncCompleted() {
synchronized (this) {
mPendingSync = false;
} }
} }
} }

Loading…
Cancel
Save