Note there's still some FIXMEs in the tests that hint at bugs discovered
by the tests.
Also this is very incomplete, but a good beginning for further tests.
Signed-off-by: Torsten Grote <t@grobox.de>
The initial goal was to make all operations completely synchronous,
so failures can be detected by apps using our DocumentsProvider.
However, `#openDocument()` could not be made fully synchronous,
because we need to wait for the ParcelFileDescriptor we are returning to
close before we can upload a file.
Nextcloud works with locally cached files that only get synchronized to
remote storage.
Things I have tried:
* Use the Handler from the calling I/O Thread:
not guaranteed to have a prepared Looper,
so can't always create Handler on that Thread
* Extend ParcelFileDescriptor and override its close() methods:
For some reason they don't get called when the stream gets closed
* notify the content URI when the upload is complete,
so callers can wait for the notification:
works, but is non-standard.
Other DPs are not doing it,
so it requires Nextcloud specific code on caller side
and is still hacky:
what happens if notification doesn't come? Timeout, but for how long?
* use other ways to get a ParcelFileDescriptor on the file:
couldn't find anything that would interface with Nextcloud's
current architecture
Signed-off-by: Torsten Grote <t@grobox.de>
When no image is selected from the intent we should set onReceiveValue to null and uploadMessage to null otherwise it does not open after closing it without selecting an image.
On API 26+ (Oreo, 8.0) running background services is restricted
by power saving mechanisms, causing occasional IllegalStateException
when service intent is rejected by the OS.
Migrate to startForegroundService API to mitigate this problem.
Audio player service is foreground by design.
Fixes#6665
Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
Media controls view were covered by a ScrollView
stealing all touch events. By changing it to FrameLayout,
touch events can reach media controls.
Content embedded inside ScrollView should not
exceed screen boundaries. If so - content must
be changed.
This fixes immediate problem with unresponsive media controls
reported in #6796 and #6782.
Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
The old solution iterates through all parents of the child until it
finds the given parent or the storage root.
This has been show to be very expensive in empirical tests.
Therefore, this commit introduces a more efficient solution that simply
compares the file paths of child and given parent.
It also ensures that parent and child belong to the same account.
Reviewers need to take extra care that this change does not introduce
security issues by claiming a document is a child of a parent when it is
really not.
Signed-off-by: Torsten Grote <t@grobox.de>
The sync operation detects changes by comparing timestamps in
milliseconds. However, the local modification time only has a precision
of seconds (even though given in milliseconds).
When the DocumentsProvider is used programmatically, operations such as
a create and a subsequent write can happen within the same second
causing the sync operation to not detect the change and therefore
failing to upload a file causing data loss.
This commit also moves the file close listener to the thread used by the
DocumentsStorageProvider as this is more appropriate than the UI thread.
Fixes#6726
Signed-off-by: Torsten Grote <t@grobox.de>
- use correct name collision info by synced folder
- syncedFolder.getNameCollisionPolicyInt -> returns int
- syncedFolder.getNameColllisionPolicy -> returns enum
- remove not needed backgroundJobManager from FilesSyncWork.kt
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>