-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e52b58
commit 40717ef
Showing
7 changed files
with
81 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package hat.holo.token.models | ||
|
||
data class DeviceInfo( | ||
val id: String, | ||
val fingerprint: String, | ||
) : java.io.Serializable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,13 @@ | ||
package hat.holo.token.utils | ||
|
||
import java.lang.reflect.Method | ||
|
||
object AppUtils { | ||
|
||
private lateinit var instance: Any | ||
private val methodTable = arrayListOf<Method>() | ||
private lateinit var inst: Any | ||
|
||
fun init(cl: ClassLoader) { | ||
val clz = cl.loadClass("com.mihoyo.hyperion.utils.AppUtils") | ||
instance = clz.getDeclaredField("INSTANCE").get(null)!! | ||
methodTable.add(clz.getDeclaredMethod("showToast", String::class.java)) | ||
inst = cl.loadClass("com.mihoyo.hyperion.utils.AppUtils").visitStaticField<Any>("INSTANCE") | ||
} | ||
|
||
fun showToast(str: String) { | ||
methodTable[0].invoke(instance, str) | ||
} | ||
fun showToast(str: String) = inst.invokeMethod<String, Unit?>("showToast", str) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package hat.holo.token.utils | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Context | ||
import hat.holo.token.models.DeviceInfo | ||
|
||
@Suppress("MemberVisibilityCanBePrivate") | ||
@SuppressLint("StaticFieldLeak") | ||
object DeviceManager { | ||
|
||
private lateinit var context: Context | ||
private lateinit var riskManager: Any | ||
private lateinit var deviceUtils: Any | ||
|
||
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 deviceFp get() = riskManager.invokeMethod<String>("getDeviceFp") | ||
|
||
val deviceId get() = deviceUtils.invokeMethod<Context, String>("getDeviceID", context) | ||
|
||
val deviceInfo get() = DeviceInfo(deviceId, deviceFp) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters