Skip to content

Commit

Permalink
opt: Fuck Cloud Control.
Browse files Browse the repository at this point in the history
  • Loading branch information
HChenX committed Feb 13, 2025
1 parent 7235073 commit 47f8a8e
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class HyperMethod {
public static final String reportStartProcess = "reportStartProcess";
public static final String checkUnused = "checkUnused";
public static final String isEnable = "isEnable";
public static final String SetdmoptEnable = "SetdmoptEnable";
public static final String init = "init";
public static final String killProcess = "killProcess";
public static final String killProcessByMinAdj = "killProcessByMinAdj";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class HyperClass {
public static final String SystemServerImpl = "com.android.server.SystemServerImpl";
public static final String ActivityTaskManagerService = "com.android.server.wm.ActivityTaskManagerService";
public static final String MemoryFreezeStubImpl = "com.android.server.am.MemoryFreezeStubImpl";
public static final String ExtendMImpl = "com.android.server.ExtendMImpl";
public static final String MemoryStandardProcessControl = "com.android.server.am.MemoryStandardProcessControl";
public static final String SystemPressureController = "com.android.server.am.SystemPressureController";
public static final String SystemPressureControllerNative = "com.android.server.am.SystemPressureControllerNative";
Expand Down
17 changes: 14 additions & 3 deletions app/src/main/java/com/hchen/appretention/hook/hyper/HyperV1.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static com.hchen.appretention.data.field.HyperField.RECLAIM_IF_NEEDED;
import static com.hchen.appretention.data.field.HyperField.sCompactSingleProcEnable;
import static com.hchen.appretention.data.field.HyperField.sCompactionEnable;
import static com.hchen.appretention.data.method.HyperMethod.SetdmoptEnable;
import static com.hchen.appretention.data.method.HyperMethod.addMiuiPeriodicCleanerService;
import static com.hchen.appretention.data.method.HyperMethod.getBackgroundAppCount;
import static com.hchen.appretention.data.method.HyperMethod.getDeviceLevelForRAM;
Expand All @@ -48,6 +49,7 @@
import static com.hchen.appretention.data.method.HyperMethod.updateScreenState;
import static com.hchen.appretention.data.path.HyperClass.ActivityTaskManagerService;
import static com.hchen.appretention.data.path.HyperClass.Build;
import static com.hchen.appretention.data.path.HyperClass.ExtendMImpl;
import static com.hchen.appretention.data.path.HyperClass.GameMemoryCleanerDeprecated;
import static com.hchen.appretention.data.path.HyperClass.GameMemoryReclaimer;
import static com.hchen.appretention.data.path.HyperClass.IAppState$IRunningProcess;
Expand Down Expand Up @@ -141,8 +143,12 @@ public void init() {
);

// 后台限制。
if (existsMethod(OomAdjusterImpl, getBackgroundAppCount))
hookMethod(OomAdjusterImpl, getBackgroundAppCount, returnResult(100));
if (existsMethod(OomAdjusterImpl, getBackgroundAppCount)) {
hookMethod(OomAdjusterImpl,
getBackgroundAppCount,
returnResult(100)
);
}

/*
* 阻止定期清洁。
Expand All @@ -153,7 +159,6 @@ public void init() {
* */
SystemPropTool.setProp("persist.sys.periodic.u.enable", FALSE);
SystemPropTool.setProp("persist.sys.periodic.u.startprocess.enable", FALSE);

if (existsMethod(SystemServerImpl, addMiuiPeriodicCleanerService, ActivityTaskManagerService)) {
hookMethod(SystemServerImpl,
addMiuiPeriodicCleanerService,
Expand All @@ -167,6 +172,12 @@ public void init() {
* */
SystemPropTool.setProp("persist.miui.extm.enable", ONE);
SystemPropTool.setProp("persist.miui.extm.dm_opt.enable", TRUE);
if (existsMethod(ExtendMImpl, SetdmoptEnable)) {
hookMethod(ExtendMImpl,
SetdmoptEnable,
doNothing()
);
}

/*
* 禁用 MemoryFreezeStubImpl。
Expand Down
17 changes: 14 additions & 3 deletions app/src/main/java/com/hchen/appretention/hook/hyper/HyperV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static com.hchen.appretention.data.field.HyperField.RECLAIM_IF_NEEDED;
import static com.hchen.appretention.data.field.HyperField.sCompactSingleProcEnable;
import static com.hchen.appretention.data.field.HyperField.sCompactionEnable;
import static com.hchen.appretention.data.method.HyperMethod.SetdmoptEnable;
import static com.hchen.appretention.data.method.HyperMethod.addMiuiPeriodicCleanerService;
import static com.hchen.appretention.data.method.HyperMethod.getBackgroundAppCount;
import static com.hchen.appretention.data.method.HyperMethod.getDeviceLevelForRAM;
Expand All @@ -50,6 +51,7 @@
import static com.hchen.appretention.data.method.HyperMethod.updateScreenState;
import static com.hchen.appretention.data.path.HyperClass.ActivityTaskManagerService;
import static com.hchen.appretention.data.path.HyperClass.Build;
import static com.hchen.appretention.data.path.HyperClass.ExtendMImpl;
import static com.hchen.appretention.data.path.HyperClass.GameMemoryCleanerDeprecated;
import static com.hchen.appretention.data.path.HyperClass.GameMemoryReclaimer;
import static com.hchen.appretention.data.path.HyperClass.IAppState$IRunningProcess;
Expand Down Expand Up @@ -132,7 +134,10 @@ public void init() {

// 后台限制。似乎没啥用,可能影响 adj 分数判定。
// Changed: HyperV2 始终存在此方法。
hookMethod(OomAdjusterImpl, getBackgroundAppCount, returnResult(100));
hookMethod(OomAdjusterImpl,
getBackgroundAppCount,
returnResult(100)
);

/*
* 阻止定期清洁。
Expand All @@ -153,6 +158,12 @@ public void init() {
* */
SystemPropTool.setProp("persist.miui.extm.enable", ONE);
SystemPropTool.setProp("persist.miui.extm.dm_opt.enable", TRUE);
if (existsMethod(ExtendMImpl, SetdmoptEnable)) {
hookMethod(ExtendMImpl,
SetdmoptEnable,
doNothing()
);
}

/*
* 禁用 MemoryFreezeStubImpl。
Expand Down Expand Up @@ -236,7 +247,6 @@ public void init() {
* */
SystemPropTool.setProp("persist.sys.mms.compact_enable", FALSE);
SystemPropTool.setProp("persist.sys.mms.single_compact_enable", FALSE);

setStaticField(MiuiMemReclaimer, RECLAIM_IF_NEEDED, false);
setStaticField(MiuiMemoryService, sCompactionEnable, false);
setStaticField(MiuiMemoryService, sCompactSingleProcEnable, false);
Expand Down Expand Up @@ -329,7 +339,8 @@ public void init() {
// Changed: Support HyperV2
hookMethod(SystemPressureControllerNative,
nStartPressureMonitor,
doNothing());
doNothing()
);

CameraOpt.doHook();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ protected void init() {
hookMethod(ProcessList,
killProcessesWhenImperceptible,
int[].class, String.class, int.class,
doNothing());
doNothing()
);

// ----------------- PhantomProcessList ---------------
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ protected void init() {
hookMethod(ProcessList,
killProcessesWhenImperceptible,
int[].class, String.class, int.class,
doNothing());
doNothing()
);

// ----------------- PhantomProcessList ---------------
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public void init() {
hookMethod(ProcessList,
killProcessesWhenImperceptible,
int[].class, String.class, int.class,
doNothing());
doNothing()
);

// ----------------- PhantomProcessList ---------------
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public void init() {
hookMethod(ProcessList,
killProcessesWhenImperceptible,
int[].class, String.class, int.class,
doNothing());
doNothing()
);

/*
* ProcessList$ImperceptibleKillRunner 类内部的私有进程 kill 方法。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ public void init() {
hookMethod(ProcessList,
killProcessesWhenImperceptible,
int[].class, String.class, int.class,
doNothing());
doNothing()
);

// ----------------- PhantomProcessList ---------------
/*
Expand Down

0 comments on commit 47f8a8e

Please sign in to comment.