New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 7.0: FileUriExposedException after selecting "Report Bug" #1105

Closed
Ghabry opened this Issue Feb 23, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@Ghabry
Member

Ghabry commented Feb 23, 2017

Google continues wasting developer time by randomly breaking APIs. Android 7.0 market share is currently 2% and will become more soon 馃憥. Fortunately this only breaks the "Report Bug" function. (which is quite ironic).

Stacktrace:

android.os.FileUriExposedException: file:///storage/emulated/0/easyrpg/rtp/2000/nobita_hazard/easyrpg_log.txt exposed beyond app through ClipData.Item.getUri()
	at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
	at android.net.Uri.checkFileUriExposed(Uri.java:2346)
	at android.content.ClipData.prepareToLeaveProcess(ClipData.java:832)
	at android.content.Intent.prepareToLeaveProcess(Intent.java:8909)
	at android.content.Intent.prepareToLeaveProcess(Intent.java:8894)
	at android.app.Instrumentation.execStartActivity(Instrumentation.java:1517)
	at android.app.Activity.startActivityForResult(Activity.java:4224)
	at android.app.Activity.startActivityForResult(Activity.java:4183)
	at android.app.Activity.startActivity(Activity.java:4507)
	at android.app.Activity.startActivity(Activity.java:4475)
	at org.easyrpg.player.player.EasyRpgPlayerActivity$3.onClick(EasyRpgPlayerActivity.java:239)
	at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:164)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:154)
	at android.app.ActivityThread.main(ActivityThread.java:6077)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Proposed solution on stackoverflow: https://stackoverflow.com/questions/38200282/android-os-fileuriexposedexception-file-storage-emulated-0-test-txt-exposed

Relevant Code for reference:

ArrayList<Uri> files = new ArrayList<Uri>();
String savepath = getIntent().getStringExtra(TAG_SAVE_PATH);
files.add(Uri.fromFile(new File(savepath + "/easyrpg_log.txt"))); // Uri.fromFile -> BAD
for (File f : GameBrowserHelper.getSavegames(new File(savepath))) {
	files.add(Uri.fromFile(f));  // Uri.fromFile -> BAD
}

Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
intent.setData(Uri.parse("mailto:"));
intent.setType("*/*");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"easyrpg@easyrpg.org"});
intent.putExtra(Intent.EXTRA_SUBJECT, "Bug report");
intent.putExtra(Intent.EXTRA_TEXT, getApplicationContext().getString(R.string.report_bug_mail));
intent.putExtra(Intent.EXTRA_STREAM, files);
if (intent.resolveActivity(getPackageManager()) != null) {
	startActivity(intent); // CRASH
}

CC @BlisterB

@Ghabry Ghabry added this to the 0.5.1 milestone Feb 23, 2017

@Ghabry

This comment has been minimized.

Show comment
Hide comment
@Ghabry

Ghabry Feb 23, 2017

Member

The message provided by the user to the crsh is "姝﹀櫒銇岃鍌欍仹銇嶃伨銇涖倱銇┿亞銈嗐亞浜嬨仹銇欍亱" which translates to "I can not equip you with weapons. What do you mean?" 炉\_(銉)_/炉

Member

Ghabry commented Feb 23, 2017

The message provided by the user to the crsh is "姝﹀櫒銇岃鍌欍仹銇嶃伨銇涖倱銇┿亞銈嗐亞浜嬨仹銇欍亱" which translates to "I can not equip you with weapons. What do you mean?" 炉\_(銉)_/炉

@Ghabry Ghabry modified the milestones: 0.6.0, 0.5.1 Feb 23, 2017

@Ghabry Ghabry changed the title from Android 7.0: FileUriExposedException after opening a game to Android 7.0: FileUriExposedException after selecting "Report Bug" Feb 23, 2017

@BlisterB

This comment has been minimized.

Show comment
Hide comment
@BlisterB

BlisterB Feb 23, 2017

Member

Hi Ghabry :).

Eeeeerf Android.
An easy fix is to lower the the targetVersionSdk version to 23, I currently don't have an Android 7.0 device and I'm afraid to encounter similar issues without extensive tests. Of course we can still apply your tip later and test it with compatible devices. Are you ok with this solution?

Member

BlisterB commented Feb 23, 2017

Hi Ghabry :).

Eeeeerf Android.
An easy fix is to lower the the targetVersionSdk version to 23, I currently don't have an Android 7.0 device and I'm afraid to encounter similar issues without extensive tests. Of course we can still apply your tip later and test it with compatible devices. Are you ok with this solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment