HBiSoft / PickiT

An Android library that returns real paths from Uri's

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

java.lang.SecurityException: Permission Denial:

milan-galitein opened this issue · comments

I am getting some crash reports on my live App.

PickIt Version: 2.0.5

Crash 1:
OS: Android 13
Model: XQ-BT52

java.lang.SecurityException: Permission Denial: opening provider com.google.android.apps.photos.contentprovider.impl.MediaContentProvider from ProcessRecord{bf6d239 29514:com.einpix.android/u0a447} (pid=29514, uid=10447) that is not exported from UID 10286 at android.os.Parcel.createExceptionOrNull(Parcel.java:3011) at android.os.Parcel.createException(Parcel.java:2995) at android.os.Parcel.readException(Parcel.java:2978) at android.os.Parcel.readException(Parcel.java:2920) at android.app.IActivityManager$Stub$Proxy.getContentProvider(IActivityManager.java:5224) at android.app.ActivityThread.acquireProvider(ActivityThread.java:7089) at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:3420) at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:2529) at android.content.ContentResolver.query(ContentResolver.java:1205) at android.content.ContentResolver.query(ContentResolver.java:1152) at android.content.ContentResolver.query(ContentResolver.java:1108) at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(SourceFile:72) at com.hbisoft.pickit.DownloadAsyncTask.doInBackground at android.os.AsyncTask$3.call(AsyncTask.java:394) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) at java.lang.Thread.run(Thread.java:1012)

Crash 2:
OS: Android 12
Model: 2207117BPG

java.lang.SecurityException: Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider from ProcessRecord{b5b441c 15031:com.einpix.android/u0a288} (pid=15031, uid=10288) requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs at android.os.Parcel.createExceptionOrNull(Parcel.java:2456) at android.os.Parcel.createException(Parcel.java:2440) at android.os.Parcel.readException(Parcel.java:2423) at android.os.Parcel.readException(Parcel.java:2365) at android.app.IActivityManager$Stub$Proxy.getContentProvider(IActivityManager.java:6131) at android.app.ActivityThread.acquireProvider(ActivityThread.java:7387) at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:3383) at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:2526) at android.content.ContentResolver.query(ContentResolver.java:1203) at android.content.ContentResolver.query(ContentResolver.java:1151) at android.content.ContentResolver.query(ContentResolver.java:1107) at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(SourceFile:72) at com.hbisoft.pickit.DownloadAsyncTask.doInBackground at android.os.AsyncTask$3.call(AsyncTask.java:394) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:920)

Please provide your intent.

I am using it for two purpose.

  1. Pick image or videos
  2. Pick any types of files

Here is intent.

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, allowMultiple);
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
intent.setType("/");
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);

@milan-galitein
Thank you, but please provide your entire intent. The mimeTypes as well. Everything related to selecting the file.

I'm pretty sure this is related to two answers I've already provided in other issues.

In your first log you provided:

Did you add the following in onActivtyResult?

@Override
public void onActivityResult (int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {
        Uri mUri = data.getData();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            // You need to take permission here
            getContext().getContentResolver().takePersistableUriPermission(mUri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
            // Now you can pass the Uri to PickiT
        }
    }
}

The second log you provided:

The issue is described in the log:

Caused by: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider from ProcessRecord{b5b441c 15031:com.einpix.android/u0a288} (pid=15031, uid=10288) requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs

You should use ACTION_OPEN_DOCUMENT instead of ACTION_GET_CONTENT

This issue was already opened here - #10


I will be closing the issue until I hear back from you.