MediaMetaDataRetriever throws IllegalArgumentException: File doesn't exists only on some devices - android

I query all videos on device using cursor and get the video paths from the MediaStore.Video.VideoColumns.DATA column.
In another fragment, I use MediaMetaDataRetriever to get more information about a video and pass the file path that I got from the DATA column to MediaMetaDataRetriever.setDataSource(String) method.
I have around 4k daily active users, and the code works on 99%, but crashlytics shows a few IllegalArgumentException saying the given file does not exists.
The issue is seen on Android 9, 10, 11, 12, 13 and mostly on Samsung and Redmi devices.
I have WRITE_EXTERNAL_STORAGE permission, and READ_MEDIA_VIDEOS permission in case of Android 13.
What can be the probable cause of this issue on only some devices?
Below is a part of the exception recorded in crashlytics:
Non-fatal Exception: java.lang.IllegalArgumentException: /storage/emulated/0/DCIM/Camera/lv_0_20220219202543.mp4 does not exist
at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:262)

Related

Expo camera.recordAsync({quality:'2160p'}) 'Error: Error retrieving camcorder profile params'. Error thrown when trying to set record quality

Environment
expo 46 -- expo-av 12.0.4 -- expo-camera 12.3.0 -- android 12 -- Samsung S8 tablet -- expo-managed workflow
Packages In Question
expo-camera
Problem
Front Facing Camera has ability to record in 3840x2160 as shown by
await camera.getAvailablePictureSizesAsync('16:9')
which returns 'LOG ["640x360", "1280x720", "1920x1080", "3840x2160"]'
when I set the quality to '2160p' with:
const data = await camera.recordAsync({quality: '2160p'})
And try to record with this method I get an error:
LOG [Error: Error retrieving camcorder profile params]
Secondary Information
--https://docs.expo.dev/versions/latest/sdk/camera/#camerarecordingoptions. As stated in the docs the quality argument is optional, and if not provided the highest available quality it chosen. When left blank 1080p is chosen which isn't the highest quality available, however no error is thrown and app records successfully.
--Back facing camera has ability to record to '4128x2322' as seen with:
await camera.getAvailablePictureSizesAsync('16:9')
LOG ["640x360", "1280x720", "1920x1080", "3840x2160", "4128x2322"]
The following code is ran with back camera selected and no error is thrown. The record quality is 2160p.
const data = await camera.recordAsync({quality: '2160p'})
Error occurs in exact same way whether useCamera2Api is false:true
The only referenced problem is from RNCamera here: github pull request I don't know if this information is applicable to current issue as I do not think expo-camera exposes the CamcorderProfile.hasProfile() method.

OMAPI OpenLogicalChannel failed on Android 13

I work on application that communicate with a custom SIM card with use of Android OMAPI. The application had worked, before I updated Google Pixel to Android 13. Since then, when openLogicalChannel of the Session is called, I get the exception below with scarce information:
Caused by: java.io.IOException: OpenLogicalChannel() failed
at android.se.omapi.Session.openLogicalChannel(Session.java:322)
at android.se.omapi.Session.openLogicalChannel(Session.java:359)
I haven't found any information about OMAPI changes or additional permission in Androdid 13 documentation.
isSecureElementPresent of Reader returns true.
Does anybody have any clues?
As you commented you are not using Android carrier privileges. I'm wondering how this was ever working in your case. In all my setups I needed it for accessing the SEService. The Access Control Enforcer was always checking the access properly in my Pixel devices. Was your previous Pixel device rooted before?
Please try to add the hash of your signing certificate to the ARA or use a generic allow all rule. Maybe you can install this allow all applet on the SIM. For analyzing the APDU traffic I have written an XPosed module displaying additional log messages in the Android radio log.

AWS Android SDK connection timeouts and retries

