simplify RemoveSmallWindowRestrictions

This commit is contained in:
QQ littleice
2022-03-10 18:34:41 +08:00
parent 5b40f07256
commit d659ed88a3

View File

@@ -1,76 +1,38 @@
package com.lt2333.simplicitytools.hook.app.android
import android.content.Context
import com.lt2333.simplicitytools.util.XSPUtils
import com.lt2333.simplicitytools.util.hasEnable
import com.lt2333.simplicitytools.util.hookAfterMethod
import com.lt2333.simplicitytools.util.hookBeforeMethod
import de.robv.android.xposed.IXposedHookLoadPackage
import de.robv.android.xposed.XC_MethodHook
import de.robv.android.xposed.XposedHelpers
import de.robv.android.xposed.callbacks.XC_LoadPackage
class RemoveSmallWindowRestrictions : IXposedHookLoadPackage {
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
// 强制所有活动设为可以调整大小
val classIfExists = XposedHelpers.findClassIfExists(
"com.android.server.wm.Task",
lpparam.classLoader
)
XposedHelpers.findAndHookMethod(
classIfExists,
"isResizeable",
object : XC_MethodHook() {
override fun beforeHookedMethod(param: MethodHookParam) {
if (XSPUtils.getBoolean("remove_small_window_restrictions", false)) {
param.result = true
}
}
})
"com.android.server.wm.Task".hookBeforeMethod(lpparam.classLoader, "isResizeable") {
hasEnable("remove_small_window_restrictions") {
it.result = true
}
}
"android.util.MiuiMultiWindowAdapter".hookAfterMethod(lpparam.classLoader, "getFreeformBlackList") {
hasEnable("remove_small_window_restrictions") {
it.result = (it.result as MutableList<*>).clear()
}
}
"android.util.MiuiMultiWindowAdapter".hookAfterMethod(lpparam.classLoader, "getFreeformBlackListFromCloud") {
hasEnable("remove_small_window_restrictions") {
it.result = (it.result as MutableList<*>).clear()
}
}
val classIfExists2 = XposedHelpers.findClassIfExists(
"android.util.MiuiMultiWindowAdapter",
lpparam.classLoader
)
XposedHelpers.findAndHookMethod(
classIfExists2,
"getFreeformBlackList",
object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam) {
if (XSPUtils.getBoolean("remove_small_window_restrictions", false)) {
val blackList = param.result as MutableList<String>
blackList.clear()
param.result = blackList
}
}
})
XposedHelpers.findAndHookMethod(
classIfExists2,
"getFreeformBlackListFromCloud",
Context::class.java,
object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam) {
if (XSPUtils.getBoolean("remove_small_window_restrictions", false)) {
val blackList = param.result as MutableList<String>
blackList.clear()
param.result = blackList
}
}
})
val classIfExists3 = XposedHelpers.findClassIfExists(
"android.util.MiuiMultiWindowUtils",
lpparam.classLoader
)
"android.util.MiuiMultiWindowUtils".hookAfterMethod(lpparam.classLoader, "supportFreeform") {
hasEnable("remove_small_window_restrictions") {
it.result = true
}
}
XposedHelpers.findAndHookMethod(
classIfExists3,
"supportFreeform",
object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam) {
if (XSPUtils.getBoolean("remove_small_window_restrictions", false)) {
param.result = true
}
}
})
}
}