通过pendingIntent启动activity被block问题
对比u上
日志:
2024-10-15 11:04:15.174 2092-4108 ActivityTaskManager system_process I START u0 {act=android.intent.action.VIEW dat=http://play.google.com/... pkg=com.android.vending cmp=com.android.vending/com.google.android.finsky.activities.MainActivity} with LAUNCH_SINGLE_TASK from uid 10156 from pid -1 callingPackage com.android.vending (realCallingUid=10294) (BAL_ALLOW_PERMISSION) result code=0
对应的代码:
if (ActivityTaskManagerService.checkPermission(START_ACTIVITIES_FROM_BACKGROUND,callingPid, callingUid) == PERMISSION_GRANTED) {return logStartAllowedAndReturnCode(BAL_ALLOW_PERMISSION,resultIfPiSenderAllowsBal, balAllowedByPiSender,/*background*/ true, callingUid, realCallingUid, intent,"START_ACTIVITIES_FROM_BACKGROUND permission granted");}
Android V上,同样满足上面这个条件的情况下,并不会就认为运行后台启动activity,而是会判断本次启动是否存在realCallUid,如果存在的话,还会有新的限制
建议在发送的时候给pendingIntent加一个opts.setPendingIntentBackgroundActivityStartMode,类似下面的写法