1/* 2* Copyright (c) 2022-2023 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 InputKit 19 */ 20 21import { AsyncCallback } from "./@ohos.base"; 22 23/** 24 * The inputDeviceCooperate module implements screen hopping for two or more networked devices to share the keyboard and mouse for collaborative operations. 25 * 26 * @namespace inputDeviceCooperate 27 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 28 * @since 9 29 */ 30 31 32declare namespace inputDeviceCooperate { 33 /** 34 * Enumerates screen hopping event. 35 * 36 * @enum { number } 37 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 38 * @systemapi hide for inner use. 39 * @since 9 40 */ 41 enum EventMsg { 42 /** 43 * Screen hopping starts. 44 * 45 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 46 * @systemapi hide for inner use 47 * @since 9 48 */ 49 MSG_COOPERATE_INFO_START = 200, 50 51 /** 52 * Screen hopping succeeds. 53 * 54 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 55 * @systemapi hide for inner use 56 * @since 9 57 */ 58 MSG_COOPERATE_INFO_SUCCESS = 201, 59 60 /** 61 * Screen hopping fails. 62 * 63 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 64 * @systemapi hide for inner use 65 * @since 9 66 */ 67 MSG_COOPERATE_INFO_FAIL = 202, 68 69 /** 70 * Screen hopping is enabled. 71 * 72 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 73 * @systemapi hide for inner use 74 * @since 9 75 */ 76 MSG_COOPERATE_STATE_ON = 500, 77 78 /** 79 * Screen hopping is disabled. 80 * 81 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 82 * @systemapi hide for inner use 83 * @since 9 84 */ 85 MSG_COOPERATE_STATE_OFF = 501, 86 } 87 88 /** 89 * Specifies whether to enable screen hopping. 90 * This API uses an asynchronous callback to return the result. 91 * 92 * @param { boolean } enable Whether to enable screen hopping. 93 * @param { AsyncCallback<void> } callback Callback used to return the result. 94 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 95 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 96 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 97 * @systemapi hide for inner use 98 * @since 9 99 */ 100 /** 101 * Specifies whether to enable screen hopping. 102 * This API uses an asynchronous callback to return the result. 103 * 104 * @param { boolean } enable Whether to enable screen hopping. 105 * @param { AsyncCallback<void> } callback Callback used to return the result. 106 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 107 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 108 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 109 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 110 * @systemapi hide for inner use 111 * @since 12 112 */ 113 function enable(enable: boolean, callback: AsyncCallback<void>): void; 114 115 /** 116 * Specifies whether to enable screen hopping. 117 * This API uses a promise to return the result. 118 * 119 * @param enable Whether to enable screen hopping. 120 * @returns { Promise<void> } Promise used to return the result. 121 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 122 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 123 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 124 * @systemapi hide for inner use 125 * @since 9 126 */ 127 /** 128 * Specifies whether to enable screen hopping. 129 * This API uses a promise to return the result. 130 * 131 * @param enable Whether to enable screen hopping. 132 * @returns { Promise<void> } Promise used to return the result. 133 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 134 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 135 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 136 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 137 * @systemapi hide for inner use 138 * @since 12 139 */ 140 function enable(enable: boolean): Promise<void>; 141 142 /** 143 * Starts screen hopping. 144 * This API uses an asynchronous callback to return the result. 145 * 146 * @param { string } sinkDeviceDescriptor Descriptor of the target device for screen hopping. 147 * @param { number } srcInputDeviceId ID of the target device for screen hopping. 148 * @param { AsyncCallback<void> } callback Callback used to return the result. 149 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 150 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 151 * @throws { BusinessError } 4400001 - Incorrect descriptor for the target device. 152 * @throws { BusinessError } 4400002 - Screen hop failed. 153 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 154 * @systemapi hide for inner use 155 * @since 9 156 */ 157 /** 158 * Starts screen hopping. 159 * This API uses an asynchronous callback to return the result. 160 * 161 * @param { string } sinkDeviceDescriptor Descriptor of the target device for screen hopping. 162 * @param { number } srcInputDeviceId ID of the target device for screen hopping. 163 * @param { AsyncCallback<void> } callback Callback used to return the result. 164 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 165 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 166 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 167 * @throws { BusinessError } 4400001 - Incorrect descriptor for the target device. 168 * @throws { BusinessError } 4400002 - Screen hop failed. 169 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 170 * @systemapi hide for inner use 171 * @since 12 172 */ 173 function start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCallback<void>): void; 174 175 /** 176 * Starts screen hopping. 177 * This API uses a promise to return the result. 178 * 179 * @param { string } sinkDeviceDescriptor Descriptor of the target device for screen hopping. 180 * @param { number } srcInputDeviceId ID of the target device for screen hopping. 181 * @returns { Promise<void> } Promise used to return the result. 182 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 183 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 184 * @throws { BusinessError } 4400001 - Incorrect descriptor for the target device. 185 * @throws { BusinessError } 4400002 - Screen hop failed. 186 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 187 * @systemapi hide for inner use 188 * @since 9 189 */ 190 /** 191 * Starts screen hopping. 192 * This API uses a promise to return the result. 193 * 194 * @param { string } sinkDeviceDescriptor Descriptor of the target device for screen hopping. 195 * @param { number } srcInputDeviceId ID of the target device for screen hopping. 196 * @returns { Promise<void> } Promise used to return the result. 197 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 198 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 199 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 200 * @throws { BusinessError } 4400001 - Incorrect descriptor for the target device. 201 * @throws { BusinessError } 4400002 - Screen hop failed. 202 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 203 * @systemapi hide for inner use 204 * @since 12 205 */ 206 function start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise<void>; 207 208 /** 209 * Stops screen hopping. 210 * This API uses an asynchronous callback to return the result. 211 * 212 * @param { AsyncCallback<void> } callback Callback used to return the result. 213 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 214 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 215 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 216 * @systemapi hide for inner use 217 * @since 9 218 */ 219 /** 220 * Stops screen hopping. 221 * This API uses an asynchronous callback to return the result. 222 * 223 * @param { AsyncCallback<void> } callback Callback used to return the result. 224 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 225 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 226 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 227 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 228 * @systemapi hide for inner use 229 * @since 12 230 */ 231 function stop(callback: AsyncCallback<void>): void; 232 233 /** 234 * Stops screen hopping. 235 * This API uses a promise to return the result. 236 * 237 * @returns { Promise<void> } Promise used to return the result. 238 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 239 * @systemapi hide for inner use 240 * @since 9 241 */ 242 /** 243 * Stops screen hopping. 244 * This API uses a promise to return the result. 245 * 246 * @returns { Promise<void> } Promise used to return the result. 247 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 248 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 249 * @systemapi hide for inner use 250 * @since 12 251 */ 252 function stop(): Promise<void>; 253 254 /** 255 * Checks whether screen hopping is enabled. 256 * This API uses an asynchronous callback to return the result. 257 * 258 * @param {string} deviceDescriptor Descriptor of the target device for screen hopping. 259 * @param {AsyncCallback<{ state: boolean }>} callback Callback used to return the result. 260 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 261 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 262 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 263 * @systemapi hide for inner use 264 * @since 9 265 */ 266 /** 267 * Checks whether screen hopping is enabled. 268 * This API uses an asynchronous callback to return the result. 269 * 270 * @param {string} deviceDescriptor Descriptor of the target device for screen hopping. 271 * @param {AsyncCallback<{ state: boolean }>} callback Callback used to return the result. 272 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 273 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 274 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 275 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 276 * @systemapi hide for inner use 277 * @since 12 278 */ 279 function getState(deviceDescriptor: string, callback: AsyncCallback<{ state: boolean }>): void; 280 281 /** 282 * Checks whether screen hopping is enabled. 283 * This API uses a promise to return the result. 284 * 285 * @param deviceDescriptor Descriptor of the target device for screen hopping. 286 * @returns { Promise<{ state: boolean }> } Promise used to return the result. 287 * The value true indicates that screen hopping is enabled, and the false indicates the opposite. 288 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 289 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 290 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 291 * @systemapi hide for inner use 292 * @since 9 293 */ 294 /** 295 * Checks whether screen hopping is enabled. 296 * This API uses a promise to return the result. 297 * 298 * @param deviceDescriptor Descriptor of the target device for screen hopping. 299 * @returns { Promise<{ state: boolean }> } Promise used to return the result. 300 * The value true indicates that screen hopping is enabled, and the false indicates the opposite. 301 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 302 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 303 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 304 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 305 * @systemapi hide for inner use 306 * @since 12 307 */ 308 function getState(deviceDescriptor: string): Promise<{ state: boolean }>; 309 310 /** 311 * Enables listening for screen hopping status change events. 312 * 313 * @param { 'cooperation' } type Event type. The value is cooperation. 314 * @param { AsyncCallback<{ deviceDescriptor: string, eventMsg: EventMsg }> } callback Callback used to return the result. 315 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 316 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 317 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 318 * @systemapi hide for inner use 319 * @since 9 320 */ 321 /** 322 * Enables listening for screen hopping status change events. 323 * 324 * @param { 'cooperation' } type Event type. The value is cooperation. 325 * @param { AsyncCallback<{ deviceDescriptor: string, eventMsg: EventMsg }> } callback Callback used to return the result. 326 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 327 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 328 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 329 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 330 * @systemapi hide for inner use 331 * @since 12 332 */ 333 function on(type: 'cooperation', callback: AsyncCallback<{ deviceDescriptor: string, eventMsg: EventMsg }>): void; 334 335 /** 336 * Disables listening for screen hopping status change events. 337 * 338 * @param { 'cooperation' } type Event type. The value is cooperation. 339 * @param { AsyncCallback<void> } callback Callback to be unregistered. 340 * If this parameter is not specified, all callbacks registered by the current application will be unregistered. 341 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 342 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 343 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 344 * @systemapi hide for inner use 345 * @since 9 346 */ 347 /** 348 * Disables listening for screen hopping status change events. 349 * 350 * @param { 'cooperation' } type Event type. The value is cooperation. 351 * @param { AsyncCallback<void> } callback Callback to be unregistered. 352 * If this parameter is not specified, all callbacks registered by the current application will be unregistered. 353 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 354 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 355 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 356 * @syscap SystemCapability.MultimodalInput.Input.Cooperator 357 * @systemapi hide for inner use 358 * @since 12 359 */ 360 function off(type: 'cooperation', callback?: AsyncCallback<void>): void; 361 362} 363 364export default inputDeviceCooperate;