Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ErrnoException: open failed: EACCES (Permission denied) #74

Open
saket opened this issue Nov 10, 2024 · 3 comments
Open

ErrnoException: open failed: EACCES (Permission denied) #74

saket opened this issue Nov 10, 2024 · 3 comments

Comments

@saket
Copy link
Contributor

saket commented Nov 10, 2024

Dropshots fails to read images every now and then with this error:

java.io.FileNotFoundException: /storage/emulated/0/Download/screenshots/me.saket.telephoto.subsamplingimage.test/various_image_orientations_in_exif_metadata[RotatedBy180,Center,Fill]_zoomed.png: open failed: EACCES (Permission denied)
at libcore.io.IoBridge.open(IoBridge.java:575)
at java.io.FileOutputStream.<init>(FileOutputStream.java:236)
at java.io.FileOutputStream.<init>(FileOutputStream.java:186)
at com.dropbox.dropshots.Dropshots.writeImage(Dropshots.kt:196)
at com.dropbox.dropshots.Dropshots.writeThen(Dropshots.kt:176)
at com.dropbox.dropshots.Dropshots.assertSnapshot(Dropshots.kt:153)
at com.dropbox.dropshots.Dropshots.assertSnapshot(Dropshots.kt:94)
at com.dropbox.dropshots.Dropshots.assertSnapshot$default(Dropshots.kt:90)
…
Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
at libcore.io.Linux.open(Native Method)
at libcore.io.ForwardingOs.open(ForwardingOs.java:567)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:273)
at libcore.io.ForwardingOs.open(ForwardingOs.java:567)
at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7725)
at libcore.io.IoBridge.open(IoBridge.java:561)
... 24 more

I used to workaround this by manually granting WRITE_EXTERNAL_STORAGE permission in my tests, but do you know why is this even needed?

// Shouldn't be needed on > API 29, but dropshots is occasionally unable to write to external storage without this.
val uiAutomation = InstrumentationRegistry.getInstrumentation().uiAutomation
uiAutomation.grantRuntimePermission(packageName, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
@rharter
Copy link
Collaborator

rharter commented Nov 12, 2024

Hmm, I've seen this from time to time as well, but I'm not sure where it's coming from, the emulator or the emulators bridge to the host system. I'm working on some updates for managed devices that I think should fix this as well, if you don't mind using your workaround until those land.

@saket
Copy link
Contributor Author

saket commented Nov 12, 2024

Sounds good! I'll also cross-post this to google's issuetracker in case they might have any ideas.

@saket
Copy link
Contributor Author

saket commented Nov 12, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants