• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   * @extends BaseProfile
103   * @typedef PbapServerProfile
104   * @syscap SystemCapability.Communication.Bluetooth.Core
105   * @since 11
106   */
107  interface PbapServerProfile extends BaseProfile {
108    /**
109     * Disconnect the PBAP connection with the remote device.
110     *
111     * @permission ohos.permission.ACCESS_BLUETOOTH
112     * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
113     * @throws { BusinessError } 201 - Permission denied.
114     * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
115     * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
116     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
117     * @throws { BusinessError } 801 - Capability not supported.
118     * @throws { BusinessError } 2900001 - Service stopped.
119     * @throws { BusinessError } 2900003 - Bluetooth disabled.
120     * @throws { BusinessError } 2900004 - Profile not supported.
121     * @throws { BusinessError } 2900099 - Operation failed.
122     * @syscap SystemCapability.Communication.Bluetooth.Core
123     * @systemapi
124     * @since 11
125     */
126    disconnect(deviceId: string): void;
127
128    /**
129     * Set the PBAP sharing type.
130     *
131     * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
132     * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
133     * @param { ShareType } type - Indicates the PBAP sharing type.
134     * @param { AsyncCallback<void> } callback - the callback result.
135     * @throws { BusinessError } 201 - Permission denied.
136     * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
137     * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
138     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
139     * @throws { BusinessError } 801 - Capability not supported.
140     * @throws { BusinessError } 2900001 - Service stopped.
141     * @throws { BusinessError } 2900003 - Bluetooth disabled.
142     * @throws { BusinessError } 2900004 - Profile not supported.
143     * @throws { BusinessError } 2900099 - Operation failed.
144     * @syscap SystemCapability.Communication.Bluetooth.Core
145     * @systemapi
146     * @since 11
147     */
148    setShareType(deviceId: string, type: ShareType, callback: AsyncCallback<void>): void;
149
150    /**
151     * Set the PBAP sharing type.
152     *
153     * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
154     * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
155     * @param { ShareType } type - Indicates the PBAP sharing type.
156     * @returns { Promise<void> } Returns the promise object.
157     * @throws { BusinessError } 201 - Permission denied.
158     * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
159     * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
160     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
161     * @throws { BusinessError } 801 - Capability not supported.
162     * @throws { BusinessError } 2900001 - Service stopped.
163     * @throws { BusinessError } 2900003 - Bluetooth disabled.
164     * @throws { BusinessError } 2900004 - Profile not supported.
165     * @throws { BusinessError } 2900099 - Operation failed.
166     * @syscap SystemCapability.Communication.Bluetooth.Core
167     * @systemapi
168     * @since 11
169     */
170    setShareType(deviceId: string, type: ShareType): Promise<void>;
171
172    /**
173     * Get the PBAP sharing type.
174     *
175     * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
176     * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
177     * @param { AsyncCallback<ShareType> } callback - the callback result.
178     * @throws { BusinessError } 201 - Permission denied.
179     * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
180     * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
181     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
182     * @throws { BusinessError } 801 - Capability not supported.
183     * @throws { BusinessError } 2900001 - Service stopped.
184     * @throws { BusinessError } 2900003 - Bluetooth disabled.
185     * @throws { BusinessError } 2900004 - Profile not supported.
186     * @throws { BusinessError } 2900099 - Operation failed.
187     * @syscap SystemCapability.Communication.Bluetooth.Core
188     * @systemapi
189     * @since 11
190     */
191    getShareType(deviceId: string, callback: AsyncCallback<ShareType>): void;
192
193    /**
194     * Get the PBAP sharing type.
195     *
196     * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
197     * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
198     * @returns { Promise<ShareType> } Returns the promise object.
199     * @throws { BusinessError } 201 - Permission denied.
200     * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
201     * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
202     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
203     * @throws { BusinessError } 801 - Capability not supported.
204     * @throws { BusinessError } 2900001 - Service stopped.
205     * @throws { BusinessError } 2900003 - Bluetooth disabled.
206     * @throws { BusinessError } 2900004 - Profile not supported.
207     * @throws { BusinessError } 2900099 - Operation failed.
208     * @syscap SystemCapability.Communication.Bluetooth.Core
209     * @systemapi
210     * @since 11
211     */
212    getShareType(deviceId: string): Promise<ShareType>;
213
214    /**
215     * Set the phone book access authorization.
216     *
217     * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
218     * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
219     * @param { AccessAuthorization } authorization - Indicates the permission.
220     * @param { AsyncCallback<void> } callback - the callback result.
221     * @throws { BusinessError } 201 - Permission denied.
222     * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
223     * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
224     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
225     * @throws { BusinessError } 801 - Capability not supported.
226     * @throws { BusinessError } 2900001 - Service stopped.
227     * @throws { BusinessError } 2900003 - Bluetooth disabled.
228     * @throws { BusinessError } 2900004 - Profile not supported.
229     * @throws { BusinessError } 2900099 - Operation failed.
230     * @syscap SystemCapability.Communication.Bluetooth.Core
231     * @systemapi
232     * @since 11
233     */
234    setPhoneBookAccessAuthorization(
235      deviceId: string,
236      authorization: AccessAuthorization,
237      callback: AsyncCallback<void>
238    ): void;
239
240    /**
241     * Set the phone book access authorization.
242     *
243     * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
244     * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
245     * @param { AccessAuthorization } authorization - Indicates the permission.
246     * @returns { Promise<void> } Returns the promise object.
247     * @throws { BusinessError } 201 - Permission denied.
248     * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
249     * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
250     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
251     * @throws { BusinessError } 801 - Capability not supported.
252     * @throws { BusinessError } 2900001 - Service stopped.
253     * @throws { BusinessError } 2900003 - Bluetooth disabled.
254     * @throws { BusinessError } 2900004 - Profile not supported.
255     * @throws { BusinessError } 2900099 - Operation failed.
256     * @syscap SystemCapability.Communication.Bluetooth.Core
257     * @systemapi
258     * @since 11
259     */
260    setPhoneBookAccessAuthorization(deviceId: string, authorization: AccessAuthorization): Promise<void>;
261
262    /**
263     * Get the phone book access authorization.
264     *
265     * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
266     * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
267     * @param { AsyncCallback<AccessAuthorization> } callback - the callback result.
268     * @throws { BusinessError } 201 - Permission denied.
269     * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
270     * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
271     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
272     * @throws { BusinessError } 801 - Capability not supported.
273     * @throws { BusinessError } 2900001 - Service stopped.
274     * @throws { BusinessError } 2900003 - Bluetooth disabled.
275     * @throws { BusinessError } 2900004 - Profile not supported.
276     * @throws { BusinessError } 2900099 - Operation failed.
277     * @syscap SystemCapability.Communication.Bluetooth.Core
278     * @systemapi
279     * @since 11
280     */
281    getPhoneBookAccessAuthorization(deviceId: string, callback: AsyncCallback<AccessAuthorization>): void;
282
283    /**
284     * Get the phone book access authorization.
285     *
286     * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
287     * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
288     * @returns { Promise<AccessAuthorization> } Returns the promise object.
289     * @throws { BusinessError } 201 - Permission denied.
290     * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
291     * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
292     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
293     * @throws { BusinessError } 801 - Capability not supported.
294     * @throws { BusinessError } 2900001 - Service stopped.
295     * @throws { BusinessError } 2900003 - Bluetooth disabled.
296     * @throws { BusinessError } 2900004 - Profile not supported.
297     * @throws { BusinessError } 2900099 - Operation failed.
298     * @syscap SystemCapability.Communication.Bluetooth.Core
299     * @systemapi
300     * @since 11
301     */
302    getPhoneBookAccessAuthorization(deviceId: string): Promise<AccessAuthorization>;
303  }
304}
305
306export default pbap;