Skip to content

Commit

Permalink
[profile] add houtai guanjia
Browse files Browse the repository at this point in the history
  • Loading branch information
Tornaco committed Nov 25, 2022
1 parent 1178843 commit c1f4947
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions files/profile/profiles/houtaiguanjia.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"author": "诗里沧海怨怼",
"version": 1,
"tags": [
"app_opt"
],
"profile": {
"name": "后台管家",
"description": "by诗里沧海怨怼 | 延时[瘦身|停止]后台应用,可重计时",
"priority": -1,
"condition": "systemReady",
"actions": [
"import java.util.HashMap;import java.util.HashSet;import java.util.ArrayList;import java.nio.file.Path;import java.nio.file.Paths;import java.nio.file.Files;import java.time.format.DateTimeFormatter;import java.time.LocalDateTime;fp='路径';long cycleTime=分钟数 *60000;cMap=new HashMap(); rMap=new HashMap();int cnt1=0;long minV=Long.MAX_VALUE;foreach(str:globalVarOf$pkgNameForTrim){if(++cnt1==50){Thread.sleep(250);cnt1=0;}if(str!=null){strs=str.split(' ');cp=Paths.get(fp,strs[0]);mtime=(strs.length==1)?cycleTime:(Math.max(30,Long.valueOf(strs[strs.length-1]))*1000);minV=Math.min(minV,mtime);cMap.put(cp,mtime);rMap.put(cp,System.currentTimeMillis());}}foreach(str:globalVarOf$pkgNameForKill){if(++cnt1==50){Thread.sleep(250);cnt1=0;}if(str!=null){strs=str.split(' ');cp=Paths.get(fp,strs[0]);mtime=0;if(strs.length==1){mtime=cycleTime;}else{endC=strs[strs.length-1];if(endC[endC.length-1]=='@'){mtime=(endC.length==1)?cycleTime:(Math.max(30,Long.valueOf(endC.split('@')[0]))*1000);mtime=mtime+4;}else{mtime=Math.max(30,Long.valueOf(endC))*1000;}}minV=Math.min(minV,mtime);if(cMap.containsKey(cp)){cMap.put(cp,2+mtime);}else{cMap.put(cp,1+mtime);}rMap.put(cp,System.currentTimeMillis());}}if(cMap.size()==0){return;}noSet=new HashSet();foreach(str:globalVarOf$noTrimProcess){if(++cnt1==50){Thread.sleep(250);cnt1=0;}if(str!=null){noSet.add(str);}}long st=4500;pat=DateTimeFormatter.ofPattern('MM/dd HH:mm:ss');sb=new StringBuilder();procLst=new ArrayList(25);logN='后台管家.log';io.writeAppend(logN,'=============init finished=============\n');while(true){Thread.sleep(st);sb.append('curTime: ').append(LocalDateTime.now().format(pat)).append('\nfrontApp: ').append(activity.frontAppPackage).append('\n');minT=minV;st=0;curT=System.currentTimeMillis();tork=false;for(entry:rMap.entrySet()){if(++cnt1==50){Thread.sleep(150);cnt1=0;}cp=(Path)entry.key;ltt=(long)entry.value;name=cp.fileName.toString();if(Files.exists(cp)){ltt=Math.max(Files.getLastModifiedTime(cp).toMillis(),ltt);}cn=(long)cMap.get(cp);ntT=ltt+cn-curT;if(ntT<=2500){if(thanos.activityManager.isPackageRunning(name)){if(!activity.frontAppPackage.equals(name)){isTrim=true;hasNoti=thanos.notificationManager.hasShowingNotificationRecordsForPackage(name);igno=(cn&4)==0;if((cn&1)!=0){isTrim=false;}else if((cn&2)!=0){isTrim=thanos.audioManager.hasAudioFocus(name)||(hasNoti&&!igno);}if(isTrim){foreach(proc:thanos.activityManager.getRunningAppProcessForPackage(name)){if(!noSet.contains(proc.processName)){procLst.add(proc.processName);}}if(procLst.size()!=0){tork=true;thanos.activityManager.killProcessByNames(procLst);foreach(str:procLst){sb.append('|trim process| ').append(str).append('\n');}procLst.clear();}}else{if(igno||!hasNoti){killer.killPackage(name);if(task.hasTaskFromPackage(name)){task.removeTasksForPackage(name);}tork=true;sb.append('|kill package| ').append(name).append('\n');}}}rMap.put(cp,curT);}}else if(ntT<=10000){st=10000;}else{minT=Math.min(minT,ntT);}}st=(st!=0)?st:minT;if(tork){sb.append('---------------\n');io.writeAppend(logN,sb.toString());}sb.setLength(0);}"
]
}
}

0 comments on commit c1f4947

Please sign in to comment.