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

Commit

Permalink
Revert "Updater: Remove miotaV3-v1 support"
Browse files Browse the repository at this point in the history
This reverts commit 5a9ab8e.
  • Loading branch information
YuKongA committed Feb 23, 2024
1 parent 1464ed8 commit 9c6fc41
Show file tree
Hide file tree
Showing 42 changed files with 107 additions and 48 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

## 注意:

由于接口限制,请登录小米账号以使用 miotaV3 接口, 这可以同时获取全部机型 `正式版公测` 和当前账号拥有权限对应机型的 `正式版内测`/`开发版公测` 的详情信息
无论是否登录, <b>都</b>可以查看服务器上所有<b>存在且公开</b>版本的<b>基础信息</b>

<b>未登录</b>小米账号时使用 miotaV3-v1 接口, 可正常获取<b>存在且公开</b>机型的 `正式版公测` 的<b>详情信息</b>

<b>登录</b>小米账号后使用 miotaV3-v2 接口, 可同时获取当前账号<b>拥有权限</b>对应机型的 `正式版内测`/`开发版公测` 的<b>详情信息</b>

## 引用:

Expand Down
6 changes: 5 additions & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ When obtaining `Beta Development Version (X)`, please enter the complete system

## Notes:

Due to interface limitations, please log in to your Xiaomi account to use the miotaV3 interface. You can simultaneously obtain the `Pubilc Release Version` of all devices and the `Beta Release Version`/`Beta Development Version` of the corresponding device that the current account has access to.
Regardless of whether you are logged in or not, you can view the <b>basic information</b> of the <b>existing and public version</b> on the server.

When you are not logged in with a Xiaomi account, you can use the miotaV3-v1 interface to obtain the detailed information of the `Pubilc Release Version` of any model.

After logging in to your Xiaomi account, you will use the miotaV3-v2 interface to obtain detailed information about the `Beta Release Version` or the `Public Development Version`, corresponding to the internal test permissions you have.

## Credits:

Expand Down
39 changes: 8 additions & 31 deletions app/src/main/kotlin/top/yukonga/update/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ class MainActivity : AppCompatActivity() {
// Setup Cutout mode.
setupCutoutMode()

// Setup main information.
setupMainInformation()

// Setup TopAppBar.
setupTopAppBar()

Expand Down Expand Up @@ -160,6 +163,7 @@ class MainActivity : AppCompatActivity() {
loginIcon.setImageResource(R.drawable.ic_error)
loginTitle.text = getString(R.string.login_expired)
loginDesc.text = getString(R.string.login_expired_desc)
cookies.clear()
cookies["authResult"] = "-1"
FileUtils.saveCookiesFile(this@MainActivity, Json.encodeToString(cookies))
showStringToast(this@MainActivity, getString(R.string.login_expired_dialog), 0)
Expand Down Expand Up @@ -272,19 +276,11 @@ class MainActivity : AppCompatActivity() {
mainContentBinding.apply {
loginIcon.setImageResource(R.drawable.ic_check_circle)
loginTitle.text = getString(R.string.logged_in)
loginDesc.visibility = View.GONE
deviceName.visibility = View.VISIBLE
codeName.visibility = View.VISIBLE
deviceRegion.visibility = View.VISIBLE
systemVersion.visibility = View.VISIBLE
androidVersion.visibility = View.VISIBLE
// Setup main information.
setupMainInformation()
loginDesc.text = getString(R.string.using_v2)
}
activityMainBinding.apply {
topAppBar.menu.findItem(R.id.login).isVisible = false
topAppBar.menu.findItem(R.id.logout).isVisible = true
implement.visibility = View.VISIBLE
}
}
}
Expand All @@ -308,18 +304,11 @@ class MainActivity : AppCompatActivity() {
mainContentBinding.apply {
loginIcon.setImageResource(R.drawable.ic_cancel)
loginTitle.text = getString(R.string.no_account)
loginDesc.text = getString(R.string.login_to_use)
loginDesc.visibility = View.VISIBLE
deviceName.visibility = View.GONE
codeName.visibility = View.GONE
deviceRegion.visibility = View.GONE
systemVersion.visibility = View.GONE
androidVersion.visibility = View.GONE
loginDesc.text = getString(R.string.login_desc)
}
activityMainBinding.apply {
topAppBar.menu.findItem(R.id.login).isVisible = true
topAppBar.menu.findItem(R.id.logout).isVisible = false
implement.visibility = View.GONE
}
}
}
Expand Down Expand Up @@ -508,19 +497,7 @@ class MainActivity : AppCompatActivity() {
}

