• 关于SecurityException RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED


    关于SecurityException RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED

    https://github.com/android/play-billing-samples/issues/618

    https://issuetracker.google.com/issues/277822279

    java.lang.SecurityException: com.mercandalli.android.apps.sample: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
    1. Caused by: java.lang.SecurityException: com.mercandalli.android.apps.sample: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
    2. at android.os.Parcel.createExceptionOrNull(Parcel.java:3057)
    3. at android.os.Parcel.createException(Parcel.java:3041)
    4. at android.os.Parcel.readException(Parcel.java:3024)
    5. at android.os.Parcel.readException(Parcel.java:2966)
    6. at android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature(IActivityManager.java:5372)
    7. at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1851)
    8. at android.app.ContextImpl.registerReceiver(ContextImpl.java:1791)
    9. at android.app.ContextImpl.registerReceiver(ContextImpl.java:1779)
    10. at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:754)
    11. at com.android.billingclient.api.zzn.zzc(com.android.billingclient:billing@@5.2.0:1)
    12. at com.android.billingclient.api.zzo.zze(com.android.billingclient:billing@@5.2.0:3)
    13. at com.android.billingclient.api.BillingClientImpl.startConnection(com.android.billingclient:billing@@5.2.0:36)

    这个例子里,是调用到

    IActivityManager$Stub$Proxy.registerReceiverWithFeature(IActivityManager.java:5393)

    在server端写入了Exception,

    查看源码 https://cs.android.com/?hl=zh-cn

    frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java

    1. // Don't enforce the flag check if we're EITHER registering for only protected
    2. // broadcasts, or the receiver is null (a sticky broadcast). Sticky broadcasts should
    3. // not be used generally, so we will be marking them as exported by default
    4. final boolean requireExplicitFlagForDynamicReceivers = CompatChanges.isChangeEnabled(
    5. DYNAMIC_RECEIVER_EXPLICIT_EXPORT_REQUIRED, callingUid);
    6. if (!onlyProtectedBroadcasts) {
    7. if (receiver == null && !explicitExportStateDefined) {
    8. // sticky broadcast, no flag specified (flag isn't required)
    9. flags |= Context.RECEIVER_EXPORTED;
    10. } else if (requireExplicitFlagForDynamicReceivers && !explicitExportStateDefined) {
    11. throw new SecurityException(
    12. callerPackage + ": One of RECEIVER_EXPORTED or "
    13. + "RECEIVER_NOT_EXPORTED should be specified when a receiver "
    14. + "isn't being registered exclusively for system broadcasts");
    15. // Assume default behavior-- flag check is not enforced
    16. } else if (!requireExplicitFlagForDynamicReceivers && (

    可以根据抛异常的原因去分析处理

  • 相关阅读:
    Linux命令(126)之help
    mysql到底需不需要容器化?
    Day802.JVM热点问题 -Java 性能调优实战
    计算机网络中的封装和分用,五层协议
    JAVA面试题
    Modelsim实现波形比较
    2022牛客多校十 F-Shannon Switching Game?(博弈+bfs)
    如何评价GPT-4o?
    12. Java异常及异常处理处理
    git_回退到上一次commit与pull
  • 原文地址:https://blog.csdn.net/aaajj/article/details/132723975