IntelRealSense / librealsense

Intel® RealSense™ SDK
https://www.intelrealsense.com/
Apache License 2.0
7.63k stars 4.83k forks source link

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

Open jnnguyen12 opened 1 month ago

jnnguyen12 commented 1 month ago

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: https://github.com/doublesymmetry/react-native-track-player/issues/2327

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

sysrsbuild commented 1 month ago

Can one of the admins verify this patch?