-
-
Notifications
You must be signed in to change notification settings - Fork 488
Description
Describe the bug
While testing and refactoring the code for #3624, I was thinking of accessing the zim file with file descriptor
without any permission(MANAGE_EXTERNAL_STORAGE
). I can read the file without permission if I select the file via the existing file picker
in the Play Store variant. I have tested it on Android 11 and Android 12.
Why we had failed to access the ZIM files in the past without special permission
- We were trying to access the
File
which is the basic requirement of our application to function, and we can not access the files without special permission. - We had some options at that time e.g. copying the content in a temp file from
inputStream
but it did not fit in our requirements, since it used twice the storage for the same ZIM file. - With the
file descriptor
approach in Storage permissions are unnecessarily required #3265. In this PR we are trying to access the fileDescriptor from a file, which gives us the permission denied message for fileDescriptor. We did this withold-libkiwix
- In the past, we were using the
java-libkiwix
which had the issue opening the ZIM files via file descriptor that we saw while we were introducing theASSET_FILE_DELIVERY
for custom apps.
Expected behavior
We should add the file picker
in the Play Store variant and if possible we should move our functionalities to rely on fileDescriptor instead of file. Since we have more access to a file descriptor
instead of a file, Android limits direct access to files without special permission on Android 11 and above.
What if we use file descriptor instead of file
- It did not work for scanning the storage.
- It will work for opening the ZIM files with the file picker without any special permission.
- It needs refactoring to make the application properly work with the file descriptor.
Additional notes to remember
- We can show the ZIM file inside the library section if possible since at that time we have the URI of that ZIM file once opened with fileDescriptor.