• 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 baseProfile from './@ohos.bluetooth.baseProfile';
22import type constant from './@ohos.bluetooth.constant';
23
24/**
25 * Provides methods to accessing bluetooth MAP(Message Access Profile)-related capabilities.
26 *
27 * @namespace map
28 * @syscap SystemCapability.Communication.Bluetooth.Core
29 * @since 11
30 */
31declare namespace map {
32  /**
33   * Base interface of profile.
34   *
35   * @typedef { baseProfile.BaseProfile } BaseProfile
36   * @syscap SystemCapability.Communication.Bluetooth.Core
37   * @since 11
38   */
39  type BaseProfile = baseProfile.BaseProfile;
40
41  /**
42   * Indicate the phone book access authorization.
43   *
44   * @typedef { constant.AccessAuthorization } AccessAuthorization
45   * @syscap SystemCapability.Communication.Bluetooth.Core
46   * @systemapi
47   * @since 11
48   */
49  type AccessAuthorization = constant.AccessAuthorization;
50
51  /**
52   * create the instance of MAP MSE profile.
53   *
54   * @returns { MapMseProfile } Returns the instance of map mse profile.
55   * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
56   * <br>2. Incorrect parameter types. 3. Parameter verification failed.
57   * @throws { BusinessError } 801 - Capability not supported.
58   * @syscap SystemCapability.Communication.Bluetooth.Core
59   * @since 11
60   */
61  function createMapMseProfile(): MapMseProfile;
62
63  /**
64   * Manager MAP MSE profile.
65   *
66   * @typedef MapMseProfile
67   * @syscap SystemCapability.Communication.Bluetooth.Core
68   * @since 11
69   */
70  interface MapMseProfile extends BaseProfile {
71    /**
72     * Disconnect the map connection with the remote device.
73     *
74     * @permission ohos.permission.ACCESS_BLUETOOTH
75     * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
76     * @throws { BusinessError } 201 - Permission denied.
77     * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
78     * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
79     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
80     * @throws { BusinessError } 801 - Capability not supported.
81     * @throws { BusinessError } 2900001 - Service stopped.
82     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
83     * @throws { BusinessError } 2900004 - Profile is not supported.
84     * @throws { BusinessError } 2900099 - Operation failed.
85     * @syscap SystemCapability.Communication.Bluetooth.Core
86     * @systemapi
87     * @since 11
88     */
89    disconnect(deviceId: string): void;
90
91    /**
92     * Set the message access authorization.
93     *
94     * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
95     * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
96     * @param { AccessAuthorization } authorization - Indicates the permission.
97     * @returns { Promise<void> } Returns the promise object.
98     * @throws { BusinessError } 201 - Permission denied.
99     * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
100     * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
101     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
102     * @throws { BusinessError } 801 - Capability not supported.
103     * @throws { BusinessError } 2900001 - Service stopped.
104     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
105     * @throws { BusinessError } 2900004 - Profile is not supported.
106     * @throws { BusinessError } 2900099 - Operation failed.
107     * @syscap SystemCapability.Communication.Bluetooth.Core
108     * @systemapi
109     * @since 11
110     */
111    setMessageAccessAuthorization(deviceId: string, authorization: AccessAuthorization): Promise<void>;
112
113    /**
114     * Get the message access authorization.
115     *
116     * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
117     * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
118     * @returns { Promise<AccessAuthorization> } Returns the promise object.
119     * @throws { BusinessError } 201 - Permission denied.
120     * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
121     * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
122     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
123     * @throws { BusinessError } 801 - Capability not supported.
124     * @throws { BusinessError } 2900001 - Service stopped.
125     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
126     * @throws { BusinessError } 2900004 - Profile is not supported.
127     * @throws { BusinessError } 2900099 - Operation failed.
128     * @syscap SystemCapability.Communication.Bluetooth.Core
129     * @systemapi
130     * @since 11
131     */
132    getMessageAccessAuthorization(deviceId: string): Promise<AccessAuthorization>;
133  }
134}
135
136export default map;