协助分析进展如下:
1.打开log开关:
oppolog---设置--动态log--Pacakge(pacage_all)/activity_broadcast/activity_oppobroadcast
2.可以开机的时候快速
adb shell dumpsys activity log broadcast 1
如下为最新日志:
05-27 14:58:05.580 1888 2936 V ActivityManager: Broadcast: Intent { act=android.settings.OPPO_REGION_CHANGED flg=0x10 } ordered=false userid=0 resultTo null
05-27 14:58:05.580 1888 2936 V ActivityManager: broadcastIntentLocked callingPid: 4036 callingUid=1001
05-27 14:58:05.581 1888 2936 D ActivityManager: multi app: collectReceiverComponents: i = 0 ResolveInfo = ResolveInfo{ed973f9 com.android.cellbroadcastreceiver/.OppoRegionChangeReceiver m=0x108000} intent = Intent { act=android.settings.OPPO_REGION_CHANGED flg=0x10 } callingUid = 1001//collectReceiverComponents函数查询当前静态注册action为android.settings.OPPO_REGION_CHANGED的reciver中的所有receiver,这里来看是没正常注册的。
05-27 14:58:05.581 1888 2936 V ActivityManager: Enqueueing broadcast: android.settings.OPPO_REGION_CHANGED replacePending=false
05-27 14:58:05.581 1888 2936 W ActivityManager: Sending non-protected broadcast android.settings.OPPO_REGION_CHANGED from system 4036:com.android.phone/1001 pkg com.android.phone
05-27 14:58:05.581 1888 2936 I ActivityManager: Broadcast intent Intent { act=android.settings.OPPO_REGION_CHANGED flg=0x10 } on background queue
05-27 14:58:05.581 1888 2936 V ActivityManager: Enqueueing parallel broadcast BroadcastRecord{f826f3e u0 android.settings.OPPO_REGION_CHANGED}
05-27 14:58:05.582 1888 2936 V BroadcastQueue: mParallelBroadcasts add: BroadcastRecord{f826f3e u0 android.settings.OPPO_REGION_CHANGED} mParallelBroadcasts [BroadcastRecord{f826f3e u0 android.settings.OPPO_REGION_CHANGED}]
05-27 14:58:05.582 1888 2936 V BroadcastQueue: Schedule broadcasts [background]: current=false
05-27 14:58:05.582 1888 2936 W ActivityManager: Sending non-protected broadcast android.settings.OPPO_REGION_CHANGED from system 4036:com.android.phone/1001 pkg com.android.phone
05-27 14:58:05.582 4128 4410 D ControllerBackup: hasChangedByUser: false:recordKey=com.android.carrierdefaultapp_splitter_10126_splitter_mobile_data_status_splitter_show_icon
05-27 14:58:05.582 1888 2936 V ActivityManager: receivers: [ResolveInfo{ed973f9 com.android.cellbroadcastreceiver/.OppoRegionChangeReceiver m=0x108000}] resultTo null
05-27 14:58:05.582 1888 2936 I ActivityManager: Broadcast intent Intent { act=android.settings.OPPO_REGION_CHANGED flg=0x10 } on background queue
05-27 14:58:05.582 1888 2936 D ColorBroadcastManager: impl hasOppoBroadcastManager true
05-27 14:58:05.582 1888 2936 V ActivityManager: Enqueueing ordered broadcast BroadcastRecord{62719f u0 android.settings.OPPO_REGION_CHANGED}
结合代码来看,如上日志来看确实在广播发出的时候,小区广播成功接收,且查询到的receiver列表中只有小区广播的receiver,怀疑timing问题。
因为从后面日志来看,查询到的receiver中已经包含了电话本,如下:
05-27 15:00:04.656 1888 6963 V ActivityManager: Broadcast: Intent { act=android.settings.OPPO_REGION_CHANGED flg=0x1000010 (has extras) } ordered=false userid=0 resultTo null
05-27 15:00:04.656 1888 6963 V ActivityManager: broadcastIntentLocked callingPid: 3705 callingUid=1000
05-27 15:00:04.656 1888 6963 D ActivityManager: multi app: collectReceiverComponents: i = 0 ResolveInfo = ResolveInfo{8282956 com.android.cellbroadcastreceiver/.OppoRegionChangeReceiver m=0x108000} intent = Intent { act=android.settings.OPPO_REGION_CHANGED flg=0x1000010 (has extras) } callingUid = 1000
05-27 15:00:04.657 1888 6963 D ActivityManager: multi app: collectReceiverComponents: i = 1 ResolveInfo = ResolveInfo{435fdd7 com.android.providers.contacts/com.android.providers.oppoExt.OppoRegionChangeReceiver m=0x108000} intent = Intent { act=android.settings.OPPO_REGION_CHANGED flg=0x1000010 (has extras) } callingUid = 1000
05-27 15:00:04.657 1888 6963 D ActivityManager: multi app: collectReceiverComponents: i = 2 ResolveInfo = ResolveInfo{99ec6c4 com.coloros.lockassistant/.receiver.NetworkLockReceiver m=0x108000} intent = Intent { act=android.settings.OPPO_REGION_CHANGED flg=0x1000010 (has extras) } callingUid = 1000
05-27 15:00:04.657 1888 6963 D ActivityManager: multi app: collectReceiverComponents: i = 3 ResolveInfo = ResolveInfo{8c289ad com.coloros.smartdrive/.receiver.ColorReceiver m=0x108000} intent = Intent { act=android.settings.OPPO_REGION_CHANGED flg=0x1000010 (has extras) } callingUid = 1000
05-27 15:00:04.657 1888 6963 V ActivityManager: Enqueueing broadcast: android.settings.OPPO_REGION_CHANGED replacePending=false
05-27 15:00:04.657 1888 6963 W ActivityManager: Sending non-protected broadcast android.settings.OPPO_REGION_CHANGED from system 3705:com.android.settings/1000 pkg com.android.settings
05-27 15:00:04.657 1888 6963 I ActivityManager: Broadcast intent Intent { act=android.settings.OPPO_REGION_CHANGED flg=0x1000010 (has extras) } on background queue
05-27 15:00:04.657 1888 6963 V ActivityManager: Enqueueing parallel broadcast BroadcastRecord{99584e2 u0 android.settings.OPPO_REGION_CHANGED}
05-27 15:00:04.657 1888 6963 V BroadcastQueue: mParallelBroadcasts add: BroadcastRecord{99584e2 u0 android.settings.OPPO_REGION_CHANGED} mParallelBroadcasts [BroadcastRecord{4ad887e u0 android.intent.action.PACKAGE_CHANGED}, BroadcastRecord{ee0de2c u0 android.app.action.DEVICE_POLICY_MANAGER_STATE_CHANGED}, BroadcastRecord{99584e2 u0 android.settings.OPPO_REGION_CHANGED}]
05-27 15:00:04.657 1888 6963 V BroadcastQueue: Schedule broadcasts [background]: current=true
05-27 15:00:04.657 1888 6963 V ActivityManager: receivers: [ResolveInfo{8282956 com.android.cellbroadcastreceiver/.OppoRegionChangeReceiver m=0x108000}, ResolveInfo{435fdd7 com.android.providers.contacts/com.android.providers.oppoExt.OppoRegionChangeReceiver m=0x108000}, ResolveInfo{99ec6c4 com.coloros.lockassistant/.receiver.NetworkLockReceiver m=0x108000}, ResolveInfo{8c289ad com.coloros.smartdrive/.receiver.ColorReceiver m=0x108000}] resultTo null
05-27 15:00:04.657 1888 6963 I ActivityManager: Broadcast intent Intent { act=android.settings.OPPO_REGION_CHANGED flg=0x1000010 (has extras) } on background queue
05-27 15:00:04.657 1888 6963 D ColorBroadcastManager: impl hasOppoBroadcastManager true
05-27 15:00:04.657 1888 6963 V ActivityManager: Enqueueing ordered broadcast BroadcastRecord{bf2a073 u0 android.settings.OPPO_REGION_CHANGED}
下一步:
需要进一步抓取日志,且同时添加debug版本进行复测,抓取更多日志。
复现方法如下:
一,一有adb口就执行
adb shell dumpsys package > package.txt && adb shell dumpsys activity log broadcast 1 && adb shell dumpsys package log install 1 && adb shell dumpsys package log scan 1 && adb shell dumpsys package log broadcast 1
二,如果执行完,还没复现的的情况下,多次执行下
adb shell dumpsys package > package1.txt(记得改名字,否则会覆盖)
三、最后提供日志的时候,尽量在开机一会儿后再次触发下能接收的情况再给我看下哈。也就是说日志尽量包含一个复现,一个不复现的情况。这样更有利于分析。
总结:
重新抓取的dump package来看复现前、复现时和跳过开机向导后恢复正常的dumpsys的package来看,均包含了对应的receiver。因此排除PackageParser.java扫描问题;重新review日志发现,
异常时:
05-27 14:58:05.580 1888 2936 V ActivityManager: Broadcast: Intent { act=android.settings.OPPO_REGION_CHANGED flg=0x10 } ordered=false userid=0 resultTo null
正常时:
05-27 15:00:04.656 1888 6963 V ActivityManager: Broadcast: Intent { act=android.settings.OPPO_REGION_CHANGED flg=0x1000010 (has extras) } ordered=false userid=0 resultTo null
异常时:
05-27 14:58:05.581 1888 2936 D ActivityManager: multi app: collectReceiverComponents: i = 0 ResolveInfo = ResolveInfo{ed973f9 com.android.cellbroadcastreceiver/.OppoRegionChangeReceiver m=0x108000} intent = Intent { act=android.settings.OPPO_REGION_CHANGED flg=0x10 } callingUid = 1001//collectReceiverComponents函数查询当前静态注册action为android.settings.OPPO_REGION_CHANGED的reciver中的所有receiver,这里来看是没正常注册的。
正常时:
05-27 15:00:04.656 1888 6963 D ActivityManager: multi app: collectReceiverComponents: i = 0 ResolveInfo = ResolveInfo{8282956 com.android.cellbroadcastreceiver/.OppoRegionChangeReceiver m=0x108000} intent = Intent { act=android.settings.OPPO_REGION_CHANGED flg=0x1000010 (has extras) } callingUid = 1000
05-27 15:00:04.657 1888 6963 D ActivityManager: multi app: collectReceiverComponents: i = 1 ResolveInfo = ResolveInfo{435fdd7 com.android.providers.contacts/com.android.providers.oppoExt.OppoRegionChangeReceiver m=0x108000} intent = Intent { act=android.settings.OPPO_REGION_CHANGED flg=0x1000010 (has extras) } callingUid = 1000
05-27 15:00:04.657 1888 6963 D ActivityManager: multi app: collectReceiverComponents: i = 2 ResolveInfo = ResolveInfo{99ec6c4 com.coloros.lockassistant/.receiver.NetworkLockReceiver m=0x108000} intent = Intent { act=android.settings.OPPO_REGION_CHANGED flg=0x1000010 (has extras) } callingUid = 1000
05-27 15:00:04.657 1888 6963 D ActivityManager: multi app: collectReceiverComponents: i = 3 ResolveInfo = ResolveInfo{8c289ad com.coloros.smartdrive/.receiver.ColorReceiver m=0x108000} intent = Intent { act=android.settings.OPPO_REGION_CHANGED flg=0x1000010 (has extras) } callingUid = 1000
两次发送广播的flag并不一样,而且响应的应用也不同。那么因此认为与广播配置flag有差异(之前有跟os确认,反馈为没有差异)。重新确认现象为问题复现时为开机向导界面,正常情况下只有配置android:directBootAware=”true”的情况下,进入DirectBoot Mode才可以在未解锁的情况下运行应用。重新让os owner r
eview配置确认为小区广播application配置了android:directBootAware=”true”,而问题应用没有配置,配置该属性后问题修复。