增加 RealmeUI 的判断

This commit is contained in:
2022-03-20 22:51:02 +08:00
parent f15e48d4a3
commit ee4da89104
2 changed files with 25 additions and 1 deletions

View File

@@ -68,7 +68,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
}
/** 设置文本 */
binding.mainTextVersion.text = "模块版本:$moduleVersion"
binding.mainTextColorOsVersion.text = "系统版本:$colorOSVersion"
binding.mainTextColorOsVersion.text = "系统版本:$colorOSFullVersion"
when {
/** 判断是否为 ColorOS 系统 */
isNotColorOS ->

View File

@@ -53,6 +53,7 @@ import com.highcapable.yukihookapi.hook.type.java.StringType
import com.topjohnwu.superuser.Shell
import java.io.ByteArrayOutputStream
/**
* 系统深色模式是否开启
* @return [Boolean] 是否开启
@@ -102,6 +103,29 @@ val isColorOS by lazy { ("oppo.R").hasClass || ("com.color.os.ColorBuild").hasCl
*/
inline val isNotColorOS get() = !isColorOS
/**
* 当前设备是否为 RealmeUI
* @return [Boolean] 是否符合条件
*/
val isRealmeUI
get() = safeOfFalse {
val query = appContext.contentResolver.query(
Uri.parse("content://com.oplus.customize.coreapp.configmanager.configprovider.AppFeatureProvider")
.buildUpon()
.appendPath("app_feature")
.build(), null, "featurename=?", arrayOf("com.android.launcher.device_rm"), null
)
val isExist = query != null && query.count > 0
query?.close()
isExist
}
/**
* 获取 ColorOS 完整版本
* @return [String]
*/
val colorOSFullVersion get() = "${if (isRealmeUI) "RealmeUI" else "ColorOS"} $colorOSVersion"
/**
* 获取 ColorOS 版本
* @return [String]