fix: get device id

This commit is contained in:
xtaodada 2024-08-19 13:27:10 +08:00
parent 40717efbf5
commit f91faa3112
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) { override fun afterHookedMethod(p: MethodHookParam) {
val app = p.args[0] as Application val app = p.args[0] as Application
AppUtils.init(classLoader) AppUtils.init(classLoader)
DeviceManager.init(classLoader, app.applicationContext)
AccountManager.init(classLoader) AccountManager.init(classLoader)
appendToClassPath(app.applicationContext) appendToClassPath(app.applicationContext)
} }
@ -68,6 +67,7 @@ class ModuleMain : IXposedHookLoadPackage, IXposedHookZygoteInit {
tokenBtn.scaleType = ImageView.ScaleType.FIT_XY tokenBtn.scaleType = ImageView.ScaleType.FIT_XY
tokenBtn.setOnClickListener { tokenBtn.setOnClickListener {
if (AccountManager.isLogin) { if (AccountManager.isLogin) {
DeviceManager.init(classLoader, ctx)
if (isPatch) { if (isPatch) {
val intent = Intent(ctx, LoaderActivity::class.java) val intent = Intent(ctx, LoaderActivity::class.java)
intent.putExtra("accountInfo", AccountManager.accountInfo) intent.putExtra("accountInfo", AccountManager.accountInfo)

View File

@ -10,22 +10,19 @@ object DeviceManager {
private lateinit var context: Context private lateinit var context: Context
private lateinit var riskManager: Any private lateinit var riskManager: Any
private lateinit var deviceUtils: Any private lateinit var deviceId: String
fun init(cl: ClassLoader, ctx: Context) { fun init(cl: ClassLoader, ctx: Context) {
context = ctx context = ctx
riskManager = cl riskManager = cl
.loadClass("com.mihoyo.platform.account.sdk.risk.RiskManager") .loadClass("com.mihoyo.platform.account.sdk.risk.RiskManager")
.visitStaticField<Any>("INSTANCE") .visitStaticField<Any>("INSTANCE")
deviceUtils = cl val preDevice = ctx.getSharedPreferences("pre_device.xml", 0)
.loadClass("com.mihoyo.platform.account.sdk.utils.DeviceUtils") deviceId = preDevice.getString("device_id", "").toString()
.visitStaticField<Any>("INSTANCE")
} }
val deviceFp get() = riskManager.invokeMethod<String>("getDeviceFp") val deviceFp get() = riskManager.invokeMethod<String>("getDeviceFp")
val deviceId get() = deviceUtils.invokeMethod<Context, String>("getDeviceID", context)
val deviceInfo get() = DeviceInfo(deviceId, deviceFp) val deviceInfo get() = DeviceInfo(deviceId, deviceFp)
} }