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
18 #include "btif_storage_mock.h"
19
20 #include <base/logging.h>
21
22 static bluetooth::storage::MockBtifStorageInterface* btif_storage_interface =
23 nullptr;
24
SetMockBtifStorageInterface(MockBtifStorageInterface * mock_btif_storage_interface)25 void bluetooth::storage::SetMockBtifStorageInterface(
26 MockBtifStorageInterface* mock_btif_storage_interface) {
27 btif_storage_interface = mock_btif_storage_interface;
28 }
29
btif_storage_set_leaudio_autoconnect(RawAddress const & addr,bool autoconnect)30 void btif_storage_set_leaudio_autoconnect(RawAddress const& addr,
31 bool autoconnect) {
32 LOG_ASSERT(btif_storage_interface) << "Mock storage module not set!";
33 btif_storage_interface->AddLeaudioAutoconnect(addr, autoconnect);
34 }
35
btif_storage_leaudio_update_pacs_bin(const RawAddress & addr)36 void btif_storage_leaudio_update_pacs_bin(const RawAddress& addr) {
37 LOG_ASSERT(btif_storage_interface) << "Mock storage module not set!";
38 btif_storage_interface->LeAudioUpdatePacs(addr);
39 }
40
btif_storage_leaudio_update_ase_bin(const RawAddress & addr)41 void btif_storage_leaudio_update_ase_bin(const RawAddress& addr) {
42 LOG_ASSERT(btif_storage_interface) << "Mock storage module not set!";
43 btif_storage_interface->LeAudioUpdateAses(addr);
44 }
45
btif_storage_leaudio_update_handles_bin(const RawAddress & addr)46 void btif_storage_leaudio_update_handles_bin(const RawAddress& addr) {
47 LOG_ASSERT(btif_storage_interface) << "Mock storage module not set!";
48 btif_storage_interface->LeAudioUpdateHandles(addr);
49 }
50
btif_storage_set_leaudio_audio_location(const RawAddress & addr,uint32_t sink_location,uint32_t source_location)51 void btif_storage_set_leaudio_audio_location(const RawAddress& addr,
52 uint32_t sink_location,
53 uint32_t source_location) {
54 LOG_ASSERT(btif_storage_interface) << "Mock storage module not set!";
55 btif_storage_interface->SetLeAudioLocations(addr, sink_location,
56 source_location);
57 }
58
btif_storage_set_leaudio_supported_context_types(const RawAddress & addr,uint16_t sink_supported_context_type,uint16_t source_supported_context_type)59 void btif_storage_set_leaudio_supported_context_types(
60 const RawAddress& addr, uint16_t sink_supported_context_type,
61 uint16_t source_supported_context_type) {
62 LOG_ASSERT(btif_storage_interface) << "Mock storage module not set!";
63 btif_storage_interface->SetLeAudioContexts(addr, sink_supported_context_type,
64 source_supported_context_type);
65 }
66
btif_storage_remove_leaudio(RawAddress const & addr)67 void btif_storage_remove_leaudio(RawAddress const& addr) {
68 LOG_ASSERT(btif_storage_interface) << "Mock storage module not set!";
69 btif_storage_interface->RemoveLeaudio(addr);
70 }
71
btif_storage_add_leaudio_has_device(const RawAddress & address,std::vector<uint8_t> presets_bin,uint8_t features,uint8_t active_preset)72 void btif_storage_add_leaudio_has_device(const RawAddress& address,
73 std::vector<uint8_t> presets_bin,
74 uint8_t features,
75 uint8_t active_preset) {
76 LOG_ASSERT(btif_storage_interface) << "Mock storage module not set!";
77 btif_storage_interface->AddLeaudioHasDevice(address, presets_bin, features,
78 active_preset);
79 };
80
btif_storage_get_leaudio_has_presets(const RawAddress & address,std::vector<uint8_t> & presets_bin,uint8_t & active_preset)81 bool btif_storage_get_leaudio_has_presets(const RawAddress& address,
82 std::vector<uint8_t>& presets_bin,
83 uint8_t& active_preset) {
84 if (btif_storage_interface)
85 return btif_storage_interface->GetLeaudioHasPresets(address, presets_bin,
86 active_preset);
87
88 return false;
89 };
90
btif_storage_set_leaudio_has_presets(const RawAddress & address,std::vector<uint8_t> presets_bin)91 void btif_storage_set_leaudio_has_presets(const RawAddress& address,
92 std::vector<uint8_t> presets_bin) {
93 LOG_ASSERT(btif_storage_interface) << "Mock storage module not set!";
94 btif_storage_interface->SetLeaudioHasPresets(address, presets_bin);
95 }
96
btif_storage_get_leaudio_has_features(const RawAddress & address,uint8_t & features)97 bool btif_storage_get_leaudio_has_features(const RawAddress& address,
98 uint8_t& features) {
99 LOG_ASSERT(btif_storage_interface) << "Mock storage module not set!";
100 return btif_storage_interface->GetLeaudioHasFeatures(address, features);
101 }
102
btif_storage_set_leaudio_has_features(const RawAddress & address,uint8_t features)103 void btif_storage_set_leaudio_has_features(const RawAddress& address,
104 uint8_t features) {
105 LOG_ASSERT(btif_storage_interface) << "Mock storage module not set!";
106 btif_storage_interface->SetLeaudioHasFeatures(address, features);
107 }
108
btif_storage_set_leaudio_has_active_preset(const RawAddress & address,uint8_t active_preset)109 void btif_storage_set_leaudio_has_active_preset(const RawAddress& address,
110 uint8_t active_preset) {
111 LOG_ASSERT(btif_storage_interface) << "Mock storage module not set!";
112 btif_storage_interface->SetLeaudioHasActivePreset(address, active_preset);
113 }
114
btif_storage_remove_leaudio_has(const RawAddress & address)115 void btif_storage_remove_leaudio_has(const RawAddress& address) {
116 LOG_ASSERT(btif_storage_interface) << "Mock storage module not set!";
117 btif_storage_interface->RemoveLeaudioHas(address);
118 }