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

Commit

Permalink
app: Support view OTA info
Browse files Browse the repository at this point in the history
  • Loading branch information
YuKongA committed Jun 7, 2024
1 parent f31e983 commit ee736ff
Show file tree
Hide file tree
Showing 17 changed files with 1,555 additions and 1,322 deletions.
301 changes: 208 additions & 93 deletions app/src/main/kotlin/top/yukonga/update/activity/MainActivity.kt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package top.yukonga.update.activity.viewModel
import androidx.lifecycle.ViewModel

class MainViewModel : ViewModel() {
var type: String? = null
var device: String? = null
var version: String? = null
var codebase: String? = null
Expand All @@ -11,8 +12,19 @@ class MainViewModel : ViewModel() {
var filesize: String? = null
var bigversion: String? = null
var officialDownload: String? = null
var officialText: String? = null
var cdn1Download: String? = null
var cdn2Download: String? = null
var changelog: String? = null
var typeIncrement: String? = null
var deviceIncrement: String? = null
var versionIncrement: String? = null
var codebaseIncrement: String? = null
var branchIncrement: String? = null
var filenameIncrement: String? = null
var filesizeIncrement: String? = null
var bigversionIncrement: String? = null
var officialDownloadIncrement: String? = null
var cdn1DownloadIncrement: String? = null
var cdn2DownloadIncrement: String? = null
var changelogIncrement: String? = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import kotlinx.serialization.Serializable

@Serializable
data class RequestParamHelper(
val security: String,
val token: String,
val id: String,
val b : String,
val c: String,
val d: String,
val f: String,
val ov: String,
val id: String,
val l: String,
val ov: String,
val p : String,
val pn : String,
val r: String,
val security: String,
val token: String,
val v: String,
val unlock: String
)
)
17 changes: 7 additions & 10 deletions app/src/main/kotlin/top/yukonga/update/logic/data/RomInfoHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,29 @@ object RomInfoHelper {
@Serializable
data class RomInfo(
@SerialName("AuthResult") val authResult: Int? = null,
@SerialName("CurrentRom") val currentRom: CurrentRom? = null,
@SerialName("LatestRom") val latestRom: LatestRom? = null,
@SerialName("CurrentRom") val currentRom: Rom? = null,
@SerialName("LatestRom") val latestRom: Rom? = null,
@SerialName("IncrementRom") val incrementRom: Rom? = null,
@SerialName("CrossRom") val crossRom: Rom? = null,
)

@Serializable
data class CurrentRom(
data class Rom(
val bigversion: String? = null,
val branch: String? = null,
val changelog: HashMap<String, Changelog>? = null,
val codebase: String? = null,
val device: String? = null,
val filename: String? = null,
val filesize: String? = null,
val md5: String? = null,
val name: String? = null,
val type: String? = null,
val version: String? = null,
val changelog: HashMap<String, Changelog>? = null,
)

@Serializable
data class Changelog(
val txt: List<String>
)

@Serializable
data class LatestRom(
val filename: String? = null,
val md5: String? = null,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ object AnimUtils {
animate().alpha(1f).setDuration(duration).withEndAction {
completion?.invoke()
}

}
}
22 changes: 14 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 @@ -24,6 +24,7 @@ object InfoUtils {
private var serviceToken = ""

private fun generateJson(
branch: String = "",
codeNameExt: String,
regionCode: String,
romVersion: String,
Expand All @@ -33,22 +34,27 @@ object InfoUtils {
token: String
): String {
val data = RequestParamHelper(
security = security,
token = token,
id = userId,
b = branch,
c = androidVersion,
d = codeNameExt,
f = "1",
ov = romVersion,
id = userId,
l = if (!codeNameExt.contains("_global")) "zh_CN" else "en_US",
ov = romVersion,
p = codeNameExt,
pn = codeNameExt,
r = regionCode,
v = "MIUI-$romVersion",
unlock = "0"
security = security,
token = token,
unlock = "0",
v = "MIUI-$romVersion"
)
return Json.encodeToString(data)
}

fun getRecoveryRomInfo(context: Context, codeNameExt: String, regionCode: String, romVersion: String, androidVersion: String): String {
fun getRecoveryRomInfo(
context: Context, branch: String, codeNameExt: String, regionCode: String, romVersion: String, androidVersion: String
): String {
if (FileUtils.isCookiesFileExists(context)) {
val cookiesFile = FileUtils.readCookiesFile(context)
val cookies = json.decodeFromString<LoginHelper>(cookiesFile)
Expand All @@ -62,7 +68,7 @@ object InfoUtils {
port = "2"
}
}
val jsonData = generateJson(codeNameExt, regionCode, romVersion, androidVersion, userId, security, serviceToken)
val jsonData = generateJson(branch, 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
60 changes: 60 additions & 0 deletions app/src/main/res/layout-land/login_card.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<com.google.android.material.card.MaterialCardView
style="?materialCardViewFilledStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="18dp"
app:cardBackgroundColor="?attr/colorPrimaryContainer">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginVertical="18dp">

<ImageView
android:id="@+id/login_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:layout_marginHorizontal="20dp"
android:src="@drawable/ic_cancel"
app:tint="?attr/colorOnPrimaryContainer"
tools:ignore="ContentDescription" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical">

<TextView
android:id="@+id/login_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:text="@string/no_account"
android:textColor="?attr/colorOnPrimaryContainer"
android:textSize="16sp"
android:textStyle="bold" />

<TextView
android:id="@+id/login_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/login_desc"
android:textColor="?attr/colorOnPrimaryContainer"
android:textSize="14sp" />

</LinearLayout>

</LinearLayout>

</com.google.android.material.card.MaterialCardView>

</LinearLayout>
Loading

0 comments on commit ee736ff

Please sign in to comment.