private fun checkIfLoggedIn() {
if (!FileUtils.isCookiesFileExists(this@MainActivity)) {
activityMainBinding.implement.visibility = View.GONE
mainContentBinding.apply {
deviceName.visibility = View.GONE
codeName.visibility = View.GONE
deviceRegion.visibility = View.GONE
systemVersion.visibility = View.GONE
androidVersion.visibility = View.GONE
}
} else {
// Setup main information.
setupMainInformation()

if (FileUtils.isCookiesFileExists(this@MainActivity)) {
val cookiesFile = FileUtils.readCookiesFile(this@MainActivity)
val cookies = json.decodeFromString<MutableMap<String, String>>(cookiesFile)
val description = cookies["description"].toString()
Expand All @@ -535,7 +512,7 @@ class MainActivity : AppCompatActivity() {
mainContentBinding.apply {
loginIcon.setImageResource(R.drawable.ic_check_circle)
loginTitle.text = getString(R.string.logged_in)
loginDesc.visibility = View.GONE
loginDesc.text = getString(R.string.using_v2)
}
activityMainBinding.apply {
topAppBar.menu.findItem(R.id.login).isVisible = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object DeviceInfoHelper {

data class Device(val deviceName: String, val codeName: String, val deviceCode: String)

private const val XIAOMI = "XM"
private const val Xiaomi = "XM"

private val androidR = Android("11", "R")
private val androidS = Android("12", "S")
Expand Down Expand Up @@ -196,6 +196,6 @@ object DeviceInfoHelper {
fun deviceCode(androidVersion: String, codeName: String, regionCode: String): String {
val android = androidList.find { it.androidNumericCode == androidVersion } ?: return ""
val device = deviceList.find { it.codeName == codeName } ?: return ""
return "${android.androidLetterCode}${device.deviceCode}${regionCode}${XIAOMI}"
return "${android.androidLetterCode}${device.deviceCode}${regionCode}${Xiaomi}"
}
}
23 changes: 15 additions & 8 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,7 +16,11 @@ 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 port = "2"
private var securityKey = "miuiotavalided11".toByteArray(Charsets.UTF_8)
private var userId = ""
private var accountType = "CN"
private var serviceToken = ""
private var port = "1"

private fun generateJson(codeNameExt: String, regionCode: String, romVersion: String, androidVersion: String, userId: String): String {
val data = RequestParamHelper(
Expand All @@ -33,13 +37,16 @@ object InfoUtils {
}

fun getRecoveryRomInfo(context: Context, codeNameExt: String, regionCode: String, romVersion: String, androidVersion: String): String {
if (!FileUtils.isCookiesFileExists(context)) return ""
val cookiesFile = FileUtils.readCookiesFile(context)
val cookies = json.decodeFromString<LoginHelper>(cookiesFile)
val userId = cookies.userId
val accountType = cookies.accountType.ifEmpty { "CN" }
val securityKey = Base64.getDecoder().decode((cookies.ssecurity))
val serviceToken = cookies.serviceToken

if (FileUtils.isCookiesFileExists(context)) {
val cookiesFile = FileUtils.readCookiesFile(context)
val cookies = json.decodeFromString<LoginHelper>(cookiesFile)
userId = cookies.userId
accountType = cookies.accountType.ifEmpty { "CN" }
securityKey = Base64.getDecoder().decode((cookies.ssecurity))
serviceToken = cookies.serviceToken
port = "2"
}
val jsonData = generateJson(codeNameExt, regionCode, romVersion, androidVersion, userId)
val encryptedText = miuiEncrypt(jsonData, securityKey)
val formBodyBuilder = FormBody.Builder().add("q", encryptedText).add("t", serviceToken).add("s", port).build()
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout-land/main_content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
android:id="@+id/login_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/login_to_use"
android:text="@string/login_desc"
android:textColor="?attr/colorOnPrimaryContainer"
android:textSize="14sp" />

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/main_content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="@string/login_to_use"
android:text="@string/login_desc"
android:textColor="?attr/colorOnPrimaryContainer"
android:textSize="14sp" />

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-af-rZA/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ar-rSA/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-bo-rBT/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ca-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-cs-rCZ/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-da-rDK/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-de-rDE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-el-rGR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-en-rUS/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-es-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">¡Inicio de sesión fallido!</string>
<string name="account_or_password_empty">¡El correo electrónico o contraseña se encuentra vacía!</string>
<string name="no_account">Sin cuenta</string>
<string name="login_desc">Usando interfaz v1</string>
<string name="using_v2">Usando interfaz v2</string>
<string name="logged_in">Sesión iniciada</string>
<string name="copy_button">Copiar</string>
<string name="download_button">Descargar</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-fi-rFI/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-fr-rFR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-hu-rHU/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-it-rIT/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-iw-rIL/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ja-rJP/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ko-rKR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-mn-rMN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-nl-rNL/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-no-rNO/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<string name="request_sign_failed">Request for _sign failed!</string>
<string name="account_or_password_empty">Account or Password empty!</string>
<string name="no_account">No account</string>
<string name="login_desc">Using v1 interface</string>
<string name="using_v2">Using v2 interface</string>
<string name="logged_in">Logged in</string>
<string name="copy_button">Copy</string>
<string name="download_button">Download</string>
Expand Down
Loading

0 comments on commit 9c6fc41

Please sign in to comment.