Manager: Enhanced Device Model Retrieval with One Plus' Market Name Checking
This commit is contained in:
@@ -579,16 +579,21 @@ private fun WarningCardPreview() {
|
|||||||
@SuppressLint("PrivateApi")
|
@SuppressLint("PrivateApi")
|
||||||
private fun getDeviceModel(context: Context): String {
|
private fun getDeviceModel(context: Context): String {
|
||||||
return try {
|
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 ->
|
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)
|
|
||||||
getMethod.invoke(null, "ro.product.marketname", "") as String
|
getMethod.invoke(null, "ro.product.marketname", "") as String
|
||||||
} ?: ""
|
} ?: ""
|
||||||
|
|
||||||
if (marketName.isNotEmpty()) {
|
if (marketName.isNotEmpty()) {
|
||||||
marketName
|
marketName
|
||||||
} else {
|
} else {
|
||||||
Build.DEVICE
|
val MarketName = getMethod.invoke(null, "ro.vendor.oplus.market.name", "") as String
|
||||||
|
if (MarketName.isNotEmpty()) {
|
||||||
|
MarketName
|
||||||
|
} else {
|
||||||
|
Build.DEVICE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Build.DEVICE
|
Build.DEVICE
|
||||||
|
|||||||
Reference in New Issue
Block a user