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 ConnectivityKit 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ciimport type { AsyncCallback } from './@ohos.base'; 2261847f8eSopenharmony_ciimport type baseProfile from './@ohos.bluetooth.baseProfile'; 2361847f8eSopenharmony_ciimport type constant from './@ohos.bluetooth.constant'; 2461847f8eSopenharmony_ci 2561847f8eSopenharmony_ci/** 2661847f8eSopenharmony_ci * Provides methods to accessing bluetooth PBAP(Phone Book Access Profile)-related capabilities. 2761847f8eSopenharmony_ci * 2861847f8eSopenharmony_ci * @namespace pbap 2961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 3061847f8eSopenharmony_ci * @since 11 3161847f8eSopenharmony_ci */ 3261847f8eSopenharmony_cideclare namespace pbap { 3361847f8eSopenharmony_ci /** 3461847f8eSopenharmony_ci * Base interface of profile. 3561847f8eSopenharmony_ci * 3661847f8eSopenharmony_ci * @typedef { baseProfile.BaseProfile } BaseProfile 3761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 3861847f8eSopenharmony_ci * @since 11 3961847f8eSopenharmony_ci */ 4061847f8eSopenharmony_ci type BaseProfile = baseProfile.BaseProfile; 4161847f8eSopenharmony_ci 4261847f8eSopenharmony_ci /** 4361847f8eSopenharmony_ci * Indicate the phone book access authorization. 4461847f8eSopenharmony_ci * 4561847f8eSopenharmony_ci * @typedef { constant.AccessAuthorization } AccessAuthorization 4661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 4761847f8eSopenharmony_ci * @systemapi 4861847f8eSopenharmony_ci * @since 11 4961847f8eSopenharmony_ci */ 5061847f8eSopenharmony_ci type AccessAuthorization = constant.AccessAuthorization; 5161847f8eSopenharmony_ci 5261847f8eSopenharmony_ci /** 5361847f8eSopenharmony_ci * Enum for the share type. 5461847f8eSopenharmony_ci * 5561847f8eSopenharmony_ci * @enum { number } 5661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 5761847f8eSopenharmony_ci * @systemapi 5861847f8eSopenharmony_ci * @since 11 5961847f8eSopenharmony_ci */ 6061847f8eSopenharmony_ci enum ShareType { 6161847f8eSopenharmony_ci /** 6261847f8eSopenharmony_ci * Share the names and numbers in contacts. 6361847f8eSopenharmony_ci * 6461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 6561847f8eSopenharmony_ci * @systemapi 6661847f8eSopenharmony_ci * @since 11 6761847f8eSopenharmony_ci */ 6861847f8eSopenharmony_ci SHARE_NAME_AND_PHONE_NUMBER = 0, 6961847f8eSopenharmony_ci /** 7061847f8eSopenharmony_ci * Share all the information. 7161847f8eSopenharmony_ci * 7261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 7361847f8eSopenharmony_ci * @systemapi 7461847f8eSopenharmony_ci * @since 11 7561847f8eSopenharmony_ci */ 7661847f8eSopenharmony_ci SHARE_ALL = 1, 7761847f8eSopenharmony_ci /** 7861847f8eSopenharmony_ci * Share nothing. 7961847f8eSopenharmony_ci * 8061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 8161847f8eSopenharmony_ci * @systemapi 8261847f8eSopenharmony_ci * @since 11 8361847f8eSopenharmony_ci */ 8461847f8eSopenharmony_ci SHARE_NOTHING = 2 8561847f8eSopenharmony_ci } 8661847f8eSopenharmony_ci 8761847f8eSopenharmony_ci /** 8861847f8eSopenharmony_ci * create the instance of PBAP server profile. 8961847f8eSopenharmony_ci * 9061847f8eSopenharmony_ci * @returns { PbapServerProfile } Returns the instance of pan profile. 9161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 9261847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 9361847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 9461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 9561847f8eSopenharmony_ci * @since 11 9661847f8eSopenharmony_ci */ 9761847f8eSopenharmony_ci function createPbapServerProfile(): PbapServerProfile; 9861847f8eSopenharmony_ci 9961847f8eSopenharmony_ci /** 10061847f8eSopenharmony_ci * Manager PBAP server profile. 10161847f8eSopenharmony_ci * 10261847f8eSopenharmony_ci * @typedef PbapServerProfile 10361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 10461847f8eSopenharmony_ci * @since 11 10561847f8eSopenharmony_ci */ 10661847f8eSopenharmony_ci interface PbapServerProfile extends BaseProfile { 10761847f8eSopenharmony_ci /** 10861847f8eSopenharmony_ci * Disconnect the PBAP connection with the remote device. 10961847f8eSopenharmony_ci * 11061847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH 11161847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 11261847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 11361847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 11461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 11561847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 11661847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 11761847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 11861847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 11961847f8eSopenharmony_ci * @throws { BusinessError } 2900004 - Profile not supported. 12061847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 12161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 12261847f8eSopenharmony_ci * @systemapi 12361847f8eSopenharmony_ci * @since 11 12461847f8eSopenharmony_ci */ 12561847f8eSopenharmony_ci disconnect(deviceId: string): void; 12661847f8eSopenharmony_ci 12761847f8eSopenharmony_ci /** 12861847f8eSopenharmony_ci * Set the PBAP sharing type. 12961847f8eSopenharmony_ci * 13061847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 13161847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 13261847f8eSopenharmony_ci * @param { ShareType } type - Indicates the PBAP sharing type. 13361847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback result. 13461847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 13561847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 13661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 13761847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 13861847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 13961847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 14061847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 14161847f8eSopenharmony_ci * @throws { BusinessError } 2900004 - Profile not supported. 14261847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 14361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 14461847f8eSopenharmony_ci * @systemapi 14561847f8eSopenharmony_ci * @since 11 14661847f8eSopenharmony_ci */ 14761847f8eSopenharmony_ci setShareType(deviceId: string, type: ShareType, callback: AsyncCallback<void>): void; 14861847f8eSopenharmony_ci 14961847f8eSopenharmony_ci /** 15061847f8eSopenharmony_ci * Set the PBAP sharing type. 15161847f8eSopenharmony_ci * 15261847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 15361847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 15461847f8eSopenharmony_ci * @param { ShareType } type - Indicates the PBAP sharing type. 15561847f8eSopenharmony_ci * @returns { Promise<void> } Returns the promise object. 15661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 15761847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 15861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 15961847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 16061847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 16161847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 16261847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 16361847f8eSopenharmony_ci * @throws { BusinessError } 2900004 - Profile not supported. 16461847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 16561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 16661847f8eSopenharmony_ci * @systemapi 16761847f8eSopenharmony_ci * @since 11 16861847f8eSopenharmony_ci */ 16961847f8eSopenharmony_ci setShareType(deviceId: string, type: ShareType): Promise<void>; 17061847f8eSopenharmony_ci 17161847f8eSopenharmony_ci /** 17261847f8eSopenharmony_ci * Get the PBAP sharing type. 17361847f8eSopenharmony_ci * 17461847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 17561847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 17661847f8eSopenharmony_ci * @param { AsyncCallback<ShareType> } callback - the callback result. 17761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 17861847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 17961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 18061847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 18161847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 18261847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 18361847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 18461847f8eSopenharmony_ci * @throws { BusinessError } 2900004 - Profile not supported. 18561847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 18661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 18761847f8eSopenharmony_ci * @systemapi 18861847f8eSopenharmony_ci * @since 11 18961847f8eSopenharmony_ci */ 19061847f8eSopenharmony_ci getShareType(deviceId: string, callback: AsyncCallback<ShareType>): void; 19161847f8eSopenharmony_ci 19261847f8eSopenharmony_ci /** 19361847f8eSopenharmony_ci * Get the PBAP sharing type. 19461847f8eSopenharmony_ci * 19561847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 19661847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 19761847f8eSopenharmony_ci * @returns { Promise<ShareType> } Returns the promise object. 19861847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 19961847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 20061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 20161847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 20261847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 20361847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 20461847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 20561847f8eSopenharmony_ci * @throws { BusinessError } 2900004 - Profile not supported. 20661847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 20761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 20861847f8eSopenharmony_ci * @systemapi 20961847f8eSopenharmony_ci * @since 11 21061847f8eSopenharmony_ci */ 21161847f8eSopenharmony_ci getShareType(deviceId: string): Promise<ShareType>; 21261847f8eSopenharmony_ci 21361847f8eSopenharmony_ci /** 21461847f8eSopenharmony_ci * Set the phone book access authorization. 21561847f8eSopenharmony_ci * 21661847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 21761847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 21861847f8eSopenharmony_ci * @param { AccessAuthorization } authorization - Indicates the permission. 21961847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback result. 22061847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 22161847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 22261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 22361847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 22461847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 22561847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 22661847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 22761847f8eSopenharmony_ci * @throws { BusinessError } 2900004 - Profile not supported. 22861847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 22961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 23061847f8eSopenharmony_ci * @systemapi 23161847f8eSopenharmony_ci * @since 11 23261847f8eSopenharmony_ci */ 23361847f8eSopenharmony_ci setPhoneBookAccessAuthorization( 23461847f8eSopenharmony_ci deviceId: string, 23561847f8eSopenharmony_ci authorization: AccessAuthorization, 23661847f8eSopenharmony_ci callback: AsyncCallback<void> 23761847f8eSopenharmony_ci ): void; 23861847f8eSopenharmony_ci 23961847f8eSopenharmony_ci /** 24061847f8eSopenharmony_ci * Set the phone book access authorization. 24161847f8eSopenharmony_ci * 24261847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 24361847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 24461847f8eSopenharmony_ci * @param { AccessAuthorization } authorization - Indicates the permission. 24561847f8eSopenharmony_ci * @returns { Promise<void> } Returns the promise object. 24661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 24761847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 24861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 24961847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 25061847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 25161847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 25261847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 25361847f8eSopenharmony_ci * @throws { BusinessError } 2900004 - Profile not supported. 25461847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 25561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 25661847f8eSopenharmony_ci * @systemapi 25761847f8eSopenharmony_ci * @since 11 25861847f8eSopenharmony_ci */ 25961847f8eSopenharmony_ci setPhoneBookAccessAuthorization(deviceId: string, authorization: AccessAuthorization): Promise<void>; 26061847f8eSopenharmony_ci 26161847f8eSopenharmony_ci /** 26261847f8eSopenharmony_ci * Get the phone book access authorization. 26361847f8eSopenharmony_ci * 26461847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 26561847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 26661847f8eSopenharmony_ci * @param { AsyncCallback<AccessAuthorization> } callback - the callback result. 26761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 26861847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 26961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 27061847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 27161847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 27261847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 27361847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 27461847f8eSopenharmony_ci * @throws { BusinessError } 2900004 - Profile not supported. 27561847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 27661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 27761847f8eSopenharmony_ci * @systemapi 27861847f8eSopenharmony_ci * @since 11 27961847f8eSopenharmony_ci */ 28061847f8eSopenharmony_ci getPhoneBookAccessAuthorization(deviceId: string, callback: AsyncCallback<AccessAuthorization>): void; 28161847f8eSopenharmony_ci 28261847f8eSopenharmony_ci /** 28361847f8eSopenharmony_ci * Get the phone book access authorization. 28461847f8eSopenharmony_ci * 28561847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 28661847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 28761847f8eSopenharmony_ci * @returns { Promise<AccessAuthorization> } Returns the promise object. 28861847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 28961847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 29061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 29161847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 29261847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 29361847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 29461847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 29561847f8eSopenharmony_ci * @throws { BusinessError } 2900004 - Profile not supported. 29661847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 29761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 29861847f8eSopenharmony_ci * @systemapi 29961847f8eSopenharmony_ci * @since 11 30061847f8eSopenharmony_ci */ 30161847f8eSopenharmony_ci getPhoneBookAccessAuthorization(deviceId: string): Promise<AccessAuthorization>; 30261847f8eSopenharmony_ci } 30361847f8eSopenharmony_ci} 30461847f8eSopenharmony_ci 30561847f8eSopenharmony_ciexport default pbap;