Status Update
Comments
vi...@google.com <vi...@google.com>
vi...@google.com <vi...@google.com>
am...@google.com <am...@google.com>
am...@google.com <am...@google.com> #2
Android build
Which Android build are you using? (e.g. PPP5.180610.010)
Device used -- Device Make, Model, Android OS Version
Which device did you use to reproduce this issue?
Please provide sample project or apk to reproduce the issue. Also mention the steps to be followed for reproducing the issue with the given sample project or apk.
Expected output
What is the expected output?
Current output
What is the current output?
Android bug report (to be captured after reproducing the issue)
For steps to capture a bug report, please refer:
Alternate method
Navigate to “Developer options”, ensure “USB debugging” is enabled, then enable “Bug report shortcut”. Capture bug report by holding the power button and selecting the “Take bug report” option.
Screen Record of the Issue
Please capture screen record or video of the issue using following steps:
adb shell screenrecord /sdcard/video.mp4
Subsequently use following command to pull the recorded file:
adb pull /sdcard/video.mp4
Attach the file to this issue.
Note: Please upload the files to google drive and share the folder to android-bugreport@google.com, then share the link here.
co...@gmail.com <co...@gmail.com> #3
I used markdown, please enable it when reading this comment.
Android build and device used:
Google Pixel 3a XL - R(RPPP1.200123.017)
Expected output:
I would like to be able to pass a file path to an external library, in this case, FFmpeg.
Once again quoting the docs-
Starting in Android 11, apps that have the READ_EXTERNAL_STORAGE permission can read a device's media files using direct file paths and native libraries. This new capability allows your app to work more smoothly with third-party media libraries.
Current output:
There is no API (I could find), to even receive a file path from media store.
What I have tried:
- Retrieving the path directly from the Uri (I know this is not recommended):
String path = data.getData().getPath();
Result (As I suspected):
/document/B1DE-1114:VID_25060906_162219.mp4: No such file or directory
- Using
proc
protocol:
ParcelFileDescriptor parcelFileDescriptor = null;
try {
parcelFileDescriptor = getContentResolver().openFileDescriptor(data.getData(), "r");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
int fd = 0;
try {
fd = parcelFileDescriptor.getFd();
} catch (Exception e) {
e.printStackTrace();
}
//Process process = new Process()
int pid = Process.myPid();
String path = "/proc/" + pid + "/fd/" + fd;
Result:
/proc/9751/fd/68: Permission denied
- I have also tried accessing the data column, which was deprecated in 29, just to make sure. But I was not able to retrieve the path.
The docs state that we can pass a file path to a native library, but I could not find a way of doing this.
al...@gmail.com <al...@gmail.com> #4
I think it can be implemented via FUSE.
I am concerned about all applications have read access to all files on the external storage. This issue could be resolved by granting permissions via FUSE also.
am...@google.com <am...@google.com> #5
am...@google.com <am...@google.com> #6
co...@gmail.com <co...@gmail.com> #7
I tried again and I was able to get the path using the data column.
But, in the documentation, it says that we should not use the data column as it is deprecated -
Is it save to keep using the data column even if it is deprecated? Will there be a new API made available replacing the data column?
co...@gmail.com <co...@gmail.com> #8
Also, once again quoting the docs -
After you update your app to target Android 11, you cannot use requestLegacyExternalStorage to opt out of scoped storage.
So, does this mean that we can remove requestLegacyExternalStorage
when targeting Android 11 and we will still be able to read file paths on Android 10? Or should we keep requestLegacyExternalStorage
in our manifest when targeting Android 11?
yv...@gmail.com <yv...@gmail.com> #9
It is not because the file cannot be accessed that the data should be hidden. It is up to the application to ensure that the desired action can be performed! Android gives all the possibilities to ask authorizations to the user.
Restricting access to insensitive metadata is probably not desirable.
Wouldn't it be simpler to give back this column to its initial status: not deprecated?
na...@google.com <na...@google.com> #10
Re #8: Do keep requestLegacyExternalStorage in the manifest if you need legacy storage on Q devices. It will be ignored on R devices once you target R. We are improving the documentation on this.
Re DATA column: will publish more guidance on this soon
co...@gmail.com <co...@gmail.com> #11
to...@gmail.com <to...@gmail.com> #12
#10 anyway to have some insight about
le...@gmail.com <le...@gmail.com> #13
pu...@gmail.com <pu...@gmail.com> #14
According to my test, this is currently the case in the R emulator, but will this behavior persist for R final ?
Another way to put, it is that requestLegacyExternalStorage=true is only ignored if oand only if running on R when targetSdkVersion is R
co...@gmail.com <co...@gmail.com> #15
#14 - requestLegacyExternalStorage
is only necessary for Android 10(Q). On Android R, this will be ignored - file access is once again available in Android R, so you can leave requestLegacyExternalStorage
in your Manifest if you want to use legacy storage on Android Q devices.
co...@gmail.com <co...@gmail.com> #16
Re 10#: The documentation has not yet been updated, nor has the clarification about the data column. Android R release is near and developers want to get ready for the release. Can you please confirm when this will be updated?
na...@google.com <na...@google.com> #17
Sorry about the delay. The detailed guide is still in the works. However I can summarize the recommendation to unblock you:
Don't use DATA column for inserting or updating into Media Store - use DISPLAY_NAME and RELATIVE_PATH for this. For existing Media Store entries if the file exists on disk DATA column will have a valid file path, which can be used with java File api or NDK library (fopen etc). Apps should however be prepared to handle any file I/O errors from these operations and should not assume file is always available.
Hope this helps
am...@google.com <am...@google.com> #18
If you still feel more information is needed, kindly log a new issue here:
Description
According to the docs file path access is granted in Android R:
>Starting in Android 11, apps that have the READ_EXTERNAL_STORAGE permission can read a device's media files using direct file paths and native libraries. This new capability allows your app to work more smoothly with third-party media libraries.
The problem is that I can't get the file path from `MediaStore`, so how are we supposed to read a file path that we can't access/retrieve? Is there a way, I'm not aware of, that we can get the file path from `MediaStore`?
---
Furthermore, [the docs say the following][1]:
>**All Files Access**
>Some apps have a core use case that requires broad file access, such as file management or backup & restore operations. They can get All Files Access by doing the following:
>1. Declare the MANAGE_EXTERNAL_STORAGE permission.
>2. Direct users to a system settings page where they can enable the Allow access to manage all files option for your app.
>This permission grants the following:
> - Read access and write access to all files within shared storage.
> - Access to the contents of the MediaStore.Files table.
But I do not need all file access, I only want the user to select a video from `MediaStore` and pass the file path to `FFmpeg`(it requires a file path).
I can not pass `FileDescriptor` to `FFmpeg` and I can not use `/proc/self/fd/` (I get `/proc/7828/fd/70: Permission denied` when selecting a file from the SD Card), have a look at [this issue][2].
---
So what am I supposed to do, am I missing something? What was meant with `can read a device's media files using direct file paths and native libraries`?
[1]:
[2]:
[3]: