Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API 34 : One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts #1020

Closed
QuentinFarizon opened this issue Jul 8, 2024 · 8 comments · Fixed by #1022
Assignees
Labels
Milestone

Comments

@QuentinFarizon
Copy link

I got this crash in production after having deployed on the Play Store : java.lang.SecurityException - <package>: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts

It is found here :
https://github.com/search?q=repo%3Adon%2Fcordova-plugin-ble-central%20registerReceiver&type=code

Here is the fix :
https://stackoverflow.com/a/77276774

I could submit a PR but I don't whether it should be exported or not

@peitschie
Copy link
Collaborator

Thanks for this @QuentinFarizon ... I'll take a look tomorrow.

@peitschie peitschie self-assigned this Jul 13, 2024
@peitschie peitschie added this to the next milestone Jul 13, 2024
@peitschie
Copy link
Collaborator

Relevant documentation from Android on this:

Although these are all system broadcasts, because they're being registered via an Activity, they're effectively context-registered receivers, and thus need a RECEIVER_EXPORTED flag, as the app needs intents coming from outside the application itself (i.e., from the system).

@peitschie
Copy link
Collaborator

@QuentinFarizon I've published this as cordova-plugin-ble-central@1.7.5-alpha.0.
Are you able to test the changes to see if this fixes the issue for you?

@QuentinFarizon
Copy link
Author

@peitschie I think you can use ContextCompat.registerReceiver(..., ..., Context.RECEIVER_EXPORTED) to avoid checking for versions yourself

@peitschie
Copy link
Collaborator

@peitschie I think you can use ContextCompat.registerReceiver(..., ..., Context.RECEIVER_EXPORTED) to avoid checking for versions yourself

I can, but only if I mandate a compile SDK version that's new enough.
I've started a draft that forces this, but that's definitely a 2.0 release as to achieve this I need to deliberately drop compatibility with a lot of older releases of the platforms.

I have a plan/patch in progress for this, but wanted to get a fix out ASAP given the impact this seems to have on Android v34.

peitschie added a commit that referenced this issue Jul 23, 2024
peitschie added a commit that referenced this issue Jul 23, 2024
@sithwarrior
Copy link
Contributor

Hey @peitschie is this needed for the Slim variant too? As everyone else we are getting ready to target lvl 34, and we are using the slim variant, because of Android permissions

@sithwarrior
Copy link
Contributor

Hey @QuentinFarizon and @peitschie Any update if this fix is needed for api level 34?

@peitschie
Copy link
Collaborator

Hi @sithwarrior

This particular issue only occurs if you're listening to location state on Android. The normal Bluetooth enable/disable states are fine.

Having said that, I've pushed out a 1.7.5 & 1.7.5-slim variant today, so feel free to use them. If you hit any problems, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants