Skip to content

fix: guard against ActivityNotFoundException when requesting all-files access#458

Closed
MiMoHo wants to merge 1 commit into
FossifyOrg:mainfrom
MiMoHo:fix/issue-295
Closed

fix: guard against ActivityNotFoundException when requesting all-files access#458
MiMoHo wants to merge 1 commit into
FossifyOrg:mainfrom
MiMoHo:fix/issue-295

Conversation

@MiMoHo

@MiMoHo MiMoHo commented Jul 3, 2026

Copy link
Copy Markdown

Type of change(s)

  • Bug fix

What changed and why

On Android 11+ (R+), SimpleActivity.handleStoragePermission() first launches Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION inside a try. If that screen is unavailable it catches ActivityNotFoundException and falls back to the generic Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION. That fallback startActivityForResult call was itself unguarded, so on devices whose Settings lacks both all-files-access screens (e.g. Android TV) the fallback also throws ActivityNotFoundException, which propagated uncaught and crashed the app.

This matches the issue's logcat exactly: two ActivityTaskManager START lines (MANAGE_APP_ALL_FILES_ACCESS_PERMISSION then MANAGE_ALL_FILES_ACCESS_PERMISSION) followed by FATAL EXCEPTION No Activity found to handle Intent { act=android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION } originating from handleStoragePermission$lambda$0.

The fix wraps the fallback intent launch in its own try/catch; on failure it calls finish() gracefully, mirroring the existing SecurityException branch directly below. No new imports are required. CHANGELOG updated under the Unreleased ### Fixed section.

Tests performed

  • detekt, lint, unit tests and the build all pass locally (CI-equivalent).
  • Source-verified: startActivityForResult(ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION) is now wrapped in try/catch, falling back to finish() if no matching Settings activity exists (the reported ActivityNotFoundException). This is a defensive guard that can only prevent the crash.
  • Note: the stock emulator has that Settings screen, so the original crash can't be reproduced here; verified via CI + code review.

Closes the following issue(s)

Checklist

  • I read the contribution guidelines.
  • I manually tested my changes on device/emulator (verified via CI + source review; see Tests performed).
  • I updated the "Unreleased" section in CHANGELOG.md (if applicable).
  • I have self-reviewed my pull request (no typos, formatting errors, etc.).
  • I understand every change in this pull request.

Coded with Opus 4.8 ultracode.

handleStoragePermission() falls back to ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION when the app-specific all-files-access screen is unavailable, but that fallback startActivityForResult was not guarded. On devices whose Settings lacks both all-files-access screens (e.g. Android TV) the fallback also throws ActivityNotFoundException, which was uncaught and crashed the app.

Wrap the fallback intent launch in its own try/catch and finish() gracefully on failure, mirroring the existing SecurityException branch.

Closes FossifyOrg#295
@MiMoHo MiMoHo requested a review from naveensingh as a code owner July 3, 2026 21:44
@MiMoHo MiMoHo closed this Jul 3, 2026
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.

ActivityNotFoundException: android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION

1 participant