feature: add distributed mission manager interface

Signed-off-by: hobbycao <caohui10@huawei.com>
This commit is contained in:
hobbycao 2023-05-06 19:25:40 +08:00
parent f36f52e9c2
commit 45727735e7
3 changed files with 200 additions and 1 deletions

View File

@ -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>): void;
function unRegisterMissionListener(parameter: MissionDeviceInfo): Promise<void>;
/**
* 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>): void;
function continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback): Promise<void>;
/**
* 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>): void;
function continueMission(parameter: ContinueMissionInfo): Promise<void>;
/**
* 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;

42
api/application/ContinuableInfo.d.ts vendored Normal file
View File

@ -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;
}

View File

@ -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 };
}