Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
af85432a
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看板
未验证
提交
af85432a
编写于
9月 16, 2022
作者:
O
openharmony_ci
提交者:
Gitee
9月 16, 2022
浏览文件
操作
浏览文件
下载
差异文件
!9567 docs一致性整改
Merge pull request !9567 from fanchenxuan/master
上级
7a4f4d87
2133792a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
76 addition
and
64 deletion
+76
-64
zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
...plication-dev/reference/apis/js-apis-abilityAccessCtrl.md
+4
-4
zh-cn/application-dev/reference/apis/js-apis-privacyManager.md
.../application-dev/reference/apis/js-apis-privacyManager.md
+72
-60
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md
浏览文件 @
af85432a
...
@@ -339,8 +339,8 @@ function OnPermissionStateChanged(data){
...
@@ -339,8 +339,8 @@ function OnPermissionStateChanged(data){
}
}
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
let
type
:
'
permissionStateChange
'
=
'
permissionStateChange
'
;
let
type
:
'
permissionStateChange
'
=
'
permissionStateChange
'
;
let
tokenIDList
:
Array
&
lt
;
number
&
gt
;
=
[];
let
tokenIDList
:
Array
<
number
>
=
[];
let
permissionNameList
:
Array
&
lt
;
string
&
gt
;
=
[];
let
permissionNameList
:
Array
<
string
>
=
[];
try
{
try
{
atManager
.
on
(
type
,
tokenIDList
,
permissionNameList
,
OnPermissionStateChanged
);
atManager
.
on
(
type
,
tokenIDList
,
permissionNameList
,
OnPermissionStateChanged
);
}
}
...
@@ -377,8 +377,8 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
...
@@ -377,8 +377,8 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
let
atManager
=
abilityAccessCtrl
.
createAtManager
();
let
type
:
'
permissionStateChange
'
=
'
permissionStateChange
'
;
let
type
:
'
permissionStateChange
'
=
'
permissionStateChange
'
;
let
tokenIDList
:
Array
&
lt
;
number
&
gt
;
=
[];
let
tokenIDList
:
Array
<
number
>
=
[];
let
permissionNameList
:
Array
&
lt
;
string
&
gt
;
=
[];
let
permissionNameList
:
Array
<
string
>
=
[];
try
{
try
{
atManager
.
off
(
type
,
tokenIDList
,
permissionNameList
);
atManager
.
off
(
type
,
tokenIDList
,
permissionNameList
);
}
}
...
...
zh-cn/application-dev/reference/apis/js-apis-privacyManager.md
浏览文件 @
af85432a
...
@@ -45,13 +45,15 @@ addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: n
...
@@ -45,13 +45,15 @@ addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: n
import
bundle
from
'
@ohos.bundle
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
privacyManager
from
'
@ohos.privacyManager
'
;
import
privacyManager
from
'
@ohos.privacyManager
'
;
let
bundleName
=
"
com.ohos.permissionmanager
"
;
// change to your bundle name
async
addPermissionUsedRecord
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
bundleName
,
16
);
// need async type function
let
bundleName
=
"
com.ohos.permissionmanager
"
;
// change to your bundle name
let
appInfo
=
await
bundle
.
getApplicationInfo
(
bundleName
,
16
);
// need async type function
var
tokenID
=
appInfo
.
accessTokenId
;
// 可以通过getApplicationInfo获取accessTokenId
privacyManager
.
addPermissionUsedRecord
(
tokenID
,
"
ohos.permission.PERMISSION_USED_STATS
"
,
1
,
0
).
then
(
data
=>
{
var
tokenID
=
appInfo
.
accessTokenId
;
// 可以通过getApplicationInfo获取accessTokenId
console
.
log
(
`promise: data->
${
JSON
.
stringify
(
data
)}
`
);
privacyManager
.
addPermissionUsedRecord
(
tokenID
,
"
ohos.permission.PERMISSION_USED_STATS
"
,
1
,
0
).
then
(
data
=>
{
});
console
.
log
(
`promise: data->
${
JSON
.
stringify
(
data
)}
`
);
});
}
```
```
## privacyManager.addPermissionUsedRecord
## privacyManager.addPermissionUsedRecord
...
@@ -81,13 +83,15 @@ addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: n
...
@@ -81,13 +83,15 @@ addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: n
import
bundle
from
'
@ohos.bundle
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
privacyManager
from
'
@ohos.privacyManager
'
;
import
privacyManager
from
'
@ohos.privacyManager
'
;
let
bundleName
=
"
com.ohos.permissionmanager
"
;
// change to your bundle name
async
addPermissionUsedRecord
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
bundleName
,
16
);
// need async type function
let
bundleName
=
"
com.ohos.permissionmanager
"
;
// change to your bundle name
let
appInfo
=
await
bundle
.
getApplicationInfo
(
bundleName
,
16
);
// need async type function
var
tokenID
=
appInfo
.
accessTokenId
;
// 可以通过getApplicationInfo获取accessTokenId
privacyManager
.
addPermissionUsedRecord
(
tokenID
,
"
ohos.permission.PERMISSION_USED_STATS
"
,
1
,
0
,
(
err
,
data
)
=>
{
var
tokenID
=
appInfo
.
accessTokenId
;
// 可以通过getApplicationInfo获取accessTokenId
console
.
log
(
`callback: data->
${
JSON
.
stringify
(
data
)}
`
);
privacyManager
.
addPermissionUsedRecord
(
tokenID
,
"
ohos.permission.PERMISSION_USED_STATS
"
,
1
,
0
,
(
err
,
data
)
=>
{
});
console
.
log
(
`callback: data->
${
JSON
.
stringify
(
data
)}
`
);
});
}
```
```
## privacyManager.getPermissionUsedRecords
## privacyManager.getPermissionUsedRecords
...
@@ -194,16 +198,18 @@ startUsingPermission(tokenID: number, permissionName: string): Promise<number
...
@@ -194,16 +198,18 @@ startUsingPermission(tokenID: number, permissionName: string): Promise<number
import
bundle
from
'
@ohos.bundle
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
privacyManager
from
'
@ohos.privacyManager
'
;
import
privacyManager
from
'
@ohos.privacyManager
'
;
let
bundleName
=
"
com.ohos.permissionmanager
"
;
// change to your bundle name
async
startUsingPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
bundleName
,
16
);
// need async type function
let
bundleName
=
"
com.ohos.permissionmanager
"
;
// change to your bundle name
let
appInfo
=
await
bundle
.
getApplicationInfo
(
bundleName
,
16
);
// need async type function
let
tokenID
=
appInfo
.
accessTokenId
;
let
permissionName
=
"
ohos.permission.CAMERA
"
;
let
tokenID
=
appInfo
.
accessTokenId
;
privacyManager
.
startUsingPermission
(
tokenID
,
permissionName
).
then
(
data
=>
{
let
permissionName
=
"
ohos.permission.CAMERA
"
;
console
.
log
(
`promise: data->
${
JSON
.
stringify
(
data
)}
`
);
privacyManager
.
startUsingPermission
(
tokenID
,
permissionName
).
then
(
data
=>
{
}).
catch
(
err
=>
{
console
.
log
(
`promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`Error: err->
${
JSON
.
stringify
(
err
)}
`
);
}).
catch
(
err
=>
{
});
console
.
log
(
`Error: err->
${
JSON
.
stringify
(
err
)}
`
);
});
}
```
```
## privacyManager.startUsingPermission<sup>9+</sup>
## privacyManager.startUsingPermission<sup>9+</sup>
...
@@ -230,18 +236,20 @@ startUsingPermission(tokenID: number, permissionName: string, callback: AsyncCal
...
@@ -230,18 +236,20 @@ startUsingPermission(tokenID: number, permissionName: string, callback: AsyncCal
import
bundle
from
'
@ohos.bundle
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
privacyManager
from
'
@ohos.privacyManager
'
;
import
privacyManager
from
'
@ohos.privacyManager
'
;
let
bundleName
=
"
com.ohos.permissionmanager
"
;
// change to your bundle name
async
startUsingPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
bundleName
,
16
);
// need async type function
let
bundleName
=
"
com.ohos.permissionmanager
"
;
// change to your bundle name
let
appInfo
=
await
bundle
.
getApplicationInfo
(
bundleName
,
16
);
// need async type function
let
tokenID
=
appInfo
.
accessTokenId
;
let
permissionName
=
"
ohos.permission.CAMERA
"
;
let
tokenID
=
appInfo
.
accessTokenId
;
privacyManager
.
startUsingPermission
(
tokenID
,
permissionName
,
(
err
,
data
)
=>
{
let
permissionName
=
"
ohos.permission.CAMERA
"
;
if
(
err
)
{
privacyManager
.
startUsingPermission
(
tokenID
,
permissionName
,
(
err
,
data
)
=>
{
console
.
log
(
`Error: err->
${
JSON
.
stringify
(
err
)}
`
);
if
(
err
)
{
}
else
{
console
.
log
(
`Error: err->
${
JSON
.
stringify
(
err
)}
`
);
console
.
log
(
`promise: data->
${
JSON
.
stringify
(
data
)}
`
);
}
else
{
}
console
.
log
(
`promise: data->
${
JSON
.
stringify
(
data
)}
`
);
});
}
});
}
```
```
## privacyManager.stopUsingPermission<sup>9+</sup>
## privacyManager.stopUsingPermission<sup>9+</sup>
...
@@ -273,16 +281,18 @@ stopUsingPermission(tokenID: number, permissionName: string): Promise<number&
...
@@ -273,16 +281,18 @@ stopUsingPermission(tokenID: number, permissionName: string): Promise<number&
import
bundle
from
'
@ohos.bundle
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
privacyManager
from
'
@ohos.privacyManager
'
;
import
privacyManager
from
'
@ohos.privacyManager
'
;
let
bundleName
=
"
com.ohos.permissionmanager
"
;
// change to your bundle name
async
stopUsingPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
bundleName
,
16
);
// need async type function
let
bundleName
=
"
com.ohos.permissionmanager
"
;
// change to your bundle name
let
appInfo
=
await
bundle
.
getApplicationInfo
(
bundleName
,
16
);
// need async type function
let
tokenID
=
appInfo
.
accessTokenId
;
let
permissionName
=
"
ohos.permission.CAMERA
"
;
let
tokenID
=
appInfo
.
accessTokenId
;
privacyManager
.
stopUsingPermission
(
tokenID
,
permissionName
).
then
(
data
=>
{
let
permissionName
=
"
ohos.permission.CAMERA
"
;
console
.
log
(
`promise: data->
${
JSON
.
stringify
(
data
)}
`
);
privacyManager
.
stopUsingPermission
(
tokenID
,
permissionName
).
then
(
data
=>
{
}).
catch
(
err
=>
{
console
.
log
(
`promise: data->
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`Error: err->
${
JSON
.
stringify
(
err
)}
`
);
}).
catch
(
err
=>
{
});
console
.
log
(
`Error: err->
${
JSON
.
stringify
(
err
)}
`
);
});
}
```
```
## privacyManager.stopUsingPermission<sup>9+</sup>
## privacyManager.stopUsingPermission<sup>9+</sup>
...
@@ -309,18 +319,20 @@ stopUsingPermission(tokenID: number, permissionName: string, callback: AsyncCall
...
@@ -309,18 +319,20 @@ stopUsingPermission(tokenID: number, permissionName: string, callback: AsyncCall
import
bundle
from
'
@ohos.bundle
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
privacyManager
from
'
@ohos.privacyManager
'
;
import
privacyManager
from
'
@ohos.privacyManager
'
;
let
bundleName
=
"
com.ohos.permissionmanager
"
;
// change to your bundle name
async
stopUsingPermission
()
{
let
appInfo
=
await
bundle
.
getApplicationInfo
(
bundleName
,
16
);
// need async type function
let
bundleName
=
"
com.ohos.permissionmanager
"
;
// change to your bundle name
let
appInfo
=
await
bundle
.
getApplicationInfo
(
bundleName
,
16
);
// need async type function
let
tokenID
=
appInfo
.
accessTokenId
;
let
permissionName
=
"
ohos.permission.CAMERA
"
;
let
tokenID
=
appInfo
.
accessTokenId
;
privacyManager
.
privacyManager
.
stopUsingPermission
(
tokenID
,
permissionName
,
(
err
,
data
)
=>
{
let
permissionName
=
"
ohos.permission.CAMERA
"
;
if
(
err
)
{
privacyManager
.
privacyManager
.
stopUsingPermission
(
tokenID
,
permissionName
,
(
err
,
data
)
=>
{
console
.
log
(
`Error: err->
${
JSON
.
stringify
(
err
)}
`
);
if
(
err
)
{
}
else
{
console
.
log
(
`Error: err->
${
JSON
.
stringify
(
err
)}
`
);
console
.
log
(
`promise: data->
${
JSON
.
stringify
(
data
)}
`
);
}
else
{
}
console
.
log
(
`promise: data->
${
JSON
.
stringify
(
data
)}
`
);
});
}
});
}
```
```
## privacyManager.on<sup>9+</sup>
## privacyManager.on<sup>9+</sup>
...
@@ -352,7 +364,7 @@ function OnPermissionUseStateChanged(data){
...
@@ -352,7 +364,7 @@ function OnPermissionUseStateChanged(data){
console
.
debug
(
"
receive permission state change, data:
"
+
JSON
.
stringify
(
data
));
console
.
debug
(
"
receive permission state change, data:
"
+
JSON
.
stringify
(
data
));
}
}
let
type
:
'
activeStateChange
'
=
'
activeStateChange
'
;
let
type
:
'
activeStateChange
'
=
'
activeStateChange
'
;
let
permissionNameList
:
Array
&
lt
;
string
&
gt
;
=
[];
let
permissionNameList
:
Array
<
string
>
=
[];
try
{
try
{
privacyManager
.
on
(
type
,
permissionNameList
,
OnPermissionUseStateChanged
);
privacyManager
.
on
(
type
,
permissionNameList
,
OnPermissionUseStateChanged
);
}
}
...
@@ -387,7 +399,7 @@ off(type: 'activeStateChange', permissionNameList: Array<string>, callback
...
@@ -387,7 +399,7 @@ off(type: 'activeStateChange', permissionNameList: Array<string>, callback
import
privacyManager
from
'
@ohos.privacyManager
'
;
import
privacyManager
from
'
@ohos.privacyManager
'
;
let
type
:
'
activeStateChange
'
=
'
activeStateChange
'
;
let
type
:
'
activeStateChange
'
=
'
activeStateChange
'
;
let
permissionNameList
:
Array
&
lt
;
string
&
gt
;
=
[];
let
permissionNameList
:
Array
<
string
>
=
[];
try
{
try
{
privacyManager
.
off
(
type
,
permissionNameList
);
privacyManager
.
off
(
type
,
permissionNameList
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录