feat: Update Android build workflow to run on Linux and enhance sync cycle handling in ProtocolManager
This commit is contained in:
@@ -14,7 +14,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: android-builders
|
runs-on: linux
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
|||||||
@@ -550,6 +550,13 @@ object ProtocolManager {
|
|||||||
subscribePushTokenIfAvailable()
|
subscribePushTokenIfAvailable()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun finishSyncCycle(reason: String) {
|
||||||
|
addLog(reason)
|
||||||
|
setSyncInProgress(false)
|
||||||
|
retryWaitingMessages()
|
||||||
|
requestMissingUserInfo()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send FCM push token to server (SUBSCRIBE).
|
* Send FCM push token to server (SUBSCRIBE).
|
||||||
* Deduplicates: won't re-send the same token within one connection session.
|
* Deduplicates: won't re-send the same token within one connection session.
|
||||||
@@ -689,6 +696,19 @@ object ProtocolManager {
|
|||||||
else -> 0L
|
else -> 0L
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Loop guard: if server keeps BATCH_END with unchanged cursor and we did not
|
||||||
|
// process anything in this batch, treat sync as finished to avoid infinite loop.
|
||||||
|
val noProgress =
|
||||||
|
failuresInBatch == 0 &&
|
||||||
|
processedMaxTimestamp <= 0L &&
|
||||||
|
(nextCursor <= 0L || nextCursor == currentCursor)
|
||||||
|
if (noProgress) {
|
||||||
|
finishSyncCycle(
|
||||||
|
"✅ SYNC COMPLETE — no progress on batch (server=$safeBatchTimestamp, current=$currentCursor)"
|
||||||
|
)
|
||||||
|
return@launch
|
||||||
|
}
|
||||||
|
|
||||||
// If server batch timestamp runs ahead of what we actually processed, clamp it.
|
// If server batch timestamp runs ahead of what we actually processed, clamp it.
|
||||||
// This avoids skipping tail messages when packet delivery/parsing was partial.
|
// This avoids skipping tail messages when packet delivery/parsing was partial.
|
||||||
if (processedMaxTimestamp > 0L && processedMaxTimestamp < safeBatchTimestamp) {
|
if (processedMaxTimestamp > 0L && processedMaxTimestamp < safeBatchTimestamp) {
|
||||||
@@ -709,18 +729,11 @@ object ProtocolManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
SyncStatus.NOT_NEEDED -> {
|
SyncStatus.NOT_NEEDED -> {
|
||||||
addLog("✅ SYNC COMPLETE — no more messages to sync")
|
|
||||||
// Synchronous — immediately marks sync as complete.
|
// Synchronous — immediately marks sync as complete.
|
||||||
// Desktop parity: NOT_NEEDED just sets state to CONNECTED,
|
// Desktop parity: NOT_NEEDED just sets state to CONNECTED,
|
||||||
// does NOT update last_sync timestamp (unnecessary since client
|
// does NOT update last_sync timestamp (unnecessary since client
|
||||||
// was already up to date).
|
// was already up to date).
|
||||||
setSyncInProgress(false)
|
finishSyncCycle("✅ SYNC COMPLETE — no more messages to sync")
|
||||||
// Retry any messages stuck in WAITING status from previous sessions.
|
|
||||||
retryWaitingMessages()
|
|
||||||
// Desktop parity: resolve names for all dialogs with empty titles.
|
|
||||||
// Desktop does this per-component via useUserInformation hook;
|
|
||||||
// we batch it after sync for efficiency.
|
|
||||||
requestMissingUserInfo()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user