diff --git a/adapter/ohos/JsonUtil.java b/adapter/ohos/JsonUtil.java index 34841750ea3d99f1562475a95a0fd63d4b05e506..35de49dedec55c1a82938bc0ba1ea916a64e7933 100644 --- a/adapter/ohos/JsonUtil.java +++ b/adapter/ohos/JsonUtil.java @@ -152,7 +152,7 @@ public class JsonUtil { } if (jsonObject.containsKey(APP)) { JSONObject appJson = jsonObject.getJSONObject(APP); - profileInfo.appInfo = parseAppInfo(appJson); + profileInfo.appInfo = parseAppInfo(appJson, data); } if (jsonObject.containsKey("module")) { JSONObject hapJson = jsonObject.getJSONObject("module"); @@ -162,6 +162,12 @@ public class JsonUtil { JSONObject deviceConfigJson = jsonObject.getJSONObject("deviceConfig"); profileInfo.deviceConfig = parseDeviceConfigInfo(deviceConfigJson, profileInfo.hapInfo.deviceType); } + if (!parseShellVersionInfoToAppInfo(paclInfoJsonString, profileInfo.appInfo)) { + profileInfo.appInfo.setDefaultShellVersion(); + } + if (!profileInfo.appInfo.appName.isEmpty()) { + return profileInfo; + } if (profileInfo.hapInfo.abilities.size() == 1) { profileInfo.appInfo.appName = profileInfo.hapInfo.abilities.get(0).label; @@ -182,10 +188,6 @@ public class JsonUtil { } } } - - if (!parseShellVersionInfoToAppInfo(paclInfoJsonString, profileInfo.appInfo)) { - profileInfo.appInfo.setDefaultShellVersion(); - } return profileInfo; } @@ -193,10 +195,11 @@ public class JsonUtil { * parse app info * * @param appJson global json Object + * @param data resource index data * @return the parseAppInfo result * @throws BundleException Throws this exception if the json is not standard. */ - static AppInfo parseAppInfo(JSONObject appJson) throws BundleException { + static AppInfo parseAppInfo(JSONObject appJson, byte[] data) throws BundleException { AppInfo appInfo = new AppInfo(); if (appJson == null) { LOG.error("Uncompress::parseAppInfo exception: appJson is null"); @@ -216,6 +219,18 @@ public class JsonUtil { appInfo.targetApiVersion = apiVersion.getIntValue("target"); appInfo.releaseType = getJsonString(apiVersion, "releaseType"); } + String labelRes = ""; + if (appJson.containsKey("labelId")) { + int labelId = appJson.getIntValue("labelId"); + labelRes = ResourcesParser.getBaseResourceById(labelId, data); + } + if (labelRes != null && !labelRes.isEmpty()) { + appInfo.appName = labelRes; + appInfo.appNameEN = labelRes; + } else if (appJson.containsKey("label")) { + appInfo.appName = getJsonString(appJson, "label"); + appInfo.appNameEN = getJsonString(appJson, "label"); + } appInfo.setMultiFrameworkBundle(appJson.getBooleanValue(MULTI_FRAMEWORK_BUNDLE)); return appInfo; }