Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
7cc8e447
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7cc8e447
编写于
6月 27, 2023
作者:
Y
yuyaozhi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix error vod
Signed-off-by:
N
yuyaozhi
<
yuyaozhi@huawei.com
>
上级
cdf3d872
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
65 addition
and
8 deletion
+65
-8
zh-cn/application-dev/reference/apis/js-apis-uripermissionmanager.md
...cation-dev/reference/apis/js-apis-uripermissionmanager.md
+65
-8
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-uripermissionmanager.md
浏览文件 @
7cc8e447
...
...
@@ -6,7 +6,6 @@
URI权限管理模块。用于应用A授权/撤销授权URI给应用B
## 导入模块
...
...
@@ -14,15 +13,18 @@ URI权限管理模块。用于应用A授权/撤销授权URI给应用B
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;
授权URI给指定应用,通过callback返回结果。
**系统API**
:该接口为系统接口,三方应用不支持调用。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**需要权限:**
ohos.permission.PROXY_AUTHORIZATION_URI
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -32,6 +34,18 @@ grantUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number,
| targetBundleName | string | 是 | 被授权URI的应用包名 |
| callback | AsyncCallback
<
number
>
| 是 | callback形式返回检验结果,返回0表示有权限,返回-1表示无权限。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 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. |
**示例:**
```
js
...
...
@@ -46,12 +60,16 @@ grantUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number,
## uriPermissionManager.grantUriPermission
grantUriPermission(uri: string, flag: wantConstant.Flags,
accessTokenId: number
): Promise
<
number
>
grantUriPermission(uri: string, flag: wantConstant.Flags,
targetBundleName: string
): Promise
<
number
>
授权URI给指定应用,通过返回值返回结果。
**系统API**
:该接口为系统接口,三方应用不支持调用。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**需要权限:**
ohos.permission.PROXY_AUTHORIZATION_URI
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -66,13 +84,25 @@ grantUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number)
| -------- | -------- |
| Promise
<
number
>
| 返回0表示有权限,返回-1表示无权限。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 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. |
**示例:**
```
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
,
w
antConstant
.
Flags
.
FLAG_AUTH_READ_URI_PERMISSION
,
targetBundleName
)
uriPermissionManager
.
grantUriPermission
(
uri
,
W
antConstant
.
Flags
.
FLAG_AUTH_READ_URI_PERMISSION
,
targetBundleName
)
.
then
((
data
)
=>
{
console
.
log
(
'
Verification succeeded.
'
+
data
)
}).
catch
((
error
)
=>
{
...
...
@@ -81,12 +111,16 @@ grantUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number)
```
## uriPermissionManager.revokeUriPermission
revokeUriPermission(uri: string,
accessTokenId: number, callback: AsyncCallback
<
number
>
): void
revokeUriPermission(uri: string,
targetBundleName: string, callback: AsyncCallback
<
number
>
): void;
撤销授权指定应用的URI,通过callback返回结果。
**系统API**
:该接口为系统接口,三方应用不支持调用。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**需要权限:**
ohos.permission.PROXY_AUTHORIZATION_URI
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -95,13 +129,22 @@ revokeUriPermission(uri: string, accessTokenId: number, callback: AsyncCallback&
| targetBundleName | string | 是 | 被撤销授权uri的应用包名 |
| callback | AsyncCallback
<
number
>
| 是 | callback形式返回检验结果,返回0表示有权限,返回-1表示无权限。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | Not System App. Interface caller is not a system app. |
| 401 | The parameter check failed. |
| 16500059 | Invalid URI type. |
**示例:**
```
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 @@ revokeUriPermission(uri: string, accessTokenId: number, callback: AsyncCallback&
## uriPermissionManager.revokeUriPermission
revokeUriPermission(uri: string,
flag: wantConstant.Flags, accessTokenId: number
): Promise
<
number
>
revokeUriPermission(uri: string,
targetBundleName: string
): Promise
<
number
>
撤销授权指定应用的URI,通过返回值返回结果。
**系统API**
:该接口为系统接口,三方应用不支持调用。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**需要权限:**
ohos.permission.PROXY_AUTHORIZATION_URI
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -128,6 +176,15 @@ revokeUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number
| -------- | -------- |
| Promise
<
number
>
| 返回0表示有权限,返回-1表示无权限。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 201 | Permissions denied. |
| 202 | Not System App. Interface caller is not a system app. |
| 401 | The parameter check failed. |
| 16500059 | Invalid URI type. |
**示例:**
```
js
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录