[core] Hook old manager app to show version mismatch dialog

This commit is contained in:
tehcneko 2021-02-22 19:28:46 +08:00
parent de185bab4d
commit c20aa3ec6a
1 changed files with 16 additions and 0 deletions

View File

@ -22,7 +22,9 @@ package io.github.lsposed.lspd.hooker;
import android.os.IBinder;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedHelpers;
import io.github.lsposed.lspd.BuildConfig;
import io.github.lsposed.lspd.util.Utils;
public class XposedInstallerHooker {
@ -37,5 +39,19 @@ public class XposedInstallerHooker {
} catch (Throwable t) {
Utils.logW("Could not hook LSPosed Manager", t);
}
// for showing the version mismatch dialog
try {
Class<?> ConstantsClass = XposedHelpers.findClass("io.github.lsposed.manager.Constants", classLoader);
try {
XposedHelpers.setStaticObjectField(ConstantsClass, "xposedVersion", BuildConfig.VERSION_NAME);
return;
} catch (Throwable ignore) {
}
XposedHelpers.findAndHookMethod(ConstantsClass, "getXposedVersion", XC_MethodReplacement.returnConstant(BuildConfig.VERSION_NAME));
} catch (Throwable ignore) {
}
}
}