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 */ 15import { Callback } from './basic'; 16import { AsyncCallback } from './basic'; 17import { ContinuationResult } from './continuation/continuationResult' 18import { ContinuationExtraParams } from './continuation/continuationExtraParams' 19 20/** 21 * Provides methods for interacting with the continuation manager servcie, including methods for registering and 22 * unregistering the ability to hop, updating the device connection state, and showing the list of devices 23 * that can be selected for hopping. 24 * @name continuationManager 25 * @since 8 26 * @syscap SystemCapability.Ability.DistributedAbilityManager 27 * @permission N/A 28 */ 29declare namespace continuationManager { 30 /** 31 * Called when the user selects devices from the candidate device list. 32 * You can implement your own processing logic in this callback to initiate the hop process. 33 * 34 * @since 9 35 * @syscap SystemCapability.Ability.DistributedAbilityManager 36 * @param type deviceConnect. 37 * @return callback Indicates the information about the selected devices. 38 */ 39 function on(type: "deviceConnect", token: number, callback: Callback<Array<ContinuationResult>>): void; 40 function off(type: "deviceConnect", token: number): void; 41 42 /** 43 * Called when devices is disconnected from the continuation manager servcie. 44 * You can implement your own processing logic in this callback, such as notifying the user of the disconnection. 45 * 46 * @since 9 47 * @syscap SystemCapability.Ability.DistributedAbilityManager 48 * @param type deviceDisconnect. 49 * @return callback Indicates the ID of the disconnected devices. 50 */ 51 function on(type: "deviceDisconnect", token: number, callback: Callback<Array<string>>): void; 52 function off(type: "deviceDisconnect", token: number): void; 53 54 /** 55 * Called when the user selects a device from the candidate device list. 56 * You can implement your own processing logic in this callback to initiate the hop process. 57 * 58 * @since 8 59 * @deprecated since 9 60 * @syscap SystemCapability.Ability.DistributedAbilityManager 61 * @param type deviceConnect. 62 * @return callback Indicates the information about the selected device. 63 */ 64 function on(type: "deviceConnect", callback: Callback<ContinuationResult>): void; 65 function off(type: "deviceConnect", callback?: Callback<ContinuationResult>): void; 66 67 /** 68 * Called when a device is disconnected from the continuation manager servcie. 69 * You can implement your own processing logic in this callback, such as notifying the user of the disconnection. 70 * 71 * @since 8 72 * @deprecated since 9 73 * @syscap SystemCapability.Ability.DistributedAbilityManager 74 * @param type deviceDisconnect. 75 * @return callback Indicates the ID of the disconnected device. 76 */ 77 function on(type: "deviceDisconnect", callback: Callback<string>): void; 78 function off(type: "deviceDisconnect", callback?: Callback<string>): void; 79 80 /** 81 * Registers an ability to be hopped with the continuation manager servcie and obtains the registration token 82 * assigned to the ability. 83 * 84 * @since 8 85 * @syscap SystemCapability.Ability.DistributedAbilityManager 86 * @param options Indicates the {@link ExtraParams} object containing the extra parameters used to filter 87 * the list of available devices. 88 * @return callback Indicates the callback to be invoked when the continuation manager servcie is connected. 89 */ 90 function register(callback: AsyncCallback<number>): void; 91 function register(options: ContinuationExtraParams, callback: AsyncCallback<number>): void; 92 function register(options?: ContinuationExtraParams): Promise<number>; 93 94 /** 95 * Unregisters a specified ability from the continuation manager servcie based on the token obtained during ability 96 * registration. 97 * 98 * @since 8 99 * @syscap SystemCapability.Ability.DistributedAbilityManager 100 * @param token Indicates the registration token of the ability. 101 * @return callback Indicates the callback to be invoked when the continuation manager servcie is connected. 102 */ 103 function unregister(token: number, callback: AsyncCallback<void>): void; 104 function unregister(token: number): Promise<void>; 105 106 /** 107 * Updates the connection state of the device where the specified ability is successfully hopped. 108 * 109 * @since 8 110 * @syscap SystemCapability.Ability.DistributedAbilityManager 111 * @param token Indicates the registration token of the ability. 112 * @param deviceId Indicates the ID of the device whose connection state is to be updated. 113 * @param status Indicates the connection state to update. 114 * @return callback Indicates the callback to be invoked when the continuation manager servcie is connected. 115 */ 116 function updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback<void>): void; 117 function updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState): Promise<void>; 118 119 /** 120 * Start to manage the devices that can be selected for continuation on the distributed network. 121 * 122 * @since 8 123 * @syscap SystemCapability.Ability.DistributedAbilityManager 124 * @param token Indicates the registration token of the ability. 125 * @param options Indicates the extraParams object containing the extra parameters used to filter 126 * the list of available devices. This parameter can be null. 127 * @return callback Indicates the callback to be invoked when the continuation manager servcie is connected. 128 */ 129 function startDeviceManager(token: number, callback: AsyncCallback<void>): void; 130 function startDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback<void>): void; 131 function startDeviceManager(token: number, options?: ContinuationExtraParams): Promise<void>; 132 133 /** 134 * Device connection status data structure. 135 * 136 * @since 8 137 * @syscap SystemCapability.Ability.DistributedAbilityManager 138 */ 139 export enum DeviceConnectState { 140 IDLE = 0, 141 CONNECTING = 1, 142 CONNECTED = 2, 143 DISCONNECTING = 3 144 } 145 146 /** 147 * Indicates the description of additional parameters for continuation. 148 * 149 * @since 8 150 * @syscap SystemCapability.Ability.DistributedAbilityManager 151 */ 152 export enum ContinuationMode { 153 154 /** 155 * Collaboration with a single device. 156 */ 157 COLLABORATION_SINGLE = 0, 158 159 /** 160 * Collaboration with multiple devices. 161 */ 162 COLLABORATION_MULTIPLE = 1, 163 } 164 165} 166export default continuationManager;