新增:电量与性能:阻止杀后台应用 (#186)

* 新增:电量与性能:阻止杀后台应用

参考自 https://www.coolapk.com/feed/37905475?shareKey=ODVjZjU1ZGI1YmMyNjJmZjkxNjU~
by 向晚今天吃了咩@coolapk
已获授权

* 新增:电量与性能:使 Millet 更加激进

参考自 https://www.coolapk.com/feed/37574229?shareKey=YWNmMWQ4ZTY2MDI4NjJmZjkxOTg~
by 向晚今天吃了咩@coolapk
已获授权

* 电量与性能:阻止杀后台应用:更新描述

* 电量与性能:阻止杀后台应用:添加更多防杀

* 电量与性能:使 Millet 更加激进: 强制开启 Millet

* 电量与性能:使 Millet 更加激进: 冻结延迟设置为3秒

* 电量与性能:使 Millet 更加激进: 允许 Millet 冻结活跃的应用

* 电量与性能:阻止杀后台应用:更新描述

* 电量与性能:允许 Millet 冻结活跃的应用: 检查使 Millet 更加激进
This commit is contained in:
Alex Zhang
2022-10-02 16:09:49 +08:00
committed by GitHub
parent 6a70d0c20f
commit 3abafe1cf9
6 changed files with 176 additions and 0 deletions

View File

@@ -505,6 +505,15 @@ class SettingsActivity : MIUIActivity() {
TitleText(textId = R.string.scope_powerkeeper)
TextSummaryWithSwitch(TextSummaryV(textId = R.string.lock_max_fps, tipsId = R.string.lock_max_fps_summary), SwitchV("lock_max_fps"))
TextSummaryWithSwitch(TextSummaryV(textId = R.string.prevent_recovery_of_battery_optimization_white_list, tipsId = R.string.failed_after_restart), SwitchV("prevent_recovery_of_battery_optimization_white_list"))
TextSummaryWithSwitch(TextSummaryV(textId = R.string.do_not_clear_app, tipsId = R.string.do_not_clear_app_summary), SwitchV("do_not_clear_app"))
val makeMilletMoreAggressiveSwitchBinding = GetDataBinding({ safeSP.getBoolean("make_millet_more_aggressive", false) }) { view, flags, data ->
when (flags) {
1 -> (view as Switch).isEnabled = data as Boolean
2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE
}
}
TextSummaryWithSwitch(TextSummaryV(textId = R.string.make_millet_more_aggressive, tipsId = R.string.make_millet_more_aggressive_summary), SwitchV("make_millet_more_aggressive", dataBindingSend = makeMilletMoreAggressiveSwitchBinding.bindingSend))
TextSummaryWithSwitch(TextSummaryV(textId = R.string.make_millet_ignore_active, tipsId = R.string.make_millet_ignore_active_summary), SwitchV("make_millet_ignore_active"), dataBindingRecv = makeMilletMoreAggressiveSwitchBinding.binding.getRecv(2))
TextSummaryArrow(TextSummaryV(textId = R.string.battery_optimization, tipsId = R.string.battery_optimization_summary, onClickListener = {
try {
val intent = Intent()

View File

@@ -1,6 +1,8 @@
package com.lt2333.simplicitytools.hook.app
import com.lt2333.simplicitytools.hook.app.powerkeeper.DoNotClearApp
import com.lt2333.simplicitytools.hook.app.powerkeeper.LockMaxFps
import com.lt2333.simplicitytools.hook.app.powerkeeper.MakeMilletMoreAggressive
import com.lt2333.simplicitytools.hook.app.powerkeeper.PreventRecoveryOfBatteryOptimizationWhitelist
import com.lt2333.simplicitytools.util.xposed.base.AppRegister
import de.robv.android.xposed.callbacks.XC_LoadPackage
@@ -12,6 +14,8 @@ object PowerKeeper: AppRegister() {
autoInitHooks(lpparam,
LockMaxFps, //锁定最高刷新率
PreventRecoveryOfBatteryOptimizationWhitelist, //防止恢复电池优化白名单
DoNotClearApp,//阻止杀后台
MakeMilletMoreAggressive,//使 Millet 更激进
)
}
}

View File

@@ -0,0 +1,74 @@
package com.lt2333.simplicitytools.hook.app.powerkeeper
import com.github.kyuubiran.ezxhelper.utils.findMethod
import com.github.kyuubiran.ezxhelper.utils.hookBefore
import com.lt2333.simplicitytools.util.hasEnable
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
object DoNotClearApp : HookRegister() {
override fun init() {
findMethod("com.miui.powerkeeper.statemachine.SleepModeControllerNew") {
name == "clearApp"
}.hookBefore {
hasEnable("do_not_clear_app") {
it.result = null
}
}
findMethod("com.miui.powerkeeper.statemachine.PowerStateMachine") {
name == "clearAppWhenScreenOffTimeOut"
}.hookBefore {
hasEnable("do_not_clear_app") {
it.result = null
}
}
findMethod("com.miui.powerkeeper.statemachine.PowerStateMachine") {
name == "clearAppWhenScreenOffTimeOutInNight"
}.hookBefore {
hasEnable("do_not_clear_app") {
it.result = null
}
}
findMethod("com.miui.powerkeeper.powerchecker.PowerCheckerController") {
name == "clearApp"
}.hookBefore {
hasEnable("do_not_clear_app") {
it.result = null
}
}
findMethod("com.miui.powerkeeper.powerchecker.PowerCheckerController") {
name == "autoKillApp"
}.hookBefore {
hasEnable("do_not_clear_app") {
it.result = null
}
}
findMethod("com.miui.powerkeeper.statemachine.SleepModeController\$SleepProcessHelper") {
name == "killAppsInSleep"
}.hookBefore {
hasEnable("do_not_clear_app") {
it.result = null
}
}
findMethod("com.miui.powerkeeper.statemachine.DynamicTurboPowerHandler") {
name == "clearApp"
}.hookBefore {
hasEnable("do_not_clear_app") {
it.result = null
}
}
findMethod("miui.process.ProcessManager") {
name == "kill"
}.hookBefore {
hasEnable("do_not_clear_app") {
it.result = false
}
}
}
}

View File

@@ -0,0 +1,77 @@
package com.lt2333.simplicitytools.hook.app.powerkeeper
import com.github.kyuubiran.ezxhelper.utils.findMethod
import com.github.kyuubiran.ezxhelper.utils.hookBefore
import com.lt2333.simplicitytools.util.hasEnable
import com.lt2333.simplicitytools.util.xposed.base.HookRegister
object MakeMilletMoreAggressive : HookRegister() {
override fun init() {
findMethod("com.miui.powerkeeper.controller.FrozenAppController") {
name == "appIsAllowToFrozen"
}.hookBefore {
hasEnable("make_millet_more_aggressive") {
it.result = true
}
}
findMethod("com.miui.powerkeeper.controller.FrozenAppController\$FrozenUtil") {
name == "isHasRunningStateProcess"
}.hookBefore {
hasEnable("make_millet_more_aggressive") {
it.result = false
}
}
findMethod("com.miui.powerkeeper.controller.FrozenAppController\$FrozenUtil") {
name == "isExectingService"
}.hookBefore {
hasEnable("make_millet_more_aggressive") {
it.result = false
}
}
findMethod("com.miui.powerkeeper.controller.FrozenAppController\$FrozenUtil") {
name == "isReceivingBroadcast"
}.hookBefore {
hasEnable("make_millet_more_aggressive") {
it.result = false
}
}
findMethod("com.miui.powerkeeper.controller.FrozenAppController\$FrozenUtil") {
name == "isHasProcessOOMTooLow"
}.hookBefore {
hasEnable("make_millet_more_aggressive") {
it.result = false
}
}
findMethod("com.miui.powerkeeper.controller.FrozenAppController") {
name == "isHasNotification"
}.hookBefore {
hasEnable("make_millet_more_aggressive") {
it.result = false
}
}
findMethod("com.miui.powerkeeper.millet.MilletConfig") {
name == "getEnable"
}.hookBefore {
hasEnable("make_millet_more_aggressive") {
it.result = true
}
}
findMethod("com.miui.powerkeeper.controller.FrozenAppController\$AppStateFrozenControl") {
name == "frozenAppLater" &&
parameterTypes.contentEquals(arrayOf(Int::class.java))
}.hookBefore {
hasEnable("make_millet_more_aggressive") {
it.args[0] = 3000
}
}
findMethod("com.miui.powerkeeper.controller.FrozenAppController\$AppStateFrozenControl") {
name == "isAllowFrozenNow"
}.hookBefore {
hasEnable("make_millet_more_aggressive") {
hasEnable("make_millet_ignore_active") {
it.result = true
}
}
}
}
}