Repository navigation
Conversation
start() used implicit flags = 0, which raises a SecurityException on Android 14+ for app-defined actions. New exported=False keyword; on SDK 33+ register with the matching flag, below that keep the legacy call.
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.
My BroadcastReceiver is failing on android 15 when on
BroadcastReceiver.start()registers with the 4-argregisterReceiver.On Android 14+, the platform requires
RECEIVER_EXPORTEDorRECEIVER_NOT_EXPORTEDfor any runtime-registered receiver whose filter is not exclusively protected system broadcasts, so registering for app-defined actions now throws:java.lang.SecurityException: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcastsp4a's own Java-side receivers
Hardware.javalisten only to protected system broadcasts and are exempt, anything registering custom actions from Python crashes instart().Fixes #3399
Changes
broadcast.py: newexported=Falsekeyword onBroadcastReceiver.__init__.On Android 14+
_register_receiver()passesContext.RECEIVER_EXPORTEDorContext.RECEIVER_NOT_EXPORTED(default) as the 5th argument.below 14 the original 4-arg call is kept, since the
RECEIVER_*constants only exist from API 33.The default is
RECEIVER_NOT_EXPORTED(least privilege): same-UID and system broadcasts are still delivered.exported=Trueis the opt-in for receiving from other apps.doc/source/apis.rst: documents the new parameter.Verification
Android 15 / API 35 device, targetSdk 36, receiver registered from a foreground service for two app-defined actions, triggered via notification buttons (
PendingIntent.getBroadcast+setPackage()):br.start()raises theSecurityExceptionabovep4a.source_dir): all taps reach the callback, no exceptiondocs to Android note on changes: https://developer.android.com/about/versions/14/behavior-changes-14#runtime-receivers-exported