• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License"),
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { AsyncCallback } from './@ohos.base';
17import { MissionInfo as _MissionInfo } from './application/MissionInfo';
18import { MissionListener as _MissionListener } from './application/MissionListener';
19import { MissionSnapshot as _MissionSnapshot } from './application/MissionSnapshot';
20import StartOptions from './@ohos.app.ability.StartOptions';
21
22/**
23 * This module provides the capability to manage abilities and obtaining system task information.
24 *
25 * @namespace missionManager
26 * @permission ohos.permission.MANAGE_MISSIONS
27 * @syscap SystemCapability.Ability.AbilityRuntime.Mission
28 * @systemapi
29 * @since 9
30 */
31declare namespace missionManager {
32  /**
33   * Register the missionListener to ams.
34   *
35   * @permission ohos.permission.MANAGE_MISSIONS
36   * @param { 'mission' } type - mission.
37   * @param { MissionListener } listener - Indicates the MissionListener to be registered.
38   * @returns { number } Returns the index number of the MissionListener.
39   * @throws { BusinessError } 201 - Permission denied.
40   * @throws { BusinessError } 202 - Not system application.
41   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
42   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
43   * @systemapi
44   * @since 9
45   */
46  function on(type: 'mission', listener: MissionListener): number;
47
48  /**
49   * Unregister the missionListener to ams.
50   *
51   * @permission ohos.permission.MANAGE_MISSIONS
52   * @param { 'mission' } type - mission.
53   * @param { number } listenerId - Indicates the listener id to be unregistered.
54   * @param { AsyncCallback<void> } callback - The callback of off.
55   * @throws { BusinessError } 201 - Permission denied.
56   * @throws { BusinessError } 202 - Not system application.
57   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
58   * @throws { BusinessError } 16300002 - Input error. The specified mission listener does not exist.
59   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
60   * @systemapi
61   * @since 9
62   */
63  function off(type: 'mission', listenerId: number, callback: AsyncCallback<void>): void;
64
65  /**
66   * Unregister the missionListener to ams.
67   *
68   * @permission ohos.permission.MANAGE_MISSIONS
69   * @param { 'mission' } type - mission.
70   * @param { number } listenerId - Indicates the listener id to be unregistered.
71   * @returns { Promise<void> } The promise returned by the function.
72   * @throws { BusinessError } 201 - Permission denied.
73   * @throws { BusinessError } 202 - Not system application.
74   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
75   * @throws { BusinessError } 16300002 - Input error. The specified mission listener does not exist.
76   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
77   * @systemapi
78   * @since 9
79   */
80  function off(type: 'mission', listenerId: number): Promise<void>;
81
82  /**
83   * Get the missionInfo with the given missionId.
84   *
85   * @permission ohos.permission.MANAGE_MISSIONS
86   * @param { string } deviceId - Indicates the device to be queried.
87   * @param { number } missionId - Indicates mission id to be queried.
88   * @param { AsyncCallback<MissionInfo> } callback - The callback is used to return the MissionInfo of the given id.
89   * @throws { BusinessError } 201 - Permission denied.
90   * @throws { BusinessError } 202 - Not system application.
91   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
92   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
93   * @systemapi
94   * @since 9
95   */
96  function getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<MissionInfo>): void;
97
98  /**
99   * Get the missionInfo with the given missionId.
100   *
101   * @permission ohos.permission.MANAGE_MISSIONS
102   * @param { string } deviceId - Indicates the device to be queried.
103   * @param { number } missionId - Indicates mission id to be queried.
104   * @returns { Promise<MissionInfo> } Returns the MissionInfo of the given id.
105   * @throws { BusinessError } 201 - Permission denied.
106   * @throws { BusinessError } 202 - Not system application.
107   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
108   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
109   * @systemapi
110   * @since 9
111   */
112  function getMissionInfo(deviceId: string, missionId: number): Promise<MissionInfo>;
113
114  /**
115   * Get missionInfos in the given deviceId with maximum number of numMax.
116   *
117   * @permission ohos.permission.MANAGE_MISSIONS
118   * @param { string } deviceId - Indicates the device to be queried.
119   * @param { number } numMax - Indicates the maximum number of returned missions.
120   * @param { AsyncCallback<Array<MissionInfo>> } callback - The callback is used to return the array of the MissionInfo.
121   * @throws { BusinessError } 201 - Permission denied.
122   * @throws { BusinessError } 202 - Not system application.
123   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
124   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
125   * @systemapi
126   * @since 9
127   */
128  function getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Array<MissionInfo>>): void;
129
130  /**
131   * Get missionInfos in the given deviceId with maximum number of numMax.
132   *
133   * @permission ohos.permission.MANAGE_MISSIONS
134   * @param { string } deviceId - Indicates the device to be queried.
135   * @param { number } numMax - Indicates the maximum number of returned missions.
136   * @returns { Promise<Array<MissionInfo>> } Returns the array of the MissionInfo.
137   * @throws { BusinessError } 201 - Permission denied.
138   * @throws { BusinessError } 202 - Not system application.
139   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
140   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
141   * @systemapi
142   * @since 9
143   */
144  function getMissionInfos(deviceId: string, numMax: number): Promise<Array<MissionInfo>>;
145
146  /**
147   * Get the mission snapshot with the given missionId.
148   *
149   * @permission ohos.permission.MANAGE_MISSIONS
150   * @param { string } deviceId - Indicates the device to be queried.
151   * @param { number } missionId - Indicates mission id to be queried.
152   * @param { AsyncCallback<MissionSnapshot> } callback - The callback is used to return the MissionSnapshot of
153   *                                                      the given id.
154   * @throws { BusinessError } 201 - Permission denied.
155   * @throws { BusinessError } 202 - Not system application.
156   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
157   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
158   * @systemapi
159   * @since 9
160   */
161  function getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback<MissionSnapshot>): void;
162
163  /**
164   * Get the mission snapshot with the given missionId.
165   *
166   * @permission ohos.permission.MANAGE_MISSIONS
167   * @param { string } deviceId - Indicates the device to be queried.
168   * @param { number } missionId - Indicates mission id to be queried.
169   * @returns { Promise<MissionSnapshot> } Returns the MissionSnapshot of the given id.
170   * @throws { BusinessError } 201 - Permission denied.
171   * @throws { BusinessError } 202 - Not system application.
172   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
173   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
174   * @systemapi
175   * @since 9
176   */
177  function getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnapshot>;
178
179  /**
180   * Get the mission low resolution snapshot with the given missionId.
181   *
182   * @permission ohos.permission.MANAGE_MISSIONS
183   * @param { string } deviceId - Indicates the device to be queried.
184   * @param { number } missionId - Indicates mission id to be queried.
185   * @param { AsyncCallback<MissionSnapshot> } callback - The callback is used to return the MissionSnapshot of
186   *                                                      the given id.
187   * @throws { BusinessError } 201 - Permission denied.
188   * @throws { BusinessError } 202 - Not system application.
189   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
190   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
191   * @systemapi
192   * @since 9
193   */
194  function getLowResolutionMissionSnapShot(
195    deviceId: string,
196    missionId: number,
197    callback: AsyncCallback<MissionSnapshot>
198  ): void;
199
200  /**
201   * Get the mission low resolution snapshot with the given missionId.
202   *
203   * @permission ohos.permission.MANAGE_MISSIONS
204   * @param { string } deviceId - Indicates the device to be queried.
205   * @param { number } missionId - Indicates mission id to be queried.
206   * @returns { Promise<MissionSnapshot> } Returns the MissionSnapshot of the given id.
207   * @throws { BusinessError } 201 - Permission denied.
208   * @throws { BusinessError } 202 - Not system application.
209   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
210   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
211   * @systemapi
212   * @since 9
213   */
214  function getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnapshot>;
215
216  /**
217   * Lock the mission.
218   *
219   * @permission ohos.permission.MANAGE_MISSIONS
220   * @param { number } missionId - Indicates mission id to be locked.
221   * @param { AsyncCallback<void> } callback - The callback of lockMission.
222   * @throws { BusinessError } 201 - Permission denied.
223   * @throws { BusinessError } 202 - Not system application.
224   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
225   * @throws { BusinessError } 16300001 - Mission not found.
226   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
227   * @systemapi
228   * @since 9
229   */
230  function lockMission(missionId: number, callback: AsyncCallback<void>): void;
231
232  /**
233   * Lock the mission.
234   *
235   * @permission ohos.permission.MANAGE_MISSIONS
236   * @param { number } missionId - Indicates mission id to be locked.
237   * @returns { Promise<void> } The promise returned by the function.
238   * @throws { BusinessError } 201 - Permission denied.
239   * @throws { BusinessError } 202 - Not system application.
240   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
241   * @throws { BusinessError } 16300001 - Mission not found.
242   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
243   * @systemapi
244   * @since 9
245   */
246  function lockMission(missionId: number): Promise<void>;
247
248  /**
249   * Unlock the mission.
250   *
251   * @permission ohos.permission.MANAGE_MISSIONS
252   * @param { number } missionId - Indicates mission id to be unlocked.
253   * @param { AsyncCallback<void> } callback - The callback of unlockMission.
254   * @throws { BusinessError } 201 - Permission denied.
255   * @throws { BusinessError } 202 - Not system application.
256   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
257   * @throws { BusinessError } 16300001 - Mission not found.
258   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
259   * @systemapi
260   * @since 9
261   */
262  function unlockMission(missionId: number, callback: AsyncCallback<void>): void;
263
264  /**
265   * Unlock the mission.
266   *
267   * @permission ohos.permission.MANAGE_MISSIONS
268   * @param { number } missionId - Indicates mission id to be unlocked.
269   * @returns { Promise<void> } The promise returned by the function.
270   * @throws { BusinessError } 201 - Permission denied.
271   * @throws { BusinessError } 202 - Not system application.
272   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
273   * @throws { BusinessError } 16300001 - Mission not found.
274   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
275   * @systemapi
276   * @since 9
277   */
278  function unlockMission(missionId: number): Promise<void>;
279
280  /**
281   * Clear the given mission in the ability manager service.
282   *
283   * @permission ohos.permission.MANAGE_MISSIONS
284   * @param { number } missionId - Indicates mission id to be cleared.
285   * @param { AsyncCallback<void> } callback - The callback of clearMission.
286   * @throws { BusinessError } 201 - Permission denied.
287   * @throws { BusinessError } 202 - Not system application.
288   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
289   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
290   * @systemapi
291   * @since 9
292   */
293  function clearMission(missionId: number, callback: AsyncCallback<void>): void;
294
295  /**
296   * Clear the given mission in the ability manager service.
297   *
298   * @permission ohos.permission.MANAGE_MISSIONS
299   * @param { number } missionId - Indicates mission id to be cleared.
300   * @returns { Promise<void> } The promise returned by the function.
301   * @throws { BusinessError } 201 - Permission denied.
302   * @throws { BusinessError } 202 - Not system application.
303   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
304   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
305   * @systemapi
306   * @since 9
307   */
308  function clearMission(missionId: number): Promise<void>;
309
310  /**
311   * Clear all missions in the ability manager service.
312   *
313   * @permission ohos.permission.MANAGE_MISSIONS
314   * @param { AsyncCallback<void> } callback - The callback of clearAllMissions.
315   * @throws { BusinessError } 201 - Permission denied.
316   * @throws { BusinessError } 202 - Not system application.
317   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
318   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
319   * @systemapi
320   * @since 9
321   */
322  function clearAllMissions(callback: AsyncCallback<void>): void;
323
324  /**
325   * Clear all missions in the ability manager service.
326   *
327   * @permission ohos.permission.MANAGE_MISSIONS
328   * @returns { Promise<void> } The promise returned by the function.
329   * @throws { BusinessError } 201 - Permission denied.
330   * @throws { BusinessError } 202 - Not system application.
331   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
332   * @systemapi
333   * @since 9
334   */
335  function clearAllMissions(): Promise<void>;
336
337  /**
338   * Schedule the given mission to foreground.
339   *
340   * @permission ohos.permission.MANAGE_MISSIONS
341   * @param { number } missionId - Indicates mission id to be moved to foreground.
342   * @param { AsyncCallback<void> } callback - The callback of moveMissionToFront.
343   * @throws { BusinessError } 201 - Permission denied.
344   * @throws { BusinessError } 202 - Not system application.
345   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
346   * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
347   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
348   * @systemapi
349   * @since 9
350   */
351  function moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void;
352
353  /**
354   * Schedule the given mission to foreground.
355   *
356   * @permission ohos.permission.MANAGE_MISSIONS
357   * @param { number } missionId - Indicates mission id to be moved to foreground.
358   * @param { StartOptions } options - Indicates the start options.
359   * @param { AsyncCallback<void> } callback - The callback of moveMissionToFront.
360   * @throws { BusinessError } 201 - Permission denied.
361   * @throws { BusinessError } 202 - Not system application.
362   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
363   * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
364   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
365   * @systemapi
366   * @since 9
367   */
368  function moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCallback<void>): void;
369
370  /**
371   * Schedule the given mission to foreground.
372   *
373   * @permission ohos.permission.MANAGE_MISSIONS
374   * @param { number } missionId - Indicates mission id to be moved to foreground.
375   * @param { StartOptions } [options] - Indicates the start options.
376   * @returns { Promise<void> } The promise returned by the function.
377   * @throws { BusinessError } 201 - Permission denied.
378   * @throws { BusinessError } 202 - Not system application.
379   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
380   * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
381   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
382   * @systemapi
383   * @since 9
384   */
385  function moveMissionToFront(missionId: number, options?: StartOptions): Promise<void>;
386
387  /**
388   * Schedule the given missions to foreground.
389   *
390   * @permission ohos.permission.MANAGE_MISSIONS
391   * @param { Array<number> } missionIds - Indicates mission ids to be moved to foreground.
392   * @param { AsyncCallback<void> } callback - The callback of moveMissionsToForeground.
393   * @throws { BusinessError } 201 - Permission denied.
394   * @throws { BusinessError } 202 - Not system application.
395   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
396   * @throws { BusinessError } 16000050 - Internal error.
397   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
398   * @systemapi
399   * @since 10
400   */
401  function moveMissionsToForeground(missionIds: Array<number>, callback: AsyncCallback<void>): void;
402
403  /**
404   * Schedule the given missions to foreground.
405   *
406   * @permission ohos.permission.MANAGE_MISSIONS
407   * @param { Array<number> } missionIds - Indicates mission ids to be moved to foreground.
408   * @param { number } topMission - Indicates mission id to be moved to top.
409   * @param { AsyncCallback<void> } callback - The callback of moveMissionsToForeground.
410   * @throws { BusinessError } 201 - Permission denied.
411   * @throws { BusinessError } 202 - Not system application.
412   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
413   * @throws { BusinessError } 16000050 - Internal error.
414   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
415   * @systemapi
416   * @since 10
417   */
418  function moveMissionsToForeground(missionIds: Array<number>, topMission: number, callback: AsyncCallback<void>): void;
419
420  /**
421   * Schedule the given missions to foreground.
422   *
423   * @permission ohos.permission.MANAGE_MISSIONS
424   * @param { Array<number> } missionIds - Indicates mission ids to be moved to foreground.
425   * @param { number } topMission - Indicates mission id to be moved to top.
426   * @returns { Promise<void> } The promise returned by the function.
427   * @throws { BusinessError } 201 - Permission denied.
428   * @throws { BusinessError } 202 - Not system application.
429   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
430   * @throws { BusinessError } 16000050 - Internal error.
431   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
432   * @systemapi
433   * @since 10
434   */
435  function moveMissionsToForeground(missionIds: Array<number>, topMission?: number): Promise<void>;
436
437  /**
438   * Schedule the given missions to background.
439   *
440   * @permission ohos.permission.MANAGE_MISSIONS
441   * @param { Array<number> } missionIds - Indicates mission ids will be moved to background
442   * @param { AsyncCallback<Array<number>> } callback - The callback of moveMissionsToForeground.
443   * @throws { BusinessError } 201 - Permission denied.
444   * @throws { BusinessError } 202 - Not system application.
445   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
446   * @throws { BusinessError } 16000050 - Internal error.
447   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
448   * @systemapi
449   * @since 10
450   */
451  function moveMissionsToBackground(missionIds: Array<number>, callback: AsyncCallback<Array<number>>): void;
452
453  /**
454   * Schedule the given missions to background.
455   *
456   * @permission ohos.permission.MANAGE_MISSIONS
457   * @param { Array<number> } missionIds - Indicates mission ids will be moved to background
458   * @returns { Promise<Array<number>> } - The promise returned by the function.
459   * @throws { BusinessError } 201 - Permission denied.
460   * @throws { BusinessError } 202 - Not system application.
461   * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
462   * @throws { BusinessError } 16000050 - Internal error.
463   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
464   * @systemapi
465   * @since 10
466   */
467  function moveMissionsToBackground(missionIds: Array<number>): Promise<Array<number>>;
468
469  /**
470   * Mission information corresponding to ability.
471   *
472   * @permission ohos.permission.MANAGE_MISSIONS
473   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
474   * @systemapi
475   * @since 9
476   */
477  export type MissionInfo = _MissionInfo;
478
479  /**
480   * MissionListener registered by app.
481   *
482   * @permission ohos.permission.MANAGE_MISSIONS
483   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
484   * @systemapi
485   * @since 9
486   */
487  export type MissionListener = _MissionListener;
488
489  /**
490   * Mission snapshot corresponding to mission.
491   *
492   * @permission ohos.permission.MANAGE_MISSIONS
493   * @syscap SystemCapability.Ability.AbilityRuntime.Mission
494   * @systemapi
495   * @since 9
496   */
497  export type MissionSnapshot = _MissionSnapshot;
498}
499
500export default missionManager;
501