cryptomator / cryptomator/android

Auto upload fails due to permission problem on some devices

Open
#434 2 comments 0 reactions 0 assignees View on GitHub
type:bug
Dominant language
Kotlin
Stars
1.2k
Forks
216
PR merge metrics
No merged PRs in 30d

Description

### Please agree to the following

- [X] I have searched [existing issues](https://github.com/cryptomator/android/issues?q=) for duplicates
- [X] I agree to follow this project's [Code of Conduct](https://github.com/cryptomator/android/blob/develop/.github/CODE_OF_CONDUCT.md)

### Summary

Auto upload fails due to permission problem while reading the file during upload

### System Setup

```markdown
- Android: 12 (GrapheneOS) on Pixel 4a
- Cryptomator: 1.7.1 (F-Droid)
```

### Cloud Type

_No response_

### Steps to Reproduce

1. Enable auto upload
2. Create some pictures
3. Unlock vault or have the vault in an unlocked state

### Expected Behavior

Pictures gets uploaded

### Actual Behavior

Upload fails due to permission exception while accessing the picture.

### Reproducibility

Always

### Relevant Log Output

```shell
AutoUploadNotification Show storage permission required notification
AutoUploadService Failed to auto upload image(s).
org.cryptomator.domain.exception.FatalBackendException: java.io.FileNotFoundException: /storage/emulated/0/Pictures/Icons/Tutanota_Icon.png: open failed: EACCES (Permission denied)
at org.cryptomator.data.cloud.crypto.CryptoImplDecorator.writeShortNameFile(CryptoImplDecorator.kt:451)
at org.cryptomator.data.cloud.crypto.CryptoImplVaultFormat7.write(CryptoImplVaultFormat7.kt:437)
at org.cryptomator.data.cloud.crypto.CryptoCloudContentRepository.write(CryptoCloudContentRepository.kt:90)
at org.cryptomator.data.cloud.crypto.CryptoCloudContentRepository.write(CryptoCloudContentRepository.kt:21)
at org.cryptomator.data.repository.DispatchingCloudContentRepository.write(DispatchingCloudContentRepository.kt:149)
at org.cryptomator.presentation.service.AutoUploadService.writeCloudFile(AutoUploadService.java:219)
at org.cryptomator.presentation.service.AutoUploadService.upload(AutoUploadService.java:206)
at org.cryptomator.presentation.service.AutoUploadService.upload(AutoUploadService.java:199)
at org.cryptomator.presentation.service.AutoUploadService.upload(AutoUploadService.java:175)
at org.cryptomator.presentation.service.AutoUploadService.lambda$startBackgroundImageUpload$1$org-cryptomator-presentation-service-AutoUploadService(AutoUploadService.java:109)
at org.cryptomator.presentation.service.AutoUploadService$$ExternalSyntheticLambda1.run(Unknown Source:6)
at java.lang.Thread.run(Thread.java:920)
Caused by: java.io.FileNotFoundException: /storage/emulated/0/Pictures/Icons/Tutanota_Icon.png: open failed: EACCES (Permission denied)
at libcore.io.IoBridge.open(IoBridge.java:575)
at java.io.FileInputStream.(FileInputStream.java:160)
at java.io.FileInputStream.(FileInputStream.java:115)
at android.content.ContentResolver.openInputStream(ContentResolver.java:1527)
at org.cryptomator.presentation.util.ContentResolverUtil.openInputStream(ContentResolverUtil.kt:20)
at org.cryptomator.presentation.presenter.UriBasedDataSource.open(UriBasedDataSource.kt:18)
at org.cryptomator.domain.usecases.cloud.CancelAwareDataSource.open(CancelAwareDataSource.kt:22)
at org.cryptomator.data.cloud.crypto.CryptoImplDecorator.writeShortNameFile(CryptoImplDecorator.kt:423)
... 11 more
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:7756)
at libcore.io.IoBridge.open(IoBridge.java:561)
... 18 more

ErrorCode: KNRD:M7LU
```

### Anything else?

I can not reproduce this on a Pixel 6 and Pixel 4 using GrapheneOS too.

According to https://developer.android.com/training/data-storage/shared/media when accessing the `MediaStore` and with `Scoped storage` enabled,
* we need granted the [READ_EXTERNAL_STORAGE](https://developer.android.com/reference/android/Manifest.permission#READ_EXTERNAL_STORAGE) permission
* the files reside in one of the [MediaStore.Images](https://developer.android.com/reference/android/provider/MediaStore.Images) and [MediaStore.Video](https://developer.android.com/reference/android/provider/MediaStore.Video) collections

See
https://github.com/cryptomator/android/blob/55d7f68f4973274b5ff272d43f9fa6847afd264d/presentation/src/main/AndroidManifest.xml#L9

and
https://github.com/cryptomator/android/blob/55d7f68f4973274b5ff272d43f9fa6847afd264d/presentation/src/main/java/org/cryptomator/presentation/service/PhotoContentJob.kt#L149-L153

So I have currently no idea what the problem is here :thinking:

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.