From 45727735e7024d14942b410a12de0e95c4b5997e Mon Sep 17 00:00:00 2001 From: hobbycao Date: Sat, 6 May 2023 19:25:40 +0800 Subject: [PATCH] feature: add distributed mission manager interface Signed-off-by: hobbycao --- api/@ohos.distributedMissionManager.d.ts | 102 ++++++++++++++++++++++- api/application/ContinuableInfo.d.ts | 42 ++++++++++ api/application/ContinueMissionInfo.d.ts | 57 +++++++++++++ 3 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 api/application/ContinuableInfo.d.ts create mode 100644 api/application/ContinueMissionInfo.d.ts diff --git a/api/@ohos.distributedMissionManager.d.ts b/api/@ohos.distributedMissionManager.d.ts index c6beb71619..e62b8cfb1f 100644 --- a/api/@ohos.distributedMissionManager.d.ts +++ b/api/@ohos.distributedMissionManager.d.ts @@ -13,9 +13,11 @@ * limitations under the License. */ -import { AsyncCallback } from './@ohos.base'; +import { AsyncCallback, Callback } from './@ohos.base'; +import { ContinuableInfo as _ContinuableInfo } from './application/ContinuableInfo'; import { ContinueCallback } from './application/ContinueCallback'; import { ContinueDeviceInfo } from './application/ContinueDeviceInfo'; +import { ContinueMissionInfo as _ContinueMissionInfo } from './application/ContinueMissionInfo'; import { MissionCallback } from './application/MissionCallbacks'; import { MissionDeviceInfo } from './application/MissionDeviceInfo'; import { MissionParameter } from './application/MissionParameter'; @@ -29,6 +31,32 @@ import { MissionParameter } from './application/MissionParameter'; * @since 9 */ declare namespace distributedMissionManager { + /** + * Continue state change event definition. + * + * @enum { number } + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @systemapi Hide this for inner system use. + * @since 10 + */ + enum ContinueState { + /** + * Mission continuable active. + * + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 10 + */ + ACTIVE = 0, + + /** + * Mission continuable inactive. + * + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 10 + */ + INACTIVE = 1 + } + /** * Start sync missions from remote device. * @@ -86,12 +114,41 @@ declare namespace distributedMissionManager { function unRegisterMissionListener(parameter: MissionDeviceInfo, callback: AsyncCallback): void; function unRegisterMissionListener(parameter: MissionDeviceInfo): Promise; + /** + * Register continuable info listener to ams. + * + * @permission ohos.permission.MANAGE_MISSIONS + * @param { 'continueStateChange' } type - Indicate the event type. + * @param { Callback } callback - The callback of continueStateChange. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @systemapi Hide this for inner system use. + * @since 10 + */ + function on(type: 'continueStateChange', callback: Callback<{ state: ContinueState, info: ContinuableInfo }>): void; + + /** + * Unregister continuable info listener to ams. + * + * @permission ohos.permission.MANAGE_MISSIONS + * @param { 'continueStateChange' } type - Indicate the event type. + * @param { Callback } callback - The callback of continueStateChange. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @systemapi Hide this for inner system use. + * @since 10 + */ + function off(type: 'continueStateChange', callback?: Callback<{ state: ContinueState, info: ContinuableInfo }>): void; + /** * Continue mission * * @permission ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC * @param parameter Parameters corresponding to continue mission. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 16300501 - The system ability work abnormally. * @throws { BusinessError } 16300502 - Failed to get the missionInfo of the specified missionId. @@ -108,5 +165,48 @@ declare namespace distributedMissionManager { */ function continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback, callback: AsyncCallback): void; function continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback): Promise; + + /** + * Continue mission by ContinueMissionInfo. + * + * @permission ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC + * @param { ContinueMissionInfo } parameter - Parameters corresponding to continue mission info. + * @param { AsyncCallback } callback - The callback of continue mission result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 16300501 - The system ability work abnormally. + * @throws { BusinessError } 16300503 - The application is not installed on the remote end and installation-free is + * not supported. + * @throws { BusinessError } 16300504 - The application is not installed on the remote end but installation-free is + * supported, try again with freeInstall flag. + * @throws { BusinessError } 16300505 - The operation device must be the device where the application to be continued + * is located or the target device to be continued. + * @throws { BusinessError } 16300506 - The local continuation task is already in progress. + * @throws { BusinessError } 16300507 - Failed to get the missionInfo of the specified bundle name. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @systemapi Hide this for inner system use. + * @since 10 + */ + function continueMission(parameter: ContinueMissionInfo, callback: AsyncCallback): void; + function continueMission(parameter: ContinueMissionInfo): Promise; + + /** + * Continuable information corresponding to ability. + * + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @systemapi Hide this for inner system use. + * @since 10 + */ + export type ContinuableInfo = _ContinuableInfo + + /** + * Parameters corresponding to continue mission. + * + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @systemapi Hide this for inner system use. + * @since 10 + */ + export type ContinueMissionInfo = _ContinueMissionInfo } export default distributedMissionManager; diff --git a/api/application/ContinuableInfo.d.ts b/api/application/ContinuableInfo.d.ts new file mode 100644 index 0000000000..f70aaa4c54 --- /dev/null +++ b/api/application/ContinuableInfo.d.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Continuable information corresponding to ability. + * + * @typedef ContinuableInfo + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @systemapi Hide this for inner system use. + * @since 10 + */ +export interface ContinuableInfo { + /** + * Indicates the original deviceId to continue mission. + * + * @type {string} + * @systemapi Hide this for inner system user. + * @since 10 + */ + srcDeviceId: string; + + /** + * Indicates bundle name. + * + * @type {string} + * @systemapi Hide this for inner system user. + * @since 10 + */ + bundleName: string; +} \ No newline at end of file diff --git a/api/application/ContinueMissionInfo.d.ts b/api/application/ContinueMissionInfo.d.ts new file mode 100644 index 0000000000..6bad14dc69 --- /dev/null +++ b/api/application/ContinueMissionInfo.d.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Parameters corresponding to continue mission. + * + * @typedef ContinueMissionInfo + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @systemapi Hide this for inner system use. + * @since 10 + */ +export interface ContinueMissionInfo { + /** + * Indicates the original deviceId to continue mission. + * + * @type string + * @systemapi Hide this for inner system user. + * @since 10 + */ + srcDeviceId: string; + /** + * Indicates the target deviceId to continue mission. + * + * @type string + * @systemapi Hide this for inner system user. + * @since 10 + */ + dstDeviceId: string; + /** + * Indicates the bundle to continue. + * + * @type string + * @systemapi Hide this for inner system user. + * @since 10 + */ + bundleName: string; + /** + * Indicates the extended param. + * + * @type object + * @systemapi Hide this for inner system user. + * @since 10 + */ + wantParam: { [key: string]: any }; +} \ No newline at end of file