161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit DistributedServiceKit
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport type { AsyncCallback, Callback } from './@ohos.base';
2261847f8eSopenharmony_ci
2361847f8eSopenharmony_ci/**
2461847f8eSopenharmony_ci * Providers interfaces to control distributed hardware.
2561847f8eSopenharmony_ci * @namespace hardwareManager
2661847f8eSopenharmony_ci * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK
2761847f8eSopenharmony_ci * @systemapi
2861847f8eSopenharmony_ci * @since 11
2961847f8eSopenharmony_ci */
3061847f8eSopenharmony_cideclare namespace hardwareManager {
3161847f8eSopenharmony_ci  /**
3261847f8eSopenharmony_ci   * Distributed hardware Type definitions
3361847f8eSopenharmony_ci   * @enum {number}
3461847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK
3561847f8eSopenharmony_ci   * @systemapi
3661847f8eSopenharmony_ci   * @since 11
3761847f8eSopenharmony_ci   */
3861847f8eSopenharmony_ci  enum DistributedHardwareType {
3961847f8eSopenharmony_ci    /**
4061847f8eSopenharmony_ci     * Indicates all hardware
4161847f8eSopenharmony_ci     * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK
4261847f8eSopenharmony_ci     * @systemapi
4361847f8eSopenharmony_ci     * @since 11
4461847f8eSopenharmony_ci     */
4561847f8eSopenharmony_ci    ALL = 0,
4661847f8eSopenharmony_ci    /**
4761847f8eSopenharmony_ci     * Distributed camera
4861847f8eSopenharmony_ci     * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK
4961847f8eSopenharmony_ci     * @systemapi
5061847f8eSopenharmony_ci     * @since 11
5161847f8eSopenharmony_ci     */
5261847f8eSopenharmony_ci    CAMERA = 1,
5361847f8eSopenharmony_ci    /**
5461847f8eSopenharmony_ci     * Distributed screen
5561847f8eSopenharmony_ci     * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK
5661847f8eSopenharmony_ci     * @systemapi
5761847f8eSopenharmony_ci     * @since 11
5861847f8eSopenharmony_ci     */
5961847f8eSopenharmony_ci    SCREEN = 8,
6061847f8eSopenharmony_ci    /**
6161847f8eSopenharmony_ci     * Mic of distributed modem
6261847f8eSopenharmony_ci     * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK
6361847f8eSopenharmony_ci     * @systemapi
6461847f8eSopenharmony_ci     * @since 11
6561847f8eSopenharmony_ci     */
6661847f8eSopenharmony_ci    MODEM_MIC = 256,
6761847f8eSopenharmony_ci    /**
6861847f8eSopenharmony_ci     * Speaker of distributed modem
6961847f8eSopenharmony_ci     * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK
7061847f8eSopenharmony_ci     * @systemapi
7161847f8eSopenharmony_ci     * @since 11
7261847f8eSopenharmony_ci     */
7361847f8eSopenharmony_ci    MODEM_SPEAKER = 512,
7461847f8eSopenharmony_ci    /**
7561847f8eSopenharmony_ci     * Distributed mic
7661847f8eSopenharmony_ci     * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK
7761847f8eSopenharmony_ci     * @systemapi
7861847f8eSopenharmony_ci     * @since 11
7961847f8eSopenharmony_ci     */
8061847f8eSopenharmony_ci    MIC = 1024,
8161847f8eSopenharmony_ci    /**
8261847f8eSopenharmony_ci     * Distributed speaker
8361847f8eSopenharmony_ci     * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK
8461847f8eSopenharmony_ci     * @systemapi
8561847f8eSopenharmony_ci     * @since 11
8661847f8eSopenharmony_ci     */
8761847f8eSopenharmony_ci    SPEAKER = 2048
8861847f8eSopenharmony_ci  }
8961847f8eSopenharmony_ci
9061847f8eSopenharmony_ci  /**
9161847f8eSopenharmony_ci   * Enum for distributed hardware error code.
9261847f8eSopenharmony_ci   * @enum {number}
9361847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK
9461847f8eSopenharmony_ci   * @systemapi
9561847f8eSopenharmony_ci   * @since 11
9661847f8eSopenharmony_ci   */
9761847f8eSopenharmony_ci  enum DistributedHardwareErrorCode {
9861847f8eSopenharmony_ci    /**
9961847f8eSopenharmony_ci     * The distributed hardware is not started.
10061847f8eSopenharmony_ci     * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK
10161847f8eSopenharmony_ci     * @systemapi
10261847f8eSopenharmony_ci     * @since 11
10361847f8eSopenharmony_ci     */
10461847f8eSopenharmony_ci    ERR_CODE_DISTRIBUTED_HARDWARE_NOT_STARTED = 24200101,
10561847f8eSopenharmony_ci
10661847f8eSopenharmony_ci    /**
10761847f8eSopenharmony_ci     * The source device is not connected.
10861847f8eSopenharmony_ci     * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK
10961847f8eSopenharmony_ci     * @systemapi
11061847f8eSopenharmony_ci     * @since 11
11161847f8eSopenharmony_ci     */
11261847f8eSopenharmony_ci    ERR_CODE_DEVICE_NOT_CONNECTED = 24200102
11361847f8eSopenharmony_ci  }
11461847f8eSopenharmony_ci
11561847f8eSopenharmony_ci  /**
11661847f8eSopenharmony_ci   * The description of the distributed hardware
11761847f8eSopenharmony_ci   * @typedef HardwareDescriptor
11861847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK
11961847f8eSopenharmony_ci   * @systemapi
12061847f8eSopenharmony_ci   * @since 11
12161847f8eSopenharmony_ci   */
12261847f8eSopenharmony_ci  interface HardwareDescriptor {
12361847f8eSopenharmony_ci    /**
12461847f8eSopenharmony_ci     * Indicates the type of distributed hardware {@link DistributedHardwareType}
12561847f8eSopenharmony_ci     * @permission ohos.permission.ACCESS_DISTRIBUTED_HARDWARE
12661847f8eSopenharmony_ci     * @type {DistributedHardwareType}
12761847f8eSopenharmony_ci     * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK
12861847f8eSopenharmony_ci     * @systemapi
12961847f8eSopenharmony_ci     * @since 11
13061847f8eSopenharmony_ci     */
13161847f8eSopenharmony_ci    type: DistributedHardwareType;
13261847f8eSopenharmony_ci
13361847f8eSopenharmony_ci    /**
13461847f8eSopenharmony_ci     * Indicates the source device. Not providing this parameter means all.
13561847f8eSopenharmony_ci     * @permission ohos.permission.ACCESS_DISTRIBUTED_HARDWARE
13661847f8eSopenharmony_ci     * @type {?string}
13761847f8eSopenharmony_ci     * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK
13861847f8eSopenharmony_ci     * @systemapi
13961847f8eSopenharmony_ci     * @since 11
14061847f8eSopenharmony_ci     */
14161847f8eSopenharmony_ci    srcNetworkId?: string;
14261847f8eSopenharmony_ci  }
14361847f8eSopenharmony_ci
14461847f8eSopenharmony_ci  /**
14561847f8eSopenharmony_ci   * Pause the distributed hardware service from the controlled device.
14661847f8eSopenharmony_ci   * @permission ohos.permission.ACCESS_DISTRIBUTED_HARDWARE
14761847f8eSopenharmony_ci   * @param { HardwareDescriptor } description - Indicates distributed hardware {@link HardwareDescriptor}.
14861847f8eSopenharmony_ci   * @returns {Promise<void>} pause result.
14961847f8eSopenharmony_ci   * @throws {BusinessError} 201 - Permission verification failed.
15061847f8eSopenharmony_ci   * @throws {BusinessError} 202 - Permission denied, non-system app called system api.
15161847f8eSopenharmony_ci   * @throws {BusinessError} 401 - Input parameter error.
15261847f8eSopenharmony_ci   * @throws {BusinessError} 24200101 - The specified distributed hardware is not started.
15361847f8eSopenharmony_ci   * @throws {BusinessError} 24200102 - The specified source device is not connected.
15461847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK
15561847f8eSopenharmony_ci   * @systemapi
15661847f8eSopenharmony_ci   * @since 11
15761847f8eSopenharmony_ci   */
15861847f8eSopenharmony_ci  function pauseDistributedHardware(description: HardwareDescriptor): Promise<void>;
15961847f8eSopenharmony_ci
16061847f8eSopenharmony_ci  /**
16161847f8eSopenharmony_ci   * Resume the distributed hardware service from the controlled device.
16261847f8eSopenharmony_ci   * @permission ohos.permission.ACCESS_DISTRIBUTED_HARDWARE
16361847f8eSopenharmony_ci   * @param { HardwareDescriptor } description - Indicates distributed hardware {@link HardwareDescriptor}.
16461847f8eSopenharmony_ci   * @returns {Promise<void>} resume result.
16561847f8eSopenharmony_ci   * @throws {BusinessError} 201 - Permission verification failed.
16661847f8eSopenharmony_ci   * @throws {BusinessError} 202 - Permission denied, non-system app called system api.
16761847f8eSopenharmony_ci   * @throws {BusinessError} 401 - Input parameter error.
16861847f8eSopenharmony_ci   * @throws {BusinessError} 24200101 - The specified distributed hardware is not started.
16961847f8eSopenharmony_ci   * @throws {BusinessError} 24200102 - The specified source device is not connected.
17061847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK
17161847f8eSopenharmony_ci   * @systemapi
17261847f8eSopenharmony_ci   * @since 11
17361847f8eSopenharmony_ci   */
17461847f8eSopenharmony_ci  function resumeDistributedHardware(description: HardwareDescriptor): Promise<void>;
17561847f8eSopenharmony_ci
17661847f8eSopenharmony_ci  /**
17761847f8eSopenharmony_ci   * Stop the distributed hardware service from the controlled device.
17861847f8eSopenharmony_ci   * @permission ohos.permission.ACCESS_DISTRIBUTED_HARDWARE
17961847f8eSopenharmony_ci   * @param { HardwareDescriptor } description - Indicates distributed hardware {@link HardwareDescriptor}.
18061847f8eSopenharmony_ci   * @returns {Promise<void>} stop result.
18161847f8eSopenharmony_ci   * @throws {BusinessError} 201 - Permission verification failed.
18261847f8eSopenharmony_ci   * @throws {BusinessError} 202 - Permission denied, non-system app called system api.
18361847f8eSopenharmony_ci   * @throws {BusinessError} 401 - Input parameter error.
18461847f8eSopenharmony_ci   * @throws {BusinessError} 24200101 - The specified distributed hardware is not started.
18561847f8eSopenharmony_ci   * @throws {BusinessError} 24200102 - The specified source device is not connected.
18661847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK
18761847f8eSopenharmony_ci   * @systemapi
18861847f8eSopenharmony_ci   * @since 11
18961847f8eSopenharmony_ci   */
19061847f8eSopenharmony_ci  function stopDistributedHardware(description: HardwareDescriptor): Promise<void>;
19161847f8eSopenharmony_ci}
19261847f8eSopenharmony_ci
19361847f8eSopenharmony_ciexport default hardwareManager;