• Home
Name Date Size #Lines LOC

..--

AppScope/06-May-2025-3633

entry/06-May-2025-1,3361,099

hvigor/06-May-2025-2422

screenshots/device/06-May-2025-

.gitignoreD06-May-2025112 88

README.mdD06-May-20251.8 KiB3618

README_zh.mdD06-May-20254.1 KiB7651

build-profile.json5D06-May-20251 KiB4341

hvigorfile.jsD06-May-2025168 21

hvigorwD06-May-20252.1 KiB6428

hvigorw.batD06-May-20252 KiB7356

oh-package.json5D06-May-2025820 2725

ohosTest.mdD06-May-2025970 119

README.md

1# Mission Manager
2
3### Introduction
4
5This sample calls APIs related to the mission manager to lock, unlock, and clear missions, and switch them to the foreground.
6
7### Concepts
8
9Mission manager: You can lock, unlock, and clear missions, and switch them to the foreground.
10
11### Required Permissions
12
13ohos.permission.MANAGE_MISSIONS
14
15### Usage
16
171. Pull down the sample app to obtain the mission information, including the bundle name, running status, locking status, mission snapshot, and whether the mission supports migration. Information about a maximum of 10 missions can be obtained.
18
192. Swipe left on the mission list and touch **Lock** to lock a mission.
20
213. If the mission is locked, touch **Unlock** to unlock it.
22
234. Touch **Delete** to delete a mission.
24
255. Touch **Move** to switch a mission to the foreground.
26
27### Constraints
28
291. This sample can only be run on standard-system devices.
30
312. This sample supports only the SDK of API version 9 and uses the system API **@ohos.application.missionManager**. Therefore, you must manually switch to the Full SDK for successful compilation. For details about the operation, see [Guide to Switching to Full SDK](https://gitee.com/openharmony/docs/blob/master/en/application-dev/faqs/full-sdk-switch-guide.md/).
32
333. DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100) must be used.
34
354. The permission **ohos.permission.MANAGE_MISSIONS** is at the system_core level. Therefore, you must manually configure the signature for the corresponding permission level. For details about the permission level, see [Permission List](https://gitee.com/openharmony/docs/blob/master/en/application-dev/security/AccessToken/permissions-for-system-apps.md). For details about the configuration operation, see [Having Your App Automatically Signed](https://gitee.com/openharmony/docs/blob/master/en/application-dev/security/hapsigntool-overview.md/).
36

README_zh.md

1# 系统任务管理(仅对系统应用开放)
2
3### 介绍
4
5本示例通过调用系统任务管理的能力,使用[@ohos.application.missionManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-application-missionManager-sys.md) 、[@ohos.multimedia.image](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-image-kit/js-apis-image.md) 等接口完成对系统任务执行锁定、解锁、清理、切换到前台等操作。
6
7### 效果预览
8
9|初始页|任务页|任务操作页|时钟页|
10|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
11|![](./screenshots/device/initPage.jpeg)|![](./screenshots/device/missionPage.jpeg)|![](./screenshots/device/misssionOperation.jpeg)|![](./screenshots/device/colokPage.jpeg)|
12
13使用说明
14
151.下拉“**获取系统任务信息**”,获取当前系统任务的包名、运行状态、锁定状态、任务是否支持迁移、任务快照等信息列表,且最多可获取10条任务;
16
172.左滑任务列表,点击“**锁定**”,即可锁定指定的任务;
18
193.若当前任务已锁定,可点击“**解锁**”,即可解锁指定的任务;
20
214.点击“**删除**”,即可删除指定的任务;
22
235.点击“**移动**”,即可将指定的任务移动到前台执行。
24
25### 工程目录
26```
27entry/src/main/ets/
28|---Application
29|---common
30|   |---MissionInfoComponent.ets       // 任务信息组件
31|   |---TitleBar.ets                   // 标题组件
32|---MainAbility
33|---model
34|   |---Logger.ts                      // 日志工具
35|   |---Mission.ts                     // 虚拟数据
36|---pages
37|   |---Index.ets                      // 首页
38```
39
40### 具体实现
41
42* 任务执行锁定、解锁、清理、切换到前台等操作的功能结构主要封装在Index、MissionInfoComponent,源码参考:[Index.ets](entry/src/main/ets/pages/Index.ets) ,[MissionInfoComponent.ets](entry/src/main/ets/common/MissionInfoComponent.ets)
43    * 获取任务信息:在Index页面中通过missionManager.getMissionInfos()方法来获取所有的mission;
44    * 执行或者解锁锁定任务:在MissionInfoComponent组件当中可以通过missionManager.lockMission(missionId)方法来锁定指定的mission,而missionManager.unlockMission(missionId)用来解锁mission;
45    * 移动指定的任务:将指定的任务移动到前台执行可以使用missionManager.moveMissionToFront(missionId)方法;
46    * 删除指定的任务:删除指定的任务可以通过missionManager.clearMission(missionId)方法实现。
47
48### 相关权限
49
50[ohos.permission.MANAGE_MISSIONS](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionmanage_missions)
51
52### 依赖
53
54不涉及。
55
56### 约束与限制
57
581.本示例仅支持在标准系统上运行。
59
602.本示例已适配API version 9版本SDK,本示例涉及使用系统接口:@ohos.application.missionManager,需要手动替换Full SDK才能编译通过,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/faqs/full-sdk-switch-guide.md)61
623.本示例需要使用DevEco Studio 3.1 Beta2 (Build Version: 3.1.0.400, built on April 7, 2023)及以上版本才可编译运行。
63
644.本示例所配置的权限ohos.permission.MANAGE_MISSIONS为system_core级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md))65
66### 下载
67
68如需单独下载本工程,执行如下命令:
69```
70git init
71git config core.sparsecheckout true
72echo code/SystemFeature/ApplicationModels/MissionManager/ > .git/info/sparse-checkout
73git remote add origin https://gitee.com/openharmony/applications_app_samples.git
74git pull origin master
75```
76