From 020a790135a1f4d7e70b998e132068995e1ed4bd Mon Sep 17 00:00:00 2001 From: HolographicHat Date: Fri, 10 Nov 2023 13:58:55 +0800 Subject: [PATCH 1/2] Use com.mihoyo.platform.account.sdk.Porte --- .../hat/holo/token/utils/AccountManager.kt | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/hat/holo/token/utils/AccountManager.kt b/app/src/main/java/hat/holo/token/utils/AccountManager.kt index e6ba377..443c9bc 100644 --- a/app/src/main/java/hat/holo/token/utils/AccountManager.kt +++ b/app/src/main/java/hat/holo/token/utils/AccountManager.kt @@ -1,37 +1,29 @@ package hat.holo.token.utils import hat.holo.token.models.AccountInfo -import java.lang.reflect.Method @Suppress("MemberVisibilityCanBePrivate", "unused") object AccountManager { - private lateinit var instance: Any - private val methodTable = arrayListOf() + private lateinit var instPorte: Any + private lateinit var clzPorte: Class<*> + private lateinit var clzAccount: Class<*> fun init(cl: ClassLoader) { - val clz = cl.loadClass("com.mihoyo.hyperion.biz.login.account.AccountManager") - instance = clz.getDeclaredField("INSTANCE").get(null)!! - methodTable.add(clz.getDeclaredMethod("getMid")) - methodTable.add(clz.getDeclaredMethod("getUserId")) - methodTable.add(clz.getDeclaredMethod("getLToken")) - methodTable.add(clz.getDeclaredMethod("getSToken")) - methodTable.add(clz.getDeclaredMethod("getSTokenV1")) - methodTable.add(clz.getDeclaredMethod("userIsLogin")) - methodTable.add(clz.getDeclaredMethod("getLastUserId")) - methodTable.add(clz.getDeclaredMethod("getLoginTicket")) + clzPorte = cl.loadClass("com.mihoyo.platform.account.sdk.Porte") + clzAccount = cl.loadClass("com.mihoyo.platform.account.sdk.bean.Account") + instPorte = clzPorte.getDeclaredField("INSTANCE").get(null)!! } - val isLogin get() = methodTable[5].invoke(instance) as Boolean + private fun loginCurrentAccount() = clzPorte.getDeclaredMethod("loginCurrentAccount").invoke(instPorte) - val mid get() = methodTable[0].invoke(instance) as String - val uid get() = methodTable[1].invoke(instance) as String - val lToken get() = methodTable[2].invoke(instance) as String - val sToken get() = methodTable[3].invoke(instance) as String - val sTokenV1 get() = methodTable[4].invoke(instance) as String - val lastUserId get() = methodTable[6].invoke(instance) as String - val loginTicket get() = methodTable[7].invoke(instance) as String + val isLogin get() = if (loginCurrentAccount() == null) false else !uid.isNullOrEmpty() && !sToken.isNullOrEmpty() - val accountInfo get() = AccountInfo(mid, uid, lToken, sToken) + val mid get() = clzAccount.getDeclaredMethod("getMid").invoke(loginCurrentAccount()) as String? + val uid get() = clzAccount.getDeclaredMethod("getAid").invoke(loginCurrentAccount()) as String? + val lToken get() = clzPorte.getDeclaredMethod("getLToken").invoke(instPorte) as String? + val sToken get() = clzAccount.getDeclaredMethod("getTokenStr").invoke(loginCurrentAccount()) as String? + + val accountInfo get() = AccountInfo(mid!!, uid!!, lToken!!, sToken!!) } From be3255f14f51040fcad5ce55df697bbcf9776443 Mon Sep 17 00:00:00 2001 From: HolographicHat <58809250+HolographicHat@users.noreply.github.com> Date: Fri, 10 Nov 2023 14:02:36 +0800 Subject: [PATCH 2/2] Update android.yml --- .github/workflows/android.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 301e03b..074d845 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -31,7 +31,7 @@ jobs: - name: Install jq run: sudo apt-get install -y jq - name: Download package - run: "curl -H 'x-rpc-client_type: 2' -H 'x-rpc-app_version: 2.37.1' -H 'x-rpc-channel: miyousheluodi' https://api-takumi.mihoyo.com/ptolemaios/api/getLatestRelease | jq --raw-output '.data.package_url' | xargs curl -o miyoushe.apk" + run: "curl -H 'x-rpc-client_type: 2' -H 'x-rpc-app_version: 2.52.1' -H 'x-rpc-channel: miyousheluodi' https://api-takumi.mihoyo.com/ptolemaios/api/getLatestRelease | jq --raw-output '.data.package_url' | xargs curl -o miyoushe.apk" - name: Patch package run: "mkdir out && mv app/build/outputs/apk/release/app-release.apk . && java -jar gradle/lspatch/jar-v0.5.1-361-release.jar -f -l 2 -m app-release.apk -o out miyoushe.apk && mv app-release.apk out" - name: Upload build artifacts