Skip to content

fix: unable to open input stream from content resolver for Uri#20918

Open
criticalAY wants to merge 9 commits intoankidroid:mainfrom
criticalAY:multimedia-bug
Open

fix: unable to open input stream from content resolver for Uri#20918
criticalAY wants to merge 9 commits intoankidroid:mainfrom
criticalAY:multimedia-bug

Conversation

@criticalAY
Copy link
Copy Markdown
Contributor

@criticalAY criticalAY commented May 1, 2026

Purpose / Description

Fix SecurityException: unsafe-content-uri-resolution when sharing an image into the note editor: file:// URIs pointing at our own /data/.../cache were being routed back through Android's content resolver, which rejects them.

Fixes

Approach

Two new helpers in MultimediaImageUri.kt (resolveFileFromUri, openImageInputStream) read those URIs directly via java.io and delegate everything else to the caller's content-resolver path

How Has This Been Tested?

7 unit tests and Pixel 10, shared image from Photos and it was added

Learning (optional, can help others)

NA

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

criticalAY added 9 commits May 1, 2026 14:59
Removes the openMultimediaImageFragment helper. Bottom-sheet dispatch
and the paste path now build their launch intents through the same
handler.
handleMultimediaActions, handleMultimediaResult, performAddMedia and
the multimediaActionJob state now live on a NoteEditorMultimediaController.
The fragment keeps the ActivityResultLauncher registration (framework
requirement) and forwards its callback.
The paste-image path now delegates to launchImagePaste, mirroring the
bottom-sheet dispatch. pastedImageCache and its savedInstanceState
plumbing move with it; the fragment forwards save/restore through
onSaveInstanceState / onRestoreInstanceState on the controller.
onPaste moves; shouldPasteAsPng stays on the fragment because the
paste listener is synchronous.
…ract

test: cover NoteEditorMultimediaController save/restore plumbing
…lver

test: cover file/content URI branching in MultimediaImageUri helpers
@criticalAY criticalAY added the Blocked by dependency Currently blocked by some other dependent / related change label May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Blocked by dependency Currently blocked by some other dependent / related change Multimedia Needs Review Priority-Medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to share image from app to AnkiDroid

1 participant