fix: get device id

This commit is contained in:
xtaodada 2024-08-19 13:27:10 +08:00
parent aadb4e38b2
commit e00ea6f28c
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 4 additions and 7 deletions

View File

@ -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)

View File

@ -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<Any>("INSTANCE")
deviceUtils = cl
.loadClass("com.mihoyo.platform.account.sdk.utils.DeviceUtils")
.visitStaticField<Any>("INSTANCE")
val preDevice = ctx.getSharedPreferences("pre_device.xml", 0)
deviceId = preDevice.getString("device_id", "").toString()
}
val deviceFp get() = riskManager.invokeMethod<String>("getDeviceFp")
val deviceId get() = deviceUtils.invokeMethod<Context, String>("getDeviceID", context)
val deviceInfo get() = DeviceInfo(deviceId, deviceFp)
}