diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2021-03-19 15:46:36 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2021-03-22 08:45:51 +0100 |
commit | 44f4e1ce493f7d241ea2952dd5e9e604a3aef788 (patch) | |
tree | 82a500e2dbdc25044da856ea2ecac8b50e6170b4 /lo.xcent | |
parent | 45c1efea0e31caf3f9484479a8f63ba4b9b4a294 (diff) |
tdf#129833 android: Move reading file to separate thread
Reading the input file from the main thread is problematic
when that happens over the network.
For example, trying to opening a file in a NextCloud share
using the system file picker from within the LO Android Viewer
app (with NextCloud app 3.15.1 serving as DocumentsProvider
for the NextCloud share in the file chooser) previously
resulted in a crash, with this in ADB log:
I DownloadFileOperation: Download of /Documents/five_pages.odt to /storage/emulated/0/Android/media/com.nextcloud.client/nextcloud/<USERNAME>@demo2.nextcloud.com/Documents/five_pages.odt: Unexpected exception
E DocumentsStorageProvider: RemoteOperationResult(mSuccess=false, mHttpCode=-1, mHttpPhrase=null, mException=android.os.NetworkOnMainThreadException, mCode=HOST_NOT_AVAILABLE, message=null, getLogMessage=Unexpected exception)
Moving this to a separate thread fixes the
NetworkOnMainThreadException and made opening, editing
and saving the modified file back work successfully
for that scenario.
(Using a separate thread when writing back does not
seem to be necessary, but could be added in a similar
way.)
This just moves the IO to a new thread and then waits
for its completion.
For a better user experience in cases where the copy
operation may be slow, providing some additional
feedback in the UI might be useful.
Change-Id: I58e2c4bb1dcd2d59383fba0f216c9614f5d3e3a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112769
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
(cherry picked from commit 7f838b73e85eb6f0a1dce4647650a5cf5f34ccd2)
Diffstat (limited to 'lo.xcent')
0 files changed, 0 insertions, 0 deletions