Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
15e5790
fix(upload): resume chunked uploads from the parts the server already…
ToteMeiSter Oct 5, 2026
bfe8366
fix(upload): prepare the file of an upload once and keep it between runs
ToteMeiSter Oct 5, 2026
a40ecad
fix(upload): keep the restart mark and the upload files safe
ToteMeiSter Oct 5, 2026
cce7ce7
fix(upload): do not start a chunked upload after a stop
ToteMeiSter Oct 5, 2026
e6fb95a
fix(upload): remember a cancel after doWork() removed its marker
ToteMeiSter Oct 5, 2026
b9d5245
fix(upload): address review findings on resume and cancel
ToteMeiSter Oct 13, 2026
4107b52
fix(upload): copy a content uri aside and rename it after success
ToteMeiSter Oct 13, 2026
26fc4ab
fix(upload): prepare the file in a subdirectory of the workspace
ToteMeiSter Oct 16, 2026
0f1e298
fix(upload): copy an empty file instead of failing it
ToteMeiSter Oct 16, 2026
6a17889
fix(upload): try an upload again after a short server outage
ToteMeiSter Oct 16, 2026
f9f5928
fix(upload): give the chunked uploader its own dispatcher
ToteMeiSter Oct 5, 2026
41da4cb
fix(upload): keep an upload running in a foreground service and retry…
ToteMeiSter Oct 5, 2026
c56aceb
fix(upload): send the cancel request from the application scope
ToteMeiSter Oct 5, 2026
18e7498
fix(upload): do not start a chunked upload after a stop
ToteMeiSter Oct 5, 2026
e019099
test(upload): cancelling one upload must not cancel the uploads behin…
ToteMeiSter Oct 14, 2026
38e91bb
fix(upload): a failed write in the cancel path must not fail the uplo…
ToteMeiSter Oct 14, 2026
48ab95e
fix(upload): keep the cancel flag when WorkManager stopped the cancel…
ToteMeiSter Oct 14, 2026
66f28e6
fix(upload): give up an upload the server keeps refusing for 24 hours
ToteMeiSter Oct 15, 2026
fe91dd9
fix(upload): fail at once when the prepared file cannot be read
ToteMeiSter Oct 15, 2026
20a1a5b
fix(upload): report a failed upload in the output data of the work
ToteMeiSter Oct 15, 2026
7177c30
fix(upload): show the upload notification only for files that are upl…
ToteMeiSter Oct 15, 2026
95f6a68
fix(upload): remove the draft file of an upload that failed
ToteMeiSter Oct 15, 2026
25cbdd4
fix(upload): take the size for the foreground decision from the prepa…
ToteMeiSter Oct 15, 2026
9f3808b
fix(upload): keep the 24 hours from failing an upload that took data
ToteMeiSter Oct 15, 2026
e063f78
fix(upload): forget the old progress when an upload starts from the b…
ToteMeiSter Oct 15, 2026
52b9b50
test(upload): keep the retry tests of FileUploader in their own file
ToteMeiSter Oct 16, 2026
9d2a1bd
Merge upstream/master into prep/6828-placeholder-failed
ToteMeiSter Oct 20, 2026
5d6de8a
fix(chat): mark an upload placeholder failed when the worker reports …
ToteMeiSter Oct 15, 2026
d8b4f38
test(upload): move the upload tests of #6828 to the mockwebserver3 AP…
ToteMeiSter Oct 20, 2026
ae7fff6
test(upload): split the upload view model tests to keep detekt TooMan…
ToteMeiSter Oct 20, 2026
215ad75
Merge upstream/master into fix/upload-foreground-service
ToteMeiSter Nov 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ dependencies {
androidTestImplementation("androidx.test:core-ktx:1.7.0")
androidTestImplementation("org.mockito:mockito-android:5.24.0")
testImplementation("androidx.work:work-testing:$workVersion")
testImplementation("androidx.concurrent:concurrent-futures:1.2.0")
androidTestImplementation("androidx.work:work-testing:$workVersion")
androidTestImplementation("androidx.test.espresso:espresso-core:$espressoVersion") {
exclude(group = "com.android.support", module = "support-annotations")
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />

<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
Expand Down Expand Up @@ -357,6 +358,14 @@
<receiver
android:name=".receivers.EndCallReceiver"
android:exported="false" />
<receiver
android:name=".receivers.UploadCancelReceiver"
android:exported="false" />

<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="dataSync"
tools:node="merge" />

<service
android:name=".utils.SyncService"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,18 @@ class ChatViewModel @AssistedInject constructor(
}

fun cancelUpload(referenceId: String) {
// uploadReferenceToWorkId is session-local (never persisted) - after an app restart it's
// empty even for an upload that's still stuck showing as "uploading" from a previous
// session, so a placeholder must still be removable even when there's no known work id to
// also cancel. Without this, cancel silently did nothing for any such placeholder, leaving
// the user with no way to clear a permanently stuck upload.
uploadReferenceToWorkId.remove(referenceId)?.let { workId ->
UploadAndShareFilesWorker.cancelUpload(referenceId, workId, _uploadedLocalPreviewMap.value[referenceId])
}
viewModelScope.launch {
// uploadReferenceToWorkId is session-local - after an app restart it's empty, then the work is
// found by its reference id. That lookup blocks, so it runs off the main thread.
// The placeholder below is removed whether or not a work is found.
// Both jobs run in appScope: leaving the chat right after the tap must not drop the cancellation.
val workId = uploadReferenceToWorkId.remove(referenceId)
// read before the map is cleared below: the cancelled upload that has not started releases the read
// access to its file
val fileUri = _uploadedLocalPreviewMap.value[referenceId]
appScope.launch(Dispatchers.IO) {
UploadAndShareFilesWorker.cancelUpload(referenceId, workId, fileUri)
}
appScope.launch {
chatRepository.deleteTempMessageByReferenceId(referenceId)
}
_uploadProgressMap.update { it - referenceId }
Expand Down Expand Up @@ -2513,7 +2516,11 @@ class ChatViewModel @AssistedInject constructor(
if (progress >= 0) {
_uploadProgressMap.update { it + (referenceId to progress) }
}
if (workInfo.state == WorkInfo.State.FAILED) {
// The worker ends a failed upload as SUCCEEDED (so the uploads queued behind it still run) and reports
// the failure in its output data; FAILED stays for a worker that crashed.
val failed = workInfo.state == WorkInfo.State.FAILED ||
workInfo.outputData.getBoolean(UploadAndShareFilesWorker.KEY_UPLOAD_FAILED, false)
if (failed) {
viewModelScope.launch { chatRepository.markUploadPlaceholderFailed(referenceId) }
}
if (workInfo.state.isFinished) {
Expand Down
Loading
Loading