Skip to content

Commit 1456da1

Browse files
committed
修改判断是否在纯血鸿蒙上面运行的方法名称
1 parent 221ba68 commit 1456da1

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ DeviceOs.isMagicOs();
108108
// 判断当前设备的厂商系统是否为 HarmonyOS(华为手机、荣耀手机的系统)
109109
DeviceOs.isHarmonyOs();
110110

111-
// 判断是否在 HarmonyOS NEXT(纯血鸿蒙)的卓易通上面运行
112-
DeviceOs.isZytOnHarmonyOsNext();
111+
// 判断是否在 HarmonyOS NEXT(纯血鸿蒙)的卓易通或者出境易环境上运行
112+
DeviceOs.isHarmonyOsNextAndroidCompatible();
113113

114114
// 判断当前设备的厂商系统是否为 EMUI 或者 EmotionUI(华为手机、荣耀手机的老系统)
115115
DeviceOs.isEmui();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ private static void initMarketName(@NonNull Context context) {
389389
if (TextUtils.isEmpty(sMarketName)) {
390390
if (DeviceOs.isHarmonyOs()) {
391391
traversalMarketNameSystemPropertyKeys(MARKET_NAME_HARMONY_OS);
392-
} else if (DeviceOs.isZytOnHarmonyOsNext()) {
392+
} else if (DeviceOs.isHarmonyOsNextAndroidCompatible()) {
393393
traversalMarketNameSystemPropertyKeys(MARKET_NAME_ZYT_ON_HARMONY_OS_NEXT);
394394
} else if (DeviceOs.isMagicOs()) {
395395
traversalMarketNameSystemPropertyKeys(MARKET_NAME_MAGIC_OS);

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

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ public final class DeviceOs {
211211
static final String[] OS_CONDITIONS_NAME_MAGIC_OS = { "msc.config.magic.version",
212212
"ro.build.version.magic" };
213213

214-
static final int OS_TYPE_ZYT_ON_HARMONY_OS_NEXT = -1214041693;
215-
static final String OS_NAME_ZYT_ON_HARMONY_OS_NEXT = "HarmonyOS NEXT ZhuoYiTong";
214+
static final int OS_TYPE_HARMONY_OS_NEXT_ANDROID_COMPATIBLE = -182666708;
215+
static final String OS_NAME_HARMONY_OS_NEXT_ANDROID_COMPATIBLE = "HarmonyOS NEXT AndroidCompatible";
216216

217217
/**
218218
* HarmonyOS NEXT 6.0.0 版本属性:
@@ -226,7 +226,7 @@ public final class DeviceOs {
226226
* 所以综合取舍下来最优解是:
227227
* [ro.sys.anco.product.software.version]: [PLA-AL10 6.0.0.100(SP6C00E47R4P3)]
228228
*/
229-
static final String OS_VERSION_ZYT_ON_HARMONY_OS_NEXT = "ro.sys.anco.product.software.version";
229+
static final String OS_VERSION_HARMONY_OS_NEXT_ANDROID_COMPATIBLE = "ro.sys.anco.product.software.version";
230230

231231
/**
232232
* [ro.product.anco.devicetype]: [phone]
@@ -237,10 +237,10 @@ public final class DeviceOs {
237237
* [ro.product.os.dist.anco.releasetype]: [Release]
238238
* [ro.product.os.dist.anco.releasetype]: [Beta5]
239239
*/
240-
static final String[] OS_CONDITIONS_ZYT_ON_HARMONY_OS_NEXT = { "ro.product.anco.devicetype",
241-
OS_VERSION_ZYT_ON_HARMONY_OS_NEXT,
242-
"ro.product.os.dist.anco.apiversion",
243-
"ro.product.os.dist.anco.releasetype" };
240+
static final String[] OS_CONDITIONS_HARMONY_OS_NEXT_ANDROID_COMPATIBLE = { "ro.product.anco.devicetype",
241+
OS_VERSION_HARMONY_OS_NEXT_ANDROID_COMPATIBLE,
242+
"ro.product.os.dist.anco.apiversion",
243+
"ro.product.os.dist.anco.releasetype" };
244244

245245
/**
246246
* MagicOS 9.0 版本属性:
@@ -658,10 +658,10 @@ private DeviceOs() {
658658

659659
// 判断是否为纯血鸿蒙应该要放在残血鸿蒙之前,因为纯血鸿蒙有 persist.sys.ohos.osd.cloud.switch 这个系统属性
660660
// 经过验证得出:如果这段代码放在残血鸿蒙之后再进行判断,会出现误判的情况,所以这里需要注意代码判断的顺序
661-
if (sCurrentOsName == null && SystemPropertyCompat.isSystemPropertyAnyOneExist(OS_CONDITIONS_ZYT_ON_HARMONY_OS_NEXT)) {
662-
sCurrentOsType = OS_TYPE_ZYT_ON_HARMONY_OS_NEXT;
663-
sCurrentOsName = OS_NAME_ZYT_ON_HARMONY_OS_NEXT;
664-
sCurrentOsVersionName = getBestVersionNameBySystemProperties(OS_VERSION_ZYT_ON_HARMONY_OS_NEXT);
661+
if (sCurrentOsName == null && SystemPropertyCompat.isSystemPropertyAnyOneExist(OS_CONDITIONS_HARMONY_OS_NEXT_ANDROID_COMPATIBLE)) {
662+
sCurrentOsType = OS_TYPE_HARMONY_OS_NEXT_ANDROID_COMPATIBLE;
663+
sCurrentOsName = OS_NAME_HARMONY_OS_NEXT_ANDROID_COMPATIBLE;
664+
sCurrentOsVersionName = getBestVersionNameBySystemProperties(OS_VERSION_HARMONY_OS_NEXT_ANDROID_COMPATIBLE);
665665
}
666666

667667
if (sCurrentOsName == null && SystemPropertyCompat.isSystemPropertyAnyOneExist(OS_CONDITIONS_HARMONY_OS)) {
@@ -1038,10 +1038,17 @@ public static boolean isHarmonyOs() {
10381038
}
10391039

10401040
/**
1041-
* 判断是否在 HarmonyOS NEXT(纯血鸿蒙)的卓易通上面运行
1041+
* @deprecated 该 API 已经过时,随时会被删除,请尽早迁移到 {@link #isHarmonyOsNextAndroidCompatible()}
10421042
*/
10431043
public static boolean isZytOnHarmonyOsNext() {
1044-
return sCurrentOsType == OS_TYPE_ZYT_ON_HARMONY_OS_NEXT;
1044+
return isHarmonyOsNextAndroidCompatible();
1045+
}
1046+
1047+
/**
1048+
* 判断是否在 HarmonyOS NEXT(纯血鸿蒙)的卓易通或者出境易环境上运行
1049+
*/
1050+
public static boolean isHarmonyOsNextAndroidCompatible() {
1051+
return sCurrentOsType == OS_TYPE_HARMONY_OS_NEXT_ANDROID_COMPATIBLE;
10451052
}
10461053

10471054
/**

0 commit comments

Comments
 (0)