更换系统版本识别方案

This commit is contained in:
2022-03-05 00:52:10 +08:00
parent efbd919482
commit cd4b9794c4
3 changed files with 5 additions and 5 deletions

View File

@@ -60,7 +60,7 @@ class MainActivity : BaseActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
/** 设置文本 */
findViewById<TextView>(R.id.main_text_version).text = "当前版本:$moduleVersion"
findViewById<TextView>(R.id.main_text_version).text = "模块版本:$moduleVersion"
findViewById<TextView>(R.id.main_text_coloros_version).text = "系统版本:$colorOSVersion"
when {
/** 判断是否为 ColorOS 系统 */

View File

@@ -107,12 +107,12 @@ inline val isNotColorOS get() = !isColorOS
*/
val colorOSVersion
get() = safeOf(default = "无法获取") {
classOf(name = "com.oplus.os.OplusBuild").let {
(classOf(name = "com.oplus.os.OplusBuild").let {
it.field { name = "VERSIONS" }.ignoredError().of<Array<String>>()
?.get((it.method { name = "getOplusOSVERSION" }.ignoredError().get().invoke<Int>() ?: 23) - 1)
} ?: findPropString(key = "ro.system.build.fingerprint", default = "无法获取")
.split("ssi:")[1]
.split("/")[0].trim()
.split("/")[0].trim()) + " ${Build.DISPLAY}"
}
/**

View File

@@ -86,7 +86,7 @@
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:alpha="0.8"
android:text="当前版本:%1"
android:text="模块版本:%1"
android:textColor="@color/white"
android:textSize="13sp" />
@@ -95,7 +95,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.8"
android:text="ColorOS 版本:%1"
android:text="系统版本:%1"
android:textColor="@color/white"
android:textSize="13sp" />
</LinearLayout>