• 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 #ifndef BLUETOOTH_MAP_MSE_H
17 #define BLUETOOTH_MAP_MSE_H
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 #include "bluetooth_def.h"
23 #include "bluetooth_remote_device.h"
24 #include "bluetooth_types.h"
25 
26 namespace OHOS {
27 namespace Bluetooth {
28 /**
29  * @brief Class for MAP MSE observer functions.
30  *
31  */
32 class MapMseObserver {
33 public:
34     /**
35      * @brief Destroy the MapMseObserver object.
36      *
37      */
38     virtual ~MapMseObserver() = default;
39 
40     /**
41      * @brief The observer function to notify connection state changed.
42      *
43      * @param device Remote device object.
44      * @param state Connection state.
45      */
OnConnectionStateChanged(const BluetoothRemoteDevice & device,int32_t state)46     virtual void OnConnectionStateChanged(const BluetoothRemoteDevice &device, int32_t state)
47     {}
48 };
49 
50 /**
51  * @brief Class for MapMse Server API.
52  *
53  */
54 class BLUETOOTH_API MapMse {
55 public:
56     /**
57      * @brief Get the instance of MapMse object.
58      *
59      * @return Returns the pointer to the MapMse instance.
60      */
61     static MapMse *GetProfile();
62 
63     /**
64      * @brief Register MapMse observer instance.
65      *
66      * @param observer MapMse observer instance.
67      */
68     void RegisterObserver(std::shared_ptr<MapMseObserver> observer);
69 
70     /**
71      * @brief Deregister MapMse observer instance.
72      *
73      * @param observer MapMse observer instance.
74      */
75     void DeregisterObserver(std::shared_ptr<MapMseObserver> observer);
76 
77     /**
78      * @brief Get remote map mse device list which are in the specified states.
79      *
80      * @param states List of remote device states.
81      * @param result the list of devices
82      * @return Returns operate result.
83      */
84     int32_t GetDevicesByStates(const std::vector<int32_t> &states, std::vector<BluetoothRemoteDevice> &result) const;
85 
86     /**
87      * @brief Get the connection state of the specified remote map device.
88      *
89      * @param device Remote device object.
90      * @param state the connection state of the remote device
91      * @return Returns operate result.
92      */
93     int32_t GetDeviceState(const BluetoothRemoteDevice &device, int32_t &state) const;
94 
95     /**
96      * @brief Release the connection from remote map device.
97      *
98      * @param device Remote device object.
99      * @return Returns operate result.
100      */
101     int32_t Disconnect(const BluetoothRemoteDevice &device);
102 
103     /**
104      * @brief Set connection strategy for remote bluetooth device.
105      *
106      * @param device Remote device object.
107      * @param strategy The device connect strategy.
108      * @return Returns operate result
109      */
110     int32_t SetConnectionStrategy(const BluetoothRemoteDevice &device, int32_t strategy);
111 
112     /**
113      * @brief Get connection strategy of remote bluetooth device.
114      *
115      * @param device The address of the peer bluetooth device.
116      * @param strategy The device connect strategy.
117      * @return Returns operate result.
118      */
119     int32_t GetConnectionStrategy(const BluetoothRemoteDevice &device, int32_t &strategy) const;
120 
121      /**
122      * @brief Set meta data for remote bluetooth device.
123      *
124      * @param device Remote device object.
125      * @param accessAuthorization The accessAuthorization.
126      * @return Returns operate result
127      */
128     int32_t SetMessageAccessAuthorization(const BluetoothRemoteDevice &device, int32_t accessAuthorization);
129 
130     /**
131      * @brief Get meta data strategy of remote bluetooth device.
132      *
133      * @param device The address of the peer bluetooth device.
134      * @param accessAuthorization out accessAuthorization.
135      * @return Returns operate result.
136      */
137     int32_t GetMessageAccessAuthorization(const BluetoothRemoteDevice &device, int32_t &accessAuthorization) const;
138 
139     void Init();
140     void Uinit();
141 
142 private:
143     MapMse();
144     ~MapMse();
145 
146     BLUETOOTH_DISALLOW_COPY_AND_ASSIGN(MapMse);
147     BLUETOOTH_DECLARE_IMPL();
148 };
149 }  // namespace Bluetooth
150 }  // namespace OHOS
151 #endif  // BLUETOOTH_MAP_MSE_H