Skip to content

Guard settings intents against missing activities - #113

Merged
in-jun merged 1 commit into
mainfrom
fix/permissions
Jul 18, 2026
Merged

Guard settings intents against missing activities#113
in-jun merged 1 commit into
mainfrom
fix/permissions

Conversation

@in-jun

@in-jun in-jun commented Jul 18, 2026

Copy link
Copy Markdown
Owner

The onboarding permission banner launches three system settings actions (all-files-access, per-app notifications, battery-optimization exemption). A matching activity for these isn't guaranteed on every device/OEM build, so on an affected phone tapping the banner threw ActivityNotFoundException and crashed the app during first-run.

  • Route all four settings launches through a startFirstAvailable helper that tries each action in order, swallows ActivityNotFoundException, and falls back to the device-wide list where one exists and finally the always-present app details page.

Fixes #69

Wrap the all-files-access, per-app notification, and battery-optimization
settings launches in a helper that tries each action in turn and swallows
ActivityNotFoundException, falling back to the device-wide list and finally
the always-present app details page. Prevents a first-run crash on OEM builds
that lack a matching activity for these actions.

@in-jun in-jun left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Confirmed this resolves #69 cleanly. All four startActivity sites in Permissions.kt — the only settings launches in the app — now route through startFirstAvailable, which tries each action in order, swallows ActivityNotFoundException, and lands on the always-present app-details page as a last resort. The preferred intent is still attempted first in every case, so happy-path behavior is unchanged and the only new behavior is the fallback chain.

A couple of things I checked:

  • Fallback constants are safe at our minSdk 26: ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS (23) and ACTION_APP_NOTIFICATION_SETTINGS (26) are always available, and ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION (30) stays inside the existing SDK_INT >= R guard.
  • If every intent fails the call is a harmless no-op rather than a crash, which is the whole point of the change.

The device-wide list / app-details fallbacks drop the user a step short of the exact toggle, but that's a reasonable trade for never crashing the first-run flow, and it matches the approach outlined in the issue. Looks good to me.

@in-jun
in-jun merged commit b0dad0d into main Jul 18, 2026
1 check passed
@in-jun
in-jun deleted the fix/permissions branch July 18, 2026 14:57
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.

Settings intents can crash the app when the device has no matching activity

1 participant