[msm8953][Android9.0] Sending non-protected broadcast ....

 

现象

2019-11-28 01:13:31.691 1541-7267/system_process E/ActivityManager: Sending non-protected broadcast com.qualcomm.qti.logkit.controller.intent.action.Controller from system 6223:com.qualcomm.qti.logkit.lite/1000 pkg com.qualcomm.qti.logkit.lite
    java.lang.Throwable
        at com.android.server.am.ActivityManagerService.checkBroadcastFromSystem(ActivityManagerService.java:21369)
        at com.android.server.am.ActivityManagerService.broadcastIntentLocked(ActivityManagerService.java:21973)
        at com.android.server.am.ActivityManagerService.broadcastIntent(ActivityManagerService.java:22115)
        at android.app.IActivityManager$Stub.onTransact$broadcastIntent$(IActivityManager.java:10175)
        at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:167)
        at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3320)
        at android.os.Binder.execTransact(Binder.java:731)

 

解决办法

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

private void checkBroadcastFromSystem(

.....

            // we've relaxed, so it's fine for system internals to send.
            return;
        }      

// wskyo add
        if( action!= null && (action.contains("com.rscja.") || action.contains("com.chengwei.") || action.contains("com.qualcomm.qti.") ) ){
            return;
        }

.

..

 

如果是自定义action的方式。。图片偷来的。。

 

 

android O系统后,隐式广播收到的限制,一定要指定包名才能发送出来。
否则会报错:
Background execution not allowed: receiving Intent { act=android.bluetooth.anw.action.PAIR_REQUEST flg=0x10 (has extras) } to com.anwsdk.sample/.BTMsgReceiver

但是在实际开发测试时,有些旧的app应用还是发送的隐式广播,导致接收不到,临时修改系统源码解决:
源码:\frameworks\base\services\core\java\com\android\server\am\BroadcastQueue.java
processNextBroadcastLocked()对广播进行了判断和处理:

       if (!skip) {
            final int allowed = mService.getAppStartModeLocked(
                    info.activityInfo.applicationInfo.uid, info.activityInfo.packageName,
                    info.activityInfo.applicationInfo.targetSdkVersion, -1, true, false, false);
            if (allowed != ActivityManager.APP_START_MODE_NORMAL) {
                // We won't allow this receiver to be launched if the app has been
                // completely disabled from launches, or it was not explicitly sent
                // to it and the app is in a state that should not receive it
                // (depending on how getAppStartModeLocked has determined that).
                if (allowed == ActivityManager.APP_START_MODE_DISABLED) {
                    Slog.w(TAG, "Background execution disabled: receiving "
                            + r.intent + " to "
                            + component.flattenToShortString());
                    skip = true;
                } else if (((r.intent.getFlags()&Intent.FLAG_RECEIVER_EXCLUDE_BACKGROUND) != 0)
                        || (r.intent.getComponent() == null
                            && r.intent.getPackage() == null
                            && ((r.intent.getFlags()
                                    & Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND) == 0)
                            && !isSignaturePerm(r.requiredPermissions))) {
                    mService.addBackgroundCheckViolationLocked(r.intent.getAction(),
                            component.getPackageName());
                    Slog.w(TAG, "Background execution not allowed: receiving "
                            + r.intent + " to "
                            + component.flattenToShortString());
			
					//取消skip=true,让广播依旧可以发送出去
                    //skip = true;
                }
            }
        }

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值