I have been using the AWS android sdk(s) to deal with files on S3 inside my android application. There were some issues that were being faced by the users and few of these are related to connection timeouts. While setting up the AmazonS3client in my application, I have set the timeout and the retries using the following code:
ClientConfiguration clientConfiguration = new ClientConfiguration();
clientConfiguration.setMaxErrorRetry(4);
clientConfiguration.setConnectionTimeout(10000); // default is 10 secs
clientConfiguration.setSocketTimeout(15000); // default is 50 secs
Everywhere I read, it says that the maxErrorRetryonly does retries for failed retryable requests. Do the errors related to the connection timeout and socket connection timeout also come under this category? If not, what is the solution for this case? I have been searching for this for quite some time now but did not get any clear answer on this.
Also, I have been facing two specific exceptions which I get in my TransferListener callback. There are:
Unable to store object contents to disk: Read time out (14% of all the users who face any AWS exception face this exception)
Unable to store object contents to disk: timeout (17.4% of all the users who face any AWS exception face this exception)
The above two are the most painful for us. I have been assuming that these occur because of there is no more storage left on the user device. I have been using the application specific directory in the external storage to store the files and now thinking to move these to the cache so that the system handles the cleaning of files if there is no more space left on the device. Do you think this is a good solution assuming that the problem is running out of space on the user device.
What are the other possibilities because of which the above mentioned storage related exceptions can occur?
This error occurs at three places in the SDK, out of which two places are significant and applicable here.
(1) https://github.com/aws/aws-sdk-android/blob/0958a37b4757c41cac40597b973ff417e0b758c4/aws-android-sdk-s3/src/main/java/com/amazonaws/services/s3/internal/ServiceUtils.java#L284
(2) https://github.com/aws/aws-sdk-android/blob/3983fda8c2d8703399ac4e9bf6ec0464d000a5af/aws-android-sdk-s3/src/main/java/com/amazonaws/mobileconnectors/s3/transferutility/DownloadTask.java#L161
I suspect that it is in the (2) which is throwing the exception in your case. This can occur for multiple reasons and storage not available is just one of them.
(1) The S3 object does not exist or the S3 bucket/object does not have the required permissions. Please check on AWS S3 Console if you have the required permissions for your users to access content.
(2) There might be a network interruption during the download. Check if there is proper network throughout the transfer
Check AWS CloudWatch Logs to see if there are any failures in the logs.

Security Exception with Google Drive and ACTION_GET_CONTENT

In my app users may import sounds, videos, images and other files.
The import is done using standard Intents, and the result handed in OnActivityResult
I am experiencing a security exception when trying to import files from Google Drive on my 4.2.2 tablet, files from other sources such as Dropbox, Onedrive, Gallery etc are all working OK.
Importing from Drive works fine on my 4.4 tablet.
The intent code looks like this:
Intent intent = new Intent();
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, getString(R.string.title_dialog_selectphoto)), SELECT_PICTURE_REQUEST);
Then in my importPhotoFromUri(uri) method I try to open the uri as an inputStream:
...
InputStream is;
try {
is = getContentResolver().openInputStream(uri);
....
At which point I get a Security Exception:
java.lang.SecurityException: Permission Denial: opening provider
com.google.android.apps.docs.sync.filemanager.FileProvider
from ProcessRecord{216d9060 18832:com.app.app/u0a10153}
(pid=18832, uid=10153) that is not exported from uid 10179
I've found a few posts that seem to refer to a similar problem from a while ago:
Google Drive + ACTION_GET_CONTENT
File View from Google Drive Android Intent
https://productforums.google.com/forum/#!topic/drive/siSKHXdE-ao/discussion
But none of these appear to have a solution, other than perhaps re-implementing the Google Drive Integration myself using their API. I'd rather avoid that and keep the user experience simple though.
From the exception tracking in my Google Analytics it looks as though this issue primarily affects users running 4.2.2 devices, I see only 3 security exceptions from other Android versions.
I also see virtually no Security Exceptions prior to May 9th (2014), which is also the date that user igorcard made his comment asking about the same exception on this answer:
https://stackoverflow.com/a/18298298/2214992
The last update to the Google Drive App on my 4.2.2 device was on the 8th May
I've also been able to observe the same problem in other apps, by trying to load images from my Drive, not just in my own app.
My question then is, can I implement the drive integration another way, without dramatically changing the User Experience, or am I left with just handling the exception and putting up an apologetic Alert Dialog?
Also, has this been broken by the recent update to Drive app or are the timings of the Drive update and the occurrences of this exception in my analytics just coincidental?
I had the same problem. The exception is thrown because there is an export false in Google drive manifest to manage the get content intent. It's unreliable to use it. At the end I used Google Drive API and in detail you can see newOpenFileActivityBuilder() method an example docs

SECURITY_ERR: DOM Exception 18 on openDatabase

I have a web-based Android app that uses WebSQL for storage. For some reason, calling openDatabase at one point (in response to a button click), causes a DOMException with the message "SECURITY_ERR: DOM Exception 18".
Note that I am not using PhoneGap.
The main question I'm asking here is: What are the possible causes for a DOMException 18 on openDatabase?
Some more details:
This exception only occurs if the database does not exist yet. If it already exists, it works as expected. The function that makes the openDatabase call is used in another part of the app and works just fine.
What I've tried so far:
Reducing the size of the database - shouldn't be an issue since it's being created by another part of the app.
I've checked the external storage permissions - again, shouldn't be an issue.
I read somewhere that the USB cable being plugged in could cause this issue - not what's causing it in this case.
EDIT:
This is what the command looks like:
db = openDatabase('my_database', '1.0', 'My database description', 5*1024*1024, function() {});
I found that it has to do with the allowed size of the database.
If you try to open a db that is larger than 50mb on iOS, you get this error.
According to the spec the spec , it cause by only two
The user agent may raise a SECURITY_ERR exception instead of returning a Database object if the request violates a policy decision (e.g. if the user agent is configured to not allow the page to open databases).
If origin is not a scheme/host/port tuple, then throw a SECURITY_ERR exception

Categories

Resources