Skip to content

Commit c75fd54

Browse files
committed
优化高版本 ColorOS 获取系统版本的颗粒度
1 parent 0eb589e commit c75fd54

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

library/src/main/java/com/hjq/device/compat/DeviceOs.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,28 @@ public final class DeviceOs {
115115
/**
116116
* ColorOS 高版本:
117117
* [ro.build.version.oplusrom]: [V12.1]
118-
*
118+
*/
119+
static final String OS_CONDITIONS_NAME_COLOR_OS_NEW = "ro.build.version.oplusrom";
120+
121+
/**
122+
* ColorOS 高版本:
123+
* [ro.build.display.id]: [IN2010_13.1.0.190(CN01)]
124+
* [ro.build.display.id.show]: [PJD110_15.0.0.840(CN01)]
125+
* [persist.sys.oplus.ota_ver_display]: [IN2010_13.1.0.190(CN01)]
126+
* [ro.build.version.oplusrom]: [V13.1.0]
127+
* [ro.build.version.oplusrom.confidential]: [V13.1.0]
128+
*/
129+
static final String[] OS_VERSION_NAME_COLOR_OS_NEW = { SYSTEM_PROPERTY_BUILD_DISPLAY_ID,
130+
"ro.build.display.id.show",
131+
"persist.sys.oplus.ota_ver_display",
132+
OS_CONDITIONS_NAME_COLOR_OS_NEW,
133+
"ro.build.version.oplusrom.confidential" };
134+
135+
/**
119136
* ColorOS 低版本:
120137
* [ro.build.version.opporom]: [V11.2]
121138
*/
122-
static final String[] OS_VERSION_NAME_COLOR_OS = { "ro.build.version.oplusrom",
123-
"ro.build.version.opporom" };
139+
static final String OS_VERSION_NAME_COLOR_OS_OLD = "ro.build.version.opporom";
124140

125141
/* ---------------------------------------- 下面是 VIVO 的系统 ---------------------------------------- */
126142

@@ -622,8 +638,13 @@ private DeviceOs() {
622638
sCurrentOsType = OS_TYPE_REALME_UI;
623639
sCurrentOsName = OS_NAME_REALME_UI;
624640
sCurrentOsVersionName = getBestVersionNameByText(realmeUiVersion);
641+
} else if (SystemPropertyCompat.isSystemPropertyExist(OS_CONDITIONS_NAME_COLOR_OS_NEW)) {
642+
sCurrentOsType = OS_TYPE_COLOR_OS;
643+
sCurrentOsName = OS_NAME_COLOR_OS;
644+
// Github issue 地址:https://github.com/getActivity/DeviceCompat/issues/10
645+
sCurrentOsVersionName = getBestVersionNameBySystemProperties(OS_VERSION_NAME_COLOR_OS_NEW);
625646
} else {
626-
String colorOsVersion = SystemPropertyCompat.getSystemPropertyAnyOneValue(OS_VERSION_NAME_COLOR_OS);
647+
String colorOsVersion = SystemPropertyCompat.getSystemPropertyValue(OS_VERSION_NAME_COLOR_OS_OLD);
627648
if (!TextUtils.isEmpty(colorOsVersion)) {
628649
sCurrentOsType = OS_TYPE_COLOR_OS;
629650
sCurrentOsName = OS_NAME_COLOR_OS;

0 commit comments

Comments
 (0)