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 16/** 17 * @file 18 * @kit AbilityKit 19 */ 20 21import type { AsyncCallback, Callback } from './@ohos.base'; 22import type { ContinuableInfo as _ContinuableInfo } from './application/ContinuableInfo'; 23import type { ContinueCallback as _ContinueCallback } from './application/ContinueCallback'; 24import type { ContinueDeviceInfo as _ContinueDeviceInfo } from './application/ContinueDeviceInfo'; 25import type { ContinueMissionInfo as _ContinueMissionInfo } from './application/ContinueMissionInfo'; 26import type { MissionCallback as _MissionCallback } from './application/MissionCallbacks'; 27import type { MissionDeviceInfo as _MissionDeviceInfo } from './application/MissionDeviceInfo'; 28import type { MissionParameter as _MissionParameter } from './application/MissionParameter'; 29 30/** 31 * This module provides the capability to manage abilities and obtain system task information for distributed 32 * scenario. 33 * 34 * @namespace distributedMissionManager 35 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 36 * @systemapi Hide this for inner system use. 37 * @since 9 38 */ 39declare namespace distributedMissionManager { 40 /** 41 * Continue state change event definition. 42 * 43 * @enum { number } 44 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 45 * @systemapi Hide this for inner system use. 46 * @since 10 47 */ 48 enum ContinueState { 49 /** 50 * Mission continuable active. 51 * 52 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 53 * @systemapi Hide this for inner system use. 54 * @since 10 55 */ 56 ACTIVE = 0, 57 58 /** 59 * Mission continuable inactive. 60 * 61 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 62 * @systemapi Hide this for inner system use. 63 * @since 10 64 */ 65 INACTIVE = 1 66 } 67 68 /** 69 * ContinueCallbackInfo. 70 * 71 * @interface ContinueCallbackInfo 72 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 73 * @systemapi Hide this for inner system use. 74 * @since 11 75 */ 76 interface ContinueCallbackInfo { 77 /** 78 * Continue state event. 79 * 80 * @type { ContinueState } 81 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 82 * @systemapi Hide this for inner system use. 83 * @since 11 84 */ 85 state: ContinueState; 86 87 /** 88 * Continuable information corresponding to ability. 89 * 90 * @type { ContinuableInfo } 91 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 92 * @systemapi Hide this for inner system use. 93 * @since 11 94 */ 95 info: ContinuableInfo; 96 } 97 98 /** 99 * Start sync missions from remote device. 100 * 101 * @permission ohos.permission.MANAGE_MISSIONS 102 * @param { MissionParameter } parameter - Parameters corresponding to mission. 103 * @param { AsyncCallback<void> } callback - the callback of startSyncRemoteMissions. 104 * @throws { BusinessError } 201 - Permission denied. 105 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 106 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 107 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 108 * @systemapi Hide this for inner system use. 109 * @since 9 110 */ 111 function startSyncRemoteMissions(parameter: MissionParameter, callback: AsyncCallback<void>): void; 112 113 /** 114 * Start sync missions from remote device. 115 * 116 * @permission ohos.permission.MANAGE_MISSIONS 117 * @param { MissionParameter } parameter - Parameters corresponding to mission. 118 * @returns { Promise<void> } - the promise returned by the function. 119 * @throws { BusinessError } 201 - Permission denied. 120 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 121 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 122 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 123 * @systemapi Hide this for inner system use. 124 * @since 9 125 */ 126 function startSyncRemoteMissions(parameter: MissionParameter): Promise<void>; 127 128 /** 129 * Stop sync missions from remote device. 130 * 131 * @permission ohos.permission.MANAGE_MISSIONS 132 * @param { MissionDeviceInfo } parameter - Parameters corresponding to mission. 133 * @param { AsyncCallback<void> } callback - the callback of stopSyncRemoteMissions. 134 * @throws { BusinessError } 201 - Permission denied. 135 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 136 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 137 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 138 * @systemapi Hide this for inner system use. 139 * @since 9 140 */ 141 function stopSyncRemoteMissions(parameter: MissionDeviceInfo, callback: AsyncCallback<void>): void; 142 143 /** 144 * Stop sync missions from remote device. 145 * 146 * @permission ohos.permission.MANAGE_MISSIONS 147 * @param { MissionDeviceInfo } parameter - Parameters corresponding to mission. 148 * @returns { Promise<void> } - the promise returned by the function. 149 * @throws { BusinessError } 201 - Permission denied. 150 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 151 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 152 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 153 * @systemapi Hide this for inner system use. 154 * @since 9 155 */ 156 function stopSyncRemoteMissions(parameter: MissionDeviceInfo): Promise<void>; 157 158 /** 159 * Register the missionListener to ams. 160 * 161 * @permission ohos.permission.MANAGE_MISSIONS 162 * @param { MissionDeviceInfo } parameter - Parameters corresponding to mission. 163 * @param { MissionCallback } options - The callbacks for registering mission. 164 * @param { AsyncCallback<void> } callback - the callback of registerMissionListener. 165 * @throws { BusinessError } 201 - Permission denied. 166 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 167 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 168 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 169 * @systemapi Hide this for inner system use. 170 * @since 9 171 */ 172 function registerMissionListener( 173 parameter: MissionDeviceInfo, 174 options: MissionCallback, 175 callback: AsyncCallback<void> 176 ): void; 177 178 /** 179 * Register the missionListener to ams. 180 * 181 * @permission ohos.permission.MANAGE_MISSIONS 182 * @param { MissionDeviceInfo } parameter - Parameters corresponding to mission. 183 * @param { MissionCallback } options - The callbacks for registering mission. 184 * @returns { Promise<void> } - the promise returned by the function. 185 * @throws { BusinessError } 201 - Permission denied. 186 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 187 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 188 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 189 * @systemapi Hide this for inner system use. 190 * @since 9 191 */ 192 function registerMissionListener(parameter: MissionDeviceInfo, options: MissionCallback): Promise<void>; 193 194 /** 195 * Unregister the missionListener to ams. 196 * 197 * @permission ohos.permission.MANAGE_MISSIONS 198 * @param { MissionDeviceInfo } parameter - Parameters corresponding to mission. 199 * @param { AsyncCallback<void> } callback - the callback of registerMissionListener. 200 * @throws { BusinessError } 201 - Permission denied. 201 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 202 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 203 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 204 * @systemapi Hide this for inner system use. 205 * @since 9 206 */ 207 function unRegisterMissionListener(parameter: MissionDeviceInfo, callback: AsyncCallback<void>): void; 208 209 /** 210 * Unregister the missionListener to ams. 211 * 212 * @permission ohos.permission.MANAGE_MISSIONS 213 * @param { MissionDeviceInfo } parameter - Parameters corresponding to mission. 214 * @returns { Promise<void> } - the promise returned by the function. 215 * @throws { BusinessError } 201 - Permission denied. 216 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 217 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 218 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 219 * @systemapi Hide this for inner system use. 220 * @since 9 221 */ 222 function unRegisterMissionListener(parameter: MissionDeviceInfo): Promise<void>; 223 224 /** 225 * Register continuable info listener to ams. 226 * 227 * @permission ohos.permission.MANAGE_MISSIONS 228 * @param { 'continueStateChange' } type - Indicate the event type. 229 * @param { Callback<{ state: ContinueState, info: ContinuableInfo }> } callback - The callback of continueStateChange. 230 * @throws { BusinessError } 201 - Permission denied. 231 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 232 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 233 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 234 * @systemapi Hide this for inner system use. 235 * @since 10 236 */ 237 /** 238 * Register continuable info listener to ams. 239 * 240 * @permission ohos.permission.MANAGE_MISSIONS 241 * @param { 'continueStateChange' } type - Indicate the event type. 242 * @param { Callback<ContinueCallbackInfo> } callback - The callback of continueStateChange. 243 * @throws { BusinessError } 201 - Permission denied. 244 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 245 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 246 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 247 * @systemapi Hide this for inner system use. 248 * @since 11 249 */ 250 function on(type: 'continueStateChange', callback: Callback<ContinueCallbackInfo>): void; 251 252 /** 253 * Unregister continuable info listener to ams. 254 * 255 * @permission ohos.permission.MANAGE_MISSIONS 256 * @param { 'continueStateChange' } type - Indicate the event type. 257 * @param { Callback<{ state: ContinueState, info: ContinuableInfo }> } [callback] - The callback of continueStateChange. 258 * @throws { BusinessError } 201 - Permission denied. 259 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 260 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 261 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 262 * @systemapi Hide this for inner system use. 263 * @since 10 264 */ 265 /** 266 * Unregister continuable info listener to ams. 267 * 268 * @permission ohos.permission.MANAGE_MISSIONS 269 * @param { 'continueStateChange' } type - Indicate the event type. 270 * @param { Callback<ContinueCallbackInfo> } callback - The callback of continueStateChange. 271 * @throws { BusinessError } 201 - Permission denied. 272 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 273 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 274 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 275 * @systemapi Hide this for inner system use. 276 * @since 11 277 */ 278 function off(type: 'continueStateChange', callback?: Callback<ContinueCallbackInfo>): void; 279 280 /** 281 * Continue mission 282 * 283 * @permission ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC 284 * @param { ContinueDeviceInfo } parameter - Parameters corresponding to continue mission. 285 * @param { ContinueCallback } options - the migration task completes the callback function. 286 * @param { AsyncCallback<void> } callback - the callback of continueMission. 287 * @throws { BusinessError } 201 - Permission denied. 288 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 289 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 290 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 291 * @throws { BusinessError } 16300501 - The system ability work abnormally. 292 * @throws { BusinessError } 16300502 - Failed to get the missionInfo of the specified missionId. 293 * @throws { BusinessError } 16300503 - The application is not installed on the remote end and installation-free is 294 * not supported. 295 * @throws { BusinessError } 16300504 - The application is not installed on the remote end but installation-free is 296 * supported, try again with freeInstall flag. 297 * @throws { BusinessError } 16300505 - The operation device must be the device where the application to be continued 298 * is located or the target device to be continued. 299 * @throws { BusinessError } 16300506 - The local continuation task is already in progress. 300 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 301 * @systemapi Hide this for inner system use. 302 * @since 9 303 */ 304 function continueMission( 305 parameter: ContinueDeviceInfo, 306 options: ContinueCallback, 307 callback: AsyncCallback<void> 308 ): void; 309 310 /** 311 * Continue mission 312 * 313 * @permission ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC 314 * @param { ContinueDeviceInfo } parameter - Parameters corresponding to continue mission. 315 * @param { ContinueCallback } options - the migration task completes the callback function. 316 * @returns { Promise<void> } - the promise returned by the function. 317 * @throws { BusinessError } 201 - Permission denied. 318 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 319 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 320 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 321 * @throws { BusinessError } 16300501 - The system ability work abnormally. 322 * @throws { BusinessError } 16300502 - Failed to get the missionInfo of the specified missionId. 323 * @throws { BusinessError } 16300503 - The application is not installed on the remote end and installation-free is 324 * not supported. 325 * @throws { BusinessError } 16300504 - The application is not installed on the remote end but installation-free is 326 * supported, try again with freeInstall flag. 327 * @throws { BusinessError } 16300505 - The operation device must be the device where the application to be continued 328 * is located or the target device to be continued. 329 * @throws { BusinessError } 16300506 - The local continuation task is already in progress. 330 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 331 * @systemapi Hide this for inner system use. 332 * @since 9 333 */ 334 function continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback): Promise<void>; 335 336 /** 337 * Continue mission by ContinueMissionInfo. 338 * 339 * @permission ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC 340 * @param { ContinueMissionInfo } parameter - Parameters corresponding to continue mission info. 341 * @param { AsyncCallback<void> } callback - The callback of continue mission result. 342 * @throws { BusinessError } 201 - Permission denied. 343 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 344 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 345 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 346 * @throws { BusinessError } 16300501 - The system ability work abnormally. 347 * @throws { BusinessError } 16300503 - The application is not installed on the remote end and installation-free is 348 * not supported. 349 * @throws { BusinessError } 16300504 - The application is not installed on the remote end but installation-free is 350 * supported, try again with freeInstall flag. 351 * @throws { BusinessError } 16300505 - The operation device must be the device where the application to be continued 352 * is located or the target device to be continued. 353 * @throws { BusinessError } 16300506 - The local continuation task is already in progress. 354 * @throws { BusinessError } 16300507 - Failed to get the missionInfo of the specified bundle name. 355 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 356 * @systemapi Hide this for inner system use. 357 * @since 10 358 */ 359 function continueMission(parameter: ContinueMissionInfo, callback: AsyncCallback<void>): void; 360 361 /** 362 * Continue mission by ContinueMissionInfo. 363 * 364 * @permission ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC 365 * @param { ContinueMissionInfo } parameter - Parameters corresponding to continue mission info. 366 * @returns { Promise<void> } - the promise returned by the function. 367 * @throws { BusinessError } 201 - Permission denied. 368 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 369 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 370 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 371 * @throws { BusinessError } 16300501 - The system ability work abnormally. 372 * @throws { BusinessError } 16300503 - The application is not installed on the remote end and installation-free is 373 * not supported. 374 * @throws { BusinessError } 16300504 - The application is not installed on the remote end but installation-free is 375 * supported, try again with freeInstall flag. 376 * @throws { BusinessError } 16300505 - The operation device must be the device where the application to be continued 377 * is located or the target device to be continued. 378 * @throws { BusinessError } 16300506 - The local continuation task is already in progress. 379 * @throws { BusinessError } 16300507 - Failed to get the missionInfo of the specified bundle name. 380 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 381 * @systemapi Hide this for inner system use. 382 * @since 10 383 */ 384 function continueMission(parameter: ContinueMissionInfo): Promise<void>; 385 386 /** 387 * Continuable information corresponding to ability. 388 * @typedef { _ContinuableInfo } 389 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 390 * @systemapi Hide this for inner system use. 391 * @since 10 392 */ 393 export type ContinuableInfo = _ContinuableInfo; 394 395 /** 396 * Parameters corresponding to continue mission. 397 * @typedef { _ContinueMissionInfo } 398 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 399 * @systemapi Hide this for inner system use. 400 * @since 10 401 */ 402 export type ContinueMissionInfo = _ContinueMissionInfo; 403 404 /** 405 * ContinueCallback registered for notify continue result. 406 * @typedef { _ContinueCallback } 407 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 408 * @systemapi 409 * @since 10 410 */ 411 export type ContinueCallback = _ContinueCallback; 412 413 /** 414 * Parameters corresponding to continue mission. 415 * @typedef { _ContinueDeviceInfo } 416 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 417 * @systemapi 418 * @since 10 419 */ 420 export type ContinueDeviceInfo = _ContinueDeviceInfo; 421 422 /** 423 * MissionCallback registered by app. 424 * @typedef { _MissionCallback } 425 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 426 * @systemapi 427 * @since 10 428 */ 429 export type MissionCallback = _MissionCallback; 430 431 /** 432 * Parameters corresponding to mission. 433 * @typedef { _MissionDeviceInfo } 434 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 435 * @systemapi 436 * @since 10 437 */ 438 export type MissionDeviceInfo = _MissionDeviceInfo; 439 440 /** 441 * Parameters corresponding to mission. 442 * @typedef { _MissionParameter } 443 * @syscap SystemCapability.Ability.AbilityRuntime.Mission 444 * @systemapi 445 * @since 10 446 */ 447 export type MissionParameter = _MissionParameter; 448} 449export default distributedMissionManager; 450