manager: Add kpmmgr to build workflows and optimize device model retrieval logic

This commit is contained in:
ShirkNeko
2025-03-29 16:03:56 +08:00
parent e6baa7fe56
commit 11ec41aadb
2 changed files with 31 additions and 12 deletions

View File

@@ -581,20 +581,18 @@ private fun getDeviceModel(context: Context): String {
return try {
val systemProperties = Class.forName("android.os.SystemProperties")
val getMethod = systemProperties.getMethod("get", String::class.java, String::class.java)
val marketName = context.getSystemService(Context.APP_OPS_SERVICE)?.let { appOps ->
getMethod.invoke(null, "ro.product.marketname", "") as String
} ?: ""
if (marketName.isNotEmpty()) {
marketName
} else {
val MarketName = getMethod.invoke(null, "ro.vendor.oplus.market.name", "") as String
if (MarketName.isNotEmpty()) {
MarketName
} else {
Build.DEVICE
val marketNameKeys = listOf(
"ro.product.marketname",
"ro.vendor.oplus.market.name",
"ro.vivo.market.name"
)
for (key in marketNameKeys) {
val marketName = getMethod.invoke(null, key, "") as String
if (marketName.isNotEmpty()) {
return marketName
}
}
Build.DEVICE
} catch (e: Exception) {
Build.DEVICE
}