关联/链式启动的拦截机制
进程拦截:主要在冷启动限制开机启动、后台启动,功能界面一般为自启动管理、后台管理;
原理:ActivityManagerService. startProcessLocked() 条件拦截,即冷启动入口拦截
组件拦截:主要在冷/热启动限制开机启动、后台启动、应用间的唤醒,组件级别拦截,功能界面一般无界面显示、或关联启动界面、或启动记录、拦截记录;
原理:
ActivityManagerService. getContentProviderImpl() 条件拦截
ActiveServices. startServiceLocked() 条件拦截
ActiveServices. bindServiceLocked() 条件拦截
ActivityStarter. startActivity() 条件拦截
BroadcastQueue. processNextBroadcastLocked()条件拦截
区别:
两者的效果都是可以限制开机启动和后台启动,组件拦截比进程拦截的区别如下:
组件拦截的时机更早,因为应用启动是先启动组件,再最后fork进程;组件拦截管控的范围更全,热启动类型的行为也可以有效拦截;组件拦截精细度更高,例如进程拦截只知道进程被启动了,而组件拦截可以具体到哪个进程通过什么方式启动了目标进程;主流的华为、OPPO、VIVO、小米都有组件拦截相关的机制;
综合上述:
海外版小米MI 8 Pro 在自启动、后台管理、关联启动都有预置黑名单进行应用管理,故Android P 上我们也可以同海外版小米的配置预置自启动黑名单;SmartManager完成了进程拦截,组件拦截可以在目前的冷启动场景的基础做查缺补漏的拦截优化,甚至做到个别场景不依赖配置名单,智能识别和拦截关联启动行为;热启动场景进行组件级拦截,例如加强Google原生的规则中后台第三方应用启动后台第三方进程的限制;拦截记录的UI界面交互,需要产品工程师进行定义;海外版-小米MI 8 Pro
1.1 小米自启动
小米关联/链式小米的没有单独的关联唤醒拦截界面,但是“禁止耗电应用相互调用”属于关联唤醒范畴
2.国内版-华为P20 Pro
华为自启动07-19 14:41:49.771 1000 1681 1705 D Boost : hostingType=broadcast, hostingName=com.android.cellbroadcastreceiver/.CellBroadcastReceiver, callerPackage=android, isSystem=true, isBoostNeeded=false.
07-19 14:41:52.599 1000 1681 2093 D Boost : hostingType=service, hostingName=com.miui.analytics/.AnalyticsService, callerPackage=com.miui.msa.global, isSystem=true, isBoostNeeded=false.
07-19 14:41:48.717 1000 1681 2072 D Boost : hostingType=content provider, hostingName=com.android.settings/.cloud.CloudSettingsProvider, callerPackage=com.android.systemui, isSystem=true, isBoostNeeded=false.
2.2 华为关联/链式
只有组件拦截才可以形成下述拦截记录
3. ROM-SMGR测评
上述中分析:
不点开任何应用会有应用被启动的原因 第一个被启动的应用,com.ss.android.article.news(uid:10129) 被 com.android.bluetooth(uid:1002) 通过 bind-service 关联启动. 存在第一个第三方应用被启动后,com.ss.android.article.news(uid:10129)通过 PUSH SDK相关的start-activity\start-service\bind-service\send-broadcast\content provider机制启动了更多的应用,手机出现后台进程数量多、卡顿、发热现象SmartManager 的自启动管控 早期版本的SmartManager存在漏洞,即content provider\activity 类型启动会不区分黑白名单直接允许后台运行。本次版本优化,主要策略如下:1.启动类型service\broadcast\content provider的为非前台进程应用,后台启动会根据黑名单进行拦截2.启动类型为 activity 类型的非前台进程,新增了一条过滤,即ClassName为 com.igexin.sdk.GActivity直接拦截启动,除此之外唐敏提供了更多Activity类型的透明界面异常后台启动:com.igexin.sdk.GActivity
com.tencent.pangu.link.LinkProxyActivity
com.ifeng.news2.getui.DynamicGetuiActivity
com.pingan.servicewindow.service.GeTuiActivity3.灭屏30分钟内,查杀3次,亮屏每5分钟查杀后台进程
privatestaticfinalList<String> ANNOYING_NAMES =newArrayList<String>(){{
add("com.igexin.sdk.GActivity");
}
3.1安装后,不进行任何操作,桌面待机
1. com.ss.android.article.news(uid:10129) 被com.android.bluetooth(uid:1002) 关联启动
07-1615:27:03.78154310106236D PowerConsumptionService: isAllowAppLaunch : com.ss.android.article.news(uid:10129), callingPackage = com.android.bluetooth(uid:1002), reason = bind-service
07-1615:27:03.78166510106236D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { act=android.media.browse.MediaBrowserService cmp=com.ss.android.article.news/com.ss.android.detail.feature.detail2.audio.service.AudioService }
2. com.ss.android.essay.joke(uid:10133) 被com.ss.android.article.news(uid:10129) 关联启动
07-1615:37:14.36217810106237D PowerConsumptionService: isAllowAppLaunch : com.ss.android.essay.joke(uid:10133), callingPackage = com.ss.android.article.news(uid:10129), reason = start-service
07-1615:37:14.36252310106237D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { act=com.ss.android.message.action.PUSH_SERVICE pkg=com.ss.android.essay.joke cmp=com.ss.android.essay.joke/com.ss.android.message.NotifyService (has extras) }
3. com.ss.android.article.lite(uid:10133) 被com.ss.android.article.news(uid:10129) 关联启动
07-1615:37:14.49385910104771D PowerConsumptionService: isAllowAppLaunch : com.ss.android.article.lite(uid:10130), callingPackage = com.ss.android.article.news(uid:10129), reason = start-service
07-1615:37:14.49408510104771D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { act=com.ss.android.message.action.PUSH_SERVICE pkg=com.ss.android.article.lite cmp=com.ss.android.article.lite/com.ss.android.message.NotifyService (has extras) }
4. com.baidu.video(uid:10168) 被com.android.bluetooth(uid:1002) 关联启动
07-1615:47:08.59666710104771D PowerConsumptionService: isAllowAppLaunch : com.baidu.video(uid:10168), callingPackage = com.android.bluetooth(uid:1002), reason = bind-service
07-1615:47:08.59685110104771D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { act=android.media.browse.MediaBrowserService cmp=com.baidu.video/.audio.service.AudioService }
5. com.baidu.BaiduMap(uid:10166) 被com.baidu.video(uid:10168) 关联启动
07-1615:47:11.11006710106231D PowerConsumptionService: isAllowAppLaunch : com.baidu.BaiduMap(uid:10166), callingPackage = com.baidu.video(uid:10168), reason = bind-service
07-1615:47:11.11023110106231D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { act=baidu.intent.action.account.SHARE_SERVICE flg=0x20 cmp=com.baidu.BaiduMap/com.baidu.sapi2.share.ShareService }
6. com.qiyi.video(uid:10163) 被com.baidu.video(uid:10168) 关联启动
07-1615:47:11.38210710106231D werConsumptionService: isAllowAppLaunch : com.qiyi.video(uid:10163), callingPackage = com.baidu.video(uid:10168), reason = bind-service
07-1615:47:11.38224510106231D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { act=baidu.intent.action.account.SHARE_SERVICE flg=0x20 cmp=com.qiyi.video/com.baidu.sapi2.share.ShareService }
7. com.baidu.searchbox(uid:10165) 被com.baidu.video(uid:10168) 关联启动
07-1615:47:13.1714341010D PowerConsumptionService: isAllowAppLaunch : com.baidu.searchbox(uid:10165), callingPackage = com.baidu.BaiduMap(uid:10166), reason = bind-service
07-1615:47:13.1715391010D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { act=baidu.intent.action.account.SHARE_SERVICE flg=0x20 cmp=com.baidu.searchbox/com.baidu.sapi2.share.ShareService }
8. com.ss.android.ugc.aweme(uid:10150) 被com.ss.android.article.news(uid:10129) 关联启动
07-1615:47:14.47921010106231D PowerConsumptionService: isAllowAppLaunch : com.ss.android.ugc.aweme(uid:10150), callingPackage = com.ss.android.article.news(uid:10129), reason = start-service
07-1615:47:14.47937910106231D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { act=com.ss.android.message.action.PUSH_SERVICE pkg=com.ss.android.ugc.aweme cmp=com.ss.android.ugc.aweme/com.ss.android.message.NotifyService (has extras) }
9. com.sina.weibo(uid:10156) 被com.baidu.video(uid:10168) 关联启动
07-1615:47:38.30885910103307D PowerConsumptionService: isAllowAppLaunch : com.sina.weibo(uid:10156), callingPackage = com.baidu.video(uid:10168), reason = send-broadcast
07-1615:47:38.30902210103307D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { act=com.huawei.intent.action.PUSH flg=0x30 pkg=com.sina.weibo (has extras) }
10. com.cubic.autohome(uid:10160) 被com.baidu.video(uid:10168) 关联启动
07-1615:47:40.02074010104818D PowerConsumptionService: isAllowAppLaunch : com.cubic.autohome(uid:10160), callingPackage = com.baidu.video(uid:10168), reason = bind-service
07-1615:47:40.02084410104818D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { flg=0x20 cmp=com.cubic.autohome/cn.jpush.android.service.DaemonService (has extras) }
11. com.cleanmaster.mguard_cn(uid:10164) 被com.baidu.video(uid:10168) 关联启动
07-1615:47:38.69437810101022D PowerConsumptionService: isAllowAppLaunch : com.cleanmaster.mguard_cn(uid:10164), callingPackage = com.baidu.video(uid:10168), reason = bind-service
07-1615:47:38.69476010101022D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { flg=0x20 cmp=com.cleanmaster.mguard_cn/com.cleanmaster.jpush.JpushDaemonService (has extras) }
12. com.hipu.yidian(uid:10125) 被com.baidu.video(uid:10168) 关联启动
07-1615:47:41.92199210106231D PowerConsumptionService: isAllowAppLaunch : com.hipu.yidian(uid:10125), callingPackage = com.baidu.video(uid:10168), reason = bind-service
07-1615:47:41.92216810106231D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { flg=0x20 cmp=com.hipu.yidian/com.yidian.wakeup.YdDaemonService (has extras) }
13. com.job.android(uid:10135) 被com.baidu.video(uid:10168) 关联启动
07-1615:47:41.94999310106237D PowerConsumptionService: isAllowAppLaunch : com.job.android(uid:10135), callingPackage = com.baidu.video(uid:10168), reason = bind-service
07-1615:47:41.95019110106237D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { flg=0x20 cmp=com.job.android/cn.jpush.android.service.DaemonService (has extras) }
14. com.qq.reader(uid:10121) 被com.baidu.video(uid:10168) 关联启动
07-1615:47:57.25165010102226D PowerConsumptionService: isAllowAppLaunch : com.qq.reader(uid:10121), callingPackage = com.baidu.video(uid:10168), reason = bind-service
07-1615:47:57.25186210102226D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { flg=0x20 cmp=com.qq.reader/cn.jpush.android.service.DaemonService (has extras) }
.xingin.xhs(uid:10144) 被com.baidu.video(uid:10168) 关联启动
07-1615:47:57.88894110101312D PowerConsumptionService: isAllowAppLaunch : com.xingin.xhs(uid:10144), callingPackage = com.baidu.video(uid:10168), reason = bind-service
07-1615:47:57.88908210101312D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { flg=0x20 cmp=com.xingin.xhs/cn.jpush.android.service.DaemonService (has extras) }
16.sogou.mobile.explorer(uid:10153) 被com.ss.android.article.news(uid:10129) 关联启动
07-1615:47:59.32198010101979D TctPowerConsumptionService: isAllowAppLaunch : sogou.mobile.explorer(uid:10153), callingPackage = com.ss.android.article.news(uid:10129), reason = bind-service
07-1615:47:59.32215110101979D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { flg=0x20 cmp=sogou.mobile.explorer/cn.jpush.android.service.DaemonService (has extras) }
17. com.wuba(uid:10117) 被com.baidu.video(uid:10168) 关联启动
07-1615:48:06.20264910101979D PowerConsumptionService: isAllowAppLaunch : com.wuba(uid:10117), callingPackage = com.baidu.video(uid:10168), reason = start-activity
07-1615:48:06.20277710101979D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { flg=0x10000000 cmp=com.wuba/com.igexin.sdk.GActivity (has extras) }
18. air.tv.douyu.android(uid:10155) 被com.baidu.video(uid:10168) 关联启动
07-1615:48:06.55074810106237D PowerConsumptionService: isAllowAppLaunch : air.tv.douyu.android(uid:10155), callingPackage = com.baidu.video(uid:10168), reason = start-activity
07-1615:48:06.55198710106237D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { flg=0x10000000 cmp=air.tv.douyu.android/com.igexin.sdk.GActivity }
19com.jingdong.app.mall(uid:10128) 被com.baidu.video(uid:10168) 关联启动
07-1615:48:41.17870410101979D PowerConsumptionService: isAllowAppLaunch : com.jingdong.app.mall(uid:10128), callingPackage = com.baidu.video(uid:10168), reason = start-activity
07-1615:48:41.17892110101979D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { flg=0x10000000 cmp=com.jingdong.app.mall/com.igexin.sdk.GActivity }
icsisland.activity(uid:10162) 被com.baidu.video(uid:10168) 关联启动
07-1615:48:41.24166710101077D PowerConsumptionService: isAllowAppLaunch : icsisland.activity(uid:10162), callingPackage = com.baidu.video(uid:10168), reason = start-activity
07-1615:48:41.24171710101077D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { flg=0x10000000 cmp=icsisland.activity/com.igexin.sdk.GActivity }
21com.huaqian(uid:10148) 被com.baidu.video(uid:10168) 关联启动
07-1615:48:06.38510310101076D PowerConsumptionService: isAllowAppLaunch : com.huaqian(uid:10148), callingPackage = com.baidu.video(uid:10168), reason = start-activity
07-1615:48:06.38521310101076D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { flg=0x10000000 cmp=com.huaqian/com.igexin.sdk.GActivity }
ease.newsreader.activity(uid:10171) 被com.android.bluetooth(uid:1002) 关联启动
07-1615:49:09.43884710104835D PowerConsumptionService: isAllowAppLaunch : ease.newsreader.activity(uid:10171), callingPackage = com.android.bluetooth(uid:1002), reason = bind-service
07-1615:49:09.43897910104835D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { act=android.media.browse.MediaBrowserService cmp=ease.newsreader.activity/ease.awakening.music.MusicService }
23cn.etouch.ecalendar(uid:10126) 被com.huaqian(uid:10148) 关联启动
07-1615:49:33.5596102001D PowerConsumptionService: isAllowAppLaunch : cn.etouch.ecalendar(uid:10126), callingPackage = com.huaqian(uid:10148), reason = start-activity
07-1615:49:33.55967310102001D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { flg=0x10000000 cmp=cn.etouch.ecalendar/com.igexin.sdk.GActivity }
24com.tencent.mtt(uid:10119) 被ease.newsreader.activity(uid:10171) 关联启动
07-1615:51:45.57329210101984D PowerConsumptionService: isAllowAppLaunch : com.tencent.mtt(uid:10119), callingPackage = ease.newsreader.activity(uid:10171), reason = start-activity
07-1615:51:45.57336410101984D PowerConsumptionService: isAllowAppLaunch : intent action:Intent { flg=0x10000000 cmp=com.tencent.mtt/com.igexin.sdk.GActivity }
3.2. 安装后,按smgr推荐名单设置,桌面待机
1. 根据黑名单和非前台进程和com.igexin.sdk.GActivity 拦截activity
07-17 17:56:29.047735 1039 1549 D PowerConsumptionService: onStartActivity # target=ActivityInfo{40fd0a0 com.igexin.sdk.GActivity}, callingPkg=com.cubic.autohome
07-17 17:56:29.047786 1039 1549 W PowerConsumptionService: onStartActivity # start activityfromannoying component.
2. 根据黑名单和非前台进程拦截service
07-17 20:00:21.728459 1034 1104 D PowerConsumptionService: onStartProcess # processName=com.baidu.video, pkg=com.baidu.video, type=service, name=com.baidu.video/.audio.service.AudioService
3. 根据黑名单和非前台进程拦截broadcast
07-17 20:00:26.830424 1034 1050 D PowerConsumptionService: onStartProcess # processName=com.sina.news, pkg=com.sina.news, type=broadcast, name=com.sina.news/.module.base.receiver.BootCompletedReceiver
07-17 20:00:26.830782 1034 1050 W PowerConsumptionService: onStartProcess # abort starting process: com.sina.news, pkg=com.sina.news
4. 根据黑名单和非前台进程拦截content provider
07-17 20:00:42.839045 1034 1573 D PowerConsumptionService: onStartProcess # processName=com.baidu.video, pkg=com.baidu.video, type=content provider, name=com.baidu.video/cn.jpush.android.service.DownloadProvider
07-17 20:00:42.839381 1034 1573 W PowerConsumptionService: onStartProcess # abort starting process: com.baidu.video, pkg=com.baidu.video
如果觉得《0722海外小米和国内华为的关联唤醒调研》对你有帮助,请点赞、收藏,并留下你的观点哦!