Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
2629ab0c
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2629ab0c
编写于
5月 17, 2023
作者:
C
chennian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
doc排查
Signed-off-by:
N
chennian
<
chennian1@huawei.com
>
上级
dd30afa9
变更
4
展开全部
显示空白变更内容
内联
并排
Showing
4 changed file
with
631 addition
and
631 deletion
+631
-631
zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
...plication-dev/reference/apis/js-apis-abilityAccessCtrl.md
+23
-23
zh-cn/application-dev/reference/apis/js-apis-appAccount.md
zh-cn/application-dev/reference/apis/js-apis-appAccount.md
+402
-402
zh-cn/application-dev/reference/apis/js-apis-osAccount.md
zh-cn/application-dev/reference/apis/js-apis-osAccount.md
+182
-182
zh-cn/application-dev/reference/apis/js-apis-privacyManager.md
.../application-dev/reference/apis/js-apis-privacyManager.md
+24
-24
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
浏览文件 @
2629ab0c
...
...
@@ -73,7 +73,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
let
tokenID
=
0
;
// 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
try
{
atManager
.
checkAccessToken
(
tokenID
,
"
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
"
).
then
((
data
)
=>
{
atManager
.
checkAccessToken
(
tokenID
,
'
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
'
).
then
((
data
)
=>
{
console
.
log
(
`checkAccessToken success, data->
${
JSON
.
stringify
(
data
)}
`
);
}).
catch
((
err
)
=>
{
console
.
log
(
`checkAccessToken fail, err->
${
JSON
.
stringify
(
err
)}
`
);
...
...
@@ -117,7 +117,7 @@ verifyAccessTokenSync(tokenID: number, permissionName: Permissions): GrantStatus
```
js
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
let
tokenID
=
0
;
// 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
let
data
=
atManager
.
verifyAccessTokenSync
(
tokenID
,
"
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
"
);
let
data
=
atManager
.
verifyAccessTokenSync
(
tokenID
,
'
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
'
);
console
.
log
(
`data->
${
JSON
.
stringify
(
data
)}
`
);
```
...
...
@@ -168,7 +168,7 @@ let atManager = abilityAccessCtrl.createAtManager();
let
tokenID
=
0
;
// 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
let
permissionFlags
=
1
;
try
{
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
"
,
permissionFlags
).
then
(()
=>
{
atManager
.
grantUserGrantedPermission
(
tokenID
,
'
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
'
,
permissionFlags
).
then
(()
=>
{
console
.
log
(
'
grantUserGrantedPermission success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
`grantUserGrantedPermission fail, err->
${
JSON
.
stringify
(
err
)}
`
);
...
...
@@ -220,7 +220,7 @@ let atManager = abilityAccessCtrl.createAtManager();
let
tokenID
=
0
;
// 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
let
permissionFlags
=
1
;
try
{
atManager
.
grantUserGrantedPermission
(
tokenID
,
"
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
"
,
permissionFlags
,
(
err
,
data
)
=>
{
atManager
.
grantUserGrantedPermission
(
tokenID
,
'
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
'
,
permissionFlags
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`grantUserGrantedPermission fail, err->
${
JSON
.
stringify
(
err
)}
`
);
}
else
{
...
...
@@ -279,7 +279,7 @@ let atManager = abilityAccessCtrl.createAtManager();
let
tokenID
=
0
;
// 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
let
permissionFlags
=
1
;
try
{
atManager
.
revokeUserGrantedPermission
(
tokenID
,
"
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
"
,
permissionFlags
).
then
(()
=>
{
atManager
.
revokeUserGrantedPermission
(
tokenID
,
'
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
'
,
permissionFlags
).
then
(()
=>
{
console
.
log
(
'
revokeUserGrantedPermission success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
`revokeUserGrantedPermission fail, err->
${
JSON
.
stringify
(
err
)}
`
);
...
...
@@ -331,7 +331,7 @@ let atManager = abilityAccessCtrl.createAtManager();
let
tokenID
=
0
;
// 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
let
permissionFlags
=
1
;
try
{
atManager
.
revokeUserGrantedPermission
(
tokenID
,
"
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
"
,
permissionFlags
,
(
err
,
data
)
=>
{
atManager
.
revokeUserGrantedPermission
(
tokenID
,
'
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
'
,
permissionFlags
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`revokeUserGrantedPermission fail, err->
${
JSON
.
stringify
(
err
)}
`
);
}
else
{
...
...
@@ -388,7 +388,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
let
tokenID
=
0
;
// 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
try
{
atManager
.
getPermissionFlags
(
tokenID
,
"
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
"
).
then
((
data
)
=>
{
atManager
.
getPermissionFlags
(
tokenID
,
'
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
'
).
then
((
data
)
=>
{
console
.
log
(
`getPermissionFlags success, data->
${
JSON
.
stringify
(
data
)}
`
);
}).
catch
((
err
)
=>
{
console
.
log
(
`getPermissionFlags fail, err->
${
JSON
.
stringify
(
err
)}
`
);
...
...
@@ -466,10 +466,10 @@ import bundleManager from '@ohos.bundle.bundleManager';
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
let
appInfo
=
bundleManager
.
getApplicationInfoSync
(
'
com.example.myapplication
'
,
0
,
100
);
let
tokenIDList
:
Array
<
number
>
=
[
appInfo
.
accessTokenId
];
let
permissionList
:
Array
<
Permissions
>
=
[
"
ohos.permission.DISTRIBUTED_DATASYNC
"
];
let
permissionList
:
Array
<
Permissions
>
=
[
'
ohos.permission.DISTRIBUTED_DATASYNC
'
];
try
{
atManager
.
on
(
'
permissionStateChange
'
,
tokenIDList
,
permissionList
,
(
data
)
=>
{
console
.
debug
(
"
receive permission state change, data:
"
+
JSON
.
stringify
(
data
));
console
.
debug
(
'
receive permission state change, data:
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
err
)
{
console
.
log
(
`catch err->
${
JSON
.
stringify
(
err
)}
`
);
...
...
@@ -504,7 +504,7 @@ off(type: 'permissionStateChange', tokenIDList: Array<number>, permissionL
| 错误码ID | 错误信息 |
| -------- | -------- |
| 12100001 | The parameter is invalid. The tokenIDs or permissionNames in the list are all invalid. |
| 12100004 | The interface is not used together with
"on"
. |
| 12100004 | The interface is not used together with
'on'
. |
| 12100007 | Service is abnormal. |
| 12100008 | Out of memory. |
...
...
@@ -517,7 +517,7 @@ import bundleManager from '@ohos.bundle.bundleManager';
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
let
appInfo
=
bundleManager
.
getApplicationInfoSync
(
'
com.example.myapplication
'
,
0
,
100
);
let
tokenIDList
:
Array
<
number
>
=
[
appInfo
.
accessTokenId
];
let
permissionList
:
Array
<
Permissions
>
=
[
"
ohos.permission.DISTRIBUTED_DATASYNC
"
];
let
permissionList
:
Array
<
Permissions
>
=
[
'
ohos.permission.DISTRIBUTED_DATASYNC
'
];
try
{
atManager
.
off
(
'
permissionStateChange
'
,
tokenIDList
,
permissionList
);
}
catch
(
err
)
{
...
...
@@ -557,7 +557,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
let
tokenID
=
0
;
// 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
let
promise
=
atManager
.
verifyAccessToken
(
tokenID
,
"
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
"
);
let
promise
=
atManager
.
verifyAccessToken
(
tokenID
,
'
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
'
);
promise
.
then
(
data
=>
{
console
.
log
(
`promise: data->
${
JSON
.
stringify
(
data
)}
`
);
});
...
...
@@ -598,10 +598,10 @@ requestPermissionsFromUser(context: Context, permissionList: Array<Permission
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
try
{
atManager
.
requestPermissionsFromUser
(
this
.
context
,
[
"
ohos.permission.CAMERA
"
],
(
err
,
data
)
=>
{
console
.
info
(
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
data permissions:
"
+
data
.
permissions
);
console
.
info
(
"
data authResults:
"
+
data
.
authResults
);
atManager
.
requestPermissionsFromUser
(
this
.
context
,
[
'
ohos.permission.CAMERA
'
],
(
err
,
data
)
=>
{
console
.
info
(
'
data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
data permissions:
'
+
data
.
permissions
);
console
.
info
(
'
data authResults:
'
+
data
.
authResults
);
});
}
catch
(
err
)
{
console
.
log
(
`catch err->
${
JSON
.
stringify
(
err
)}
`
);
...
...
@@ -649,12 +649,12 @@ requestPermissionsFromUser(context: Context, permissionList: Array<Permission
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
try
{
atManager
.
requestPermissionsFromUser
(
this
.
context
,
[
"
ohos.permission.CAMERA
"
]).
then
((
data
)
=>
{
console
.
info
(
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
data permissions:
"
+
data
.
permissions
);
console
.
info
(
"
data authResults:
"
+
data
.
authResults
);
atManager
.
requestPermissionsFromUser
(
this
.
context
,
[
'
ohos.permission.CAMERA
'
]).
then
((
data
)
=>
{
console
.
info
(
'
data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
data permissions:
'
+
data
.
permissions
);
console
.
info
(
'
data authResults:
'
+
data
.
authResults
);
}).
catch
((
err
)
=>
{
console
.
info
(
"
data:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
'
data:
'
+
JSON
.
stringify
(
err
));
})
}
catch
(
err
)
{
console
.
log
(
`catch err->
${
JSON
.
stringify
(
err
)}
`
);
...
...
@@ -693,7 +693,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
let
tokenID
=
0
;
// 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
let
promise
=
atManager
.
verifyAccessToken
(
tokenID
,
"
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
"
);
let
promise
=
atManager
.
verifyAccessToken
(
tokenID
,
'
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
'
);
promise
.
then
(
data
=>
{
console
.
log
(
`promise: data->
${
JSON
.
stringify
(
data
)}
`
);
});
...
...
@@ -733,7 +733,7 @@ checkAccessTokenSync(tokenID: number, permissionName: Permissions): GrantStatus;
```
js
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
let
tokenID
=
0
;
// 系统应用可以通过bundleManager.getApplicationInfo获取,普通应用可以通过bundleManager.getBundleInfoForSelf获取
let
data
=
atManager
.
checkAccessTokenSync
(
tokenID
,
"
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
"
);
let
data
=
atManager
.
checkAccessTokenSync
(
tokenID
,
'
ohos.permission.GRANT_SENSITIVE_PERMISSIONS
'
);
console
.
log
(
`data->
${
JSON
.
stringify
(
data
)}
`
);
```
...
...
zh-cn/application-dev/reference/apis/js-apis-appAccount.md
浏览文件 @
2629ab0c
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-osAccount.md
浏览文件 @
2629ab0c
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-privacyManager.md
浏览文件 @
2629ab0c
...
...
@@ -58,7 +58,7 @@ import privacyManager from '@ohos.privacyManager';
let
tokenID
=
0
;
// 可以通过getApplicationInfo获取accessTokenId
try
{
privacyManager
.
addPermissionUsedRecord
(
tokenID
,
"
ohos.permission.PERMISSION_USED_STATS
"
,
1
,
0
).
then
(()
=>
{
privacyManager
.
addPermissionUsedRecord
(
tokenID
,
'
ohos.permission.PERMISSION_USED_STATS
'
,
1
,
0
).
then
(()
=>
{
console
.
log
(
'
addPermissionUsedRecord success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
`addPermissionUsedRecord fail, err->
${
JSON
.
stringify
(
err
)}
`
);
...
...
@@ -108,7 +108,7 @@ import privacyManager from '@ohos.privacyManager';
let
tokenID
=
0
;
// 可以通过getApplicationInfo获取accessTokenId
try
{
privacyManager
.
addPermissionUsedRecord
(
tokenID
,
"
ohos.permission.PERMISSION_USED_STATS
"
,
1
,
0
,
(
err
,
data
)
=>
{
privacyManager
.
addPermissionUsedRecord
(
tokenID
,
'
ohos.permission.PERMISSION_USED_STATS
'
,
1
,
0
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`addPermissionUsedRecord fail, err->
${
JSON
.
stringify
(
err
)}
`
);
}
else
{
...
...
@@ -160,14 +160,14 @@ getPermissionUsedRecord(request: PermissionUsedRequest): Promise<PermissionUs
import
privacyManager
from
'
@ohos.privacyManager
'
;
let
request
=
{
"
tokenId
"
:
1
,
"
isRemote
"
:
false
,
"
deviceId
"
:
"
device
"
,
"
bundleName
"
:
"
bundle
"
,
"
permissionNames
"
:
[],
"
beginTime
"
:
0
,
"
endTime
"
:
1
,
"
flag
"
:
privacyManager
.
PermissionUsageFlag
.
FLAG_PERMISSION_USAGE_DETAIL
,
'
tokenId
'
:
1
,
'
isRemote
'
:
false
,
'
deviceId
'
:
'
device
'
,
'
bundleName
'
:
'
bundle
'
,
'
permissionNames
'
:
[],
'
beginTime
'
:
0
,
'
endTime
'
:
1
,
'
flag
'
:
privacyManager
.
PermissionUsageFlag
.
FLAG_PERMISSION_USAGE_DETAIL
,
};
try
{
privacyManager
.
getPermissionUsedRecord
(
request
).
then
((
data
)
=>
{
...
...
@@ -215,14 +215,14 @@ getPermissionUsedRecord(request: PermissionUsedRequest, callback: AsyncCallback&
import
privacyManager
from
'
@ohos.privacyManager
'
;
let
request
=
{
"
tokenId
"
:
1
,
"
isRemote
"
:
false
,
"
deviceId
"
:
"
device
"
,
"
bundleName
"
:
"
bundle
"
,
"
permissionNames
"
:
[],
"
beginTime
"
:
0
,
"
endTime
"
:
1
,
"
flag
"
:
privacyManager
.
PermissionUsageFlag
.
FLAG_PERMISSION_USAGE_DETAIL
,
'
tokenId
'
:
1
,
'
isRemote
'
:
false
,
'
deviceId
'
:
'
device
'
,
'
bundleName
'
:
'
bundle
'
,
'
permissionNames
'
:
[],
'
beginTime
'
:
0
,
'
endTime
'
:
1
,
'
flag
'
:
privacyManager
.
PermissionUsageFlag
.
FLAG_PERMISSION_USAGE_DETAIL
,
};
try
{
privacyManager
.
getPermissionUsedRecord
(
request
,
(
err
,
data
)
=>
{
...
...
@@ -280,7 +280,7 @@ import privacyManager from '@ohos.privacyManager';
let
tokenID
=
0
;
// 可以通过getApplicationInfo获取accessTokenId
try
{
privacyManager
.
startUsingPermission
(
tokenID
,
"
ohos.permission.PERMISSION_USED_STATS
"
).
then
(()
=>
{
privacyManager
.
startUsingPermission
(
tokenID
,
'
ohos.permission.PERMISSION_USED_STATS
'
).
then
(()
=>
{
console
.
log
(
'
startUsingPermission success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
`startUsingPermission fail, err->
${
JSON
.
stringify
(
err
)}
`
);
...
...
@@ -328,7 +328,7 @@ import privacyManager from '@ohos.privacyManager';
let
tokenID
=
0
;
// 可以通过getApplicationInfo获取accessTokenId
try
{
privacyManager
.
startUsingPermission
(
tokenID
,
"
ohos.permission.PERMISSION_USED_STATS
"
,
(
err
,
data
)
=>
{
privacyManager
.
startUsingPermission
(
tokenID
,
'
ohos.permission.PERMISSION_USED_STATS
'
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`startUsingPermission fail, err->
${
JSON
.
stringify
(
err
)}
`
);
}
else
{
...
...
@@ -383,7 +383,7 @@ import privacyManager from '@ohos.privacyManager';
let
tokenID
=
0
;
// 可以通过getApplicationInfo获取accessTokenId
try
{
privacyManager
.
stopUsingPermission
(
tokenID
,
"
ohos.permission.PERMISSION_USED_STATS
"
).
then
(()
=>
{
privacyManager
.
stopUsingPermission
(
tokenID
,
'
ohos.permission.PERMISSION_USED_STATS
'
).
then
(()
=>
{
console
.
log
(
'
stopUsingPermission success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
`stopUsingPermission fail, err->
${
JSON
.
stringify
(
err
)}
`
);
...
...
@@ -431,7 +431,7 @@ import privacyManager from '@ohos.privacyManager';
let
tokenID
=
0
;
// 可以通过getApplicationInfo获取accessTokenId
try
{
privacyManager
.
stopUsingPermission
(
tokenID
,
"
ohos.permission.PERMISSION_USED_STATS
"
,
(
err
,
data
)
=>
{
privacyManager
.
stopUsingPermission
(
tokenID
,
'
ohos.permission.PERMISSION_USED_STATS
'
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`stopUsingPermission fail, err->
${
JSON
.
stringify
(
err
)}
`
);
}
else
{
...
...
@@ -481,7 +481,7 @@ import privacyManager from '@ohos.privacyManager';
let
permissionList
=
[];
try
{
privacyManager
.
on
(
'
activeStateChange
'
,
permissionList
,
(
data
)
=>
{
console
.
debug
(
"
receive permission state change, data:
"
+
JSON
.
stringify
(
data
));
console
.
debug
(
'
receive permission state change, data:
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
err
)
{
console
.
log
(
`catch err->
${
JSON
.
stringify
(
err
)}
`
);
...
...
@@ -513,7 +513,7 @@ off(type: 'activeStateChange', permissionList: Array<Permissions>, callbac
| 错误码ID | 错误信息 |
| -------- | -------- |
| 12100001 | The permissionNames in the list are all invalid, or the list size exceeds 1024 bytes. |
| 12100004 | The interface is not used together with
"on"
|
| 12100004 | The interface is not used together with
'on'
|
| 12100007 | Service is abnormal. |
| 12100008 | Out of memory. |
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录