酷安APP 发现科技新生活

诗里沧海怨怼

2022-10-01 一加10 Pro

新鲜出炉的 后台瘦身2.0 应用保活2.0
后台瘦身,在1.0的基础上,添加判断条件,如果多任务里有对应进程,不会进行瘦身(未测试过,但理论应该成立)。此外改善打印日志,讲前台应用也打印出来
应用保活,在1.0基础上,加入拉起判断,如果拉起了个空进程,会进行提示。

[
{
"name": "后台瘦身",
"description": "销毁除变量外的所有子进程,可搭配乖巧模式一起使用。需要两个全局变量[pkgNameForTrim | 需要瘦身的包名] [noTrimProcess | 需要保留的进程名(从内存管理处直接添加即可)]",
"priority": 1,
"condition": "frontPkgChanged || batteryChanged",
"actions": [
"if(thanos.getProfileManager().isGlobalRuleVarByNameExists(\"pkgNameForTrim\")&&thanos.getProfileManager().isGlobalRuleVarByNameExists(\"noTrimProcess\")){if(globalVarOf$pkgNameForTrim.size()==0||globalVarOf$noTrimProcess.size()==0){ui.showShortToast(\"请为全局变量添加内容\")} else{foreach(name:globalVarOf$pkgNameForTrim){if(!activity.getFrontAppPackage().equals(name)&&!task.hasTaskFromPackage(name)) {foreach(proc:thanos.getActivityManager().getRunningAppProcessForPackage(name)) { if(!globalVarOf$noTrimProcess.contains(proc.getProcessName())){thanos.getActivityManager().killProcess(proc.getPid()); io.writeAppend(\"后台瘦身.txt\",\"[INFO]\"+new java.text.SimpleDateFormat(\"yyyy/MM/dd HH:mm:ss\").format(new java.util.Date())+'\n'+activity.getFrontAppPackage()+\" | kill \"+proc.getProcessName() + '\n')}}}}}}else{thanos.getProfileManager().disableRuleByName(\"后台瘦身\");ui.showShortToast(\"变量缺失!\");}"
]
}
]

---------------------------分割线---------------------------

[
{
"name": "应用保活",
"description": "拉起主进程(但是有时候无法拉起特定服务,或者其子进程)",
"priority": 1,
"condition": "pkgKilled",
"actions": [
"if(thanos.getProfileManager().isGlobalRuleVarByNameExists(\"keepAlive\")){if(globalVarOf$keepAlive.size()==0){ui.showShortToast(\"请为全局变量添加内容\")}else{foreach(proc:globalVarOf$keepAlive){if(!thanos.getActivityManager().isPackageRunning(proc)){activity.launchProcessForPackage(proc);Thread.sleep(6000);if(thanos.getActivityManager().hasRunningServiceForPackage(proc)){ui.showShortToast(\"拉起\"+proc);}else{ui.showLongToast(\"请手动打开:\"+proc);}}}}}else{thanos.getProfileManager().disableRuleByName(\"应用保活\");thanos.getProfileManager().addGlobalRuleVar(\"keepAlive\",new String[0]);ui.showShortToast(\"全局变量不存在!\");}"
]
}
]

Thanox