From 0419f12d94198142a7e6d064ec704889fa5e6dc6 Mon Sep 17 00:00:00 2001 From: xushizhe Date: Tue, 22 Aug 2023 20:11:38 +0800 Subject: [PATCH 1/2] code slim Signed-off-by: xushizhe --- adapter/ohos/Compressor.java | 33 +-- adapter/ohos/ModuleJsonUtil.java | 343 +++++-------------------------- 2 files changed, 55 insertions(+), 321 deletions(-) diff --git a/adapter/ohos/Compressor.java b/adapter/ohos/Compressor.java index 59e4e3fd..1b1bc74f 100644 --- a/adapter/ohos/Compressor.java +++ b/adapter/ohos/Compressor.java @@ -1794,7 +1794,7 @@ public class Compressor { zipEntry.setSize(srcFile.length()); // update crc - CRC32 crc = getCrcFromFile(utility, srcFile); + CRC32 crc = getCrcFromFile(srcFile); zipEntry.setCrc(crc.getValue()); } @@ -1857,37 +1857,6 @@ public class Compressor { return false; } - /** - * get CRC32 from file. - * - * @param utility common data - * @param file source file - * @return CRC32 - * @throws BundleException FileNotFoundException|IOException. - */ - private CRC32 getCrcFromFile(Utility utility, File file) throws BundleException { - FileInputStream fileInputStream = null; - CRC32 crc = new CRC32(); - try { - fileInputStream = new FileInputStream(file); - byte[] buffer = new byte[BUFFER_SIZE]; - - int count = fileInputStream.read(buffer); - while (count > 0) { - crc.update(buffer, 0, count); - count = fileInputStream.read(buffer); - } - } catch (FileNotFoundException ignored) { - throw new BundleException("Get Crc from file failed."); - } catch (IOException exception) { - LOG.error("Compressor::getCrcFromFile io exception: " + exception.getMessage()); - throw new BundleException("Get Crc from file failed."); - } finally { - Utility.closeStream(fileInputStream); - } - return crc; - } - private void infoSpecialProcess(Utility utility, File srcFile) throws BundleException { FileInputStream fileInputStream = null; diff --git a/adapter/ohos/ModuleJsonUtil.java b/adapter/ohos/ModuleJsonUtil.java index 752a3443..cc4f3b8c 100644 --- a/adapter/ohos/ModuleJsonUtil.java +++ b/adapter/ohos/ModuleJsonUtil.java @@ -364,19 +364,7 @@ class ModuleJsonUtil { * @throws BundleException Throws this exception if the json is not standard. */ public static String parseBundleName(String jsonString) throws BundleException { - JSONObject jsonObject; - try { - jsonObject = JSON.parseObject(jsonString); - } catch (JSONException exception) { - String errMsg = "parse JSONobject failed."; - LOG.error(errMsg); - throw new BundleException(errMsg); - } - JSONObject appObject = jsonObject.getJSONObject(APP); - if (appObject == null) { - LOG.error("ModuleJsonUtil::parseStageBundleName json object do not contain app."); - throw new BundleException("ModuleJsonUtil::parseStageBundleName json object do not contain app."); - } + JSONObject appObject = getAppObj(jsonString); String bundleName = ""; if (appObject.containsKey(BUNDLE_NAME)) { bundleName = appObject.getString(BUNDLE_NAME); @@ -395,19 +383,7 @@ class ModuleJsonUtil { * @throws BundleException Throws this exception if the json is not standard. */ public static String parseVendor(String jsonString) throws BundleException { - JSONObject jsonObject; - try { - jsonObject = JSON.parseObject(jsonString); - } catch (JSONException exception) { - String errMsg = "parse JSONobject failed."; - LOG.error(errMsg); - throw new BundleException(errMsg); - } - JSONObject appObject = jsonObject.getJSONObject(APP); - if (appObject == null) { - LOG.error("ModuleJsonUtil::parseStageBundleName json object do not contain app."); - throw new BundleException("ModuleJsonUtil::parseStageBundleName json object do not contain app."); - } + JSONObject appObject = getAppObj(jsonString); String vendor = ""; if (appObject.containsKey(VENDOR)) { vendor = appObject.getString(VENDOR); @@ -1122,17 +1098,9 @@ class ModuleJsonUtil { * @return ability names */ public static List parseAbilityNames(String jsonString) throws BundleException { - JSONObject jsonObj; - try { - jsonObj = JSON.parseObject(jsonString); - } catch (JSONException exception) { - String errMsg = "parse JSONobject failed."; - LOG.error(errMsg); - throw new BundleException(errMsg); - } List abilityNames = new ArrayList<>(); - JSONObject moduleObj = jsonObj.getJSONObject(MODULE); - if (moduleObj != null && moduleObj.containsKey(ABILITIES)) { + JSONObject moduleObj = getModuleObj(jsonString); + if (moduleObj.containsKey(ABILITIES)) { JSONArray abilityObjs = moduleObj.getJSONArray(ABILITIES); for (int i = 0; i < abilityObjs.size(); ++i) { JSONObject abilityObj = abilityObjs.getJSONObject(i); @@ -1152,19 +1120,7 @@ class ModuleJsonUtil { * @return extensionAbilityNames */ public static List parseExtensionAbilityName(String jsonString) throws BundleException { - JSONObject jsonObj; - try { - jsonObj = JSON.parseObject(jsonString); - } catch (JSONException exception) { - String errMsg = "parse JSONobject failed."; - LOG.error(errMsg); - throw new BundleException(errMsg); - } - JSONObject moduleObj = jsonObj.getJSONObject(MODULE); - if (moduleObj == null) { - LOG.error("ModuleJsonUtil::parseExtensionAbilityName failed, module is null."); - throw new BundleException("ModuleJsonUtil::parseExtensionAbilityName failed, module is null."); - } + JSONObject moduleObj = getModuleObj(jsonString); List extensionAbilityNames = new ArrayList<>(); if (moduleObj.containsKey(EXTENSION_ABILITIES)) { JSONArray extensionAbilityObjs = moduleObj.getJSONArray(EXTENSION_ABILITIES); @@ -1230,19 +1186,7 @@ class ModuleJsonUtil { } static List parseDependencies(String jsonString, String bundleName) throws BundleException { - JSONObject jsonObj; - try { - jsonObj = JSON.parseObject(jsonString); - } catch (JSONException exception) { - String errMsg = "parse json object failed."; - LOG.error(errMsg); - throw new BundleException(errMsg); - } - JSONObject moduleObj = jsonObj.getJSONObject(MODULE); - if (moduleObj == null) { - LOG.error("parseDependencies failed: lack of module object."); - throw new BundleException("parseDependencies failed: lack of module object."); - } + JSONObject moduleObj = getModuleObj(jsonString); List dependencyItemList = new ArrayList<>(); if (!moduleObj.containsKey(DEPENDENCIES)) { return dependencyItemList; @@ -1265,19 +1209,7 @@ class ModuleJsonUtil { } static boolean parseStageInstallation(String jsonString) throws BundleException { - JSONObject jsonObj; - try { - jsonObj = JSON.parseObject(jsonString); - } catch (JSONException exception) { - String errMsg = "parse JSONobject failed."; - LOG.error(errMsg); - throw new BundleException(errMsg); - } - JSONObject moduleObj = jsonObj.getJSONObject(MODULE); - if (moduleObj == null) { - LOG.error("ModuleJsonUtil::parseStageInstallation json do not contain module."); - throw new BundleException("ModuleJsonUtil::parseStageInstallation json do not contain module."); - } + JSONObject moduleObj = getModuleObj(jsonString); if (moduleObj.containsKey(INSTALLATION_FREE)) { return moduleObj.getBoolean(INSTALLATION_FREE); } @@ -1349,14 +1281,7 @@ class ModuleJsonUtil { static List parseAtomicServicePreloads(String jsonString) throws BundleException { List preloadItems = new ArrayList<>(); - JSONObject jsonObject; - try { - jsonObject = JSON.parseObject(jsonString); - } catch (JSONException exception) { - LOG.error("parse JOSNObject failed in getStageAsanEnabled."); - throw new BundleException("parse JOSNObject failed in getStageAsanEnabled."); - } - JSONObject moduleObj = jsonObject.getJSONObject(MODULE); + JSONObject moduleObj = getModuleObj(jsonString); JSONObject atomicServiceObj = null; if (!moduleObj.containsKey(ATOMIC_SERVICE)) { return preloadItems; @@ -1379,14 +1304,7 @@ class ModuleJsonUtil { static List parseProxyDataUri(String jsonString) throws BundleException { List proxyDataUris = new ArrayList<>(); - JSONObject jsonObject; - try { - jsonObject = JSON.parseObject(jsonString); - } catch (JSONException exception) { - LOG.error("parse JOSNObject failed in parseProxyDataUri."); - throw new BundleException("parse JOSNObject failed in parseProxyDataUri."); - } - JSONObject moduleObj = jsonObject.getJSONObject(MODULE); + JSONObject moduleObj = getModuleObj(jsonString); if (!moduleObj.containsKey(PROXY_DATAS) && !moduleObj.containsKey(PROXY_DATA)) { return proxyDataUris; } else if (moduleObj.containsKey(PROXY_DATA)) { @@ -1432,7 +1350,7 @@ class ModuleJsonUtil { return appObj; } - static String parseTargetBundleName(String jsonString) throws BundleException { + static JSONObject getModuleObj(String jsonString) throws BundleException { JSONObject jsonObject; try { jsonObject = JSON.parseObject(jsonString); @@ -1441,11 +1359,16 @@ class ModuleJsonUtil { LOG.error(errMsg); throw new BundleException(errMsg); } - JSONObject appObject = jsonObject.getJSONObject(APP); - if (appObject == null) { - LOG.error("ModuleJsonUtil::parseTargetBundleName json object do not contain app."); - throw new BundleException("ModuleJsonUtil::parseTargetBundleName json object do not contain app."); + JSONObject moduleObj = jsonObject.getJSONObject(MODULE); + if (moduleObj == null) { + LOG.error("ModuleJsonUtil::parseStageInstallation json do not contain module."); + throw new BundleException("ModuleJsonUtil::parseStageInstallation json do not contain module."); } + return moduleObj; + } + + static String parseTargetBundleName(String jsonString) throws BundleException { + JSONObject appObject = getAppObj(jsonString); String targetBundleName = ""; if (appObject.containsKey(TARGET_BUNDLE_NAME)) { targetBundleName = appObject.getString(TARGET_BUNDLE_NAME); @@ -1454,19 +1377,8 @@ class ModuleJsonUtil { } static int parseTargetPriority(String jsonString) throws BundleException { - JSONObject jsonObject; - try { - jsonObject = JSON.parseObject(jsonString); - } catch (JSONException exception) { - String errMsg = "parse JSONobject failed."; - LOG.error(errMsg); - throw new BundleException(errMsg); - } - JSONObject appObject = jsonObject.getJSONObject(APP); - if (appObject == null) { - LOG.error("ModuleJsonUtil::parseTargetPriority json object do not contain app."); - throw new BundleException("ModuleJsonUtil::parseTargetPriority json object do not contain app."); - } + JSONObject appObject = getAppObj(jsonString); + int targetPriority = 0; if (appObject.containsKey(TARGET_PRIORITY)) { targetPriority = appObject.getIntValue(TARGET_PRIORITY); @@ -1475,61 +1387,26 @@ class ModuleJsonUtil { } static String parseTargetModuleName(String jsonString) throws BundleException { - JSONObject jsonObject; - try { - jsonObject = JSON.parseObject(jsonString); - } catch (JSONException exception) { - String errMsg = "parse JSONobject failed."; - LOG.error(errMsg); - throw new BundleException(errMsg); - } - JSONObject appObject = jsonObject.getJSONObject(MODULE); - if (appObject == null) { - LOG.error("ModuleJsonUtil::parseTargetBundleName json object do not contain app."); - throw new BundleException("ModuleJsonUtil::parseTargetBundleName json object do not contain app."); - } + JSONObject moduleObject = getModuleObj(jsonString); String targetModuleName = ""; - if (appObject.containsKey(TARGET_MODULE_NAME)) { - targetModuleName = appObject.getString(TARGET_MODULE_NAME); + if (moduleObject.containsKey(TARGET_MODULE_NAME)) { + targetModuleName = moduleObject.getString(TARGET_MODULE_NAME); } return targetModuleName; } static int parseTargetModulePriority(String jsonString) throws BundleException { - JSONObject jsonObject; - try { - jsonObject = JSON.parseObject(jsonString); - } catch (JSONException exception) { - String errMsg = "parse JSONobject failed."; - LOG.error(errMsg); - throw new BundleException(errMsg); - } - JSONObject appObject = jsonObject.getJSONObject(MODULE); - if (appObject == null) { - LOG.error("ModuleJsonUtil::parseTargetPriority json object do not contain app."); - throw new BundleException("ModuleJsonUtil::parseTargetPriority json object do not contain app."); - } + JSONObject moduleObject = getModuleObj(jsonString); int targetModulePriority = 0; - if (appObject.containsKey(TARGET_PRIORITY)) { - targetModulePriority = appObject.getIntValue(TARGET_PRIORITY); + if (moduleObject.containsKey(TARGET_PRIORITY)) { + targetModulePriority = moduleObject.getIntValue(TARGET_PRIORITY); } return targetModulePriority; } static boolean parseFAInstallationFree(String jsonString) throws BundleException { - JSONObject jsonObject; - try { - jsonObject = JSON.parseObject(jsonString); - } catch (JSONException exception) { - String errMsg = "parse JSONobject failed."; - LOG.error(errMsg); - throw new BundleException(errMsg); - } - JSONObject moduleObj = jsonObject.getJSONObject(MODULE); - if (moduleObj == null) { - LOG.error("ModuleJsonUtil::parseStageInstallation json do not contain module."); - throw new BundleException("ModuleJsonUtil::parseStageInstallation json do not contain module."); - } + JSONObject moduleObj = getModuleObj(jsonString); + JSONObject distroObj = moduleObj.getJSONObject(DISTRO); if (distroObj == null) { LOG.error("ModuleJsonUtil::parseStageInstallation json do not contain distro."); @@ -1560,21 +1437,9 @@ class ModuleJsonUtil { * @return HQFVerifyInfo */ static HQFInfo parsePatch(String jsonString) throws BundleException { - JSONObject jsonObject; - try { - jsonObject = JSON.parseObject(jsonString); - } catch (JSONException exception) { - String errMsg = "parse JSONobject failed."; - LOG.error(errMsg); - throw new BundleException(errMsg); - } - JSONObject moduleObj = jsonObject.getJSONObject(MODULE); - if (moduleObj == null) { - LOG.error("parse failed, input patch.json is invalid, patch.json has no module."); - throw new BundleException("parse failed, input patch.json is invalid, patch.json has no module."); - } + JSONObject moduleObj = getModuleObj(jsonString); + JSONObject appObj = getAppObj(jsonString); - JSONObject appObj = jsonObject.getJSONObject(APP); HQFInfo hqfVerifyInfo = new HQFInfo(); if (appObj.containsKey(BUNDLE_NAME)) { hqfVerifyInfo.setBundleName(appObj.getString(BUNDLE_NAME)); @@ -1613,19 +1478,8 @@ class ModuleJsonUtil { * @return the result */ public static boolean stageIsCompressNativeLibs(String jsonString) throws BundleException { - JSONObject jsonObject; - try { - jsonObject = JSON.parseObject(jsonString); - } catch (JSONException exception) { - String errMsg = "parse JSONobject failed."; - LOG.error(errMsg); - throw new BundleException(errMsg); - } - JSONObject moduleObj = jsonObject.getJSONObject(MODULE); - if (moduleObj == null) { - LOG.error("parse failed, input module.json is invalid, module.json has no module."); - throw new BundleException("parse failed, input module.json is invalid, module.json has no module."); - } + JSONObject moduleObj = getModuleObj(jsonString); + if (moduleObj.containsKey(COMPRESS_NATIVE_LIBS)) { return moduleObj.getBoolean(COMPRESS_NATIVE_LIBS); } @@ -1640,18 +1494,7 @@ class ModuleJsonUtil { * @return the value of asanEnabled */ public static boolean getStageAsanEnabled(String jsonString) throws BundleException { - JSONObject jsonObject; - try { - jsonObject = JSON.parseObject(jsonString); - } catch (JSONException exception) { - LOG.error("parse JOSNObject failed in getStageAsanEnabled."); - throw new BundleException("parse JOSNObject failed in getStageAsanEnabled."); - } - JSONObject appObj = jsonObject.getJSONObject(APP); - if (appObj == null) { - LOG.error("parse failed, input module.json is invalid, module.json has no app."); - throw new BundleException("parse failed, input module.json is invalid, module.json has no app."); - } + JSONObject appObj = getAppObj(jsonString); if (appObj.containsKey(ASAN_ENABLED)) { return appObj.getBoolean(ASAN_ENABLED); } @@ -1665,18 +1508,7 @@ class ModuleJsonUtil { * @return the result */ public static String getStageApiReleaseType(String jsonString) throws BundleException { - JSONObject jsonObject; - try { - jsonObject = JSON.parseObject(jsonString); - } catch (JSONException exception) { - LOG.error("parse JOSNObject failed in getStageApiReleaseType."); - throw new BundleException("parse JOSNObject failed in getStageApiReleaseType."); - } - JSONObject appObj = jsonObject.getJSONObject(APP); - if (appObj == null) { - LOG.error("parse failed, input module.json is invalid, module.json has no app."); - throw new BundleException("parse failed, input module.json is invalid, module.json has no app."); - } + JSONObject appObj = getAppObj(jsonString); return getJsonString(appObj, API_RELEASE_TYPE); } @@ -1764,23 +1596,11 @@ class ModuleJsonUtil { */ public static String getCompileSdkVersion(String jsonString) throws BundleException { String compileSdkVersion = ""; - JSONObject jsonObject; - try { - jsonObject = JSON.parseObject(jsonString); - JSONObject appObj = jsonObject.getJSONObject(APP); - if (appObj == null) { - LOG.error("ModuleJsonUtil:parseStageModuleName failed: json file do not contain app."); - throw new BundleException("ModuleJsonUtil:parseStageModuleName failed: json file do not contain app."); - } - if (appObj.containsKey(COMPILE_SDK_VERSION)) { - compileSdkVersion = appObj.getString(COMPILE_SDK_VERSION); - } else { - LOG.warning( - "ModuleJsonUtil:getCompileSdkType failed: json file do not contain module compileSdkVersion."); - } - } catch (BundleException e) { - LOG.error("ModuleJsonUtil:parseStageModuleName failed."); - throw new BundleException("ModuleJsonUtil:parseStageModuleName failed."); + JSONObject appObj = getAppObj(jsonString); + if (appObj.containsKey(COMPILE_SDK_VERSION)) { + compileSdkVersion = appObj.getString(COMPILE_SDK_VERSION); + } else { + LOG.warning("ModuleJsonUtil:getCompileSdkType failed: json file do not contain compileSdkVersion."); } return compileSdkVersion; } @@ -1793,17 +1613,11 @@ class ModuleJsonUtil { */ public static String getCompileSdkType(String jsonString) throws BundleException { String compileSdkType = ""; - try { - JSONObject appObj = getAppObj(jsonString); - if (appObj.containsKey(COMPILE_SDK_TYPE)) { - compileSdkType = appObj.getString(COMPILE_SDK_TYPE); - } else { - LOG.warning( - "ModuleJsonUtil:getCompileSdkType failed: json file do not contain module compileSdkType."); - } - } catch (BundleException e) { - LOG.error("ModuleJsonUtil:parseStageModuleName failed."); - throw new BundleException("ModuleJsonUtil:parseStageModuleName failed."); + JSONObject appObj = getAppObj(jsonString); + if (appObj.containsKey(COMPILE_SDK_TYPE)) { + compileSdkType = appObj.getString(COMPILE_SDK_TYPE); + } else { + LOG.warning("ModuleJsonUtil:getCompileSdkType failed: json file do not contain compileSdkType."); } return compileSdkType; } @@ -1815,18 +1629,8 @@ class ModuleJsonUtil { * @return the result */ public static String getStageTargetModuleName(String jsonString) throws BundleException { - JSONObject jsonObject; - try { - jsonObject = JSON.parseObject(jsonString); - } catch (JSONException exception) { - LOG.error("parse JOSNObject failed in getStageTargetModuleName."); - throw new BundleException("parse JOSNObject failed in getStageTargetModuleName."); - } - JSONObject moduleObj = jsonObject.getJSONObject(MODULE); - if (moduleObj == null) { - LOG.error("parse failed, input module.json is invalid, module.json has no app."); - throw new BundleException("parse failed, input module.json is invalid, module.json has no app."); - } + JSONObject moduleObj = getModuleObj(jsonString); + return getJsonString(moduleObj, TARGET_MODULE_NAME); } @@ -1926,26 +1730,12 @@ class ModuleJsonUtil { * @throws BundleException Throws this exception if the json is not standard. */ public static boolean isModuleAtomicServiceValid(String jsonString) throws BundleException { - JSONObject jsonObject; - try { - jsonObject = JSON.parseObject(jsonString); - } catch (JSONException exception) { - LOG.error("parse JOSNObject failed in getStageApiReleaseType."); - throw new BundleException("parse JOSNObject failed in getStageApiReleaseType."); - } - JSONObject moduleObj = jsonObject.getJSONObject(MODULE); - if (moduleObj == null) { - LOG.error("parse failed, input config.json is invalid, config.json has no module."); - throw new BundleException("parse failed, input config.json is invalid, module.json has no app."); - } + JSONObject moduleObj = getModuleObj(jsonString); if (!moduleObj.containsKey(ATOMIC_SERVICE)) { return true; } - JSONObject appObj = jsonObject.getJSONObject(APP); - if (appObj == null) { - LOG.error("parse failed, input config.json is invalid, module.json has no app."); - throw new BundleException("parse failed, input config.json is invalid, module.json has no app."); - } + + JSONObject appObj = getAppObj(jsonString); if (moduleObj.containsKey(ATOMIC_SERVICE) && (!appObj.containsKey(BUNDLE_TYPE) || !getJsonString(appObj, BUNDLE_TYPE).equals(ATOMIC_SERVICE))) { LOG.error("module can not config atomicService when bundleType is not atomicService."); @@ -1961,18 +1751,7 @@ class ModuleJsonUtil { * @return Returns true if jsonString is valid. */ public static boolean checkEntryInAtomicService(String jsonString) throws BundleException { - JSONObject jsonObject; - try { - jsonObject = JSON.parseObject(jsonString); - } catch (JSONException exception) { - LOG.error("parse JOSNObject failed in getStageApiReleaseType."); - throw new BundleException("parse JOSNObject failed in getStageApiReleaseType."); - } - JSONObject moduleObj = jsonObject.getJSONObject(MODULE); - if (moduleObj == null) { - LOG.error("parse failed, input config.json is invalid, config.json has no module."); - throw new BundleException("parse failed, input config.json is invalid, module.json has no app."); - } + JSONObject moduleObj = getModuleObj(jsonString); if (!parseStageBundleType(jsonString).equals(ATOMIC_SERVICE)) { return true; } @@ -1991,23 +1770,9 @@ class ModuleJsonUtil { * @throws BundleException Throws this exception if the json is not standard. */ public static boolean checkAtomicServiceInstallationFree(String jsonString) throws BundleException { - JSONObject jsonObject; - try { - jsonObject = JSON.parseObject(jsonString); - } catch (JSONException exception) { - LOG.error("parse JOSNObject failed in getStageApiReleaseType."); - throw new BundleException("parse JOSNObject failed in getStageApiReleaseType."); - } - JSONObject moduleObj = jsonObject.getJSONObject(MODULE); - if (moduleObj == null) { - LOG.error("parse failed, input config.json is invalid, config.json has no module."); - throw new BundleException("parse failed, input config.json is invalid, module.json has no app."); - } - JSONObject appObj = jsonObject.getJSONObject(APP); - if (appObj == null) { - LOG.error("parse failed, input config.json is invalid, module.json has no app."); - throw new BundleException("parse failed, input config.json is invalid, module.json has no app."); - } + JSONObject moduleObj = getModuleObj(jsonString); + JSONObject appObj = getAppObj(jsonString); + boolean installationFree = getJsonBooleanValue(moduleObj, INSTALLATION_FREE, false); if (!appObj.containsKey(BUNDLE_TYPE)) { if (installationFree) { -- Gitee From 62cf452f2e6a1bb4e5dc807d3645778723c334a1 Mon Sep 17 00:00:00 2001 From: xushizhe Date: Thu, 7 Sep 2023 16:30:52 +0800 Subject: [PATCH 2/2] add device type '2in1' Signed-off-by: xushizhe --- adapter/ohos/Compressor.java | 4 ++-- adapter/ohos/JsonUtil.java | 2 ++ modulecheck/module.json | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/adapter/ohos/Compressor.java b/adapter/ohos/Compressor.java index 7719818b..ddde108c 100644 --- a/adapter/ohos/Compressor.java +++ b/adapter/ohos/Compressor.java @@ -96,7 +96,7 @@ public class Compressor { private static final String REGEX_SCRIPT = "^[A-Z][a-z]{3}$"; private static final String REGEX_COUNTRY = "^[A-Z]{2,3}|[0-9]{3}$"; private static final String REGEX_ORIENTATION = "^vertical|horizontal$"; - private static final String REGEX_DEVICE_TYPE = "^phone|tablet|car|tv|wearable|liteWearable$"; + private static final String REGEX_DEVICE_TYPE = "^phone|tablet|car|tv|wearable|liteWearable|2in1$"; private static final String REGEX_SCREEN_DENSITY = "^sdpi|mdpi|ldpi|xldpi|xxldpi$"; private static final String REGEX_COLOR_MODE = "^light|dark$"; private static final String REGEX_SHAPE = "^circle$"; @@ -1490,7 +1490,7 @@ public class Compressor { private boolean checkDeviceType(String deviceType) { if (!Pattern.compile(REGEX_DEVICE_TYPE).matcher(deviceType).matches()) { LOG.error("Compressor::compressProcess deviceType " + deviceType + - " is not in {phone, tablet, car, tv, wearable, liteWearable} list."); + " is not in {phone, tablet, car, tv, wearable, liteWearable, 2in1} list."); return false; } return true; diff --git a/adapter/ohos/JsonUtil.java b/adapter/ohos/JsonUtil.java index 9fd5bd72..73eb572c 100644 --- a/adapter/ohos/JsonUtil.java +++ b/adapter/ohos/JsonUtil.java @@ -101,6 +101,7 @@ public class JsonUtil { private static final String SPEAKER = "speaker"; private static final String LINK_IOT = "linkIOT"; private static final String ROUTER = "router"; + private static final String TWO_IN_ONE = "2in1"; private static final String DELIVERY_WITH_INSTALL = "deliveryWithInstall"; private static final String INSTALLATION_FREE = "installationFree"; private static final String VIRTUAL_MACHINE = "virtualMachine"; @@ -467,6 +468,7 @@ public class JsonUtil { parseDeviceType(appJson, moduleAppInfo, SPEAKER); parseDeviceType(appJson, moduleAppInfo, LINK_IOT); parseDeviceType(appJson, moduleAppInfo, ROUTER); + parseDeviceType(appJson, moduleAppInfo, TWO_IN_ONE); } /** diff --git a/modulecheck/module.json b/modulecheck/module.json index 9a3c3416..b770b7f3 100644 --- a/modulecheck/module.json +++ b/modulecheck/module.json @@ -241,7 +241,8 @@ "tablet", "tv", "wearable", - "car" + "car", + "2in1" ] } }, -- Gitee