1/* 2 * Copyright (c) 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 DistributedServiceKit 19 */ 20 21import type { AsyncCallback, Callback } from './@ohos.base'; 22 23/** 24 * Providers interfaces to control distributed hardware. 25 * @namespace hardwareManager 26 * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK 27 * @systemapi 28 * @since 11 29 */ 30declare namespace hardwareManager { 31 /** 32 * Distributed hardware Type definitions 33 * @enum {number} 34 * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK 35 * @systemapi 36 * @since 11 37 */ 38 enum DistributedHardwareType { 39 /** 40 * Indicates all hardware 41 * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK 42 * @systemapi 43 * @since 11 44 */ 45 ALL = 0, 46 /** 47 * Distributed camera 48 * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK 49 * @systemapi 50 * @since 11 51 */ 52 CAMERA = 1, 53 /** 54 * Distributed screen 55 * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK 56 * @systemapi 57 * @since 11 58 */ 59 SCREEN = 8, 60 /** 61 * Mic of distributed modem 62 * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK 63 * @systemapi 64 * @since 11 65 */ 66 MODEM_MIC = 256, 67 /** 68 * Speaker of distributed modem 69 * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK 70 * @systemapi 71 * @since 11 72 */ 73 MODEM_SPEAKER = 512, 74 /** 75 * Distributed mic 76 * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK 77 * @systemapi 78 * @since 11 79 */ 80 MIC = 1024, 81 /** 82 * Distributed speaker 83 * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK 84 * @systemapi 85 * @since 11 86 */ 87 SPEAKER = 2048 88 } 89 90 /** 91 * Enum for distributed hardware error code. 92 * @enum {number} 93 * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK 94 * @systemapi 95 * @since 11 96 */ 97 enum DistributedHardwareErrorCode { 98 /** 99 * The distributed hardware is not started. 100 * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK 101 * @systemapi 102 * @since 11 103 */ 104 ERR_CODE_DISTRIBUTED_HARDWARE_NOT_STARTED = 24200101, 105 106 /** 107 * The source device is not connected. 108 * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK 109 * @systemapi 110 * @since 11 111 */ 112 ERR_CODE_DEVICE_NOT_CONNECTED = 24200102 113 } 114 115 /** 116 * The description of the distributed hardware 117 * @typedef HardwareDescriptor 118 * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK 119 * @systemapi 120 * @since 11 121 */ 122 interface HardwareDescriptor { 123 /** 124 * Indicates the type of distributed hardware {@link DistributedHardwareType} 125 * @permission ohos.permission.ACCESS_DISTRIBUTED_HARDWARE 126 * @type {DistributedHardwareType} 127 * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK 128 * @systemapi 129 * @since 11 130 */ 131 type: DistributedHardwareType; 132 133 /** 134 * Indicates the source device. Not providing this parameter means all. 135 * @permission ohos.permission.ACCESS_DISTRIBUTED_HARDWARE 136 * @type {?string} 137 * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK 138 * @systemapi 139 * @since 11 140 */ 141 srcNetworkId?: string; 142 } 143 144 /** 145 * Pause the distributed hardware service from the controlled device. 146 * @permission ohos.permission.ACCESS_DISTRIBUTED_HARDWARE 147 * @param { HardwareDescriptor } description - Indicates distributed hardware {@link HardwareDescriptor}. 148 * @returns {Promise<void>} pause result. 149 * @throws {BusinessError} 201 - Permission verification failed. 150 * @throws {BusinessError} 202 - Permission denied, non-system app called system api. 151 * @throws {BusinessError} 401 - Input parameter error. 152 * @throws {BusinessError} 24200101 - The specified distributed hardware is not started. 153 * @throws {BusinessError} 24200102 - The specified source device is not connected. 154 * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK 155 * @systemapi 156 * @since 11 157 */ 158 function pauseDistributedHardware(description: HardwareDescriptor): Promise<void>; 159 160 /** 161 * Resume the distributed hardware service from the controlled device. 162 * @permission ohos.permission.ACCESS_DISTRIBUTED_HARDWARE 163 * @param { HardwareDescriptor } description - Indicates distributed hardware {@link HardwareDescriptor}. 164 * @returns {Promise<void>} resume result. 165 * @throws {BusinessError} 201 - Permission verification failed. 166 * @throws {BusinessError} 202 - Permission denied, non-system app called system api. 167 * @throws {BusinessError} 401 - Input parameter error. 168 * @throws {BusinessError} 24200101 - The specified distributed hardware is not started. 169 * @throws {BusinessError} 24200102 - The specified source device is not connected. 170 * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK 171 * @systemapi 172 * @since 11 173 */ 174 function resumeDistributedHardware(description: HardwareDescriptor): Promise<void>; 175 176 /** 177 * Stop the distributed hardware service from the controlled device. 178 * @permission ohos.permission.ACCESS_DISTRIBUTED_HARDWARE 179 * @param { HardwareDescriptor } description - Indicates distributed hardware {@link HardwareDescriptor}. 180 * @returns {Promise<void>} stop result. 181 * @throws {BusinessError} 201 - Permission verification failed. 182 * @throws {BusinessError} 202 - Permission denied, non-system app called system api. 183 * @throws {BusinessError} 401 - Input parameter error. 184 * @throws {BusinessError} 24200101 - The specified distributed hardware is not started. 185 * @throws {BusinessError} 24200102 - The specified source device is not connected. 186 * @syscap SystemCapability.DistributedHardware.DistributedHardwareFWK 187 * @systemapi 188 * @since 11 189 */ 190 function stopDistributedHardware(description: HardwareDescriptor): Promise<void>; 191} 192 193export default hardwareManager;