需要Thanox,该软件目前需要付费
此教程基于Android12的MIUI13测试通过
安装Su插件
微信图片_20220503125638.jpg
启用su插件
微信图片_20220503125648.jpg
Thanox情景模式添加,一条一条加

[
    {
        "name": "冻结进程",
        "description": "冻结开启乖巧模式且不在全局白名单变量中的APP后台进程",
        "priority": 1,
        "condition": "frontPkgChanged == true && thanos.getActivityManager().isPkgSmartStandByEnabled(from) && !globalVarOf$whiteApps.contains(from)",
        "actions": [
            "su.exe(\"appops set \" +from + \" RUN_ANY_IN_BACKGROUND ignore\");",
            "su.exe(\"appops set \" +from + \" RUN_IN_BACKGROUND ignore\");",
            "su.exe(\"appops set \" +from + \" WAKE_LOCK ignore\");",
            "activity.setInactive(from);",
            "su.exe(\"am make-uid-idle \" +from);",
            "su.exe(\"am set-standby-bucket \" +from +\" restricted\");",
            "do{Thread.sleep(1000)}until(activity.getFrontAppPackage()!=\"android\");",
            "actor.delayed(1000,\"if(activity.getFrontAppPackage()!=from){su.exe(\\\"kill -STOP `pgrep -f \\\"+ from+ \\\"`\\\")}\");"
        ]
    }
]

[
    {
        "name": "解冻进程",
        "description": "当应用进入前台时解冻进程",
        "priority": 1,
        "condition": "frontPkgChanged == true && thanos.getActivityManager().isPkgSmartStandByEnabled(to) && !globalVarOf$whiteApps.contains(to)",
        "actions": [
            "su.exe(\"appops set \" +to + \" RUN_ANY_IN_BACKGROUND default\");",
            "su.exe(\"appops set \" +to + \" RUN_IN_BACKGROUND default\");",
            "su.exe(\"appops set \" +to + \" WAKE_LOCK default\");",
            "su.exe(\"am set-standby-bucket \" +to +\" rare\");",
            "su.exe(\"kill -CONT `pgrep -f \"+ to + \"`\");"
        ]
    }
]

微信图片_20220503130036.jpg
新建全局变量whiteApps,并选择需要加入白名单的APP
微信图片_20220503130114.jpg
然后开启乖巧模式,选择需要墓碑的APP
为了方便可以去设置开启模板,新应用自动开启乖巧
微信图片_20220503130325.jpg
做到这一步成功了一半了,接下来需要安装NoANR
安卓10以下自测哈,没有看10以下的源码
这么做是因为应用在后台进程被冻结,无法响应广播处理服务,导致触发安卓的ANR,用Hook来屏蔽ANR
Lsposed作用域选择系统框架,重启,完美实现