Skip to content

Commit

Permalink
chore: improve version display
Browse files Browse the repository at this point in the history
  • Loading branch information
septs committed May 26, 2024
1 parent 0f295ed commit 69e3b9e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
17 changes: 15 additions & 2 deletions app/src/main/java/app/septs/euiccprobe/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,23 @@ class MainActivity : AppCompatActivity() {
private suspend fun init() = withContext(Dispatchers.Main) {
val markdown = buildString {
appendLine(runBlocking {
val model = Build.MODEL.removePrefix(Build.BRAND).trim()
return@runBlocking "${Build.BRAND} $model (${Build.MANUFACTURER})"
val parts = mutableListOf(
Build.BRAND,
Build.MODEL.removePrefix(Build.BRAND).trim(),
)
if (!Build.BRAND.contentEquals(Build.MANUFACTURER, ignoreCase = true)) {
parts.add("(${Build.MANUFACTURER})")
}
parts.joinToString(" ")
})
appendLine()
appendLine(runBlocking {
val parts = mutableListOf(
"Android ${Build.VERSION.RELEASE}",
)
Version.getVersion()?.let { parts.add(it) }
parts.joinToString("; ")
})
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
val state = SystemService.getEuiccServiceState(applicationContext)
appendLine()
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/app/septs/euiccprobe/Version.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package app.septs.euiccprobe

object Version {
fun getVersion(): String? {
val miVersion = SystemProperties.get("ro.mi.os.version.code")
val miuiVersion = SystemProperties.get("ro.miui.ui.version.name")
val oneuiVersion = SystemProperties.get("ro.build.version.oneui")
return when {
miVersion != null -> "HyperOS $miVersion"
miuiVersion != null -> "MIUI $miuiVersion"
oneuiVersion != null -> "OneUI $oneuiVersion"
else -> null
}
}
}

0 comments on commit 69e3b9e

Please sign in to comment.