未验证 提交 c2f4697a 编写于 作者: O openharmony_ci 提交者: Gitee

!21102 [翻译完成】#I7GB48

Merge pull request !21102 from Annie_wang/PR20161
...@@ -6,7 +6,6 @@ ...@@ -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). 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 ## Modules to Import
...@@ -14,15 +13,18 @@ The **uriPermissionManager** module provides APIs for granting permissions on a ...@@ -14,15 +13,18 @@ The **uriPermissionManager** module provides APIs for granting permissions on a
import uriPermissionManager from '@ohos.application.uriPermissionManager'; import uriPermissionManager from '@ohos.application.uriPermissionManager';
``` ```
## uriPermissionManager.grantUriPermission ## 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. 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 **System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Required permissions**: ohos.permission.PROXY_AUTHORIZATION_URI
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -32,6 +34,18 @@ Grants permission on the file of the specified URI to an application. This API u ...@@ -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.| | 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.| | 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** **Example**
```js ```js
...@@ -46,12 +60,16 @@ Grants permission on the file of the specified URI to an application. This API u ...@@ -46,12 +60,16 @@ Grants permission on the file of the specified URI to an application. This API u
## uriPermissionManager.grantUriPermission ## 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. 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 **System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Required permissions**: ohos.permission.PROXY_AUTHORIZATION_URI
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -66,13 +84,25 @@ Grants permission on the file of the specified URI to an application. This API u ...@@ -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.| | 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** **Example**
```js ```js
import WantConstant from '@ohos.ability.wantConstant'; import WantConstant from '@ohos.ability.wantConstant';
let targetBundleName = 'com.example.test_case1' let targetBundleName = 'com.example.test_case1'
let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10" 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) => { .then((data) => {
console.log('Verification succeeded.' + data) console.log('Verification succeeded.' + data)
}).catch((error) => { }).catch((error) => {
...@@ -81,12 +111,16 @@ Grants permission on the file of the specified URI to an application. This API u ...@@ -81,12 +111,16 @@ Grants permission on the file of the specified URI to an application. This API u
``` ```
## uriPermissionManager.revokeUriPermission ## 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. 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 **System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Required permissions**: ohos.permission.PROXY_AUTHORIZATION_URI
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -95,13 +129,22 @@ Revokes the permission on the file of the specified URI from an application. Thi ...@@ -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.| | 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.| | 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** **Example**
```js ```js
import WantConstant from '@ohos.ability.wantConstant'; import WantConstant from '@ohos.ability.wantConstant';
let targetBundleName = 'com.example.test_case1' let targetBundleName = 'com.example.test_case1'
let URI = "fileshare:///com.samples.filesharetest.FileShare/person/10" 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) console.log("result.code = " + result.code)
}) })
``` ```
...@@ -109,12 +152,17 @@ Revokes the permission on the file of the specified URI from an application. Thi ...@@ -109,12 +152,17 @@ Revokes the permission on the file of the specified URI from an application. Thi
## uriPermissionManager.revokeUriPermission ## 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. 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 **System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Required permissions**: ohos.permission.PROXY_AUTHORIZATION_URI
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -128,6 +176,15 @@ Revokes the permission on the file of the specified URI from an application. Thi ...@@ -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.| | 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** **Example**
```js ```js
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册