1/* 2 * Copyright (c) 2022 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 './basic'; 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 * @permission ohos.permission.MANAGE_MISSIONS 25 * @namespace missionManager 26 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 27 * @systemapi 28 * @since 9 29 */ 30declare namespace missionManager { 31 /** 32 * Register the missionListener to ams. 33 * @param { string } type - mission. 34 * @param { MissionListener } listener - Indicates the MissionListener to be registered. 35 * @returns { number } Returns the index number of the MissionListener. 36 * @throws { BusinessError } 201 - Permission denied. 37 * @throws { BusinessError } 202 - Not system application. 38 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 39 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 40 * @since 9 41 */ 42 function on(type: "mission", listener: MissionListener): number; 43 44 /** 45 * Unregister the missionListener to ams. 46 * @param { string } type - mission. 47 * @param { number } listenerId - Indicates the listener id to be unregistered. 48 * @param { AsyncCallback<void> } callback - The callback of off. 49 * @throws { BusinessError } 201 - Permission denied. 50 * @throws { BusinessError } 202 - Not system application. 51 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 52 * @throws { BusinessError } 16300002 - Input error. The specified mission listener does not exist. 53 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 54 * @since 9 55 */ 56 function off(type: "mission", listenerId: number, callback: AsyncCallback<void>): void; 57 58 /** 59 * Unregister the missionListener to ams. 60 * @param { string } type - mission. 61 * @param { number } listenerId - Indicates the listener id to be unregistered. 62 * @returns { Promise<void> } The promise returned by the function. 63 * @throws { BusinessError } 201 - Permission denied. 64 * @throws { BusinessError } 202 - Not system application. 65 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 66 * @throws { BusinessError } 16300002 - Input error. The specified mission listener does not exist. 67 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 68 * @since 9 69 */ 70 function off(type: "mission", listenerId: number): Promise<void>; 71 72 /** 73 * Get the missionInfo with the given missionId. 74 * @param { string } deviceId - Indicates the device to be queried. 75 * @param { number } missionId - Indicates mission id to be queried. 76 * @param { AsyncCallback<MissionInfo> } callback - The callback is used to return the MissionInfo of the given id. 77 * @throws { BusinessError } 201 - Permission denied. 78 * @throws { BusinessError } 202 - Not system application. 79 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 80 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 81 * @since 9 82 */ 83 function getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<MissionInfo>): void; 84 85 /** 86 * Get the missionInfo with the given missionId. 87 * @param { string } deviceId - Indicates the device to be queried. 88 * @param { number } missionId - Indicates mission id to be queried. 89 * @returns { Promise<MissionInfo> } Returns the MissionInfo of the given id. 90 * @throws { BusinessError } 201 - Permission denied. 91 * @throws { BusinessError } 202 - Not system application. 92 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 93 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 94 * @since 9 95 */ 96 function getMissionInfo(deviceId: string, missionId: number): Promise<MissionInfo>; 97 98 /** 99 * Get missionInfos in the given deviceId with maximum number of numMax. 100 * @param { string } deviceId - Indicates the device to be queried. 101 * @param { number } numMax - Indicates the maximum number of returned missions. 102 * @param { AsyncCallback<Array<MissionInfo>> } callback - The callback is used to return the array of the MissionInfo. 103 * @throws { BusinessError } 201 - Permission denied. 104 * @throws { BusinessError } 202 - Not system application. 105 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 106 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 107 * @since 9 108 */ 109 function getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Array<MissionInfo>>): void; 110 111 /** 112 * Get missionInfos in the given deviceId with maximum number of numMax. 113 * @param { string } deviceId - Indicates the device to be queried. 114 * @param { number } numMax - Indicates the maximum number of returned missions. 115 * @returns { Promise<Array<MissionInfo>> } Returns the array of the MissionInfo. 116 * @throws { BusinessError } 201 - Permission denied. 117 * @throws { BusinessError } 202 - Not system application. 118 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 119 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 120 * @since 9 121 */ 122 function getMissionInfos(deviceId: string, numMax: number): Promise<Array<MissionInfo>>; 123 124 /** 125 * Get the mission snapshot with the given missionId. 126 * @param { string } deviceId - Indicates the device to be queried. 127 * @param { number } missionId - Indicates mission id to be queried. 128 * @param { AsyncCallback<MissionSnapshot> } callback - The callback is used to return the MissionSnapshot of the given id. 129 * @throws { BusinessError } 201 - Permission denied. 130 * @throws { BusinessError } 202 - Not system application. 131 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 132 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 133 * @since 9 134 */ 135 function getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback<MissionSnapshot>): void; 136 137 /** 138 * Get the mission snapshot with the given missionId. 139 * @param { string } deviceId - Indicates the device to be queried. 140 * @param { number } missionId - Indicates mission id to be queried. 141 * @returns { Promise<MissionSnapshot> } Returns the MissionSnapshot of the given id. 142 * @throws { BusinessError } 201 - Permission denied. 143 * @throws { BusinessError } 202 - Not system application. 144 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 145 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 146 * @since 9 147 */ 148 function getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnapshot>; 149 150 /** 151 * Get the mission low resolution snapshot with the given missionId. 152 * @param { string } deviceId - Indicates the device to be queried. 153 * @param { number } missionId - Indicates mission id to be queried. 154 * @param { AsyncCallback<MissionSnapshot> } callback - The callback is used to return the MissionSnapshot of the given id. 155 * @throws { BusinessError } 201 - Permission denied. 156 * @throws { BusinessError } 202 - Not system application. 157 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 158 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 159 * @since 9 160 */ 161 function getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback<MissionSnapshot>): void; 162 163 /** 164 * Get the mission low resolution snapshot with the given missionId. 165 * @param { string } deviceId - Indicates the device to be queried. 166 * @param { number } missionId - Indicates mission id to be queried. 167 * @returns { Promise<MissionSnapshot> } Returns the MissionSnapshot of the given id. 168 * @throws { BusinessError } 201 - Permission denied. 169 * @throws { BusinessError } 202 - Not system application. 170 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 171 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 172 * @since 9 173 */ 174 function getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnapshot>; 175 176 /** 177 * Lock the mission. 178 * @param { number } missionId - Indicates mission id to be locked. 179 * @param { AsyncCallback<void> } callback - The callback of lockMission. 180 * @throws { BusinessError } 201 - Permission denied. 181 * @throws { BusinessError } 202 - Not system application. 182 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 183 * @throws { BusinessError } 16300001 - Mission not found. 184 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 185 * @since 9 186 */ 187 function lockMission(missionId: number, callback: AsyncCallback<void>): void; 188 189 /** 190 * Lock the mission. 191 * @param { number } missionId - Indicates mission id to be locked. 192 * @returns { Promise<void> } The promise returned by the function. 193 * @throws { BusinessError } 201 - Permission denied. 194 * @throws { BusinessError } 202 - Not system application. 195 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 196 * @throws { BusinessError } 16300001 - Mission not found. 197 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 198 * @since 9 199 */ 200 function lockMission(missionId: number): Promise<void>; 201 202 /** 203 * Unlock the mission. 204 * @param { number } missionId - Indicates mission id to be unlocked. 205 * @param { AsyncCallback<void> } callback - The callback of unlockMission. 206 * @throws { BusinessError } 201 - Permission denied. 207 * @throws { BusinessError } 202 - Not system application. 208 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 209 * @throws { BusinessError } 16300001 - Mission not found. 210 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 211 * @since 9 212 */ 213 function unlockMission(missionId: number, callback: AsyncCallback<void>): void; 214 215 /** 216 * Unlock the mission. 217 * @param { number } missionId - Indicates mission id to be unlocked. 218 * @returns { Promise<void> } The promise returned by the function. 219 * @throws { BusinessError } 201 - Permission denied. 220 * @throws { BusinessError } 202 - Not system application. 221 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 222 * @throws { BusinessError } 16300001 - Mission not found. 223 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 224 * @since 9 225 */ 226 function unlockMission(missionId: number): Promise<void>; 227 228 /** 229 * Clear the given mission in the ability manager service. 230 * @param { number } missionId - Indicates mission id to be cleared. 231 * @param { AsyncCallback<void> } callback - The callback of clearMission. 232 * @throws { BusinessError } 201 - Permission denied. 233 * @throws { BusinessError } 202 - Not system application. 234 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 235 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 236 * @since 9 237 */ 238 function clearMission(missionId: number, callback: AsyncCallback<void>): void; 239 240 /** 241 * Clear the given mission in the ability manager service. 242 * @param { number } missionId - Indicates mission id to be cleared. 243 * @returns { Promise<void> } The promise returned by the function. 244 * @throws { BusinessError } 201 - Permission denied. 245 * @throws { BusinessError } 202 - Not system application. 246 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 247 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 248 * @since 9 249 */ 250 function clearMission(missionId: number): Promise<void>; 251 252 /** 253 * Clear all missions in the ability manager service. 254 * @param { AsyncCallback<void> } callback - The callback of clearAllMissions. 255 * @throws { BusinessError } 201 - Permission denied. 256 * @throws { BusinessError } 202 - Not system application. 257 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 258 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 259 * @since 9 260 */ 261 function clearAllMissions(callback: AsyncCallback<void>): void; 262 263 /** 264 * Clear all missions in the ability manager service. 265 * @returns { Promise<void> } The promise returned by the function. 266 * @throws { BusinessError } 201 - Permission denied. 267 * @throws { BusinessError } 202 - Not system application. 268 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 269 * @since 9 270 */ 271 function clearAllMissions(): Promise<void>; 272 273 /** 274 * Schedule the given mission to foreground. 275 * @param { number } missionId - Indicates mission id to be moved to foreground. 276 * @param { AsyncCallback<void> } callback - The callback of moveMissionToFront. 277 * @throws { BusinessError } 201 - Permission denied. 278 * @throws { BusinessError } 202 - Not system application. 279 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 280 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 281 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 282 * @since 9 283 */ 284 function moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void; 285 286 /** 287 * Schedule the given mission to foreground. 288 * @param { number } missionId - Indicates mission id to be moved to foreground. 289 * @param { StartOptions } options - Indicates the start options. 290 * @param { AsyncCallback<void> } callback - The callback of moveMissionToFront. 291 * @throws { BusinessError } 201 - Permission denied. 292 * @throws { BusinessError } 202 - Not system application. 293 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 294 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 295 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 296 * @since 9 297 */ 298 function moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCallback<void>): void; 299 300 /** 301 * Schedule the given mission to foreground. 302 * @param { number } missionId - Indicates mission id to be moved to foreground. 303 * @param { StartOptions } options - Indicates the start options. 304 * @returns { Promise<void> } The promise returned by the function. 305 * @throws { BusinessError } 201 - Permission denied. 306 * @throws { BusinessError } 202 - Not system application. 307 * @throws { BusinessError } 401 - If the input parameter is not valid parameter. 308 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 309 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 310 * @since 9 311 */ 312 function moveMissionToFront(missionId: number, options?: StartOptions): Promise<void>; 313 314 /** 315 * Mission information corresponding to ability. 316 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 317 * @systemapi 318 * @since 9 319 */ 320 export type MissionInfo = _MissionInfo 321 322 /** 323 * MissionListener registered by app. 324 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 325 * @systemapi 326 * @since 9 327 */ 328 export type MissionListener = _MissionListener 329 330 /** 331 * Mission snapshot corresponding to mission. 332 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 333 * @systemapi 334 * @since 9 335 */ 336 export type MissionSnapshot = _MissionSnapshot 337} 338 339export default missionManager;