#43 Don't handle intent if file already saved in an accessible location

Chiuso
aperto 2 anni fa da rz · 13 commenti
rz commented 2 anni fa

..another step towards perfection. I think it is of little use to invoke SaveTo if the file is already in /sdcard/Downloads .

The idea came to me when I accidentally set SaveTo as default action when dealing with the app mentioned in #37 - with the result that I could no longer view the stored PDF file on that device. Not a serious problem though.

An example from my device :

intent://org.openintents.filemanager/%2Fstorage%2Femulated%2F0%2FDownload%2Fecg-signal-01-06-2022_02_00_PM.pdf#Intent;scheme=content;type=application/pdf;launchFlags=0x3000000;end

ACTION: android.intent.action.VIEW DATA: content://org.openintents.filemanager/%2Fstorage%2Femulated%2F0%2FDownload%2Fecg-signal-01-06-2022_02_00_PM.pdf MIME: application/pdf URI: intent://org.openintents.filemanager/%2Fstorage%2Femulated%2F0%2FDownload%2Fecg-signal-01-06-2022_02_00_PM.pdf#Intent;scheme=content;type=application/pdf;launchFlags=0x3000000;end FLAGS: FLAG_ACTIVITY_FORWARD_RESULT FLAG_ACTIVITY_PREVIOUS_IS_TOP


MATCHING ACTIVITIES: Drive (com.google.android.apps.docs - com.google.android.apps.viewer.PdfViewerActivity) Termux (com.termux - com.termux.filepicker.TermuxFileReceiverActivity) browser (de.monocles.browser - de.monocles.browser.activities.MainWebViewActivity) Save as (org.openintents.filemanager - org.openintents.filemanager.SaveAsActivity)

..another step towards perfection. I think it is of little use to invoke SaveTo if the file is already in /sdcard/Downloads . The idea came to me when I accidentally set SaveTo as default action when dealing with the app mentioned in https://notabug.org/Umnik/SaveTo/issues/37 - with the result that I could no longer view the stored PDF file on that device. Not a serious problem though. An example from my device : intent://org.openintents.filemanager/%2Fstorage%2Femulated%2F0%2FDownload%2Fecg-signal-01-06-2022_02_00_PM.pdf#Intent;scheme=content;type=application/pdf;launchFlags=0x3000000;end ------------ ACTION: android.intent.action.VIEW DATA: content://org.openintents.filemanager/%2Fstorage%2Femulated%2F0%2FDownload%2Fecg-signal-01-06-2022_02_00_PM.pdf MIME: application/pdf URI: intent://org.openintents.filemanager/%2Fstorage%2Femulated%2F0%2FDownload%2Fecg-signal-01-06-2022_02_00_PM.pdf#Intent;scheme=content;type=application/pdf;launchFlags=0x3000000;end FLAGS: FLAG_ACTIVITY_FORWARD_RESULT FLAG_ACTIVITY_PREVIOUS_IS_TOP ------------ MATCHING ACTIVITIES: Drive (com.google.android.apps.docs - com.google.android.apps.viewer.PdfViewerActivity) Termux (com.termux - com.termux.filepicker.TermuxFileReceiverActivity) browser (de.monocles.browser - de.monocles.browser.activities.MainWebViewActivity) Save as (org.openintents.filemanager - org.openintents.filemanager.SaveAsActivity)
Umnik commented 2 anni fa
Proprietario

