From 87bbb5b139682c70dda234e06d65d444781bd8d6 Mon Sep 17 00:00:00 2001 From: yuanneng Date: Wed, 13 Oct 2021 16:56:59 +0800 Subject: [PATCH] =?UTF-8?q?IssueNo:#I4DQ8Q=20Description:=E4=BB=8Econfig.j?= =?UTF-8?q?son=E4=B8=ADapp=E8=8A=82=E7=82=B9=E4=B8=8B=E6=8F=90=E5=8F=96app?= =?UTF-8?q?Name=20Sig:aafwk=20Feature=20or=20Bugfix:=20Bugfig=20Binary=20S?= =?UTF-8?q?ource:=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fenghao --- adapter/ohos/JsonUtil.java | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/adapter/ohos/JsonUtil.java b/adapter/ohos/JsonUtil.java index 34841750..35de49de 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; } -- Gitee