• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 a device from the candidate device list.
32     * You can implement your own processing logic in this callback to initiate the hop process.
33     *
34     * @since 8
35     * @syscap SystemCapability.Ability.DistributedAbilityManager
36     * @param type deviceConnect.
37     * @return callback Indicates the information about the selected device.
38     */
39    function on(type: "deviceConnect", callback: Callback<ContinuationResult>): void;
40    function off(type: "deviceConnect", callback?: Callback<ContinuationResult>): void;
41
42    /**
43     * Called when a device 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 8
47     * @syscap SystemCapability.Ability.DistributedAbilityManager
48     * @param type deviceDisconnect.
49     * @return callback Indicates the ID of the disconnected device.
50     */
51    function on(type: "deviceDisconnect", callback: Callback<string>): void;
52    function off(type: "deviceDisconnect", callback?: Callback<string>): void;
53
54    /**
55     * Registers an ability to be hopped with the continuation manager servcie and obtains the registration token
56     * assigned to the ability.
57     *
58     * @since 8
59     * @syscap SystemCapability.Ability.DistributedAbilityManager
60     * @param options Indicates the {@link ExtraParams} object containing the extra parameters used to filter
61     * the list of available devices.
62     * @return callback Indicates the callback to be invoked when the continuation manager servcie is connected.
63     */
64    function register(callback: AsyncCallback<number>): void;
65    function register(options: ContinuationExtraParams, callback: AsyncCallback<number>): void;
66    function register(options?: ContinuationExtraParams): Promise<number>;
67
68    /**
69     * Unregisters a specified ability from the continuation manager servcie based on the token obtained during ability
70     * registration.
71     *
72     * @since 8
73     * @syscap SystemCapability.Ability.DistributedAbilityManager
74     * @param token Indicates the registration token of the ability.
75     * @return callback Indicates the callback to be invoked when the continuation manager servcie is connected.
76     */
77    function unregister(token: number, callback: AsyncCallback<void>): void;
78    function unregister(token: number): Promise<void>;
79
80    /**
81     * Updates the connection state of the device where the specified ability is successfully hopped.
82     *
83     * @since 8
84     * @syscap SystemCapability.Ability.DistributedAbilityManager
85     * @param token Indicates the registration token of the ability.
86     * @param deviceId Indicates the ID of the device whose connection state is to be updated.
87     * @param status Indicates the connection state to update.
88     * @return callback Indicates the callback to be invoked when the continuation manager servcie is connected.
89     */
90    function updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback<void>): void;
91    function updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState): Promise<void>;
92
93    /**
94     * Start to manage the devices that can be selected for continuation on the distributed network.
95     *
96     * @since 8
97     * @syscap SystemCapability.Ability.DistributedAbilityManager
98     * @param token Indicates the registration token of the ability.
99     * @param options Indicates the extraParams object containing the extra parameters used to filter
100     * the list of available devices. This parameter can be null.
101     * @return callback Indicates the callback to be invoked when the continuation manager servcie is connected.
102     */
103    function startDeviceManager(token: number, callback: AsyncCallback<void>): void;
104    function startDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback<void>): void;
105    function startDeviceManager(token: number, options?: ContinuationExtraParams): Promise<void>;
106
107    /**
108     * Device connection status data structure.
109     *
110     * @since 8
111     * @syscap SystemCapability.Ability.DistributedAbilityManager
112     */
113    export enum DeviceConnectState {
114        IDLE = 0,
115        CONNECTING = 1,
116        CONNECTED = 2,
117        DISCONNECTING = 3
118    }
119
120    /**
121     * Indicates the description of additional parameters for continuation.
122     *
123     * @since 8
124     * @syscap SystemCapability.Ability.DistributedAbilityManager
125     */
126    export enum ContinuationMode {
127
128        /**
129         * Collaboration with a single device.
130         */
131        COLLABORATION_SINGLE = 0,
132
133        /**
134         * Collaboration with multiple devices.
135         */
136        COLLABORATION_MULTIPLE = 1,
137    }
138
139}
140export default continuationManager;