View Single Post
Old 04-07-2016, 01:06 PM   #23
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,471
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by crane3 View Post
How was the CC "default" folder, "com.multipie.calibreandroid" created? Was it done by the OS or CC?

...

At this point, just curious.
This is somewhat complicated. The answer depends on whether you are running pre-Kitkat, Kitkat, or post-Kitkat (Lollipop+).

In all versions of Android, an app like CC can ask for and receive rights to manipulate main memory (not an SD card) using "normal" (standard, classic) IO functions. CC asks for those rights. When it starts for the first time CC knows to put the default folder in main_memory/Calibre Companion. It creates that folder as a normal user using normal IO functions. This avoids CC needing "stuff" to deal with the Storage Access Framework (Lollipop+) and lots of hassles when upgrading.

The "private" data folders are created by Android. I am not sure when, but I think it is either when the app is installed or when the app asks for them. Android creates them as "standard" (non-SAF) folders so apps can read and write them using normal I/O functions. This avoids problems with SAF, and in particular problems with Kitkat.

When a user asks CC to move a folder, what happens depends on what version of Android is running. For pre-Kitkat, CC opens its own folder chooser. The user can create folders anywhere s/he wants, SD card or main memory. For Kitkat, which has broken SAF support, the choice is a folder chooser for main memory and the "special" folder on an SD card.

For Lollipop and later, CC always opens an Android SAF chooser dialog. The SAF is used no matter which memory is being used. Reasons: CC cannot know ahead of time where the user wants to store books, so must permit browsing the SD card. By the time the answer comes back, the folder has already been created "somewhere". It is rather difficult for CC to figure out which memory was used, and in any event permissions can make it impossible for CC to use the resulting folder without the SAF. Finally, I thought it better to use one user interface for folder choosing instead of two.

From what I have seen, the permissions assigned to SAF-created folders have nothing to do with the user. Instead, they use the permission of the "provider" (the daemon bit of Android that really reads & writes the files). The provider is responsible for verifying that the user has permission to access the files. I have seen providers that run as root and, apparently, something else.

Last edited by chaley; 04-07-2016 at 01:08 PM.
chaley is offline   Reply With Quote