1 /*
2  * Copyright 2021 HIMSA II K/S - www.himsa.com.
3  * Represented by EHIMA - www.ehima.com
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #pragma once
18 
19 #include <vector>
20 
21 #include "base/functional/callback.h"
22 #include "bind_helpers.h"
23 #include "bta/include/bta_groups.h"
24 #include "hardware/bt_csis.h"
25 
26 namespace bluetooth {
27 namespace csis {
28 
29 using CsisLockCb = base::OnceCallback<void(int group_id, bool locked,
30                                            CsisGroupLockStatus status)>;
31 
32 class CsisClient {
33  public:
34   virtual ~CsisClient() = default;
35   static void Initialize(bluetooth::csis::CsisClientCallbacks* callbacks,
36                          base::Closure initCb);
37   static void AddFromStorage(const RawAddress& addr,
38                              const std::vector<uint8_t>& in);
39   static bool GetForStorage(const RawAddress& addr, std::vector<uint8_t>& out);
40   static void CleanUp();
41   static CsisClient* Get();
42   static void DebugDump(int fd);
43   static bool IsCsisClientRunning();
44   virtual void Connect(const RawAddress& addr) = 0;
45   virtual void Disconnect(const RawAddress& addr) = 0;
46   virtual void RemoveDevice(const RawAddress& address) = 0;
47   virtual int GetGroupId(
48       const RawAddress& addr,
49       bluetooth::Uuid uuid = bluetooth::groups::kGenericContextUuid) = 0;
50   virtual void LockGroup(int group_id, bool lock, CsisLockCb cb) = 0;
51   virtual std::vector<RawAddress> GetDeviceList(int group_id) = 0;
52   virtual int GetDesiredSize(int group_id) const = 0;
53 };
54 }  // namespace csis
55 }  // namespace bluetooth
56