Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
app: Support search A15 PRE-DPP info
Browse files Browse the repository at this point in the history
  • Loading branch information
YuKongA committed May 24, 2024
1 parent cac7448 commit a2e13de
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import kotlinx.serialization.Serializable

@Serializable
data class RequestParamHelper(
val security: String,
val token: String,
val id: String,
val c: String,
val d: String,
Expand Down
26 changes: 19 additions & 7 deletions app/src/main/kotlin/top/yukonga/update/logic/utils/InfoUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,33 @@ object InfoUtils {

private const val CN_RECOVERY_URL = "https://update.miui.com/updates/miotaV3.php"
private const val INTL_RECOVERY_URL = "https://update.intl.miui.com/updates/miotaV3.php"
private var securityKey = "miuiotavalided11".toByteArray(Charsets.UTF_8)
private var userId = ""
private var securityKey = "miuiotavalided11".toByteArray()
private var accountType = "CN"
private var serviceToken = ""
private var port = "1"
private var userId = ""
private var security = ""
private var serviceToken = ""

private fun generateJson(codeNameExt: String, regionCode: String, romVersion: String, androidVersion: String, userId: String): String {
private fun generateJson(
codeNameExt: String,
regionCode: String,
romVersion: String,
androidVersion: String,
userId: String,
security: String,
token: String
): String {
val data = RequestParamHelper(
security = security,
token = token,
id = userId,
c = androidVersion,
d = codeNameExt,
f = "1",
ov = romVersion,
l = if (!codeNameExt.contains("_global")) "zh_CN" else "en_US",
r = regionCode,
v = "miui-$romVersion",
v = "MIUI-$romVersion",
unlock = "0"
)
return Json.encodeToString(data)
Expand All @@ -45,12 +56,13 @@ object InfoUtils {
if (authResult != "-1") {
userId = cookies.userId.toString()
accountType = cookies.accountType.toString().ifEmpty { "CN" }
securityKey = Base64.getDecoder().decode((cookies.ssecurity))
security = cookies.ssecurity.toString()
securityKey = Base64.getDecoder().decode(security)
serviceToken = cookies.serviceToken.toString()
port = "2"
}
}
val jsonData = generateJson(codeNameExt, regionCode, romVersion, androidVersion, userId)
val jsonData = generateJson(codeNameExt, regionCode, romVersion, androidVersion, userId, security, serviceToken)
val encryptedText = miuiEncrypt(jsonData, securityKey)
val formBodyBuilder = FormBody.Builder().add("q", encryptedText).add("t", serviceToken).add("s", port).build()
val recoveryUrl = if (accountType == "GL") INTL_RECOVERY_URL else CN_RECOVERY_URL
Expand Down

0 comments on commit a2e13de

Please sign in to comment.