Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 22, 2025

On Android SDK 23 devices with removable SD cards, getExternalCacheDir() returns a path on the SD card (e.g., /storage/1234-5678/Android/data/.../cache/), but FileProvider's external-cache-path only maps to primary external storage, causing IllegalArgumentException when capturing photos.

Changes

  • PersistentBlobProvider.createForExternal(): Catch IllegalArgumentException from FileProvider and fall back to internal cache directory
  • file_provider_paths.xml: Add <cache-path> element to enable FileProvider URIs for internal cache

The existing getExternalDir() fallback handles null external cache; this handles valid external paths that FileProvider rejects.

try {
  File externalDir = getExternalDir(context);
  File target = new File(externalDir, filename);
  return FileProviderUtil.getUriFor(context, target);
} catch (IllegalArgumentException e) {
  // External cache on removable SD card - use internal cache instead
  File internalDir = context.getCacheDir();
  // ... fallback logic
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx4608m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/gradle-daemon-main-8.13.jar (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>clicking the quick-camera button doesn't work</issue_title>
<issue_description>device specs:
``
device=HUAWEI CAM-L21 (CAM-L21)
android=6.0 (C403B173, CAM-L21C403B173)
sdk=23


when user clicks the quick-access camera button to take a picture, it doesn't work, user is not able to attach the picture properly, this is the crash report:

12-17 12:20:47.761 31095 31095 🟠 X0 : onCreate(null)
12-17 12:20:47.768 31095 31095 🔵 AppCompatDelegate: You should now use the AppCompatDelegate.FEATURE_SUPPORT_ACTION_BAR_OVERLAY id when requesting this feature.
12-17 12:20:47.991 31095 31095 🔵 ConversationActivity: handleSecurityChange(false, true)
12-17 12:20:48.028 31095 31105 🔵 art : Background partial concurrent mark sweep GC freed 4461(352KB) AllocSpace objects, 12(1140KB) LOS objects, 15% free, 22MB/26MB, paused 13.507ms total 61.164ms
12-17 12:20:48.073 31095 31095 🔵 o0 : ⏰ getChatMsgs(242): 2ms
12-17 12:20:49.888 31095 31095 🔵 ConversationActivity: onConfigurationChanged(1)
12-17 12:20:50.009 31095 31095 🔵 w : rotation changed
12-17 12:20:50.009 31095 31095 🔵 w : onKeyboardClose()
12-17 12:20:50.009 31095 31095 🔵 ScaleStableImageView: Keyboard hidden
12-17 12:20:50.038 31095 31105 🔵 art : Background partial concurrent mark sweep GC freed 1714(103KB) AllocSpace objects, 3(108KB) LOS objects, 12% free, 28MB/32MB, paused 4.570ms total 102.070ms
12-17 12:20:50.539 31095 31105 🔵 art : Background sticky concurrent mark sweep GC freed 6262(363KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 34MB/34MB, paused 1.743ms total 208.121ms
12-17 12:20:50.649 31095 31105 🔵 art : Background partial concurrent mark sweep GC freed 846(58KB) AllocSpace objects, 3(6MB) LOS objects, 12% free, 28MB/32MB, paused 1.823ms total 108.714ms
12-17 12:20:52.752 31095 31095 🟠 j : java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/1234-5678/Android/data/chat.delta.lite/cache/1765992052741.jpg
12-17 12:20:52.752 31095 31095 🟠 j : at androidx.core.content.FileProvider$SimplePathStrategy.android.net.Uri getUriForFile(java.io.File)(FileProvider.java:867)
12-17 12:20:52.752 31095 31095 🟠 j : at androidx.core.content.FileProvider.android.net.Uri getUriForFile(android.content.Context,java.lang.String,java.io.File)(FileProvider.java:467)
12-17 12:20:52.752 31095 31095 🟠 j : at org.thoughtcrime.securesms.util.FileProviderUtil.android.net.Uri getUriFor(android.content.Context,java.io.File)(FileProviderUtil.java:19)
12-17 12:20:52.752 31095 31095 🟠 j : at org.thoughtcrime.securesms.providers.PersistentBlobProvider.android.net.Uri createForExternal(android.content.Context,java.lang.String)(PersistentBlobProvider.java:126)
12-17 12:20:52.752 31095 31095 🟠 j : at org.thoughtcrime.securesms.mms.AttachmentManager.void lambda$capturePhoto$4(android.app.Activity,int)(AttachmentManager.java:528)
12-17 12:20:52.752 31095 31095 🟠 j : at org.thoughtcrime.securesms.permissions.PermissionsRequest.void onResult(java.lang.String[],int[],boolean[])(PermissionsRequest.java:57)
12-17 12:20:52.752 31095 31095 🟠 j : at org.thoughtcrime.securesms.permissions.Permissions$PermissionsBuilder.void executePreGrantedPermissionsRequest(org.thoughtcrime.securesms.permissions.PermissionsRequest)(Permissions.java:166)
12-17 12:20:52.752 31095 31095 🟠 j : at org.thoughtcrime.securesms.permissions.Permissions$PermissionsBuilder.void execute()(Permissions.java:154)
12-17 12:20:52.752 31095 31095 🟠 j : at org.thoughtcrime.securesms.mms.AttachmentManager.void capturePhoto(android.app.Activity,int)(AttachmentManager.java:538)
12-17 12:20:52.752 31095 31095 🟠 j : at org.thoughtcrime.securesms.ConversationActivity.void lambda$initializeViews$14(android.view.View)(ConversationActivity.java:927)
12-17 12:20:52.752 31095 31095 🟠 j : at android.view.View.performClick(View.java:5273)
12-17 12:20:52.752 31095 31095 🟠 j : at android.view.View$PerformClick.run(View.java:21315)
12-17 12:20:52.752 31095 31095 🟠 j : at android.os.Handler.handleCallback(Handler.java:743)
12-17 12:20:52.752 31095 31095 🟠 j : at android.os.Handler.dispatchMessage(Handler.java:95)
12-17 12:20:52.752 31095 31095 🟠 j : at android.os.Looper.loop(Looper.java:150)
12-17 12:20:52.752 31095 31095 🟠 j : at android.app.ActivityThread.main(ActivityThread.java:5665)
12-17 12:20:52.752 31095 31095 🟠 j : at java.lang.reflect.Method.invoke(Native Method)
12-17 12:20:52.752 31095 31095 🟠 j : at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:822)
12-17 12:20:52.752 31095 31095 🟠 j : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:712)
12-17 12:20:55.785 31095 31149 🟠 DeltaChat: [accId=1] src/scheduler.rs:423: Failed inbox fetch_idle: idle: INBOX: IMAP IDLE protocol timed out: deadline has elapsed.
...


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 22, 2025 16:55
Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com>
Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix quick-access camera button not functioning Fix camera capture crash on devices with removable SD cards Dec 22, 2025
Copilot AI requested a review from adbenitez December 22, 2025 17:00
@adbenitez adbenitez requested a review from Copilot December 22, 2025 17:03
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a crash on Android SDK 23 devices with removable SD cards where getExternalCacheDir() returns a path that FileProvider's external-cache-path cannot map, causing IllegalArgumentException when capturing photos with the quick-camera button.

Key Changes:

  • Added exception handling in createForExternal() to catch IllegalArgumentException from FileProvider and fallback to internal cache directory
  • Added <cache-path> element to file_provider_paths.xml to enable FileProvider URIs for internal cache directory

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/main/java/org/thoughtcrime/securesms/providers/PersistentBlobProvider.java Added try-catch block around FileProvider call to catch IllegalArgumentException when external cache is on removable SD card, with fallback to internal cache
src/main/res/xml/file_provider_paths.xml Added cache-path mapping to support FileProvider URIs for internal cache directory used in fallback

@github-actions
Copy link

To test the changes in this pull request, install this apk:
📦 app-preview.apk

@adbenitez adbenitez closed this Dec 22, 2025
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

Successfully merging this pull request may close these issues.

clicking the quick-camera button doesn't work

2 participants