Manager: Enhanced Device Model Retrieval with One Plus' Market Name Checking

This commit is contained in:
ShirkNeko
2025-03-29 01:35:33 +08:00
parent 8b4ecf24f1
commit ae3c591638

View File

@@ -579,17 +579,22 @@ private fun WarningCardPreview() {
@SuppressLint("PrivateApi")
private fun getDeviceModel(context: Context): String {
return try {
val marketName = context.getSystemService(Context.APP_OPS_SERVICE)?.let { appOps ->
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
}
}
} catch (e: Exception) {
Build.DEVICE
}