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 ConnectivityKit 19 */ 20 21import type { AsyncCallback } from './@ohos.base'; 22import type baseProfile from './@ohos.bluetooth.baseProfile'; 23import type constant from './@ohos.bluetooth.constant'; 24 25/** 26 * Provides methods to accessing bluetooth PBAP(Phone Book Access Profile)-related capabilities. 27 * 28 * @namespace pbap 29 * @syscap SystemCapability.Communication.Bluetooth.Core 30 * @since 11 31 */ 32declare namespace pbap { 33 /** 34 * Base interface of profile. 35 * 36 * @typedef { baseProfile.BaseProfile } BaseProfile 37 * @syscap SystemCapability.Communication.Bluetooth.Core 38 * @since 11 39 */ 40 type BaseProfile = baseProfile.BaseProfile; 41 42 /** 43 * Indicate the phone book access authorization. 44 * 45 * @typedef { constant.AccessAuthorization } AccessAuthorization 46 * @syscap SystemCapability.Communication.Bluetooth.Core 47 * @systemapi 48 * @since 11 49 */ 50 type AccessAuthorization = constant.AccessAuthorization; 51 52 /** 53 * Enum for the share type. 54 * 55 * @enum { number } 56 * @syscap SystemCapability.Communication.Bluetooth.Core 57 * @systemapi 58 * @since 11 59 */ 60 enum ShareType { 61 /** 62 * Share the names and numbers in contacts. 63 * 64 * @syscap SystemCapability.Communication.Bluetooth.Core 65 * @systemapi 66 * @since 11 67 */ 68 SHARE_NAME_AND_PHONE_NUMBER = 0, 69 /** 70 * Share all the information. 71 * 72 * @syscap SystemCapability.Communication.Bluetooth.Core 73 * @systemapi 74 * @since 11 75 */ 76 SHARE_ALL = 1, 77 /** 78 * Share nothing. 79 * 80 * @syscap SystemCapability.Communication.Bluetooth.Core 81 * @systemapi 82 * @since 11 83 */ 84 SHARE_NOTHING = 2 85 } 86 87 /** 88 * create the instance of PBAP server profile. 89 * 90 * @returns { PbapServerProfile } Returns the instance of pan profile. 91 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 92 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 93 * @throws { BusinessError } 801 - Capability not supported. 94 * @syscap SystemCapability.Communication.Bluetooth.Core 95 * @since 11 96 */ 97 function createPbapServerProfile(): PbapServerProfile; 98 99 /** 100 * Manager PBAP server profile. 101 * 102 * @typedef PbapServerProfile 103 * @syscap SystemCapability.Communication.Bluetooth.Core 104 * @since 11 105 */ 106 interface PbapServerProfile extends BaseProfile { 107 /** 108 * Disconnect the PBAP connection with the remote device. 109 * 110 * @permission ohos.permission.ACCESS_BLUETOOTH 111 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 112 * @throws { BusinessError } 201 - Permission denied. 113 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 114 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 115 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 116 * @throws { BusinessError } 801 - Capability not supported. 117 * @throws { BusinessError } 2900001 - Service stopped. 118 * @throws { BusinessError } 2900003 - Bluetooth disabled. 119 * @throws { BusinessError } 2900004 - Profile not supported. 120 * @throws { BusinessError } 2900099 - Operation failed. 121 * @syscap SystemCapability.Communication.Bluetooth.Core 122 * @systemapi 123 * @since 11 124 */ 125 disconnect(deviceId: string): void; 126 127 /** 128 * Set the PBAP sharing type. 129 * 130 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 131 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 132 * @param { ShareType } type - Indicates the PBAP sharing type. 133 * @param { AsyncCallback<void> } callback - the callback result. 134 * @throws { BusinessError } 201 - Permission denied. 135 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 136 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 137 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 138 * @throws { BusinessError } 801 - Capability not supported. 139 * @throws { BusinessError } 2900001 - Service stopped. 140 * @throws { BusinessError } 2900003 - Bluetooth disabled. 141 * @throws { BusinessError } 2900004 - Profile not supported. 142 * @throws { BusinessError } 2900099 - Operation failed. 143 * @syscap SystemCapability.Communication.Bluetooth.Core 144 * @systemapi 145 * @since 11 146 */ 147 setShareType(deviceId: string, type: ShareType, callback: AsyncCallback<void>): void; 148 149 /** 150 * Set the PBAP sharing type. 151 * 152 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 153 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 154 * @param { ShareType } type - Indicates the PBAP sharing type. 155 * @returns { Promise<void> } Returns the promise object. 156 * @throws { BusinessError } 201 - Permission denied. 157 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 158 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 159 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 160 * @throws { BusinessError } 801 - Capability not supported. 161 * @throws { BusinessError } 2900001 - Service stopped. 162 * @throws { BusinessError } 2900003 - Bluetooth disabled. 163 * @throws { BusinessError } 2900004 - Profile not supported. 164 * @throws { BusinessError } 2900099 - Operation failed. 165 * @syscap SystemCapability.Communication.Bluetooth.Core 166 * @systemapi 167 * @since 11 168 */ 169 setShareType(deviceId: string, type: ShareType): Promise<void>; 170 171 /** 172 * Get the PBAP sharing type. 173 * 174 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 175 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 176 * @param { AsyncCallback<ShareType> } callback - the callback result. 177 * @throws { BusinessError } 201 - Permission denied. 178 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 179 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 180 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 181 * @throws { BusinessError } 801 - Capability not supported. 182 * @throws { BusinessError } 2900001 - Service stopped. 183 * @throws { BusinessError } 2900003 - Bluetooth disabled. 184 * @throws { BusinessError } 2900004 - Profile not supported. 185 * @throws { BusinessError } 2900099 - Operation failed. 186 * @syscap SystemCapability.Communication.Bluetooth.Core 187 * @systemapi 188 * @since 11 189 */ 190 getShareType(deviceId: string, callback: AsyncCallback<ShareType>): void; 191 192 /** 193 * Get the PBAP sharing type. 194 * 195 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 196 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 197 * @returns { Promise<ShareType> } Returns the promise object. 198 * @throws { BusinessError } 201 - Permission denied. 199 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 200 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 201 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 202 * @throws { BusinessError } 801 - Capability not supported. 203 * @throws { BusinessError } 2900001 - Service stopped. 204 * @throws { BusinessError } 2900003 - Bluetooth disabled. 205 * @throws { BusinessError } 2900004 - Profile not supported. 206 * @throws { BusinessError } 2900099 - Operation failed. 207 * @syscap SystemCapability.Communication.Bluetooth.Core 208 * @systemapi 209 * @since 11 210 */ 211 getShareType(deviceId: string): Promise<ShareType>; 212 213 /** 214 * Set the phone book access authorization. 215 * 216 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 217 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 218 * @param { AccessAuthorization } authorization - Indicates the permission. 219 * @param { AsyncCallback<void> } callback - the callback result. 220 * @throws { BusinessError } 201 - Permission denied. 221 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 222 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 223 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 224 * @throws { BusinessError } 801 - Capability not supported. 225 * @throws { BusinessError } 2900001 - Service stopped. 226 * @throws { BusinessError } 2900003 - Bluetooth disabled. 227 * @throws { BusinessError } 2900004 - Profile not supported. 228 * @throws { BusinessError } 2900099 - Operation failed. 229 * @syscap SystemCapability.Communication.Bluetooth.Core 230 * @systemapi 231 * @since 11 232 */ 233 setPhoneBookAccessAuthorization( 234 deviceId: string, 235 authorization: AccessAuthorization, 236 callback: AsyncCallback<void> 237 ): void; 238 239 /** 240 * Set the phone book access authorization. 241 * 242 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 243 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 244 * @param { AccessAuthorization } authorization - Indicates the permission. 245 * @returns { Promise<void> } Returns the promise object. 246 * @throws { BusinessError } 201 - Permission denied. 247 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 248 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 249 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 250 * @throws { BusinessError } 801 - Capability not supported. 251 * @throws { BusinessError } 2900001 - Service stopped. 252 * @throws { BusinessError } 2900003 - Bluetooth disabled. 253 * @throws { BusinessError } 2900004 - Profile not supported. 254 * @throws { BusinessError } 2900099 - Operation failed. 255 * @syscap SystemCapability.Communication.Bluetooth.Core 256 * @systemapi 257 * @since 11 258 */ 259 setPhoneBookAccessAuthorization(deviceId: string, authorization: AccessAuthorization): Promise<void>; 260 261 /** 262 * Get the phone book access authorization. 263 * 264 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 265 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 266 * @param { AsyncCallback<AccessAuthorization> } callback - the callback result. 267 * @throws { BusinessError } 201 - Permission denied. 268 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 269 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 270 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 271 * @throws { BusinessError } 801 - Capability not supported. 272 * @throws { BusinessError } 2900001 - Service stopped. 273 * @throws { BusinessError } 2900003 - Bluetooth disabled. 274 * @throws { BusinessError } 2900004 - Profile not supported. 275 * @throws { BusinessError } 2900099 - Operation failed. 276 * @syscap SystemCapability.Communication.Bluetooth.Core 277 * @systemapi 278 * @since 11 279 */ 280 getPhoneBookAccessAuthorization(deviceId: string, callback: AsyncCallback<AccessAuthorization>): void; 281 282 /** 283 * Get the phone book access authorization. 284 * 285 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 286 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 287 * @returns { Promise<AccessAuthorization> } Returns the promise object. 288 * @throws { BusinessError } 201 - Permission denied. 289 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 290 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 291 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 292 * @throws { BusinessError } 801 - Capability not supported. 293 * @throws { BusinessError } 2900001 - Service stopped. 294 * @throws { BusinessError } 2900003 - Bluetooth disabled. 295 * @throws { BusinessError } 2900004 - Profile not supported. 296 * @throws { BusinessError } 2900099 - Operation failed. 297 * @syscap SystemCapability.Communication.Bluetooth.Core 298 * @systemapi 299 * @since 11 300 */ 301 getPhoneBookAccessAuthorization(deviceId: string): Promise<AccessAuthorization>; 302 } 303} 304 305export default pbap;