fix(android): set background activity launch mode for PendingIntent - #2796
Open
Luca-CZ wants to merge 1 commit into
Open
fix(android): set background activity launch mode for PendingIntent#2796Luca-CZ wants to merge 1 commit into
Luca-CZ wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
see #2795
Summary
Adds explicit background activity launch handling for Android 14+ activity
PendingIntents created by the plugin.This updates
PendingIntent.getActivity(...)usage to pass anActivityOptionsbundle on API 34+ and explicitly set the pending intent creator background activity start mode.Motivation
Android 14 introduced stricter handling around background activity launches. When creating activity
PendingIntents, apps should explicitly opt in or opt out of background activity start behavior instead of relying on implicit or system-defined defaults.Previously, the plugin created activity
PendingIntents for notification taps and notification actions without passingActivityOptions.setPendingIntentCreatorBackgroundActivityStartMode(...).This made the behavior implicit on API 34+ and could trigger Android security/compliance findings. Making the behavior explicit allows the plugin to:
The change is backward compatible because it only applies on Android 14+ and keeps the existing behavior for older Android versions.
Implementation notes
ActivityOptionsusage to Android activityPendingIntentcreation.PendingIntent.getActivity(...)path.PendingIntent.getActivity(...)whenshowsUserInterfaceis true.Build.VERSION.SDK_INT >= VERSION_CODES.UPSIDE_DOWN_CAKEto gate the new behavior.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_DENIEDas the explicit default.activityOptions.toBundle()to the 5-argumentPendingIntent.getActivity(...)overload on API 34+.PendingIntent.getActivity(...)call on older Android versions.Testing
Tested using:
melos bootstrap
melos run analyze
melos run test:unit