免su插件版(无需Thanox后台,部分系统无效,如果无效可以将代码中的19改成20再试试,如果再不行就换su版)

[
    {
        "name": "NoActive",
        "description": "应用进入后台冻结进程",
        "priority": -1,
        "condition": "frontPkgChanged",
        "actions": [
            "if(thanos.getActivityManager().isPkgSmartStandByEnabled(to)){foreach (proc:thanos.getActivityManager().getRunningAppProcess()){if (proc.packageName==to){android.os.Process.sendSignal(proc.pid,18);}};context.getSystemService(context.APP_OPS_SERVICE).setMode(android.app.AppOpsManager.OP_WAKE_LOCK, thanos.getPkgManager().getUidForPkgName(to), to, android.app.AppOpsManager.MODE_DEFAULT);}",
            "if(!thanos.getActivityManager().isPkgSmartStandByEnabled(from)){break}",
            "foreach (rule : thanos.getActivityManager().getAllStandbyRules()){if(rule.startsWith(\"KEEP\") && rule.contains(from + \"/\")){break}}",
            "context.getSystemService(context.APP_OPS_SERVICE).setMode(android.app.AppOpsManager.OP_WAKE_LOCK, thanos.getPkgManager().getUidForPkgName(from), from, android.app.AppOpsManager.MODE_IGNORED);",
            "Thread.sleep(2000);",
            "if(activity.getFrontAppPackage()!=from && !thanos.windowManager.hasVisibleWindows(from) && !thanos.getActivityManager().hasTopVisibleActivities(from)){foreach (proc:thanos.getActivityManager().getRunningAppProcess()){if (proc.packageName==from){android.os.Process.sendSignal(proc.pid,19);}}};"
        ]
    }
]

su插件版(兼容性好)

[
    {
        "name": "NoActive",
        "description": "应用进入后台冻结进程",
        "priority": -1,
        "condition": "frontPkgChanged",
        "actions": [
            "if(thanos.getActivityManager().isPkgSmartStandByEnabled(to)){su.exe(\"kill -CONT `pgrep -f \"+ to + \"`\");su.exe(\"appops set \" +to + \" WAKE_LOCK default\")}",
            "if(!thanos.getActivityManager().isPkgSmartStandByEnabled(from)){break}",
            "foreach (rule : thanos.getActivityManager().getAllStandbyRules()){if(rule.startsWith(\"KEEP\") && rule.contains(from + \"/\")){break}}",
            "su.exe(\"appops set \" + from + \" WAKE_LOCK ignore\");",
            "Thread.sleep(2000);",
            "if(activity.getFrontAppPackage()!=from && !thanos.windowManager.hasVisibleWindows(from) && !thanos.getActivityManager().hasTopVisibleActivities(from)){su.exe(\"kill -STOP `pgrep -f \"+ from +\"`\")};"
        ]
    }
]

MIUI13普通版

[
    {
        "name": "NoActive",
        "description": "应用进入后台冻结进程",
        "priority": -1,
        "condition": "frontPkgChanged",
        "actions": [
            "if(thanos.getActivityManager().isPkgSmartStandByEnabled(to)){foreach (proc:thanos.getActivityManager().getRunningAppProcess()){if (proc.packageName==to){com.miui.server.greeze.FreezeUtils.thawPid(proc.pid);}};context.getSystemService(context.APP_OPS_SERVICE).setMode(android.app.AppOpsManager.OP_WAKE_LOCK, thanos.getPkgManager().getUidForPkgName(to), to, android.app.AppOpsManager.MODE_DEFAULT);}",
            "if(!thanos.getActivityManager().isPkgSmartStandByEnabled(from)){break}",
            "foreach (rule : thanos.getActivityManager().getAllStandbyRules()){if(rule.startsWith(\"KEEP\") && rule.contains(from + \"/\")){break}}",
            "context.getSystemService(context.APP_OPS_SERVICE).setMode(android.app.AppOpsManager.OP_WAKE_LOCK, thanos.getPkgManager().getUidForPkgName(from), from, android.app.AppOpsManager.MODE_IGNORED);",
            "Thread.sleep(2000);",
            "if(activity.getFrontAppPackage()!=from && !thanos.windowManager.hasVisibleWindows(from) && !thanos.getActivityManager().hasTopVisibleActivities(from)){foreach (proc:thanos.getActivityManager().getRunningAppProcess()){if (proc.packageName==from){com.miui.server.greeze.FreezeUtils.freezePid(proc.pid);}}};"
        ]
    }
]

免su音频焦点版

[
    {
        "name": "NoActive",
        "description": "应用进入后台冻结进程",
        "priority": -1,
        "condition": "frontPkgChanged",
        "actions": [
            "if(thanos.getActivityManager().isPkgSmartStandByEnabled(to)){foreach (proc:thanos.getActivityManager().getRunningAppProcess()){if (proc.packageName==to){android.os.Process.sendSignal(proc.pid,18);}};context.getSystemService(context.APP_OPS_SERVICE).setMode(android.app.AppOpsManager.OP_WAKE_LOCK, thanos.getPkgManager().getUidForPkgName(to), to, android.app.AppOpsManager.MODE_DEFAULT);}",
            "if(!thanos.getActivityManager().isPkgSmartStandByEnabled(from)){break}",
            "foreach (rule : thanos.getActivityManager().getAllStandbyRules()){if(rule.startsWith(\"KEEP\") && rule.contains(from + \"/\")){break}}",
            "if(thanos.getAudioManager().hasAudioFocus(from) && thanos.getNotificationManager().hasShowingNotificationRecordsForPackage(from)){break}",
            "context.getSystemService(context.APP_OPS_SERVICE).setMode(android.app.AppOpsManager.OP_WAKE_LOCK, thanos.getPkgManager().getUidForPkgName(from), from, android.app.AppOpsManager.MODE_IGNORED);",
            "Thread.sleep(2000);",
            "if(activity.getFrontAppPackage()!=from && !thanos.windowManager.hasVisibleWindows(from) && !thanos.getActivityManager().hasTopVisibleActivities(from)){foreach (proc:thanos.getActivityManager().getRunningAppProcess()){if (proc.packageName==from){android.os.Process.sendSignal(proc.pid,20);}}};"
        ]
    }
]