mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-14 12:21:18 +08:00
Remove DexBuilder
This commit is contained in:
@@ -4,24 +4,14 @@ import com.lt2333.simplicitytools.hook.app.securitycenter.LockOneHundred
|
||||
import com.lt2333.simplicitytools.hook.app.securitycenter.RemoveMacroBlacklist
|
||||
import com.lt2333.simplicitytools.hook.app.securitycenter.ShowBatteryTemperature
|
||||
import com.lt2333.simplicitytools.hook.app.securitycenter.SkipWaitingTime
|
||||
import com.lt2333.simplicitytools.util.log
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XposedBridge
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam
|
||||
import me.iacn.biliroaming.utils.DexHelper
|
||||
|
||||
class SecurityCenter : IXposedHookLoadPackage {
|
||||
|
||||
var dexHelper: DexHelper? = null
|
||||
|
||||
override fun handleLoadPackage(lpparam: LoadPackageParam) {
|
||||
XposedBridge.log("Simplicitytools: 成功 Hook "+javaClass.simpleName)
|
||||
try {
|
||||
System.loadLibrary("DexBuilder")
|
||||
dexHelper = DexHelper.getInstance(lpparam.classLoader)
|
||||
} catch (e: UnsatisfiedLinkError) {
|
||||
log("DexBuilder 加载失败")
|
||||
}
|
||||
//跳过 5/10秒等待时间
|
||||
SkipWaitingTime().handleLoadPackage(lpparam)
|
||||
//锁定 100分
|
||||
@@ -29,6 +19,6 @@ class SecurityCenter : IXposedHookLoadPackage {
|
||||
//去除自动连招黑名单
|
||||
RemoveMacroBlacklist().handleLoadPackage(lpparam)
|
||||
//显示电池温度
|
||||
ShowBatteryTemperature(dexHelper).handleLoadPackage(lpparam)
|
||||
ShowBatteryTemperature().handleLoadPackage(lpparam)
|
||||
}
|
||||
}
|
||||
@@ -16,37 +16,12 @@ import cn.fkj233.ui.activity.dp2px
|
||||
import com.lt2333.simplicitytools.util.*
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import me.iacn.biliroaming.utils.DexHelper
|
||||
import java.lang.reflect.Field
|
||||
|
||||
class ShowBatteryTemperature(private val dexHelper: DexHelper?): IXposedHookLoadPackage {
|
||||
class ShowBatteryTemperature: IXposedHookLoadPackage {
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
if (!XSPUtils.getBoolean("battery_life_function", false)) return
|
||||
if (dexHelper == null) {
|
||||
log("DexHelper为null,hook ShowBatteryTemperature 失败")
|
||||
return
|
||||
}
|
||||
|
||||
val methodIndex = dexHelper.findMethodUsingString(
|
||||
"isBatteryLifeFunctionSupported",
|
||||
true,
|
||||
-1,
|
||||
0,
|
||||
null,
|
||||
-1,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
true
|
||||
).firstOrNull()
|
||||
if (methodIndex == null) {
|
||||
log("ShowBatteryTemperature 无法定位方法")
|
||||
return
|
||||
}
|
||||
val method = dexHelper.decodeMethodIndex(methodIndex)
|
||||
log(method)
|
||||
method.hookBeforeMethod { it.result = true }
|
||||
val a = "com.miui.powercenter.a\$a".findClass(lpparam.classLoader)
|
||||
"com.miui.powercenter.a".hookBeforeMethod(lpparam.classLoader, "b", Context::class.java) {
|
||||
it.result = getBatteryTemperature(it.args[0] as Context).toString()
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
package me.iacn.biliroaming.utils;
|
||||
|
||||
import com.lt2333.simplicitytools.util.KotlinXposedHelperKt;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Member;
|
||||
|
||||
import dalvik.system.BaseDexClassLoader;
|
||||
|
||||
public class DexHelper implements AutoCloseable, Closeable {
|
||||
public static final int NO_CLASS_INDEX = -1;
|
||||
private final ClassLoader classLoader;
|
||||
private final long token;
|
||||
private static DexHelper instance;
|
||||
|
||||
public static DexHelper getInstance(ClassLoader classLoader) {
|
||||
synchronized (DexHelper.class) {
|
||||
if (instance != null) return instance;
|
||||
BaseDexClassLoader loader = KotlinXposedHelperKt.findDexClassLoader(classLoader);
|
||||
if (loader == null) {
|
||||
return null;
|
||||
}
|
||||
instance = new DexHelper(loader);
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
public DexHelper(ClassLoader classLoader) {
|
||||
this.classLoader = classLoader;
|
||||
token = load(classLoader);
|
||||
}
|
||||
|
||||
public native long[] findMethodUsingString(
|
||||
String str, boolean matchPrefix, long returnType, short parameterCount,
|
||||
String parameterShorty, long declaringClass, long[] parameterTypes,
|
||||
long[] containsParameterTypes, int[] dexPriority, boolean findFirst);
|
||||
|
||||
public native long[] findMethodInvoking(long methodIndex, long returnType,
|
||||
short parameterCount, String parameterShorty,
|
||||
long declaringClass, long[] parameterTypes,
|
||||
long[] containsParameterTypes,
|
||||
int[] dexPriority, boolean findFirst);
|
||||
|
||||
public native long[] findMethodInvoked(long methodIndex, long returnType,
|
||||
short parameterCount, String parameterShorty,
|
||||
long declaringClass, long[] parameterTypes,
|
||||
long[] containsParameterTypes,
|
||||
int[] dexPriority, boolean findFirst);
|
||||
|
||||
public native long[] findMethodSettingField(
|
||||
long fieldIndex, long returnType, short parameterCount,
|
||||
String parameterShorty, long declaringClass, long[] parameterTypes,
|
||||
long[] containsParameterTypes, int[] dexPriority, boolean findFirst);
|
||||
|
||||
public native long[] findMethodGettingField(
|
||||
long fieldIndex, long returnType, short parameterCount,
|
||||
String parameterShorty, long declaringClass, long[] parameterTypes,
|
||||
long[] containsParameterTypes, int[] dexPriority, boolean findFirst);
|
||||
|
||||
public native long[] findField(long type, int[] dexPriority, boolean findFirst);
|
||||
|
||||
public native Member decodeMethodIndex(long methodIndex);
|
||||
|
||||
public native long encodeMethodIndex(Member method);
|
||||
|
||||
public native Field decodeFieldIndex(long fieldIndex);
|
||||
|
||||
public native long encodeFieldIndex(Field field);
|
||||
|
||||
public native long encodeClassIndex(Class<?> clazz);
|
||||
|
||||
public native Class<?> decodeClassIndex(long classIndex);
|
||||
|
||||
public native void createFullCache();
|
||||
|
||||
@Override
|
||||
public native void close();
|
||||
|
||||
@Override
|
||||
protected void finalize() {
|
||||
close();
|
||||
}
|
||||
|
||||
private native long load(ClassLoader classLoader);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user