diff --git a/adapter/ohos/ModuleJsonUtil.java b/adapter/ohos/ModuleJsonUtil.java index bc17d3029b95f6f5575f32cdd5e6704dcbf257ea..dbae6be094b2affb272c1470fc9849c04625fbb7 100644 --- a/adapter/ohos/ModuleJsonUtil.java +++ b/adapter/ohos/ModuleJsonUtil.java @@ -90,6 +90,7 @@ class ModuleJsonUtil { private static final String COMPILE_SDK_VERSION = "compileSdkVersion"; private static final String COMPILE_SDK_TYPE = "compileSdkType"; private static final String PROXY_DATAS = "proxyDatas"; + private static final String PROXY_DATA = "proxyData"; private static final String PROXY_URI = "uri"; private static final Log LOG = new Log(ModuleJsonUtil.class.toString()); @@ -1420,18 +1421,30 @@ class ModuleJsonUtil { throw new BundleException("parse JOSNObject failed in parseProxyDataUri."); } JSONObject moduleObj = jsonObject.getJSONObject(MODULE); - if (!moduleObj.containsKey(PROXY_DATAS)) { + if (!moduleObj.containsKey(PROXY_DATAS) && !moduleObj.containsKey(PROXY_DATA)) { return proxyDataUris; - } - JSONArray proxyDatas = moduleObj.getJSONArray(PROXY_DATAS); - for (int i = 0; i < proxyDatas.size(); ++i) { - JSONObject itemObj = proxyDatas.getJSONObject(i); - if (!itemObj.containsKey(PROXY_URI)) { - LOG.error("parse JOSNObject failed in parseProxyDataUri."); - throw new BundleException("parse JOSNObject failed in parseProxyDataUri."); + } else if (moduleObj.containsKey(PROXY_DATA)) { + JSONArray proxyData = moduleObj.getJSONArray(PROXY_DATA); + for (int i = 0; i < proxyData.size(); ++i) { + JSONObject itemObj = proxyData.getJSONObject(i); + if (!itemObj.containsKey(PROXY_URI)) { + LOG.error("parse JOSNObject failed in parseProxyDataUri."); + throw new BundleException("parse JOSNObject failed in parseProxyDataUri."); + } + String uri = itemObj.getString(PROXY_URI); + proxyDataUris.add(uri); + } + } else { + JSONArray proxyDatas = moduleObj.getJSONArray(PROXY_DATAS); + for (int i = 0; i < proxyDatas.size(); ++i) { + JSONObject itemObj = proxyDatas.getJSONObject(i); + if (!itemObj.containsKey(PROXY_URI)) { + LOG.error("parse JOSNObject failed in parseProxyDataUri."); + throw new BundleException("parse JOSNObject failed in parseProxyDataUri."); + } + String uri = itemObj.getString(PROXY_URI); + proxyDataUris.add(uri); } - String uri = itemObj.getString(PROXY_URI); - proxyDataUris.add(uri); } return proxyDataUris; } diff --git a/modulecheck/module.json b/modulecheck/module.json index 7f0db5339c2e82ecd577f9f865dd844e9fff824a..90a898994522e8ac850ed0b707380fc87d3ceeef 100644 --- a/modulecheck/module.json +++ b/modulecheck/module.json @@ -128,7 +128,8 @@ "atomicService", "generateBuildHash", "proxyDatas", - "isolationMode" + "isolationMode", + "proxyData" ] }, "required": [ @@ -175,7 +176,8 @@ "atomicService", "generateBuildHash", "proxyDatas", - "isolationMode" + "isolationMode", + "proxyData" ] }, "required": [ @@ -1244,6 +1246,7 @@ }, "proxyDatas": { "description": "Indicates all the proxy data of the module.", + "deprecationMessage": "Deprecated since api 10, use proxyData instead.", "type": "array", "items": { "type": "object", @@ -1311,6 +1314,65 @@ "nonisolationFirst" ], "default": "nonisolationFirst" + }, + "proxyData": { + "description": "Indicates all the proxy data of the module.", + "type": "array", + "items": { + "type": "object", + "required": [ + "uri" + ], + "propertyNames": { + "enum": [ + "uri", + "requiredReadPermission", + "requiredWritePermission", + "metadata" + ] + }, + "properties": { + "uri": { + "description": "Indicates the uri of the data proxy.", + "type": "string", + "pattern": "^datashareproxy:", + "maxLength": 255 + }, + "requiredReadPermission": { + "description": "Indicates the permission required to read data from the proxy.", + "type": "string", + "maxLength": 255 + }, + "requiredWritePermission": { + "description": "Indicates the permission required to write data to the proxy.", + "type": "string", + "maxLength": 255 + }, + "metadata": { + "description": "Indicates the metadata of the proxy.", + "type": "object", + "propertyNames": { + "enum": [ + "name", + "resource" + ] + }, + "properties": { + "name": { + "description": "Indicates the key of a data element. The value is a string with a maximum of 255 bytes.", + "type": "string", + "maxLength": 255 + }, + "resource": { + "description": "Indicates the resource of a data element.", + "type": "string", + "pattern": "^[$]profile:[0-9a-zA-Z_.]+|(?=.*[{])(?=.*[}])[0-9a-zA-Z_.{}]+$", + "maxLength": 255 + } + } + } + } + } } } }