Research on STOPPED application in Android system cannot receive broadcast

I wrote an article before: 

After Android 3.1, the newly installed and the user forcibly stopped the apk, unable to monitor the broadcast problem

 

Today I finally studied the principle and posted the code execution logic:

ContextImpl.sendBroadcast ()
    ActivityManagerNative.getDefault().broadcastIntent()
        ActivityManagerService.broadcastIntent()
            ActivityManagerService.broadcastIntentLocked()
                ActivityManagerService.collectReceiverComponents()
                    PackageManagerService.queryIntentReceivers()
                        PackageManagerService.ActivityIntentResolver.queryIntentForPackage()
                            IntentResolver.queryIntentFromList()
                                IntentResolver.buildResolveList()
                                    PackageManagerService.ActivityIntentResolver.isFilterStopped()
                                        return (ps.pkgFlags&ApplicationInfo.FLAG_SYSTEM) == 0 && ps.getStopped(userId);

 

in conclusion: 

Only non-STOPPED applications, and system applications, can receive broadcasts that do not contain FLAG_INCLUDE_STOPPED_PACKAGES in the Intent.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326713211&siteId=291194637