From 94f9f7b0b3b2e912daf21792c30bfd36c0fd8646 Mon Sep 17 00:00:00 2001 From: MiMoHo <37556964+MiMoHo@users.noreply.github.com> Date: Fri, 3 Jul 2026 20:58:48 +0200 Subject: [PATCH] fix: prevent crash when storage-access settings screen is missing 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 #295 --- CHANGELOG.md | 2 ++ .../fossify/filemanager/activities/SimpleActivity.kt | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd08943f..15610ebf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed - Fixed the modification of the original timestamp when decompressing folders ([#190]) +- Fixed a crash when requesting storage access on devices without an all-files-access settings screen (e.g. Android TV) ([#295]) ## [1.6.1] - 2026-02-14 ### Changed @@ -135,6 +136,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#250]: https://github.com/FossifyOrg/File-Manager/issues/250 [#251]: https://github.com/FossifyOrg/File-Manager/issues/251 [#267]: https://github.com/FossifyOrg/File-Manager/issues/267 +[#295]: https://github.com/FossifyOrg/File-Manager/issues/295 [Unreleased]: https://github.com/FossifyOrg/File-Manager/compare/1.6.1...HEAD [1.6.1]: https://github.com/FossifyOrg/File-Manager/compare/1.6.0...1.6.1 diff --git a/app/src/main/kotlin/org/fossify/filemanager/activities/SimpleActivity.kt b/app/src/main/kotlin/org/fossify/filemanager/activities/SimpleActivity.kt index e98b7a9a..d8411bea 100644 --- a/app/src/main/kotlin/org/fossify/filemanager/activities/SimpleActivity.kt +++ b/app/src/main/kotlin/org/fossify/filemanager/activities/SimpleActivity.kt @@ -81,9 +81,13 @@ open class SimpleActivity : BaseSimpleActivity() { startActivityForResult(intent, MANAGE_STORAGE_RC) } catch (e: android.content.ActivityNotFoundException) { showErrorToast(e) - val intent = Intent() - intent.action = Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION - startActivityForResult(intent, MANAGE_STORAGE_RC) + try { + val intent = Intent() + intent.action = Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION + startActivityForResult(intent, MANAGE_STORAGE_RC) + } catch (_: Exception) { + finish() + } } catch (e: SecurityException) { showErrorToast(e) finish()