Version 1.15.2 has new option for monitoring defaults. Android does not allow reset defaults since 4.0.3 ( https://developer.android.com/reference/android/content/pm/PackageManager#removePackageFromPreferred(java.lang.String) )

The app showing notification for quick open settings and you can manually reset defaults.

Version 1.15.2 has new option for monitoring defaults. Android does not allow reset defaults since 4.0.3 ( https://developer.android.com/reference/android/content/pm/PackageManager#removePackageFromPreferred(java.lang.String) ) The app showing notification for quick open settings and you can manually reset defaults.
Umnik commented 2 anni fa
Proprietario

Android 6:

Android 6:
Umnik commented 2 anni fa
Proprietario

Android 12:

Android 12:
rz commented 2 anni fa
Autore

Thanks, it was not a big problem to reset the default handler.

I was wondering if the app could choose not to handle some events if the object is obviously already a file on shared storage? If a file manager happens to share a file from /sdcard/Downloads it makes little sense for SaveTo to catch the intent.

Thanks, it was not a big problem to reset the default handler. I was wondering if the app could choose not to handle some events if the object is obviously already a file on shared storage? If a file manager happens to share a file from /sdcard/Downloads it makes little sense for SaveTo to catch the intent.
Umnik commented 2 anni fa
Proprietario

Saveto does not uses storage permissions (for privacy and security reasons) and cannot provide access for other apps for /sdcard/Dowloads/ and so on. Saveto delegates saving files to "Android Storage Framework".

How it works:

  1. External app create Intent with action SHARE or VIEW. Also the app adds temporary permission for reading file to Intent
  2. The app sends Intent to OS
  3. OS looking for applications what can handle this Intent. It can be default handler or chooser for user
  4. Intent passed to handler
  5. Handler gets permission for file access and process it

When handler is SaveTo:

  1. Shared file coping inside SaveTo cache dir
  2. SaveTo creates new Intent for Android Storage Framework
  3. SAF process Intent: ask user for target file or saves file in predefined directory

I.e. SaveTo always saves file in cache because initial app can recall temporary access permisssion. And SaveTo process file inside own cache but not original file.

When SaveTo just was created it has ability to proxy Intents for other apps. But I found an app what crashed after sharing and SaveTo's Intent has link to already expired temporary permission for reading file. And SaveTo gots feature with quick saving file to own cache. And now if SAF gots Intent from SaveTo it means SaveTo 100% can control file. Intent will not has expired permissions.

Saveto does not uses storage permissions (for privacy and security reasons) and cannot provide access for other apps for /sdcard/Dowloads/ and so on. Saveto delegates saving files to "Android Storage Framework". How it works: 1. External app create Intent with action SHARE or VIEW. Also the app adds temporary permission for reading file to Intent 2. The app sends Intent to OS 3. OS looking for applications what can handle this Intent. It can be default handler or chooser for user 4. Intent passed to handler 5. Handler gets permission for file access and process it When handler is SaveTo: 5. Shared file coping inside SaveTo cache dir 6. SaveTo creates new Intent for Android Storage Framework 5. SAF process Intent: ask user for target file or saves file in predefined directory I.e. SaveTo always saves file in cache because initial app can recall temporary access permisssion. And SaveTo process file inside own cache but not original file. When SaveTo just was created it has ability to proxy Intents for other apps. But I found an app what crashed after sharing and SaveTo's Intent has link to already expired temporary permission for reading file. And SaveTo gots feature with quick saving file to own cache. And now if SAF gots Intent from SaveTo it means SaveTo 100% can control file. Intent will not has expired permissions.
rz commented 2 anni fa
Autore

Thanks for the explanation. Not sure if I expressed my thoughts very well previously.

What I was trying to say, if the incoming intent is share or view a file in /sdcard/Downloads it does not make sense for SaveTo to handle this intent - because the file is already save in a place where it is easy to get.

Consider for example the situation - there is "abc.pdf" in folder /sdcard/Download, user opens a file manager and wants to view or share "abc.pdf" . If SaveTo intercepts this intent it will save it in /sdcard/Download again but in this case it is almost certainly not what the user intended. Rather SaveTo should not intercept the intent in this situation or pass it to the default chooser.

Thanks for the explanation. Not sure if I expressed my thoughts very well previously. What I was trying to say, if the incoming intent is share or view a file in /sdcard/Downloads it does not make sense for SaveTo to handle this intent - because the file is already save in a place where it is easy to get. Consider for example the situation - there is "abc.pdf" in folder /sdcard/Download, user opens a file manager and wants to view or share "abc.pdf" . If SaveTo intercepts this intent it will save it in /sdcard/Download again but in this case it is almost certainly not what the user intended. Rather SaveTo should not intercept the intent in this situation or pass it to the default chooser.
Umnik commented 2 anni fa
Proprietario

I added recreate Intent. But it very unstable feature because SaveTo… has not permissions for FS. See 1.15.3 version

I added recreate Intent. But it very unstable feature because SaveTo… has not permissions for FS. See 1.15.3 version
rz commented 2 anni fa
Autore

Works perfectly here. I understand the problem, but luckily my PDF viewer (muPDF) has file access rights so perhaps in this special situation it is stable.

I like it that the app creates a notification to make it easy to clear the default but no need to sound repeatedly many times if the notification is already present.

Works perfectly here. I understand the problem, but luckily my PDF viewer (muPDF) has file access rights so perhaps in this special situation it is stable. I like it that the app creates a notification to make it easy to clear the default but no need to sound repeatedly many times if the notification is already present.
Umnik commented 2 anni fa
Proprietario

Fixes like this? #48

Your file manager supported by SaveTo in 1.15.3? Or SaveTo still does not recognize sdcard?

Fixes like this? https://notabug.org/Umnik/SaveTo/issues/48 Your file manager supported by SaveTo in 1.15.3? Or SaveTo still does not recognize sdcard?
rz commented 2 anni fa
Autore

It always recognized sdcard. The weird thing was that to select the /sdcard/Download dir as target dir I first had to go into a subdir and back up one level. Do not know how to test whether this is still the case.

It always recognized sdcard. The weird thing was that to select the /sdcard/Download dir as target dir I first had to go into a subdir and back up one level. Do not know how to test whether this is still the case.
Umnik commented 2 anni fa
Proprietario

It always recognized sdcard

I mean Save To… should pass your pdf (and others) file to another apps if it was opened from sdcard. It was new feature in 1.15.3.

1.15.2 creates duplicates instead.

1.15.3 works as you expects?

> It always recognized sdcard I mean Save To… should pass your pdf (and others) file to another apps if it was opened from sdcard. It was new feature in 1.15.3. 1.15.2 creates duplicates instead. 1.15.3 works as you expects?
Umnik commented 2 anni fa
Proprietario

Can I close the issue?

Can I close the issue?
rz commented 2 anni fa
Autore

Just tested again, 1.15.4 from F-droid and this seems to work perfectly :)

Just tested again, 1.15.4 from F-droid and this seems to work perfectly :)
rz chiuso 2 anni fa
Sign in to join this conversation.
Nessuna milestone
Nessun assegnatario
2 Partecipanti
Caricamento...
Annulla
Salva
Non ci sono ancora contenuti.