[Interest] QDir().rename() or QFile::rename() on Android 11
maitai
maitai at virtual-winds.org
Tue Oct 26 09:36:16 CEST 2021
Hello,
The real device I test with has a kernel: 4.14.113-210542248 (Feb 1,
2018)
For the simulator I don't know, it just says :
sdk_gphone_x86_arm-userdebug 11 RSR1.201013.001 6903271 dev-keys.
After more experiments I made the following findings:
I have a folder at the root of the sdCard (/storage/emulated/0/myApp)
that I try to move in /Android/data/org.xxx.myapp/files. That does not
work with QDir::rename, it also does not work in Java with
File.renameTo(), and it does not work in Java with Files.move(Path,
Path). In this later case I catch an IOException on the "from"
directory: java.nio.file.DirectoryNotEmptyException (of course the
"from" directory is not empty and I made sure that the destination
directory does not exist).
If I manually recurse on all the subfolders in the "from" directory and
create all the needed folders in /Android/data/org.xxx.myapp/files then
I can move (QFile::rename) the files one by one into it, then delete
recursively the "from" directory and I am OK. Only (huge) problem is
that it takes hours.
Alternatively, if I move the "from" directory into Documents/myApp, all
3 methods are working fine including QDir::rename, and takes less that a
second. The manual/recurse method also takes less than a second, so my
conclusion is that /Android/data is a very very slow place.
--Philippe
Le 26-10-2021 00:50, Thiago Macieira a écrit :
> On Monday, 25 October 2021 05:37:06 PDT maitai wrote:
>> It works perfectly on Android 9 (cannot test on Android 10), but fails
>> miserably on Android 11.
>
> Can you let me know what kernel versions those two systems have? Qt
> uses a
> different system call for renaming in kernels 3.16 and later. Your
> sandbox may
> be blocking them.
More information about the Interest
mailing list