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

(Android) Add RECEIVER_EXPORTED flags upon registering receiver for Android 12+ requirements #13438

Open
wants to merge 6 commits into
base: development
Choose a base branch
from

Conversation

jnnguyen12
Copy link

Android applications with Android 12 and above that uses the published AAR will crash upon startup without the required RECEIVER_EXPORTED flags, declared upon registering receivers in intent filters. Errors are as shown below:

Java.Lang.SecurityException: com.company.app: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
 ---> Android.OS.RemoteException: Remote stack trace:
	at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:16680)
	at android.app.IActivityManager$Stub.onTransact$registerReceiverWithFeature$(IActivityManager.java:11613)
	at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2961)
	at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3199)
	at android.os.Binder.execTransactInternal(Binder.java:1375)


  --- End of managed Android.OS.RemoteException stack trace ---
android.os.RemoteException: Remote stack trace:
	at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:16680)
	at android.app.IActivityManager$Stub.onTransact$registerReceiverWithFeature$(IActivityManager.java:11613)
	at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2961)
	at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3199)
	at android.os.Binder.execTransactInternal(Binder.java:1375)


  --- End of managed Android.OS.RemoteException stack trace ---
android.os.RemoteException: Remote stack trace:
	at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:16680)
	at android.app.IActivityManager$Stub.onTransact$registerReceiverWithFeature$(IActivityManager.java:11613)
	at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2961)
	at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3199)
	at android.os.Binder.execTransactInternal(Binder.java:1375)


   --- End of inner exception stack trace ---

A similar, solved incident was reported here: doublesymmetry/react-native-track-player#2327

This PR adds the required RECEIVER_EXPORTED flags. Published as AAR and tested in my own application.

@sysrsbuild
Copy link
Collaborator

Can one of the admins verify this patch?

@Nir-Az Nir-Az requested a review from mengyui October 20, 2024 07:33
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.

4 participants