Default FileScope - is this the same in Screen and File?

In the designer for Screen there is a section to set the Default FileScope (there is not a corresponding property block in Screen to set this in blocks?)

In the designer for File, there is also a section to set the Default Filescope - with a corresponding property block in the editor

Are these two inter-related, or entirely separate things? If I set one does it set the other, or do I also need to set the other as well?

For example, I set the Filescope to Legacy in Screen in the designer. Is the Filescope now set to Legacy if I use the File component ? Similalry, if i set the Filescope to App using the File component block, does this set the Screen Filescope to App ?

As per usual, confused :wink:

Also. doesn't seem to be possible to set File1.Scope to a label ?

image

1 Like

No.

Yes.

DefaultFileScope (only) determines which storage permissions are declared in the Manifest.
If DefaultFileScope is set to Legacy, then (and only then) READ and WRITE permissions are declared in the Manifest (also on Android 11, which doesn't make sense as it doesn't exist there).

I am not convinced by this property "DefaultFileScope" in the designer. I consider this to be dispensable / superfluous (not to say: confusing).

Why shouldn't the storage permissions be declared like this (on all Android versions):

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />

or this (since AI2 decided to declare requestLegacyExternalStorage=true in the Manifest, so it continues to work on Android 10):

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" />

I have already asked this question many times and have not yet received an answer.

grafik

The function of FileScope is to determine the respective path of the File component.
grafik

And again this has nothing to do with DefaultFileScope (in the designer):

grafik

Note: I think this is interesting for everyone too, not just power users, so it should be available on the public forum. Maybe you want to move it there.

1 Like

@TIMAI2 see also the design document

Taifun

The DefaultFileScope controls all of the other components in the app. We thought this would be more convenient for developers than introducing a scope property on every single component that touches the file system. Additionally, extensions can be hooked into the same system if the appropriate APIs are used so that if we need to make changes extensions will automatically be compatible with future versions. The File component was an exception because its the one component intended to manipulate files in the file system and therefore needs the ability to reference different scopes at different points during app execution, such as to migrate data from older locations in the file system to newer locations allowed by the Android 10+ changes.

yes, I agree... imho it would be a good idea, because WRITE_EXTERNAL_STORAGE does not exist anymore in Android 11+

what is your opinion on that @ewpatton?

Taifun

1 Like

Just one example:

Of course, DefaultFileScope has no influence on this (because the SoundRecorder uses an absolute path).

which means, this is an inconsistency, isn't it?
After setting DefaultFileScope to App I would expect to get the file stored in the ASD...
Taifun

1 Like

If you specify an absolute path it will be honored. This is necessary for backward compatibility. However, people will bump up into Android file system constraints if they make use of absolute paths. The Android documentation discourages this because there's no guarantee that a mounted file system will get mapped to the exact same mount point in future versions. See the caution note on this page.

Yes, we already spoce about this (one year ago):

Thank you all.

I now understand (through your words and images, and through my own investigations and tests) that the DefaultFileScope set in the designer remains static, and cannot be changed elsewhere in the app - companion or compiled, whatever you set here stays set. However for the File component, it is possible to change the FileScope for only file component operations.

Another one:

Regardless of the DefaultFileScope, the video is always saved here:
/storage/emulated/0/DCIM/Camera/...mp4

1 Like

Apparently not, as I have shown with two examples. So we should investigate which components that touch the file system are actually controlled by DefaultFileScope.

And as I already said, this is relevant for all users (not only PUs). @TIMAI2

2 Likes