From ff37e403e0d74446fa7baf75543f431f391ac0de Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Wed, 19 Jul 2023 16:30:48 +0800 Subject: [PATCH] update docs Signed-off-by: Annie_wang --- .../apis/js-apis-uripermissionmanager.md | 73 +++++++++++++++++-- 1 file changed, 65 insertions(+), 8 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-uripermissionmanager.md b/en/application-dev/reference/apis/js-apis-uripermissionmanager.md index c066b5d483..609bdf9e0b 100644 --- a/en/application-dev/reference/apis/js-apis-uripermissionmanager.md +++ b/en/application-dev/reference/apis/js-apis-uripermissionmanager.md @@ -6,7 +6,6 @@ The **uriPermissionManager** module provides APIs for granting permissions on a file to or revoking the granted permission from an application. The file is identified by a uniform resource identifier (URI). - ## Modules to Import @@ -14,15 +13,18 @@ The **uriPermissionManager** module provides APIs for granting permissions on a import uriPermissionManager from '@ohos.application.uriPermissionManager'; ``` - ## uriPermissionManager.grantUriPermission -grantUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number, callback: AsyncCallback<number>): void +grantUriPermission(uri: string, flag: wantConstant.Flags, targetBundleName: string, callback: AsyncCallback<number>): void; Grants permission on the file of the specified URI to an application. This API uses an asynchronous callback to return the result. +**System API**: This is a system API and cannot be called by third-party applications. + **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**Required permissions**: ohos.permission.PROXY_AUTHORIZATION_URI + **Parameters** | Name| Type| Mandatory| Description| @@ -32,6 +34,18 @@ Grants permission on the file of the specified URI to an application. This API u | targetBundleName | string | Yes| Bundle name of the application, to which the permission is granted.| | callback | AsyncCallback<number> | Yes| Callback invoked to return the result. If the operation is successful, **0** is returned; otherwise, **-1** is returned.| +**Error codes** + + | ID| Error Message| + | -------- | -------- | + | 201 | Permissions denied. | + | 202 | Not System App. Interface caller is not a system app. | + | 401 | The parameter check failed. | + | 16500050 | Internal error. | + | 16500058 | Invalid URI flag. | + | 16500059 | Invalid URI type. | + | 16500060 | Sandbox application can not grant URI permission. | + **Example** ```js @@ -46,12 +60,16 @@ Grants permission on the file of the specified URI to an application. This API u ## uriPermissionManager.grantUriPermission -grantUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number): Promise<number> +grantUriPermission(uri: string, flag: wantConstant.Flags, targetBundleName: string): Promise<number> Grants permission on the file of the specified URI to an application. This API uses a promise to return the result. +**System API**: This is a system API and cannot be called by third-party applications. + **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**Required permissions**: ohos.permission.PROXY_AUTHORIZATION_URI + **Parameters** | Name| Type| Mandatory| Description| @@ -66,13 +84,25 @@ Grants permission on the file of the specified URI to an application. This API u | -------- | -------- | | Promise<number> | Promise used to return the result. If the operation is successful, **0** is returned; otherwise, **-1** is returned.| +**Error codes** + + | ID| Error Message| + | -------- | -------- | + | 201 | Permissions denied. | + | 202 | Not System App. Interface caller is not a system app. | + | 401 | The parameter check failed. | + | 16500050 | Internal error. | + | 16500058 | Invalid URI flag. | + | 16500059 | Invalid URI type. | + | 16500060 | Sandbox application can not grant URI permission. | + **Example** ```js import WantConstant from '@ohos.ability.wantConstant'; let targetBundleName = 'com.example.test_case1' let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10" - uriPermissionManager.grantUriPermission(uri, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, targetBundleName) + uriPermissionManager.grantUriPermission(uri, WantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, targetBundleName) .then((data) => { console.log('Verification succeeded.' + data) }).catch((error) => { @@ -81,12 +111,16 @@ Grants permission on the file of the specified URI to an application. This API u ``` ## uriPermissionManager.revokeUriPermission -revokeUriPermission(uri: string, accessTokenId: number, callback: AsyncCallback<number>): void +revokeUriPermission(uri: string, targetBundleName: string, callback: AsyncCallback<number>): void; Revokes the permission on the file of the specified URI from an application. This API uses an asynchronous callback to return the result. +**System API**: This is a system API and cannot be called by third-party applications. + **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**Required permissions**: ohos.permission.PROXY_AUTHORIZATION_URI + **Parameters** | Name| Type| Mandatory| Description| @@ -95,13 +129,22 @@ Revokes the permission on the file of the specified URI from an application. Thi | targetBundleName | string | Yes| Bundle name of the application, from which the permission is revoked.| | callback | AsyncCallback<number> | Yes| Callback invoked to return the result. If the operation is successful, **0** is returned; otherwise, **-1** is returned.| +**Error codes** + + | ID| Error Message| + | -------- | -------- | + | 201 | Permissions denied. | + | 202 | Not System App. Interface caller is not a system app. | + | 401 | The parameter check failed. | + | 16500059 | Invalid URI type. | + **Example** ```js import WantConstant from '@ohos.ability.wantConstant'; let targetBundleName = 'com.example.test_case1' let URI = "fileshare:///com.samples.filesharetest.FileShare/person/10" - uriPermissionManager.revokeUriPermission(uri, targetBundleName, (result) => { + uriPermissionManager.revokeUriPermission(URI, targetBundleName, (result) => { console.log("result.code = " + result.code) }) ``` @@ -109,12 +152,17 @@ Revokes the permission on the file of the specified URI from an application. Thi ## uriPermissionManager.revokeUriPermission -revokeUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number): Promise<number> +revokeUriPermission(uri: string, targetBundleName: string): Promise<number> Revokes the permission on the file of the specified URI from an application. This API uses a promise to return the result. +**System API**: This is a system API and cannot be called by third-party applications. + **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**Required permissions**: ohos.permission.PROXY_AUTHORIZATION_URI + + **Parameters** | Name| Type| Mandatory| Description| @@ -128,6 +176,15 @@ Revokes the permission on the file of the specified URI from an application. Thi | -------- | -------- | | Promise<number> | Promise used to return the result. If the operation is successful, **0** is returned; otherwise, **-1** is returned.| +**Error codes** + + | ID| Error Message| + | -------- | -------- | + | 201 | Permissions denied. | + | 202 | Not System App. Interface caller is not a system app. | + | 401 | The parameter check failed. | + | 16500059 | Invalid URI type. | + **Example** ```js -- GitLab