Repository navigation
feat: open files through the host in Formatter, BitmapFactory and MediaMetadataRetriever - #24
Merged
Merged
Conversation
…iaMetadataRetriever
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Classes that open a file by path inside themselves bypassed the guard and failed with EACCES in engine apps without storage permission. Three common ones now have same-shaped replacements registered in
GuardPolicy.substitutes, so both Javet and GraalJS pick them up through the existing lookup:java.util.Formatter(final): all constructors; the file name andFileones write throughGuardFileOutputStream, the charset is checked before the file is opened as in the real class.android.graphics.BitmapFactory:decodeFilereads through the host and, like the real class, logs and returns null on failure; the other decoders are the real ones.android.media.MediaMetadataRetriever: subclass whosesetDataSource(String)opens paths andfile:addresses through the host (other schemes go to the real URL path).Still not covered (they need a real path): SQLite databases (use the host
dbmodule),java.util.logging.FileHandler,URL("file:..."), XMLparse(File),MediaPlayer.setDataSource(path),AtomicFile.Testing
:guard:connectedDebugAndroidTeston an API 36 x86_64 emulator: 26/26 (new boundary tests; the parity test now also checks the three replacements against the real classes).JavaGuardConformancegainsclassesThatOpenAPathGoThroughTheHost; NodeJSPlugin and the GraalJS fixture pass 12/12 on the emulator with this revision.🤖 Generated with Claude Code