• 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   * @extends BaseProfile
67   * @typedef MapMseProfile
68   * @syscap SystemCapability.Communication.Bluetooth.Core
69   * @since 11
70   */
71  interface MapMseProfile extends BaseProfile {
72    /**
73     * Disconnect the map connection with the remote device.
74     *
75     * @permission ohos.permission.ACCESS_BLUETOOTH
76     * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
77     * @throws { BusinessError } 201 - Permission denied.
78     * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
79     * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
80     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
81     * @throws { BusinessError } 801 - Capability not supported.
82     * @throws { BusinessError } 2900001 - Service stopped.
83     * @throws { BusinessError } 2900003 - Bluetooth disabled.
84     * @throws { BusinessError } 2900004 - Profile not supported.
85     * @throws { BusinessError } 2900099 - Operation failed.
86     * @syscap SystemCapability.Communication.Bluetooth.Core
87     * @systemapi
88     * @since 11
89     */
90    disconnect(deviceId: string): void;
91
92    /**
93     * Set the message access authorization.
94     *
95     * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
96     * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
97     * @param { AccessAuthorization } authorization - Indicates the permission.
98     * @returns { Promise<void> } Returns the promise object.
99     * @throws { BusinessError } 201 - Permission denied.
100     * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
101     * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
102     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
103     * @throws { BusinessError } 801 - Capability not supported.
104     * @throws { BusinessError } 2900001 - Service stopped.
105     * @throws { BusinessError } 2900003 - Bluetooth disabled.
106     * @throws { BusinessError } 2900004 - Profile not supported.
107     * @throws { BusinessError } 2900099 - Operation failed.
108     * @syscap SystemCapability.Communication.Bluetooth.Core
109     * @systemapi
110     * @since 11
111     */
112    setMessageAccessAuthorization(deviceId: string, authorization: AccessAuthorization): Promise<void>;
113
114    /**
115     * Get the message access authorization.
116     *
117     * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
118     * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
119     * @returns { Promise<AccessAuthorization> } Returns the promise object.
120     * @throws { BusinessError } 201 - Permission denied.
121     * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
122     * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
123     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
124     * @throws { BusinessError } 801 - Capability not supported.
125     * @throws { BusinessError } 2900001 - Service stopped.
126     * @throws { BusinessError } 2900003 - Bluetooth disabled.
127     * @throws { BusinessError } 2900004 - Profile not supported.
128     * @throws { BusinessError } 2900099 - Operation failed.
129     * @syscap SystemCapability.Communication.Bluetooth.Core
130     * @systemapi
131     * @since 11
132     */
133    getMessageAccessAuthorization(deviceId: string): Promise<AccessAuthorization>;
134  }
135}
136
137export default map;