nextcloud / nextcloud/android

Photo shared to Google Messages via share sheet fails to attach — Messages rejects our DiskLruImageCacheFileProvider URI as "private"

Open
#17,414 1 comment 0 reactions 0 assignees View on GitHub
0. Needs triage bug
Dominant language
Kotlin
Stars
5.6k
Forks
2k
Avg merge
2d 18h
Merged PRs (30d)
92

Description

### ⚠️ Before posting ⚠️

- [x] This is a **bug**, not a question or an enhancement.
- [x] I've [searched for similar issues](https://github.com/nextcloud/android/issues) and didn't find a duplicate.
- [x] I've written a clear and descriptive title for this issue, not just "Bug" or "Crash".
- [x] I agree to follow Nextcloud's [Code of Conduct](https://nextcloud.com/contribute/code-of-conduct/).

### Steps to reproduce

Step 1: Open the Nextcloud app, go to Photos, tap a photo, tap the share icon.
Step 2: Choose "Reduced size" or "Original file" (not "Public link").
Step 3: In Android's native share sheet, choose Messages and select a contact/thread.
Step 4: Observe -- Messages opens, but no image attachment appears, no error shown to the user.

### Expected behaviour

The image should attach, the same way it does when sharing the identical photo via Signal or Nextcloud Talk.

### Actual behaviour

Messages opens, but no image attachment appears. No error is shown to the user.

Confirmed via `adb logcat` while reproducing -- Messages' own process logs:

```
E MessagingApp: Assert.fail() called: Cannot send private file content://org.nextcloud.imageCache.provider/Household/Photos/.../IMG_20260106_103619_161.jpg
at com.android.messaging.ui.conversationlist.ShareIntentActivity.addSharedPartToDraft(SourceFile:244)
```

This assertion fires before Messages attempts to actually read the file (no preceding SecurityException from opening it) -- it's Messages' own defensive check on the incoming shared Intent, deciding the URI/grant isn't trustworthy and refusing outright, not an OS-level permission wall being tripped mid-read. That points at something in how the share Intent is constructed for content://org.nextcloud.imageCache.provider/... (our DiskLruImageCacheFileProvider) not satisfying whatever Messages checks for (possibly related to ClipData/grant-flag handling, not confirmed at the code level on our side).

Isolation testing done:

| Source app | Target app | Result |
|---|---|---|
| Nextcloud | Messages | Fails silently -- no attachment |
| Nextcloud | Nextcloud Talk | Works |
| Nextcloud | Signal | Works |
| Default Gallery app | Messages | Works |

Reproduced identically on two separate GrapheneOS phones (Pixel 10 / Pixel 10 XL), ruling out a device-specific issue.

Related report: we hit the same Messages-side symptom (identical Assert.fail(): Cannot send private file) from the separate Memories Android app (pulsejet/memories) too, but via a different URI -- Memories routes its share through Android's DownloadManager (content://downloads/all_downloads/) rather than a FileProvider at all. Filed as a separate issue there: https://github.com/pulsejet/memories/issues/1706 -- linking in case the two clients share relevant file-sharing code.

Suspected cause: whatever combination of Intent flags / ClipData construction Messages requires to accept a shared content:// URI as legitimate isn't being satisfied when serving files through DiskLruImageCacheFileProvider. Happy to help narrow this down further or test a patched build if useful.

### Android version

17 (GrapheneOS)

### Device brand and model

Google Pixel 10 Pro XL / Pixel 10

### Stock or custom OS?

Custom (explain in "additional information")

### Nextcloud android app version

34.1.0

### Nextcloud server version

33.0.6

### Using a reverse proxy?

Yes

### Android logs

Relevant excerpt from `adb logcat -v threadtime` captured while reproducing (share icon -> Original file -> Messages -> select contact -> send):

```
ActivityTaskManager: START u0 {act=android.intent.action.SEND typ=image/jpeg ... cmp=com.android.messaging/.ui.conversationlist.ShareIntentActivity ...} from uid 10195 (com.nextcloud.client) (realCallingUid=10080)
ImageLoader: java.io.IOException: java.lang.SecurityException: Permission Denial: opening provider com.owncloud.android.providers.DiskLruImageCacheFileProvider from ProcessRecord{... com.android.intentresolver/u0a80} (pid=31835, uid=10080) requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
MessagingApp: Assert.fail() called: Cannot send private file content://org.nextcloud.imageCache.provider/Household/Photos/.../IMG_20260106_103619_161.jpg
at com.android.messaging.ui.conversationlist.ShareIntentActivity.addSharedPartToDraft(SourceFile:244)
```

Note the first SecurityException is from the share sheet's own preview-thumbnail loader (com.android.intentresolver, uid 10080) trying to render a preview -- that happens for any target app, before one is chosen, so it's a separate cosmetic issue. The `Assert.fail()` from MessagingApp (Messages' own process) is the actual cause of the attach failure.

### Server error logs

```bash

```

### Additional information

Custom OS: GrapheneOS (a hardened, de-Googled Android fork). Messages app referenced above is `com.android.messaging`, the built-in AOSP Messaging app that GrapheneOS ships by default (not a Google Play app).

Contributor guide

Open the contributing guide

Research direction

Start at the Photos share action and trace how the Reduced size and Original file paths construct the SEND Intent for DiskLruImageCacheFileProvider. Reproduce with Messages while collecting adb logcat, then verify that Messages attaches the image without breaking the existing Signal and Nextcloud Talk sharing cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.