From e00ea6f28cd8a6b14893af9c74aef91fe874f1c1 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Mon, 19 Aug 2024 13:27:10 +0800 Subject: [PATCH] fix: get device id --- app/src/main/java/hat/holo/token/ModuleMain.kt | 2 +- app/src/main/java/hat/holo/token/utils/DeviceManager.kt | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/hat/holo/token/ModuleMain.kt b/app/src/main/java/hat/holo/token/ModuleMain.kt index 8587f30..263b406 100644 --- a/app/src/main/java/hat/holo/token/ModuleMain.kt +++ b/app/src/main/java/hat/holo/token/ModuleMain.kt @@ -48,7 +48,6 @@ class ModuleMain : IXposedHookLoadPackage, IXposedHookZygoteInit { override fun afterHookedMethod(p: MethodHookParam) { val app = p.args[0] as Application AppUtils.init(classLoader) - DeviceManager.init(classLoader, app.applicationContext) AccountManager.init(classLoader) appendToClassPath(app.applicationContext) } @@ -68,6 +67,7 @@ class ModuleMain : IXposedHookLoadPackage, IXposedHookZygoteInit { tokenBtn.scaleType = ImageView.ScaleType.FIT_XY tokenBtn.setOnClickListener { if (AccountManager.isLogin) { + DeviceManager.init(classLoader, ctx) if (isPatch) { val intent = Intent(ctx, LoaderActivity::class.java) intent.putExtra("accountInfo", AccountManager.accountInfo) diff --git a/app/src/main/java/hat/holo/token/utils/DeviceManager.kt b/app/src/main/java/hat/holo/token/utils/DeviceManager.kt index c0d03fc..3a593b0 100644 --- a/app/src/main/java/hat/holo/token/utils/DeviceManager.kt +++ b/app/src/main/java/hat/holo/token/utils/DeviceManager.kt @@ -10,22 +10,19 @@ object DeviceManager { private lateinit var context: Context private lateinit var riskManager: Any - private lateinit var deviceUtils: Any + private lateinit var deviceId: String fun init(cl: ClassLoader, ctx: Context) { context = ctx riskManager = cl .loadClass("com.mihoyo.platform.account.sdk.risk.RiskManager") .visitStaticField("INSTANCE") - deviceUtils = cl - .loadClass("com.mihoyo.platform.account.sdk.utils.DeviceUtils") - .visitStaticField("INSTANCE") + val preDevice = ctx.getSharedPreferences("pre_device.xml", 0) + deviceId = preDevice.getString("device_id", "").toString() } val deviceFp get() = riskManager.invokeMethod("getDeviceFp") - val deviceId get() = deviceUtils.invokeMethod("getDeviceID", context) - val deviceInfo get() = DeviceInfo(deviceId, deviceFp) }