Class Attachments
cache/sioul/attachments/<message>/<name>, after Sioul's own
checks: mail set aside keeps its attachments closed, and programs and
installers are never opened. A phone has no antivirus Sioul can call, and
nothing here claims one.
Since Android 7 a file goes to another app by a content://
address, never by its path. Here it is an address of Qt's FileProvider
(authority <package>.qtprovider), whose root "attachments"
(res/xml/qtprovider_paths.xml) is that folder of the cache alone. Android
lends the address, to read only, to the one app that opens it: that app
reads this file and nothing else of Sioul's. When no app is set for its
type, Android asks which one ("Open with").
Saving asks Android where (ACTION_CREATE_DOCUMENT, in
AttachmentSave), then copies the file there; the copy in the cache goes,
saved or not.
The pure parts (the address, the type, what an app is handed, what Android is asked) are checked on a computer: android/jvm-checks, AttachmentsCheck.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classAndroid's question "where?" for a file to save: an action, a category, a type, the name offered.(package private) static final classWhat another app is handed to open a file: an action, an address, a type, flags. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringQt's FileProvider, the one Sioul declares: its authority, after the package's name.(package private) static final StringA type nothing more is known of.(package private) static final StringThat root's folder, in the app's cache, where Rust writes attachments (XDG_CACHE_HOME/sioul/attachments).private static final char[](package private) static final StringAndroid's installer's type: never handed to open, whatever the name says.(package private) static final StringThe provider's root for attachments, by its name in res/xml/qtprovider_paths.xml.(package private) static final String(package private) static final intA file handed to open: to read, and nothing more, in a task of its own (Rust asks from Sioul's application, not from its window). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringandroidType(String file) Android's own type for a file's extension; null when it has none.(package private) static Stringcall(Context context, String verb, JSONObject asked) Rust's question (StepService.call(android.content.Context, java.lang.String, java.lang.String), verbs "attachment-…"): "attachment-open" {path, type}, answered {opened} or {problem}; "attachment-save" {path, name, type}, answered {asked} or {problem}, then AttachmentSave tells Rust what became of it.(package private) static StringcontentUri(String packageName, String folder, String file) The address FileProvider givesfilein the root "attachments", whose folder isfolder(both canonical paths, as FileProvider compares them):content://<package>.qtprovider/attachments/<the rest, encoded part by part>.(package private) static StringcontentUri(String packageName, String folder, String file, String root) The address FileProvider givesfilein its rootroot(res/xml/qtprovider_paths.xml), whose folder isfolder, ascontentUri(String, String, String)says it for the attachments: a multimedia message's file, for Android to read it (TextSend.sendMms, root "files_path").(package private) static StringUri.decode's way back: each%XXa byte, the bytes read as UTF-8.(package private) static StringA part of an address as Android's Uri.encode writes it, as FileProvider does: letters, digits and_-!.~'()*kept, every other byte of its UTF-8 as%XX.(package private) static StringFileProvider's way back (its getFileForUri), for the checks: the file an address names in the root "attachments", whose folder isfolder; null when it names no file there.private static StringThe attachments' folder in this app's cache, as FileProvider reads it (canonical).(package private) static JSONObjectThe attachment atpathhanded to the app you choose: {opened: true}, else {problem: "refused" | "gone" | "no-app" | "failed"}.(package private) static JSONObjectA JSON answer from pairs of names and values; what cannot be written is left out.(package private) static JSONObjectAndroid asked where to save the attachment atpath(AttachmentSave, never shown itself): {asked: true}, else {problem: "refused" | "gone" | "failed"}.(package private) static Attachments.SaveAsWhat Android is asked to save a file: ACTION_CREATE_DOCUMENT, among the files that open (CATEGORY_OPENABLE), of its type (plain bytes when none), under its name (the attachment's when none).private static StringThe name the saved file has where it went (Android may add " (1)");namewhen it does not say.(package private) static StringThe type an app is asked to open: Rust's, from the name's extension (sioul_core::compose::mime_of), else Android's own for that extension, else plain bytes; in lower case.(package private) static Attachments.ViewWhat is handed to openfile(a canonical path) of typetype(from type()): ACTION_VIEW, its content address, the type, read only; null when the file is not in the attachments' folder, or for an installer.(package private) static JSONObjectThe attachment atpathcopied where Android's question answered (target, null when you closed it), then taken out of the cache, saved or not: {path, name, saved, shown (the name it has there)} or {path, name, saved: false, problem}.
-
Field Details
-
TAG
- See Also:
-
AUTHORITY
Qt's FileProvider, the one Sioul declares: its authority, after the package's name.- See Also:
-
ROOT
The provider's root for attachments, by its name in res/xml/qtprovider_paths.xml.- See Also:
-
FOLDER
That root's folder, in the app's cache, where Rust writes attachments (XDG_CACHE_HOME/sioul/attachments).- See Also:
-
INSTALLER
Android's installer's type: never handed to open, whatever the name says.- See Also:
-
BYTES
A type nothing more is known of.- See Also:
-
VIEW_FLAGS
A file handed to open: to read, and nothing more, in a task of its own (Rust asks from Sioul's application, not from its window).- See Also:
-
HEX
-
-
Constructor Details
-
Attachments
private Attachments()
-
-
Method Details
-
encode
A part of an address as Android's Uri.encode writes it, as FileProvider does: letters, digits and_-!.~'()*kept, every other byte of its UTF-8 as%XX. -
decode
Uri.decode's way back: each%XXa byte, the bytes read as UTF-8. -
contentUri
The address FileProvider givesfilein the root "attachments", whose folder isfolder(both canonical paths, as FileProvider compares them):content://<package>.qtprovider/attachments/<the rest, encoded part by part>. Null for a file outside the folder, the folder itself, or a path with an empty, "." or ".." part. -
contentUri
The address FileProvider givesfilein its rootroot(res/xml/qtprovider_paths.xml), whose folder isfolder, ascontentUri(String, String, String)says it for the attachments: a multimedia message's file, for Android to read it (TextSend.sendMms, root "files_path"). -
fileOf
FileProvider's way back (its getFileForUri), for the checks: the file an address names in the root "attachments", whose folder isfolder; null when it names no file there. -
type
The type an app is asked to open: Rust's, from the name's extension (sioul_core::compose::mime_of), else Android's own for that extension, else plain bytes; in lower case. Null for Android's installer, whatever gave it: an installer is never handed to open. -
view
What is handed to openfile(a canonical path) of typetype(from type()): ACTION_VIEW, its content address, the type, read only; null when the file is not in the attachments' folder, or for an installer. -
saveAs
What Android is asked to save a file: ACTION_CREATE_DOCUMENT, among the files that open (CATEGORY_OPENABLE), of its type (plain bytes when none), under its name (the attachment's when none). -
call
Rust's question (StepService.call(android.content.Context, java.lang.String, java.lang.String), verbs "attachment-…"): "attachment-open" {path, type}, answered {opened} or {problem}; "attachment-save" {path, name, type}, answered {asked} or {problem}, then AttachmentSave tells Rust what became of it. -
said
A JSON answer from pairs of names and values; what cannot be written is left out. -
androidType
Android's own type for a file's extension; null when it has none. -
folder
The attachments' folder in this app's cache, as FileProvider reads it (canonical).- Throws:
IOException
-
open
The attachment atpathhanded to the app you choose: {opened: true}, else {problem: "refused" | "gone" | "no-app" | "failed"}. Nothing of the file's name goes to the log. -
save
Android asked where to save the attachment atpath(AttachmentSave, never shown itself): {asked: true}, else {problem: "refused" | "gone" | "failed"}. -
write
The attachment atpathcopied where Android's question answered (target, null when you closed it), then taken out of the cache, saved or not: {path, name, saved, shown (the name it has there)} or {path, name, saved: false, problem}. A copy that fails midway is removed there. On a thread of its own. -
shownName
The name the saved file has where it went (Android may add " (1)");namewhen it does not say.
-