You might check the best path for the Android application depending on your 
needs:
https://developer.android.com/guide/topics/data

Then compare with the QStandards path, I’m not sure they are all friendly with 
the scoped storage.

For the actual path resolving are written down into the documentation (scroll 
down a little after the enum):
https://doc.qt.io/qt-5/qstandardpaths.html#StandardLocation-enum

Anything that use <APPROOT> for mobile is protected against other now and are 
part of the scoped storage. Note, you cannot write into the actual application 
binary anymore and other application based binary.

AppLocalDataLocation, ConfigLocation
should be safe for example. DataLocation should also be ok too normally. But 
make sure the path resolved make sense and play well with scoped storage. Try 
to keep the data as private as much as possible depending on your requirement. 
It’s easier to expose data later then loosing access to it! You can expose the 
data into a more public when needed with an application update, loosing access 
to a path with an update will prevent you from migrating those data.

Make sure you ask for the proper permission (manifest.xml) and at runtime to 
access the storage with your application (note the read/write external storage 
on Android 11 doesn’t do much since there is now the scoped storage that is 
more restrictive, but you will still need them for older Android version). 
Normally that should work for both internal and external storage data, the 
internal data storage is now encrypted and therefore should be used for 
sensitive data.

Jérôme Godbout, B. Ing.

Software / Firmware Team Lead
O: (418) 682-3636 ext.: 114
C: (581) 777-0050
godbo...@dimonoff.com<mailto:godbo...@dimonoff.com>
[signature_1620770654]<https://www.dimonoff.com/>
dimonoff.com<https://www.dimonoff.com/>
1015 Avenue Wilfrid-Pelletier,
Québec, QC G1W 0C4, 4e étage


From: Nuno Santos <nuno.san...@imaginando.pt>
Date: Tuesday, May 25, 2021 at 12:02 PM
To: Jérôme Godbout <godbo...@amotus.ca>
Cc: Qt Interest <interest@qt-project.org>
Subject: Re: [Interest] Problems writing files to Android file system on some 
newer devices using QStandardPaths
Jerome,

Thank you very much for your reply and for the link.

DocumentsLocation is point to /storage/emulated/…

But I’ve been trying with other QStandardPath such as ConfigLocation and 
DataLocation. Those were point to something like 
/user/app_identififier_/files/, can’t remember exactly now. But when trying to 
write to those locations, it would always fail.

Are QStandardPath Android locations compatible with Scoped Storage? Would I 
need to refactor my Qt code or this is just a thing we need to enable in the 
app manifest?

Thank you!

Best regards,

Nuno

On 25 May 2021, at 14:22, Jérôme Godbout 
<godbo...@amotus.ca<mailto:godbo...@amotus.ca>> wrote:

Where the standard path resolve on the device?

On Android 10, they changed the way we can access the file system, you can opt 
out with android:requestLegacyExternalStorage=“true” but this flag doesn’t work 
for Android 11+. If removing this flag break your applications, it means your 
application won’t work on any Android 11 devices.

The application are now sandboxed, Android 10 make it optional, Android 11 
enforce it. You need to move to scoped storage.
https://developer.android.com/about/versions/11/privacy/storage


Jérôme Godbout, B. Ing.

Software / Firmware Team Lead
O: (418) 682-3636 ext.: 114
C: (581) 777-0050
godbo...@dimonoff.com<mailto:godbo...@dimonoff.com>
<image001.png><https://www.dimonoff.com/>
dimonoff.com<https://www.dimonoff.com/>
1015 Avenue Wilfrid-Pelletier,
Québec, QC G1W 0C4, 4e étage


From: Interest 
<interest-boun...@qt-project.org<mailto:interest-boun...@qt-project.org>> on 
behalf of Nuno Santos 
<nuno.san...@imaginando.pt<mailto:nuno.san...@imaginando.pt>>
Date: Monday, May 24, 2021 at 8:17 AM
To: Qt Interest <interest@qt-project.org<mailto:interest@qt-project.org>>
Subject: [Interest] Problems writing files to Android file system on some newer 
devices using QStandardPaths
Hi,

Is anyone aware of changes to the way that Android filesystem works and how Qt 
interacts with it?

I’ve been writing to QStandardPaths::DocumentLocations without any issues 
until. However, on some newer devices, it fails to open files for writing. One 
example is Samsung Tab A (SM-T500)

It seems though that using android:requestLegacyExternalStorage=“true” seems to 
fix the problem but this solution will not last long because it seems it will 
be ignored when the app targets API 30 (Android 11):

https://developer.android.com/training/data-storage/use-cases

Caution: After you update your app to target Android 11 (API level 30), the 
system ignores the requestLegacyExternalStorage 
attribute<https://developer.android.com/about/versions/11/privacy/storage#scoped-storage>
 when your app is running on Android 11 devices, so your app must be ready to 
support scoped storage and to migrate app 
data<https://developer.android.com/training/data-storage/use-cases#migrate-legacy-storage>
 for users on those devices.

Is there any common knowledge about this?

Thanks!

Regards,

Nuno

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to