[Q]Sending non-protected broadcast问题分析
有同事遇到发送广播接收不到的问题,分析log发现是system进程发送non-protected广播的问题。Ams在发送广播时,对于systemApp会要求广播必须是声明在frameworks\base\core\res\AndroidManifest.xml里面的protected-broadcast。这样可以避免三方垃圾应用也发送这些广播来捣蛋。
03-30 09:35:31.829 3827 4459 E ActivityManager: Sending non-protected broadcast
droidlogic.hdr.policy.source_1 from system 4556:com.android.tv.settings/1000 pkg
com.android.tv.settings
检查system进程权限的函数
private void checkBroadcastFromSystem(Intent intent, ProcessRecord callerApp,String callerPackage, int callingUid, boolean isProtectedBroadcast, List receivers) {if ((intent.getFlags() & Intent.FLAG_RECEIVER_FROM_SHELL) != 0) {// Don't yell about broadcasts sent via shellreturn;}final String action = intent.getAction();if (isProtectedBroadcast|| Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)|| Intent.ACTION_DISMISS_KEYBOARD_SHORTCUTS.equals(action)|| Intent.ACTION_MEDIA_BUTTON.equals(action)|| Intent.ACTION_MEDIA_SCANNER_SCAN_FILE.equals(action)|| Intent.ACTION_SHOW_KEYBOARD_SHORTCUTS.equals(action)|| Intent.ACTION_MASTER_CLEAR.equals(action)|| Intent.ACTION_FACTORY_RESET.equals(action)|| AppWidgetManager.ACTION_APPWIDGET_CONFIGURE.equals(action)|| AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)|| LocationManager.HIGH_POWER_REQUEST_CHANGE_ACTION.equals(action)|| TelephonyIntents.ACTION_REQUEST_OMADM_CONFIGURATION_UPDATE.equals(action)|| SuggestionSpan.ACTION_SUGGESTION_PICKED.equals(action)|| AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION.equals(action)|| AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION.equals(action)) {// Broadcast is either protected, or it's a public action that// we've relaxed, so it's fine for system internals to send.return;}// This broadcast may be a problem... but there are often system components that// want to send an internal broadcast to themselves, which is annoying to have to// explicitly list each action as a protected broadcast, so we will check for that// one safe case and allow it: an explicit broadcast, only being received by something// that has protected itself.if (intent.getPackage() != null || intent.getComponent() != null) {if (receivers == null || receivers.size() == 0) {// Intent is explicit and there's no receivers.// This happens, e.g. , when a system component sends a broadcast to// its own runtime receiver, and there's no manifest receivers for it,// because this method is called twice for each broadcast,// for runtime receivers and manifest receivers and the later check would find// no receivers.return;}boolean allProtected = true;for (int i = receivers.size()-1; i >= 0; i--) {Object target = receivers.get(i);if (target instanceof ResolveInfo) {ResolveInfo ri = (ResolveInfo)target;if (ri.activityInfo.exported && ri.activityInfo.permission == null) {allProtected = false;break;}} else {BroadcastFilter bf = (BroadcastFilter)target;if (bf.requiredPermission == null) {allProtected = false;break;}}}if (allProtected) {// All safe!return;}}// The vast majority of broadcasts sent from system internals// should be protected to avoid security holes, so yell loudly// to ensure we examine these cases.if (callerApp != null) {Log.wtf(TAG, "Sending non-protected broadcast " + action+ " from system " + callerApp.toShortString() + " pkg " + callerPackage,new Throwable());} else {Log.wtf(TAG, "Sending non-protected broadcast " + action+ " from system uid " + UserHandle.formatUid(callingUid)+ " pkg " + callerPackage,new Throwable());}}
AndroidManifest.xml的位置
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="android" coreApp="true" android:sharedUserId="android.uid.system"android:sharedUserLabel="@string/android_system_label"><!-- ================================================ --><!-- Special broadcasts that only the system can send --><!-- ================================================ --><eat-comment /><protected-broadcast android:name="android.intent.action.SCREEN_OFF" /><protected-broadcast android:name="android.intent.action.SCREEN_ON" /><protected-broadcast android:name="android.intent.action.USER_PRESENT" /><protected-broadcast android:name="android.intent.action.TIME_SET" /><protected-broadcast android:name="android.intent.action.TIME_TICK" /><protected-broadcast android:name="android.intent.action.TIMEZONE_CHANGED" /><protected-broadcast android:name="android.intent.action.DATE_CHANGED" /><protected-broadcast android:name="android.intent.action.PRE_BOOT_COMPLETED" />
[Q]Sending non-protected broadcast问题分析相关推荐
- Android Q 10.1 KeyMaster源码分析(二) - 各家方案的实现
写在之前 这两篇文章是我2021年3月初看KeyMaster的笔记,本来打算等分析完KeyMaster和KeyStore以后再一起做成一系列贴出来,后来KeyStore的分析中断了,这一系列的文章就变 ...
- Android 11 Sending non-protected broadcast问题分析
带android:sharedUserId="android.uid.system" 发送广播时,会出现 Sending non-protected broadcast 异常提醒: ...
- mysql索引无效且sending data耗时巨大原因分析
一朋友最近新上线一个项目,本地测试环境跑得好好的,部署到线上却慢得像蜗牛一样.后来查询了一下发现一个sql执行了16秒,有些长的甚至80秒.本地运行都是毫秒级别的查询.下面记录一下困扰了两天的,其中一 ...
- 小Q同学的微信账单可视化分析(Tableau)
Tableau微信账单可视化分析 先用python对小Q同学在2019-11.2019-12.2020-01三个月的微信账单数据进行简单的描述性分析,并将结果输出到excel文件中,再将excel文件 ...
- RemoteServiceException: can‘t deliver broadcast 问题分析
一.问题背景 最近测试跑monkey连续压测,报了一个应用稳定性的问题.因为该问题比较典型,并且需要我们编码上也要注意规避该问题.我在分析过程中一直没找到根因,最后求助于leader,非常感谢不吝指教 ...
- Android Q 基站刷新接口源码分析 适配双卡手机基站刷新逻辑
目录 一.获取基站信息的两个关键方法 getAllCellInfo调用流程总结 requestCellInfoUpdate 流程总结 问题 二.双卡手机适配 Android Q requestCell ...
- Android Broadcast原理分析之registerReceiver(一)
目录 BroadcastReceiver概述 BroadcastReceiver分类 registerReceiver流程图 源码解析 总结 1. BroadcastReceiver概述 广播作为四大 ...
- Sending non-protected broadcast
Android发送广播时报错: Sending non-protected broadcast xxxxxxx from system xxxxxxxxxx 原因: Ams在发送广播时,对于syste ...
- Android Sending non-protected broadcast,sendBroadcastAsUser方式发送广播
有同事遇到发送广播接收不到的问题,分析log发现是system进程发送non-protected广播的问题.Ams在发送广播时,对于systemApp会要求广播必须是声明在frameworks\bas ...
最新文章
- 独家 | 在PyTorch中用图像混合(Mixup)增强神经网络(附链接)
- Linux 还能这么玩,10 个非常有趣的命令!
- CSS基础必备知识点04
- Page 和Ability之间区别
- 福建首个区块链赋能教育信息化项目上线
- cad卸载_盘点那些年用过的神级CAD插件,每一款都舍不得卸载
- 粒子群优化算法(PSO)附代码
- 录音文件下载_录音啦(文字语音转换)软件安装教程
- 服务器草稿位置在c盘可以吗,T+增加凭证的时候保存草稿,保存到那里去了
- 极限理论总结04:Delta方法
- sql cai bird教程学习记录
- 笔记本电脑f11功能键_笔记本电脑按键功能详细图解_笔记本电脑键盘功能详细介绍是什么-win7之家...
- 清橙A1210. 光棱坦克
- 《通信原理》(2):信息量及平均信息量
- SpringCloud搭建微服务之Hystrix熔断器
- 百度Paddle团队招聘算法实习生
- html中一条单线这么设置,html单线表格制作方法
- android MapBox地图基于openstreetmap开发
- python 中运行 pip 或者 easy_install 时出现 error: unable to find vcvarsall.bat 的解决办法
- python求解多元多次方程组或非线性方程组