Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
9a6ca42e
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,发现更多精彩内容 >>
提交
9a6ca42e
编写于
12月 24, 2022
作者:
zyjhandsome
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://gitee.com/openharmony/docs
上级
f6cb200c
4fe41944
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
507 addition
and
216 deletion
+507
-216
zh-cn/application-dev/application-test/arkxtest-guidelines.md
...n/application-dev/application-test/arkxtest-guidelines.md
+159
-5
zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md
...-dev/reference/apis/js-apis-app-ability-missionManager.md
+74
-25
zh-cn/application-dev/reference/apis/js-apis-application-missionManager.md
...-dev/reference/apis/js-apis-application-missionManager.md
+69
-24
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionInfo.md
...v/reference/apis/js-apis-inner-application-missionInfo.md
+23
-12
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionListener.md
...ference/apis/js-apis-inner-application-missionListener.md
+8
-3
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionSnapshot.md
...ference/apis/js-apis-inner-application-missionSnapshot.md
+30
-16
zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md
...erence/apis/js-apis-inner-application-uiAbilityContext.md
+17
-82
zh-cn/application-dev/reference/apis/js-apis-launcherBundleManager.md
...ation-dev/reference/apis/js-apis-launcherBundleManager.md
+18
-15
zh-cn/application-dev/reference/apis/js-apis-router.md
zh-cn/application-dev/reference/apis/js-apis-router.md
+29
-29
zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md
...pplication-dev/reference/apis/js-apis-useriam-userauth.md
+5
-0
zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-location.md
...ev/reference/arkui-ts/ts-universal-attributes-location.md
+5
-5
zh-cn/application-dev/reference/errorcodes/errorcode-useriam.md
...application-dev/reference/errorcodes/errorcode-useriam.md
+70
-0
未找到文件。
zh-cn/application-dev/application-test/arkxtest-guidelines.md
浏览文件 @
9a6ca42e
...
...
@@ -154,7 +154,9 @@ export default function abilityTest() {
## 执行测试脚本
执行测试脚本可以直接在DevEco Studio中通过点击按钮执行,当前支持以下执行方式:
### DevEco Studio执行
通过点击按钮执行,当前支持以下执行方式:
1、测试包级别执行即执行测试包内的全部用例。
...
...
@@ -164,12 +166,161 @@ export default function abilityTest() {
![](
figures/Execute.PNG
)
## 查看测试结果
**查看测试结果**
测试执行完毕后可直接在DevEco Studio中查看测试结果,如下图示例所示:
![](
figures/TestResult.PNG
)
### CMD执行
通过在cmd窗口中输入aa命令执行触发用例执行,并通过设置执行参数触发不同功能。
**aa test命令执行配置参数**
| 执行参数全写 | 执行参数缩写 | 执行参数含义 | 执行参数示例 |
| ------------- | ------------ | -------------------------------------- | ---------------------------------- |
| --bundleName | -b | 应用包名 | - b com.test.example |
| --packageName | -p | 应用模块名,适用于FA模型应用 | - p com.test.example.entry |
| --moduleName | -m | 应用模块名,适用于STAGE模型应用 | -m entry |
| NA | -s | 特定参数,以
<key
,
value
>
键值对方式传入 | - s unittest OpenHarmonyTestRunner |
框架当前支持多种用例执行方式,通过上表中的-s参数后的配置键值对参数传入触发,如下表所示。
| 配置参数值 | 配置参数含义 | 配置参数有值 | 配置参数示例 |
| ------------ | ----------------------------------------------------------------------------- | ------------------------------------------------------------ | ----------------------------------------- |
| unittest | 用例执行所使用OpenHarmonyTestRunner对象 | OpenHarmonyTestRunner或用户自定义runner名称 | - s unittest OpenHarmonyTestRunner |
| class | 指定要执行的测试套或测试用例 | {describeName}#{itName},{describeName} | -s class attributeTest#testAttributeIt |
| notClass | 指定不需要执行的测试套或测试用例 | {describeName}#{itName},{describeName} | -s notClass attributeTest#testAttributeIt |
| itName | 指定要执行的测试用例 | {itName} | -s itName testAttributeIt |
| timeout | 测试用例执行的超时时间 | 正整数(单位ms),如不设置默认为 5000 | -s timeout 15000 |
| breakOnError | 遇错即停模式,当执行用例断言失败或者发生错误时,退出测试执行流程 | true/false(默认值) | -s breakOnError true |
| testType | 指定要执行用例的用例类型 | function,performance,power,reliability, security,global,compatibility,user,standard,safety,resilience' | -s testType function |
| level | 指定要执行用例的用例级别 | 0,1,2,3,4 | -s level 0 |
| size | 指定要执行用例的用例规模 | small,medium,large | -s size small |
**通过在cmd窗口直接执行命令。**
> 使用cmd的方式,需要配置好hdc相关的环境变量
-
打开cmd窗口
-
执行 aa test 命令
**示例代码1**
:执行所有测试用例。
```
shell
hdc shell aa
test
-b
xxx
-p
xxx
-s
unittest OpenHarmonyTestRunner
```
**示例代码2**
:执行指定的describe测试套用例,指定多个需用逗号隔开。
```
shell
hdc shell aa
test
-b
xxx
-p
xxx
-s
unittest OpenHarmonyTestRunner
-s
class s1,s2
```
**示例代码3**
:执行指定测试套中指定的用例,指定多个需用逗号隔开。
```
shell
hdc shell aa
test
-b
xxx
-p
xxx
-s
unittest OpenHarmonyTestRunner
-s
class testStop#stop_1,testStop1#stop_0
```
**示例代码4**
:执行指定除配置以外的所有的用例,设置不执行多个测试套需用逗号隔开。
```
shell
hdc shell aa
test
-b
xxx
-p
xxx
-s
unittest OpenHarmonyTestRunner
-s
notClass testStop
```
**示例代码5**
:执行指定it名称的所有用例,指定多个需用逗号隔开。
```
shell
hdc shell aa
test
-b
xxx
-p
xxx
-s
unittest OpenHarmonyTestRunner
-s
itName stop_0
```
**示例代码6**
:用例执行超时时长配置。
```
shell
hdc shell aa
test
-b
xxx
-p
xxx
-s
unittest OpenHarmonyTestRunner
-s
timeout
15000
```
**示例代码7**
:用例以breakOnError模式执行用例。
```
shell
hdc shell aa
test
-b
xxx
-p
xxx
-s
unittest OpenHarmonyTestRunner
-s
breakOnError
true
```
**示例代码8**
:执行测试类型匹配的测试用例。
```
shell
hdc shell aa
test
-b
xxx
-p
xxx
-s
unittest OpenHarmonyTestRunner
-s
testType
function
```
**示例代码9**
:执行测试级别匹配的测试用例。
```
shell
hdc shell aa
test
-b
xxx
-p
xxx
-s
unittest OpenHarmonyTestRunner
-s
level 0
```
**示例代码10**
:执行测试规模匹配的测试用例。
```
shell
hdc shell aa
test
-b
xxx
-p
xxx
-s
unittest OpenHarmonyTestRunner
-s
size small
```
**查看测试结果**
-
cmd模式执行过程,会打印如下相关日志信息。
```
OHOS_REPORT_STATUS: class=testStop
OHOS_REPORT_STATUS: current=1
OHOS_REPORT_STATUS: id=JS
OHOS_REPORT_STATUS: numtests=447
OHOS_REPORT_STATUS: stream=
OHOS_REPORT_STATUS: test=stop_0
OHOS_REPORT_STATUS_CODE: 1
OHOS_REPORT_STATUS: class=testStop
OHOS_REPORT_STATUS: current=1
OHOS_REPORT_STATUS: id=JS
OHOS_REPORT_STATUS: numtests=447
OHOS_REPORT_STATUS: stream=
OHOS_REPORT_STATUS: test=stop_0
OHOS_REPORT_STATUS_CODE: 0
OHOS_REPORT_STATUS: consuming=4
```
| 日志输出字段 | 日志输出字段含义 |
| ------- | -------------------------|
| OHOS_REPORT_SUM | 当前测试套用例总数 |
| OHOS_REPORT_STATUS: class | 当前执行用例测试套名称|
| OHOS_REPORT_STATUS: id | 用例执行语言,默认JS |
| OHOS_REPORT_STATUS: numtests | 测试包中测试用例总数 |
| OHOS_REPORT_STATUS: stream | 当前用例发生错误时,记录错误信息 |
| OHOS_REPORT_STATUS: test| 当前用例执行的it name |
| OHOS_REPORT_STATUS_CODE | 当前用例执行结果状态 0 (pass) 1(error) 2(fail) |
| OHOS_REPORT_STATUS: consuming | 当前用例执行消耗的时长 |
-
cmd执行完成后,会打印如下相关日志信息。
```
OHOS_REPORT_RESULT: stream=Tests run: 447, Failure: 0, Error: 1, Pass: 201, Ignore: 245
OHOS_REPORT_CODE: 0
OHOS_REPORT_RESULT: breakOnError model, Stopping whole test suite if one specific test case failed or error
OHOS_REPORT_STATUS: taskconsuming=16029
```
| 日志输出字段 | 日志输出字段含义 |
| ------------------| -------------------------|
| run | 当前测试包用例总数 |
| Failure | 当前测试失败用例个数 |
| Error | 当前执行用例发生错误用例个数 |
| Pass | 当前执行用例通过用例个数 |
| Ignore | 当前未执行用例个数 |
| taskconsuming| 执行当前测试用例总耗时 |
> 当处于breakOnError模式,用例发生错误时,注意查看Ignore以及中断说明
## 常见问题
### 单元测试用例常见问题
...
...
@@ -180,11 +331,11 @@ export default function abilityTest() {
用例中增加的日志打印信息,没有在用例执行过程中出现,而是在用例执行结束之后才出现。
**可能原因**
**可能原因**
此类情况只会存在于用例中有调用异步接口的情况,原则上用例中所有的日志信息均在用例执行结束之前打印。
**解决方法**
**解决方法**
当被调用的异步接口多于一个时,建议将接口调用封装成Promise方式调用。
...
...
@@ -214,12 +365,15 @@ export default function abilityTest() {
2.
用例调用函数耗时过长,超过用例执行设置的超时时间。
3.
用例调用函数中断言失败,抛出失败异常,导致用例执行一直没有结束,直到超时结束。
**解决方法**
1.
检查用例代码逻辑,确保即使断言失败场景认可走到done函数,保证用例执行结束。
2.
可在IDE中Run/Debug Configurations中修改用例执行超时配置参数,避免用例执行超时。
2.
可在IDE中Run/Debug Configurations中修改用例执行超时配置参数,避免用例执行超时。
3.
检查用例代码逻辑,断言结果,确保断言Pass。
### UI测试用例常见问题
**1、失败日志有“Get windows failed/GetRootByWindow failed”错误信息**
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md
浏览文件 @
9a6ca42e
...
...
@@ -20,7 +20,7 @@ ohos.permission.MANAGE_MISSIONS
on(type:"mission", listener: MissionListener): number;
注册系统任务状态监听。
注册系统任务状态监听
器
。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -32,13 +32,13 @@ on(type:"mission", listener: MissionListener): number;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| listener | MissionListener | 是 | 系统任务监听
方法
。 |
| listener | MissionListener | 是 | 系统任务监听
器
。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| number | 监听
方法的index值,由系统创建,在注册系统任务状态监听时分配,和监听方法
一一对应
。 |
| number | 监听
器的index值,由系统创建,在注册系统任务状态监听时分配,和监听器
一一对应
。 |
**示例:**
...
...
@@ -51,7 +51,8 @@ var listener = {
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionSnapshotChanged-------
"
)},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionMovedToFront-------
"
)},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
"
--------onMissionIconUpdated-------
"
)},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionClosed-------
"
)}
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionClosed-------
"
)},
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionLabelUpdated-------
"
)}
};
var
listenerId
=
-
1
;
...
...
@@ -105,7 +106,7 @@ export default class MainAbility extends UIAbility {
off(type: "mission", listenerId: number, callback: AsyncCallback
<
void
>
): void;
取消任务状态监听
。
解注册任务状态监听器
。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -117,7 +118,7 @@ off(type: "mission", listenerId: number, callback: AsyncCallback<void>): v
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| listenerId | number | 是 | 系统任务状态监
听方法的index值,和监听方法一一对应,由registerMissionListener
方法返回。 |
| listenerId | number | 是 | 系统任务状态监
器法的index值,和监听器一一对应,由on
方法返回。 |
| callback | AsyncCallback
<
void
>
| 是 | 执行结果回调函数。 |
**示例:**
...
...
@@ -131,7 +132,8 @@ var listener = {
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionSnapshotChanged-------
"
)},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionMovedToFront-------
"
)},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
"
--------onMissionIconUpdated-------
"
)},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionClosed-------
"
)}
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionClosed-------
"
)},
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionLabelUpdated-------
"
)}
};
var
listenerId
=
-
1
;
...
...
@@ -185,7 +187,7 @@ export default class MainAbility extends UIAbility {
off(type: "mission", listenerId: number): Promise
<
void
>
;
取消
任务状态监听,以promise方式返回执行结果。
解注册
任务状态监听,以promise方式返回执行结果。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -197,7 +199,7 @@ off(type: "mission", listenerId: number): Promise<void>;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| listenerId | number | 是 | 系统任务状态监听
方法的index值,和监听方法一一对应,由registerMissionListener
方法返回。 |
| listenerId | number | 是 | 系统任务状态监听
器的index值,和监听器一一对应,由on
方法返回。 |
**返回值:**
...
...
@@ -216,7 +218,8 @@ var listener = {
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionSnapshotChanged-------
"
)},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionMovedToFront-------
"
)},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
"
--------onMissionIconUpdated-------
"
)},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionClosed-------
"
)}
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionClosed-------
"
)},
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionLabelUpdated-------
"
)}
};
var
listenerId
=
-
1
;
...
...
@@ -292,7 +295,12 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<M
try
{
var
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);});
missionManager
.
getMissionInfo
(
""
,
allMissions
[
0
].
missionId
,
(
error
,
mission
)
=>
{
console
.
log
(
"
getMissionInfo is called, error.code =
"
+
error
.
code
)
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfo failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
mission.missionId =
"
+
mission
.
missionId
);
console
.
log
(
"
mission.runningState =
"
+
mission
.
runningState
);
console
.
log
(
"
mission.lockedState =
"
+
mission
.
lockedState
);
...
...
@@ -369,7 +377,11 @@ getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Arr
```
ts
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfo failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
})
...
...
@@ -442,14 +454,22 @@ getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback&
```
ts
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
missionManager
.
getMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getMissionSnapShot is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
missionManager
.
getMissionSnapShot
(
""
,
id
,
(
err
,
snapshot
)
=>
{
if
(
err
.
code
)
{
console
.
log
(
"
getMissionInfos failed, err.code:
"
+
JSON
.
stringify
(
err
.
code
)
+
"
err.message:
"
+
JSON
.
stringify
(
err
.
message
));
return
;
}
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
})
})
}
catch
(
paramError
)
{
...
...
@@ -507,7 +527,7 @@ getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnaps
getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback
\<
MissionSnapshot>): void;
使用给定的任务ID
获取任务低分辨率快照。
获取任务低分辨率快照。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -528,13 +548,21 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A
```
ts
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getLowResolutionMissionSnapShot is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getLowResolutionMissionSnapShot failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
})
})
...
...
@@ -548,7 +576,7 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A
getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise
\<
MissionSnapshot>;
使用给定的任务ID
获取任务低分辨率快照。
获取任务低分辨率快照。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -614,7 +642,12 @@ lockMission(missionId: number, callback: AsyncCallback<void>): void;
```
ts
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
@@ -698,7 +731,11 @@ unlockMission(missionId: number, callback: AsyncCallback<void>): void;
```
ts
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
@@ -785,7 +822,11 @@ clearMission(missionId: number, callback: AsyncCallback<void>): void;
```
ts
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
@@ -917,7 +958,11 @@ moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void
```
ts
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
@@ -957,7 +1002,11 @@ moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCall
```
ts
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
zh-cn/application-dev/reference/apis/js-apis-application-missionManager.md
浏览文件 @
9a6ca42e
...
...
@@ -20,7 +20,7 @@ ohos.permission.MANAGE_MISSIONS
registerMissionListener(listener: MissionListener): number;
注册系统任务状态监听。
注册系统任务状态监听
器
。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -32,13 +32,13 @@ registerMissionListener(listener: MissionListener): number;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| listener |
[
MissionListener
](
js-apis-inner-application-missionListener.md
)
| 是 | 系统任务监听
方法
。 |
| listener |
[
MissionListener
](
js-apis-inner-application-missionListener.md
)
| 是 | 系统任务监听
器
。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| number | 监听
方法的index值,由系统创建,在注册系统任务状态监听时分配,和监听方法
一一对应
。 |
| number | 监听
器的index值,由系统创建,在注册系统任务状态监听器时分配,和监听器
一一对应
。 |
**示例:**
...
...
@@ -61,7 +61,7 @@ var listenerid = missionManager.registerMissionListener(listener);
unregisterMissionListener(listenerId: number, callback: AsyncCallback
<
void
>
): void;
取消任务状态监听
。
解注册任务状态监听器
。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -73,7 +73,7 @@ unregisterMissionListener(listenerId: number, callback: AsyncCallback<void>
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| listenerId | number | 是 | 系统任务状态监听
方法的index值,和监听方法
一一对应,由registerMissionListener方法返回。 |
| listenerId | number | 是 | 系统任务状态监听
器的index值,和监听器
一一对应,由registerMissionListener方法返回。 |
| callback | AsyncCallback
<
void
>
| 是 | 执行结果回调函数。 |
**示例:**
...
...
@@ -101,7 +101,7 @@ unregisterMissionListener(listenerId: number, callback: AsyncCallback<void>
unregisterMissionListener(listenerId: number): Promise
<
void
>
;
取消任务状态监听
,以promise方式返回执行结果。
反注册任务状态监听器
,以promise方式返回执行结果。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -113,7 +113,7 @@ unregisterMissionListener(listenerId: number): Promise<void>;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| listenerId | number | 是 | 系统任务状态监听
方法的index值,和监听方法
一一对应,由registerMissionListener方法返回。 |
| listenerId | number | 是 | 系统任务状态监听
器的index值,和监听器
一一对应,由registerMissionListener方法返回。 |
**返回值:**
...
...
@@ -146,7 +146,7 @@ unregisterMissionListener(listenerId: number): Promise<void>;
getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback
<
MissionInfo
>
): void;
获取任务信息,以异步回调的方式返回任务信息。
获取
单个
任务信息,以异步回调的方式返回任务信息。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -169,7 +169,12 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<M
var
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);});
missionManager
.
getMissionInfo
(
""
,
allMissions
[
0
].
missionId
,
(
error
,
mission
)
=>
{
console
.
log
(
"
getMissionInfo is called, error.code =
"
+
error
.
code
)
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfo failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
mission.missionId =
"
+
mission
.
missionId
);
console
.
log
(
"
mission.runningState =
"
+
mission
.
runningState
);
console
.
log
(
"
mission.lockedState =
"
+
mission
.
lockedState
);
...
...
@@ -184,7 +189,7 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<M
getMissionInfo(deviceId: string, missionId: number): Promise
<
MissionInfo
>
;
获取任务信息,以promise方式返回任务信息。
获取
单个
任务信息,以promise方式返回任务信息。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -242,7 +247,11 @@ getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Arr
import
missionManager
from
'
@ohos.application.missionManager
'
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
})
...
...
@@ -311,14 +320,22 @@ getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback&
import
missionManager
from
'
@ohos.application.missionManager
'
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
missionManager
.
getMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getMissionSnapShot is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionSnapShot failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
})
})
```
...
...
@@ -371,7 +388,7 @@ getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnaps
getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback
\<
MissionSnapshot>): void;
使用给定的任务ID
获取任务低分辨率快照。
获取任务低分辨率快照。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -393,14 +410,22 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A
import
missionManager
from
'
@ohos.application.missionManager
'
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getLowResolutionMissionSnapShot is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
if
(
error
.
code
)
{
console
.
log
(
"
getLowResolutionMissionSnapShot failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
})
})
```
...
...
@@ -410,7 +435,7 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A
getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise
\<
MissionSnapshot>;
使用给定的任务ID
获取任务低分辨率快照。
获取任务低分辨率快照。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -475,7 +500,11 @@ lockMission(missionId: number, callback: AsyncCallback<void>): void;
import
missionManager
from
'
@ohos.application.missionManager
'
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
@@ -554,7 +583,11 @@ unlockMission(missionId: number, callback: AsyncCallback<void>): void;
import
missionManager
from
'
@ohos.application.missionManager
'
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
@@ -637,7 +670,11 @@ clearMission(missionId: number, callback: AsyncCallback<void>): void;
import
missionManager
from
'
@ohos.application.missionManager
'
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
@@ -768,7 +805,11 @@ moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void
import
missionManager
from
'
@ohos.application.missionManager
'
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
@@ -806,7 +847,11 @@ moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCall
import
missionManager
from
'
@ohos.application.missionManager
'
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionInfo.md
浏览文件 @
9a6ca42e
# MissionInfo
表示
Ability对应的任务
信息,可以通过
[
getMissionInfo
](
js-apis-app-ability-missionManager.md#missionmanagergetmissioninfo
)
获取。
表示
任务的详细
信息,可以通过
[
getMissionInfo
](
js-apis-app-ability-missionManager.md#missionmanagergetmissioninfo
)
获取。
**系统能力**
:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Mission
...
...
@@ -19,16 +19,27 @@
**示例:**
```
ts
import
missionManager
from
'
@ohos.app
lication
.missionManager
'
import
missionManager
from
'
@ohos.app
.ability
.missionManager
'
missionManager
.
getMissionInfo
(
"
12345
"
,
1
,
(
error
,
data
)
=>
{
console
.
info
(
'
getMissionInfo missionId is:
'
+
JSON
.
stringify
(
data
.
missionId
));
console
.
info
(
'
getMissionInfo runningState is:
'
+
JSON
.
stringify
(
data
.
runningState
));
console
.
info
(
'
getMissionInfo lockedState is:
'
+
JSON
.
stringify
(
data
.
lockedState
));
console
.
info
(
'
getMissionInfo timestamp is:
'
+
JSON
.
stringify
(
data
.
timestamp
));
console
.
info
(
'
getMissionInfo want is:
'
+
JSON
.
stringify
(
data
.
want
));
console
.
info
(
'
getMissionInfo label is:
'
+
JSON
.
stringify
(
data
.
label
));
console
.
info
(
'
getMissionInfo iconPath is:
'
+
JSON
.
stringify
(
data
.
iconPath
));
console
.
info
(
'
getMissionInfo continuable is:
'
+
JSON
.
stringify
(
data
.
continuable
));
});
try
{
missionManager
.
getMissionInfo
(
""
,
1
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
// 处理业务逻辑错误
console
.
log
(
"
getMissionInfo failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
'
getMissionInfo missionId is:
'
+
JSON
.
stringify
(
data
.
missionId
));
console
.
log
(
'
getMissionInfo runningState is:
'
+
JSON
.
stringify
(
data
.
runningState
));
console
.
log
(
'
getMissionInfo lockedState is:
'
+
JSON
.
stringify
(
data
.
lockedState
));
console
.
log
(
'
getMissionInfo timestamp is:
'
+
JSON
.
stringify
(
data
.
timestamp
));
console
.
log
(
'
getMissionInfo want is:
'
+
JSON
.
stringify
(
data
.
want
));
console
.
log
(
'
getMissionInfo label is:
'
+
JSON
.
stringify
(
data
.
label
));
console
.
log
(
'
getMissionInfo iconPath is:
'
+
JSON
.
stringify
(
data
.
iconPath
));
console
.
log
(
'
getMissionInfo continuable is:
'
+
JSON
.
stringify
(
data
.
continuable
));
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionListener.md
浏览文件 @
9a6ca42e
# MissionListener
定义系统任务状态监听,可以通过
[
registerMissionListener
](
js-apis-application-missionManager.md#missionmanagerregistermissionlistener
)
注册。
定义系统任务状态监听,可以通过
[
on
](
js-apis-app-ability-missionManager.md#missionmanageron
)
注册。
**系统能力**
:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Mission
...
...
@@ -16,7 +16,7 @@
**示例:**
```
ts
import
missionManager
from
'
@ohos.app
lication
.missionManager
'
import
missionManager
from
'
@ohos.app
.ability
.missionManager
'
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
...
...
@@ -38,5 +38,10 @@ let listener = {
console
.
log
(
"
onMissionClosed mission:
"
+
JSON
.
stringify
(
mission
));
}
};
let
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
try
{
let
listenerId
=
missionManager
.
on
(
"
mission
"
,
listener
);
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionSnapshot.md
浏览文件 @
9a6ca42e
...
...
@@ -11,7 +11,7 @@
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| ability | ElementName | 是 | 是 | 表示
Ability任务元素名称
。 |
| ability | ElementName | 是 | 是 | 表示
该任务的组件信息
。 |
| snapshot |
[
image.PixelMap
](
js-apis-image.md
)
| 是 | 是 | 表示任务快照。 |
## 使用说明
...
...
@@ -20,19 +20,33 @@
**示例:**
```
ts
import
ElementName
from
'
@ohos.bundle
'
;
import
image
from
'
@ohos.multimedia.image
'
;
import
missionManager
from
'
@ohos.application.missionManager
'
;
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
missionManager
.
getMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getMissionSnapShot is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
})
})
import
ElementName
from
'
@ohos.bundle
'
;
import
image
from
'
@ohos.multimedia.image
'
;
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
missionManager
.
getMissionSnapShot
(
""
,
id
,
(
err
,
snapshot
)
=>
{
if
(
err
.
code
)
{
console
.
log
(
"
getMissionInfos failed, err.code:
"
+
JSON
.
stringify
(
err
.
code
)
+
"
err.message:
"
+
JSON
.
stringify
(
err
.
message
));
return
;
}
// 执行正常业务
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
})
})
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md
浏览文件 @
9a6ca42e
...
...
@@ -447,7 +447,7 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityRes
startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback
\<
AbilityResult>): void;
启动一个Ability并在该Ability
帐号
销毁时返回执行结果(callback形式)。
启动一个Ability并在该Ability销毁时返回执行结果(callback形式)。
**需要权限**
: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
...
...
@@ -621,7 +621,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
[AbilityResult](js-apis-inner-ability-abilityResult.md)
>
| Ability被销毁时的回调函数,包含Ability
结果
。 |
| Promise
<
[AbilityResult](js-apis-inner-ability-abilityResult.md)
>
| Ability被销毁时的回调函数,包含Ability
Result参数
。 |
**错误码:**
...
...
@@ -693,8 +693,8 @@ startServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 启动Ability的want信息。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 启动Ability的回调函数。 |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 启动
ServiceExtension
Ability的want信息。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 启动
ServiceExtension
Ability的回调函数。 |
**错误码:**
...
...
@@ -816,9 +816,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 启动Ability的want信息。 |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 启动
ServiceExtension
Ability的want信息。 |
| accountId | number | 是 | 系统帐号的帐号ID,详情参考
[
getCreatedOsAccountsCount
](
js-apis-osAccount.md#getCreatedOsAccountsCount
)
。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 启动Ability的回调函数。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 启动
ServiceExtension
Ability的回调函数。 |
**错误码:**
...
...
@@ -940,8 +940,8 @@ stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 |
启动
Ability的want信息。 |
| callback | AsyncCallback
\<
void
\>
| 是 |
启动
Ability的回调函数。 |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 |
停止ServiceExtension
Ability的want信息。 |
| callback | AsyncCallback
\<
void
\>
| 是 |
停止ServiceExtension
Ability的回调函数。 |
**错误码:**
...
...
@@ -1225,7 +1225,7 @@ terminateSelf(): Promise<void>;
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
void
>
|
返回一个Promise,包含接口的结果
。 |
| Promise
<
void
>
|
停止Ability自身的回调函数
。 |
**错误码:**
...
...
@@ -1397,8 +1397,8 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 |
启动
Ability的want信息。 |
| options |
[
ConnectOptions
](
js-apis-inner-ability-connectOptions.md
)
|
否 | 远端对象
实例。 |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 |
连接ServiceExtension
Ability的want信息。 |
| options |
[
ConnectOptions
](
js-apis-inner-ability-connectOptions.md
)
|
是 | 与ServiceExtensionAbility建立连接后回调函数的
实例。 |
**返回值:**
...
...
@@ -1461,7 +1461,7 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 启动Ability的want信息。 |
| accountId | number | 是 | 系统帐号的帐号ID,详情参考
[
getCreatedOsAccountsCount
](
js-apis-osAccount.md#getCreatedOsAccountsCount
)
。 |
| options |
[
ConnectOptions
](
js-apis-inner-ability-connectOptions.md
)
|
否 | 远端对象实例
。 |
| options |
[
ConnectOptions
](
js-apis-inner-ability-connectOptions.md
)
|
是 | 与ServiceExtensionAbility建立连接后回调函数的实例。
。 |
**返回值:**
...
...
@@ -1579,7 +1579,7 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback\<vo
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| connection | number | 是 | 连接的ServiceExtensionAbility的数字代码,即connectServiceExtensionAbility返回的connectionId。 |
| callback | AsyncCallback
\<
void> | 是 |
表示指定的回调方法
。 |
| callback | AsyncCallback
\<
void> | 是 |
callback形式返回断开连接的结果
。 |
**错误码:**
...
...
@@ -1707,7 +1707,7 @@ startAbilityByCall(want: Want): Promise<Caller>;
startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback
\<
void
\>
): void;
根据accountId启动Ability(callback形式)。
根据
want和
accountId启动Ability(callback形式)。
**需要权限**
: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
...
...
@@ -1781,7 +1781,7 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<
startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback
\<
void
\>
): void;
根据accountId及startOptions启动Ability(callback形式)。
根据
want、
accountId及startOptions启动Ability(callback形式)。
**需要权限**
: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
...
...
@@ -1795,7 +1795,7 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 启动Ability的want信息。 |
| accountId | number | 是 | 系统帐号的帐号ID,详情参考
[
getCreatedOsAccountsCount
](
js-apis-osAccount.md#getCreatedOsAccountsCount
)
。|
| options |
[
StartOptions
](
js-apis-app-ability-startOptions.md
)
|
否
| 启动Ability所携带的参数。 |
| options |
[
StartOptions
](
js-apis-app-ability-startOptions.md
)
|
是
| 启动Ability所携带的参数。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 启动Ability的回调函数。 |
**错误码:**
...
...
@@ -1859,7 +1859,7 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca
startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise
\<
void
\>
;
根据accountId和startOptions启动Ability(Promise形式)。
根据
want、
accountId和startOptions启动Ability(Promise形式)。
**需要权限**
: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
...
...
@@ -1931,71 +1931,6 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions):
}
```
## UIAbilityContext.requestPermissionsFromUser
> **说明:**
> - 该接口自API version 9已废弃。
requestPermissionsFromUser(permissions: Array
<
string
>
, requestCallback: AsyncCallback
<
PermissionRequestResult
>
) : void;
拉起弹窗请求用户授权(callback形式)。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| permissions | Array
<
string
>
| 是 | 权限列表。 |
| callback | AsyncCallback
<
[PermissionRequestResult](js-apis-inner-application-permissionRequestResult.md)
>
| 是 | 回调函数,返回接口调用是否成功的结果。 |
**示例:**
```
ts
var
permissions
=
[
'
com.example.permission
'
]
this
.
context
.
requestPermissionsFromUser
(
permissions
,(
result
)
=>
{
console
.
log
(
'
requestPermissionsFromUserresult:
'
+
JSON
.
stringify
(
result
));
});
```
## UIAbilityContext.requestPermissionsFromUser
> **说明:**
> - 该接口自API version 9已废弃。
requestPermissionsFromUser(permissions: Array
<
string
>
) : Promise
<
PermissionRequestResult
>
;
拉起弹窗请求用户授权(promise形式)。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| permissions | Array
<
string
>
| 是 | 权限列表。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
[PermissionRequestResult](js-apis-inner-application-permissionRequestResult.md)
>
| 返回一个Promise,包含接口的结果。 |
**示例:**
```
ts
var
permissions
=
[
'
com.example.permission
'
]
this
.
context
.
requestPermissionsFromUser
(
permissions
).
then
((
data
)
=>
{
console
.
log
(
'
success:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
log
(
'
failed:
'
+
JSON
.
stringify
(
error
));
});
```
## UIAbilityContext.setMissionLabel
setMissionLabel(label: string, callback:AsyncCallback
<
void
>
): void;
...
...
zh-cn/application-dev/reference/apis/js-apis-launcherBundleManager.md
浏览文件 @
9a6ca42e
...
...
@@ -55,12 +55,13 @@ import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
try
{
launcherBundleManager
.
getLauncherAbilityInfo
(
'
com.example.demo
'
,
100
,
(
errData
,
data
)
=>
{
if
(
errData
!==
null
)
{
console
.
log
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
}
else
{
console
.
log
(
"
data is
"
+
JSON
.
stringify
(
data
));
}
console
.
log
(
"
data is
"
+
JSON
.
stringify
(
data
));
})
}
catch
(
errData
)
{
console
.
log
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
}
```
...
...
@@ -107,10 +108,10 @@ try {
launcherBundleManager
.
getLauncherAbilityInfo
(
"
com.example.demo
"
,
100
).
then
(
data
=>
{
console
.
log
(
"
data is
"
+
JSON
.
stringify
(
data
));
}).
catch
(
errData
=>
{
console
.
log
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
})
}
catch
(
errData
)
{
console
.
log
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
}
```
...
...
@@ -154,12 +155,13 @@ import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
try
{
launcherBundleManager
.
getAllLauncherAbilityInfo
(
100
,
(
errData
,
data
)
=>
{
if
(
errData
!==
null
)
{
console
.
log
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
}
else
{
console
.
log
(
"
data is
"
+
JSON
.
stringify
(
data
));
}
console
.
log
(
"
data is
"
+
JSON
.
stringify
(
data
));
});
}
catch
(
errData
)
{
console
.
log
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
}
```
## launcherBundlemanager.getAllLauncherAbilityInfo<sup>9+</sup>
...
...
@@ -203,10 +205,10 @@ try {
launcherBundleManager
.
getAllLauncherAbilityInfo
(
100
).
then
(
data
=>
{
console
.
log
(
"
data is
"
+
JSON
.
stringify
(
data
));
}).
catch
(
errData
=>
{
console
.
log
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
});
}
catch
(
errData
)
{
console
.
log
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
}
```
...
...
@@ -248,12 +250,13 @@ import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
try
{
launcherBundleManager
.
getShortcutInfo
(
"
com.example.demo
"
,
(
errData
,
data
)
=>
{
if
(
errData
!==
null
)
{
console
.
log
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
}
else
{
console
.
log
(
"
data is
"
+
JSON
.
stringify
(
data
));
}
console
.
log
(
"
data is
"
+
JSON
.
stringify
(
data
));
});
}
catch
(
errData
)
{
console
.
log
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
}
```
...
...
@@ -296,9 +299,9 @@ try {
launcherBundleManager
.
getShortcutInfo
(
"
com.example.demo
"
).
then
(
data
=>
{
console
.
log
(
"
data is
"
+
JSON
.
stringify
(
data
));
}).
catch
(
errData
=>
{
console
.
log
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
});
}
catch
(
errData
)
{
console
.
log
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
console
.
error
(
`errData is errCode:
${
errData
.
code
}
message:
${
errData
.
message
}
`
);
}
```
zh-cn/application-dev/reference/apis/js-apis-router.md
浏览文件 @
9a6ca42e
...
...
@@ -54,8 +54,8 @@ try {
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
,
}
,
}
}
})
.
then
(()
=>
{
// success
...
...
@@ -103,8 +103,8 @@ try {
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
,
}
,
}
}
},
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`pushUrl failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
...
...
@@ -157,8 +157,8 @@ try {
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
,
}
,
}
}
},
router
.
RouterMode
.
Standard
)
.
then
(()
=>
{
// success
...
...
@@ -207,8 +207,8 @@ try {
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
,
}
,
}
}
},
router
.
RouterMode
.
Standard
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`pushUrl failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
...
...
@@ -257,8 +257,8 @@ try {
router
.
replaceUrl
({
url
:
'
pages/detail
'
,
params
:
{
data1
:
'
message
'
,
}
,
data1
:
'
message
'
}
})
.
then
(()
=>
{
// success
...
...
@@ -302,8 +302,8 @@ try {
router
.
replaceUrl
({
url
:
'
pages/detail
'
,
params
:
{
data1
:
'
message
'
,
}
,
data1
:
'
message
'
}
},
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`replaceUrl failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
...
...
@@ -354,8 +354,8 @@ try {
router
.
replaceUrl
({
url
:
'
pages/detail
'
,
params
:
{
data1
:
'
message
'
,
}
,
data1
:
'
message
'
}
},
router
.
RouterMode
.
Standard
)
.
then
(()
=>
{
// success
...
...
@@ -400,8 +400,8 @@ try {
router
.
replaceUrl
({
url
:
'
pages/detail
'
,
params
:
{
data1
:
'
message
'
,
}
,
data1
:
'
message
'
}
},
router
.
RouterMode
.
Standard
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`replaceUrl failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
...
...
@@ -465,7 +465,7 @@ getLength(): string
**示例:**
```
js
var
size
=
router
.
getLength
();
let
size
=
router
.
getLength
();
console
.
log
(
'
pages stack size =
'
+
size
);
```
...
...
@@ -486,7 +486,7 @@ getState(): RouterState
**示例:**
```
js
var
page
=
router
.
getState
();
let
page
=
router
.
getState
();
console
.
log
(
'
current index =
'
+
page
.
index
);
console
.
log
(
'
current name =
'
+
page
.
name
);
console
.
log
(
'
current path =
'
+
page
.
path
);
...
...
@@ -618,8 +618,8 @@ export default {
router
.
push
({
url
:
'
pages/detail/detail
'
,
params
:
{
data1
:
'
message
'
,
}
,
data1
:
'
message
'
}
});
}
}
...
...
@@ -649,7 +649,7 @@ struct Index {
text
:
'
这是第一页的值
'
,
data
:
{
array
:
[
12
,
45
,
78
]
}
,
}
}
}
try
{
...
...
@@ -741,8 +741,8 @@ router.push({
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
,
}
,
}
}
});
```
## router.push<sup>(deprecated)</sup>
...
...
@@ -772,8 +772,8 @@ router.push({
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
,
}
,
}
}
},
router
.
RouterMode
.
Standard
);
```
...
...
@@ -799,8 +799,8 @@ replace(options: RouterOptions): void
router
.
replace
({
url
:
'
pages/detail
'
,
params
:
{
data1
:
'
message
'
,
}
,
data1
:
'
message
'
}
});
```
...
...
@@ -827,8 +827,8 @@ replace(options: RouterOptions, mode: RouterMode): void
router
.
replace
({
url
:
'
pages/detail/detail
'
,
params
:
{
data1
:
'
message
'
,
}
,
data1
:
'
message
'
}
},
router
.
RouterMode
.
Standard
);
```
...
...
zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md
浏览文件 @
9a6ca42e
...
...
@@ -277,9 +277,14 @@ start : () => void
| -------- | ------- |
| 201 | Permission verification failed. |
| 401 | Incorrect parameters. |
| 12500001 | Execution failed. |
| 12500002 | General operation error. |
| 12500003 | The operation is canceled. |
| 12500004 | The operation is time-out. |
| 12500005 | The authentication type is not supported. |
| 12500006 | The authentication trust level is not supported. |
| 12500007 | The authentication task is busy. |
| 12500009 | The authenticator is locked. |
| 12500010 | The type of credential has not been enrolled. |
**示例:**
...
...
zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-location.md
浏览文件 @
9a6ca42e
...
...
@@ -58,16 +58,16 @@ struct PositionExample1 {
.
direction
(
Direction
.
Ltr
)
// 父容器设置direction为Direction.Rtl,子元素从右到左排列
Row
()
{
Text
(
'
1
'
).
height
(
50
).
width
(
'
25%
'
).
fontSize
(
16
).
backgroundColor
(
0xF5DEB3
)
Text
(
'
2
'
).
height
(
50
).
width
(
'
25%
'
).
fontSize
(
16
).
backgroundColor
(
0xD2B48C
)
Text
(
'
3
'
).
height
(
50
).
width
(
'
25%
'
).
fontSize
(
16
).
backgroundColor
(
0xF5DEB3
)
Text
(
'
4
'
).
height
(
50
).
width
(
'
25%
'
).
fontSize
(
16
).
backgroundColor
(
0xD2B48C
)
Text
(
'
1
'
).
height
(
50
).
width
(
'
25%
'
).
fontSize
(
16
).
backgroundColor
(
0xF5DEB3
)
.
textAlign
(
TextAlign
.
End
)
Text
(
'
2
'
).
height
(
50
).
width
(
'
25%
'
).
fontSize
(
16
).
backgroundColor
(
0xD2B48C
)
.
textAlign
(
TextAlign
.
End
)
Text
(
'
3
'
).
height
(
50
).
width
(
'
25%
'
).
fontSize
(
16
).
backgroundColor
(
0xF5DEB3
)
.
textAlign
(
TextAlign
.
End
)
Text
(
'
4
'
).
height
(
50
).
width
(
'
25%
'
).
fontSize
(
16
).
backgroundColor
(
0xD2B48C
)
.
textAlign
(
TextAlign
.
End
)
}
.
width
(
'
90%
'
)
.
direction
(
Direction
.
Rtl
)
}
}
.
width
(
'
100%
'
).
margin
({
top
:
5
})
.
direction
(
Direction
.
Rtl
)
.
width
(
'
100%
'
).
margin
({
top
:
5
})
}
}
```
...
...
zh-cn/application-dev/reference/errorcodes/errorcode-useriam.md
浏览文件 @
9a6ca42e
...
...
@@ -12,6 +12,20 @@
具体参见
[
通用错误码
](
./errorcode-universal.md
)
## 12500001 执行认证失败
**错误信息**
Authentication failed.
**可能原因**
出现该错误码一般是系统内部错误,例如内存申请失败、内存拷贝出错等。
**处理步骤**
重启设备,重新调用接口。
## 12500002 一般的操作错误
**错误信息**
...
...
@@ -30,6 +44,34 @@ General operation error.
重启设备,重新调用接口。
## 12500003 认证被取消
**错误信息**
Authentication canceled.
**可能原因**
当前的认证操作已经被取消。
**处理步骤**
重新调用认证接口,发起认证。
## 12500004 认证操作超时
**错误信息**
Authentication timeout.
**可能原因**
当前的认证操作超过了设定的时限。
**处理步骤**
重新调用认证接口,发起认证。
## 12500005 认证类型不支持
**错误信息**
...
...
@@ -60,6 +102,34 @@ The authentication trust level is not supported.
检查传入的authTrustLevel是否在合理范围,如果在合理范围,则是当前的设备不支持该认证信任等级。
## 12500007 认证服务已经繁忙
**错误信息**
Authentication service is busy.
**可能原因**
当前已经存在某个尚未结束的认证,又发起了一次认证。
**处理步骤**
稍后重新发起认证。
## 12500009 认证被锁定
**错误信息**
Authentication is lockout.
**可能原因**
当前认证失败的次数超过了上限,触发防爆模式,认证被锁定。
**处理步骤**
稍后重新发起一次成功的认证。
## 12500010 该类型的凭据没有录入
**错误信息**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录