SecurityException: Permission Denial: opening provider org.chromium.chrome.browser.util.ChromeFileProvider from ProcessRecord

我的未来我决定 提交于 2019-12-08 03:49:27

问题


I'm building a Chooser app that replaces the native Android Share dialog. It works fine except when I try to share an image from Chrome via longpress image > share image.

If I try to do: Focus Gallery (by Franco) > Share (My App) > Google+ > No problem. Chrome > Share (My App) > Crash.

As soon as I try to access the content:// uri that is passed to my app as the EXTRA_STREAM, I get an error:

java.lang.SecurityException: Permission Denial: opening provider org.chromium.chrome.browser.util.ChromeFileProvider from ProcessRecord{9a9ad72 13494:com.rejh.sharedr/u0a226} (pid=13494, uid=10226) that is not exported from UID 10101

The content uri looks like this:

content://com.android.chrome.FileProvider/images/screenshot/15307085865714015389178311011200.jpg

Here's what I do (simplified):

@override 
public void onCreate() {
    handleIntent();

@override 
public void onNewIntent() {
    handleIntent();
}

public void handleIntent() {
    Parcelable parcel = getIntent().getParcelableExtra(Intent.EXTRA_INTENT);
    payloadIntent = new Intent((Intent) parcel);

    Uri extraStreamUri = (Uri) payloadIntent.getExtras().get(Intent.EXTRA_STREAM);
    ContentResolver contentResolver = getContentResolver();
    String fileMimeType = contentResolver.getType(extraStreamUri);
    Cursor returnCursor = contentResolver.query(extraStreamUri, null, null, null, null);
}

I get the error on the last line (contentResolver.query()). Weirdly enough, getType() does work.

Manifest declaration of the activity:

<activity
    android:name=".ActShareReplace"
    android:label="Sharedr"
    android:theme="@style/AppTheme.TransparentActivity"
    >
    <intent-filter>
        <action android:name="android.intent.action.CHOOSER" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

As far as I can tell I should still have access to the URI since I try to access it from the same activity that receives the intent.

Btw, Chrome is the only app I've been having problems with so far. A user did report that sharing an image from Whatsapp resulted in similar error(s).

来源:https://stackoverflow.com/questions/51174627/securityexception-permission-denial-opening-provider-org-chromium-chrome-brows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!