1 /*
2 * Copyright (C) 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18 #define LOG_TAG "client_interface_fuzzer"
19
20 #include <fuzzer/FuzzedDataProvider.h>
21
22 #include "audio_hal_interface/a2dp_encoding.h"
23 #include "audio_hal_interface/hal_version_manager.h"
24 #include "audio_hal_interface/hidl/client_interface_hidl.h"
25 #include "audio_hal_interface/hidl/codec_status_hidl.h"
26 #include "audio_hal_interface/le_audio_software.h"
27 #include "include/btif_av_co.h"
28 #include "osi/include/properties.h"
29
30 using ::android::hardware::bluetooth::audio::V2_0::AacObjectType;
31 using ::android::hardware::bluetooth::audio::V2_0::AacParameters;
32 using ::android::hardware::bluetooth::audio::V2_0::AacVariableBitRate;
33 using ::android::hardware::bluetooth::audio::V2_0::AptxParameters;
34 using ::android::hardware::bluetooth::audio::V2_0::CodecType;
35 using ::android::hardware::bluetooth::audio::V2_0::LdacChannelMode;
36 using ::android::hardware::bluetooth::audio::V2_0::LdacParameters;
37 using ::android::hardware::bluetooth::audio::V2_0::LdacQualityIndex;
38 using ::android::hardware::bluetooth::audio::V2_0::SbcAllocMethod;
39 using ::android::hardware::bluetooth::audio::V2_0::SbcBlockLength;
40 using ::android::hardware::bluetooth::audio::V2_0::SbcChannelMode;
41 using ::android::hardware::bluetooth::audio::V2_0::SbcNumSubbands;
42 using ::android::hardware::bluetooth::audio::V2_0::SbcParameters;
43 using ::bluetooth::audio::a2dp::update_codec_offloading_capabilities;
44 using ::bluetooth::audio::hidl::AudioConfiguration;
45 using ::bluetooth::audio::hidl::AudioConfiguration_2_1;
46 using ::bluetooth::audio::hidl::BluetoothAudioSinkClientInterface;
47 using ::bluetooth::audio::hidl::BluetoothAudioSourceClientInterface;
48 using ::bluetooth::audio::hidl::PcmParameters;
49 using ::bluetooth::audio::hidl::PcmParameters_2_1;
50 using ::bluetooth::audio::hidl::SampleRate;
51 using ::bluetooth::audio::hidl::SampleRate_2_1;
52 using ::bluetooth::audio::hidl::SessionType;
53 using ::bluetooth::audio::hidl::SessionType_2_1;
54 using ::bluetooth::audio::hidl::codec::A2dpAacToHalConfig;
55 using ::bluetooth::audio::hidl::codec::A2dpAptxToHalConfig;
56 using ::bluetooth::audio::hidl::codec::A2dpCodecToHalBitsPerSample;
57 using ::bluetooth::audio::hidl::codec::A2dpCodecToHalChannelMode;
58 using ::bluetooth::audio::hidl::codec::A2dpCodecToHalSampleRate;
59 using ::bluetooth::audio::hidl::codec::A2dpLdacToHalConfig;
60 using ::bluetooth::audio::hidl::codec::A2dpSbcToHalConfig;
61 using ::bluetooth::audio::hidl::codec::BitsPerSample;
62 using ::bluetooth::audio::hidl::codec::ChannelMode;
63 using ::bluetooth::audio::hidl::codec::CodecConfiguration;
64 using ::bluetooth::audio::hidl::codec::IsCodecOffloadingEnabled;
65 using ::bluetooth::audio::hidl::codec::UpdateOffloadingCapabilities;
66
67 extern "C" {
android_get_exported_namespace(const char *)68 struct android_namespace_t* android_get_exported_namespace(const char*) { return nullptr; }
69 }
70
71 constexpr SessionType kSessionTypes[] = {
72 SessionType::UNKNOWN,
73 SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH,
74 SessionType::A2DP_HARDWARE_OFFLOAD_DATAPATH,
75 SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH,
76 };
77
78 constexpr bluetooth::audio::hidl::BluetoothAudioCtrlAck kBluetoothAudioCtrlAcks[] = {
79 bluetooth::audio::hidl::BluetoothAudioCtrlAck::SUCCESS_FINISHED,
80 bluetooth::audio::hidl::BluetoothAudioCtrlAck::PENDING,
81 bluetooth::audio::hidl::BluetoothAudioCtrlAck::FAILURE_UNSUPPORTED,
82 bluetooth::audio::hidl::BluetoothAudioCtrlAck::FAILURE_BUSY,
83 bluetooth::audio::hidl::BluetoothAudioCtrlAck::FAILURE_DISCONNECTING,
84 bluetooth::audio::hidl::BluetoothAudioCtrlAck::FAILURE};
85
86 constexpr SessionType_2_1 kSessionTypes_2_1[] = {
87 SessionType_2_1::UNKNOWN,
88 SessionType_2_1::A2DP_SOFTWARE_ENCODING_DATAPATH,
89 SessionType_2_1::A2DP_HARDWARE_OFFLOAD_DATAPATH,
90 SessionType_2_1::HEARING_AID_SOFTWARE_ENCODING_DATAPATH,
91 SessionType_2_1::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH,
92 SessionType_2_1::LE_AUDIO_SOFTWARE_DECODED_DATAPATH,
93 SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH,
94 SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH,
95 };
96
97 constexpr SampleRate kSampleRates[] = {
98 SampleRate::RATE_UNKNOWN, SampleRate::RATE_44100, SampleRate::RATE_48000,
99 SampleRate::RATE_88200, SampleRate::RATE_96000, SampleRate::RATE_176400,
100 SampleRate::RATE_192000, SampleRate::RATE_16000, SampleRate::RATE_24000};
101
102 constexpr btav_a2dp_codec_sample_rate_t kBtavSampleRates[] = {
103 BTAV_A2DP_CODEC_SAMPLE_RATE_NONE, BTAV_A2DP_CODEC_SAMPLE_RATE_44100,
104 BTAV_A2DP_CODEC_SAMPLE_RATE_48000, BTAV_A2DP_CODEC_SAMPLE_RATE_88200,
105 BTAV_A2DP_CODEC_SAMPLE_RATE_96000, BTAV_A2DP_CODEC_SAMPLE_RATE_176400,
106 BTAV_A2DP_CODEC_SAMPLE_RATE_192000, BTAV_A2DP_CODEC_SAMPLE_RATE_16000,
107 BTAV_A2DP_CODEC_SAMPLE_RATE_24000};
108
109 constexpr SampleRate_2_1 kSampleRates_2_1[] = {
110 SampleRate_2_1::RATE_UNKNOWN, SampleRate_2_1::RATE_8000, SampleRate_2_1::RATE_16000,
111 SampleRate_2_1::RATE_24000, SampleRate_2_1::RATE_32000, SampleRate_2_1::RATE_44100,
112 SampleRate_2_1::RATE_48000};
113
114 constexpr BitsPerSample kBitsPerSamples[] = {BitsPerSample::BITS_UNKNOWN, BitsPerSample::BITS_16,
115 BitsPerSample::BITS_24, BitsPerSample::BITS_32};
116
117 constexpr btav_a2dp_codec_bits_per_sample_t kBtavA2dpCodecBitsPerSample[] = {
118 BTAV_A2DP_CODEC_BITS_PER_SAMPLE_NONE, BTAV_A2DP_CODEC_BITS_PER_SAMPLE_16,
119 BTAV_A2DP_CODEC_BITS_PER_SAMPLE_24, BTAV_A2DP_CODEC_BITS_PER_SAMPLE_32};
120
121 constexpr ChannelMode kChannelModes[] = {ChannelMode::UNKNOWN, ChannelMode::MONO,
122 ChannelMode::STEREO};
123
124 constexpr btav_a2dp_codec_channel_mode_t kBtavA2dpCodecChannelModes[] = {
125 BTAV_A2DP_CODEC_CHANNEL_MODE_NONE, BTAV_A2DP_CODEC_CHANNEL_MODE_MONO,
126 BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO};
127
128 constexpr uint16_t kPeerMtus[] = {660, 663, 883, 1005, 1500};
129
130 constexpr btav_a2dp_codec_index_t kCodecIndices[] = {
131 BTAV_A2DP_CODEC_INDEX_SOURCE_SBC, BTAV_A2DP_CODEC_INDEX_SOURCE_AAC,
132 BTAV_A2DP_CODEC_INDEX_SOURCE_APTX, BTAV_A2DP_CODEC_INDEX_SOURCE_APTX_HD,
133 BTAV_A2DP_CODEC_INDEX_SOURCE_LDAC, BTAV_A2DP_CODEC_INDEX_SINK_SBC,
134 BTAV_A2DP_CODEC_INDEX_SINK_AAC, BTAV_A2DP_CODEC_INDEX_SINK_LDAC};
135
136 class TestSinkTransport : public bluetooth::audio::hidl::IBluetoothSinkTransportInstance {
137 private:
138 public:
TestSinkTransport(SessionType session_type)139 TestSinkTransport(SessionType session_type)
140 : bluetooth::audio::hidl::IBluetoothSinkTransportInstance(session_type, {}) {}
141
TestSinkTransport(SessionType_2_1 session_type_2_1)142 TestSinkTransport(SessionType_2_1 session_type_2_1)
143 : bluetooth::audio::hidl::IBluetoothSinkTransportInstance(session_type_2_1,
144 (AudioConfiguration_2_1){}) {}
145
StartRequest()146 bluetooth::audio::hidl::BluetoothAudioCtrlAck StartRequest() override {
147 return bluetooth::audio::hidl::BluetoothAudioCtrlAck::SUCCESS_FINISHED;
148 }
149
SuspendRequest()150 bluetooth::audio::hidl::BluetoothAudioCtrlAck SuspendRequest() override {
151 return bluetooth::audio::hidl::BluetoothAudioCtrlAck::SUCCESS_FINISHED;
152 }
153
StopRequest()154 void StopRequest() override {}
155
GetPresentationPosition(uint64_t *,uint64_t *,timespec *)156 bool GetPresentationPosition(uint64_t*, uint64_t*, timespec*) override { return true; }
157
MetadataChanged(const source_metadata_t &)158 void MetadataChanged(const source_metadata_t&) override {}
159
ResetPresentationPosition()160 void ResetPresentationPosition() override {}
161
LogBytesRead(size_t)162 void LogBytesRead(size_t) override {}
163 };
164
165 class TestSourceTransport : public bluetooth::audio::hidl::IBluetoothSourceTransportInstance {
166 private:
167 public:
TestSourceTransport(SessionType session_type)168 TestSourceTransport(SessionType session_type)
169 : bluetooth::audio::hidl::IBluetoothSourceTransportInstance(session_type, {}) {}
170
TestSourceTransport(SessionType_2_1 session_type_2_1)171 TestSourceTransport(SessionType_2_1 session_type_2_1)
172 : bluetooth::audio::hidl::IBluetoothSourceTransportInstance(session_type_2_1,
173 (AudioConfiguration_2_1){}) {}
174
StartRequest()175 bluetooth::audio::hidl::BluetoothAudioCtrlAck StartRequest() override {
176 return bluetooth::audio::hidl::BluetoothAudioCtrlAck::SUCCESS_FINISHED;
177 }
178
SuspendRequest()179 bluetooth::audio::hidl::BluetoothAudioCtrlAck SuspendRequest() override {
180 return bluetooth::audio::hidl::BluetoothAudioCtrlAck::SUCCESS_FINISHED;
181 }
182
StopRequest()183 void StopRequest() override {}
184
GetPresentationPosition(uint64_t *,uint64_t *,timespec *)185 bool GetPresentationPosition(uint64_t*, uint64_t*, timespec*) override { return true; }
186
MetadataChanged(const source_metadata_t &)187 void MetadataChanged(const source_metadata_t&) override {}
188
ResetPresentationPosition()189 void ResetPresentationPosition() override {}
190
LogBytesWritten(size_t)191 void LogBytesWritten(size_t) override {}
192 };
193
194 class ClientInterfaceFuzzer {
195 public:
~ClientInterfaceFuzzer()196 ~ClientInterfaceFuzzer() {
197 delete (mFdp);
198 delete (mTestSinkTransport);
199 delete (mTestSourceTransport);
200 delete (mClientIfSink);
201 delete (mClientIfSource);
202 }
203 void process(const uint8_t* data, size_t size);
204
205 private:
206 FuzzedDataProvider* mFdp = nullptr;
207 TestSinkTransport* mTestSinkTransport = nullptr;
208 TestSourceTransport* mTestSourceTransport = nullptr;
209 BluetoothAudioSinkClientInterface* mClientIfSink = nullptr;
210 BluetoothAudioSourceClientInterface* mClientIfSource = nullptr;
211 };
212
SbcCodecConfigurationsGenerator(FuzzedDataProvider * mFdp)213 static CodecConfiguration SbcCodecConfigurationsGenerator(FuzzedDataProvider* mFdp) {
214 SbcNumSubbands numSubbands[] = {SbcNumSubbands::SUBBAND_4, SbcNumSubbands::SUBBAND_8};
215
216 SbcAllocMethod allocMethods[] = {SbcAllocMethod::ALLOC_MD_S, SbcAllocMethod::ALLOC_MD_L};
217
218 SbcChannelMode channelModes[] = {
219 SbcChannelMode::UNKNOWN, SbcChannelMode::JOINT_STEREO, SbcChannelMode::STEREO,
220 SbcChannelMode::DUAL, SbcChannelMode::MONO,
221 };
222
223 SbcBlockLength blockLengths[] = {SbcBlockLength::BLOCKS_4, SbcBlockLength::BLOCKS_8,
224 SbcBlockLength::BLOCKS_12, SbcBlockLength::BLOCKS_16};
225
226 SbcParameters sbc = {};
227 sbc.sampleRate = mFdp->PickValueInArray(kSampleRates);
228 sbc.channelMode = mFdp->PickValueInArray(channelModes);
229 sbc.blockLength = mFdp->PickValueInArray(blockLengths);
230 sbc.numSubbands = mFdp->PickValueInArray(numSubbands);
231 sbc.allocMethod = mFdp->PickValueInArray(allocMethods);
232 sbc.bitsPerSample = mFdp->PickValueInArray(kBitsPerSamples);
233 sbc.minBitpool = mFdp->ConsumeIntegral<uint8_t>();
234 sbc.maxBitpool = mFdp->ConsumeIntegral<uint8_t>();
235
236 CodecConfiguration codecConfig = {};
237 codecConfig.config.sbcConfig(sbc);
238 codecConfig.codecType = CodecType::SBC;
239 codecConfig.peerMtu = mFdp->PickValueInArray(kPeerMtus);
240 codecConfig.isScmstEnabled = mFdp->ConsumeBool();
241 codecConfig.encodedAudioBitrate = mFdp->ConsumeIntegral<uint32_t>();
242
243 return codecConfig;
244 }
245
AacCodecConfigurationsGenerator(FuzzedDataProvider * mFdp)246 static CodecConfiguration AacCodecConfigurationsGenerator(FuzzedDataProvider* mFdp) {
247 AacObjectType objectTypes[] = {AacObjectType::MPEG2_LC, AacObjectType::MPEG4_LC,
248 AacObjectType::MPEG4_LTP, AacObjectType::MPEG4_SCALABLE};
249
250 AacVariableBitRate variableBitrates[] = {AacVariableBitRate::DISABLED,
251 AacVariableBitRate::ENABLED};
252
253 AacParameters aac = {};
254 aac.objectType = mFdp->PickValueInArray(objectTypes);
255 aac.sampleRate = mFdp->PickValueInArray(kSampleRates);
256 aac.channelMode = mFdp->PickValueInArray(kChannelModes);
257 aac.variableBitRateEnabled = mFdp->PickValueInArray(variableBitrates);
258 aac.bitsPerSample = mFdp->PickValueInArray(kBitsPerSamples);
259
260 CodecConfiguration codecConfig = {};
261 codecConfig.config.aacConfig(aac);
262 codecConfig.codecType = CodecType::AAC;
263 codecConfig.peerMtu = mFdp->PickValueInArray(kPeerMtus);
264 codecConfig.isScmstEnabled = mFdp->ConsumeBool();
265 codecConfig.encodedAudioBitrate = mFdp->ConsumeIntegral<uint32_t>();
266
267 return codecConfig;
268 }
269
LdacCodecConfigurationsGenerator(FuzzedDataProvider * mFdp)270 static CodecConfiguration LdacCodecConfigurationsGenerator(FuzzedDataProvider* mFdp) {
271 LdacQualityIndex qualityIndexes[] = {LdacQualityIndex::QUALITY_HIGH,
272 LdacQualityIndex::QUALITY_MID, LdacQualityIndex::QUALITY_LOW,
273 LdacQualityIndex::QUALITY_ABR};
274
275 LdacChannelMode kChannelModes[] = {
276 LdacChannelMode::UNKNOWN,
277 LdacChannelMode::STEREO,
278 LdacChannelMode::DUAL,
279 LdacChannelMode::MONO,
280 };
281
282 LdacParameters ldac = {};
283 ldac.sampleRate = mFdp->PickValueInArray(kSampleRates);
284 ldac.channelMode = mFdp->PickValueInArray(kChannelModes);
285 ldac.qualityIndex = mFdp->PickValueInArray(qualityIndexes);
286 ldac.bitsPerSample = mFdp->PickValueInArray(kBitsPerSamples);
287
288 CodecConfiguration codecConfig = {};
289 codecConfig.config.ldacConfig(ldac);
290 codecConfig.codecType = CodecType::LDAC;
291 codecConfig.peerMtu = mFdp->PickValueInArray(kPeerMtus);
292 codecConfig.isScmstEnabled = mFdp->ConsumeBool();
293 codecConfig.encodedAudioBitrate = mFdp->ConsumeIntegral<uint32_t>();
294
295 return codecConfig;
296 }
297
AptxCodecConfigurationsGenerator(FuzzedDataProvider * mFdp)298 static CodecConfiguration AptxCodecConfigurationsGenerator(FuzzedDataProvider* mFdp) {
299 CodecType codecTypes[] = {CodecType::APTX, CodecType::APTX_HD};
300
301 AptxParameters aptx = {};
302 aptx.sampleRate = mFdp->PickValueInArray(kSampleRates);
303 aptx.channelMode = mFdp->PickValueInArray(kChannelModes);
304 aptx.bitsPerSample = mFdp->PickValueInArray(kBitsPerSamples);
305
306 CodecConfiguration codecConfig = {};
307 codecConfig.config.aptxConfig(aptx);
308 codecConfig.codecType = mFdp->PickValueInArray(codecTypes);
309 codecConfig.peerMtu = mFdp->PickValueInArray(kPeerMtus);
310 codecConfig.isScmstEnabled = mFdp->ConsumeBool();
311 codecConfig.encodedAudioBitrate = mFdp->ConsumeIntegral<uint32_t>();
312
313 return codecConfig;
314 }
315
CodecOffloadingPreferenceGenerator()316 std::vector<std::vector<btav_a2dp_codec_config_t>> CodecOffloadingPreferenceGenerator() {
317 std::vector<std::vector<btav_a2dp_codec_config_t>> offloadingPreferences = {
318 std::vector<btav_a2dp_codec_config_t>(0)};
319 btav_a2dp_codec_config_t a2dpCodecConfig = {};
320 for (btav_a2dp_codec_index_t i : kCodecIndices) {
321 a2dpCodecConfig.codec_type = i;
322 auto duplicated_preferences = offloadingPreferences;
323 for (auto iter = duplicated_preferences.begin(); iter != duplicated_preferences.end(); ++iter) {
324 iter->push_back(a2dpCodecConfig);
325 }
326 offloadingPreferences.insert(offloadingPreferences.end(), duplicated_preferences.begin(),
327 duplicated_preferences.end());
328 }
329 return offloadingPreferences;
330 }
331
process(const uint8_t * data,size_t size)332 void ClientInterfaceFuzzer::process(const uint8_t* data, size_t size) {
333 mFdp = new FuzzedDataProvider(data, size);
334 osi_property_set("persist.bluetooth.a2dp_offload.disabled",
335 mFdp->PickValueInArray({"true", "false"}));
336
337 btav_a2dp_codec_config_t a2dpCodecConfig = {};
338 a2dpCodecConfig.sample_rate = mFdp->PickValueInArray(kBtavSampleRates);
339 a2dpCodecConfig.bits_per_sample = mFdp->PickValueInArray(kBtavA2dpCodecBitsPerSample);
340 a2dpCodecConfig.channel_mode = mFdp->PickValueInArray(kBtavA2dpCodecChannelModes);
341
342 A2dpCodecToHalSampleRate(a2dpCodecConfig);
343 A2dpCodecToHalBitsPerSample(a2dpCodecConfig);
344 A2dpCodecToHalChannelMode(a2dpCodecConfig);
345
346 SessionType sessionType;
347 SessionType_2_1 sessionType_2_1;
348
349 bool isSessionType_2_1 = mFdp->ConsumeBool();
350 if (isSessionType_2_1) {
351 sessionType_2_1 = mFdp->PickValueInArray(kSessionTypes_2_1);
352 mTestSinkTransport = new TestSinkTransport(sessionType_2_1);
353 mTestSourceTransport = new TestSourceTransport(sessionType_2_1);
354 } else {
355 sessionType = mFdp->PickValueInArray(kSessionTypes);
356 mTestSinkTransport = new TestSinkTransport(sessionType);
357 mTestSourceTransport = new TestSourceTransport(sessionType);
358 }
359
360 mClientIfSink = new BluetoothAudioSinkClientInterface(mTestSinkTransport, nullptr);
361 mClientIfSink->GetTransportInstance();
362 mClientIfSink->IsValid();
363
364 mClientIfSource = new BluetoothAudioSourceClientInterface(mTestSourceTransport, nullptr);
365 mClientIfSource->IsValid();
366
367 CodecConfiguration codecConfig = {};
368 switch (mFdp->ConsumeIntegralInRange<int>(1, 4)) {
369 case 1:
370 codecConfig = SbcCodecConfigurationsGenerator(mFdp);
371 break;
372 case 2:
373 codecConfig = AacCodecConfigurationsGenerator(mFdp);
374 break;
375 case 3:
376 codecConfig = LdacCodecConfigurationsGenerator(mFdp);
377 break;
378 default:
379 codecConfig = AptxCodecConfigurationsGenerator(mFdp);
380 break;
381 }
382
383 if ((!isSessionType_2_1) && (sessionType == SessionType::A2DP_HARDWARE_OFFLOAD_DATAPATH)) {
384 for (auto codec_offloading_preference : CodecOffloadingPreferenceGenerator()) {
385 UpdateOffloadingCapabilities(codec_offloading_preference);
386 update_codec_offloading_capabilities(codec_offloading_preference, false);
387 }
388 IsCodecOffloadingEnabled(codecConfig);
389 }
390
391 if (isSessionType_2_1) {
392 PcmParameters_2_1 pcmConfig = {};
393 pcmConfig.sampleRate = mFdp->PickValueInArray(kSampleRates_2_1);
394 pcmConfig.bitsPerSample = mFdp->PickValueInArray(kBitsPerSamples);
395 pcmConfig.channelMode = mFdp->PickValueInArray(kChannelModes);
396
397 AudioConfiguration_2_1 audioConfig = {};
398 audioConfig.pcmConfig(pcmConfig);
399 audioConfig.codecConfig(codecConfig);
400
401 mClientIfSink->StartSession_2_1();
402 mClientIfSink->GetAudioCapabilities_2_1();
403 mClientIfSink->GetAudioCapabilities_2_1(sessionType_2_1);
404 mClientIfSink->UpdateAudioConfig_2_1(audioConfig);
405 } else {
406 PcmParameters pcmConfig = {};
407 pcmConfig.sampleRate = mFdp->PickValueInArray(kSampleRates);
408 pcmConfig.bitsPerSample = mFdp->PickValueInArray(kBitsPerSamples);
409 pcmConfig.channelMode = mFdp->PickValueInArray(kChannelModes);
410
411 AudioConfiguration audioConfig = {};
412 audioConfig.pcmConfig(pcmConfig);
413 audioConfig.codecConfig(codecConfig);
414
415 mClientIfSink->StartSession();
416 mClientIfSink->GetAudioCapabilities();
417 mClientIfSink->GetAudioCapabilities(sessionType);
418 mClientIfSink->UpdateAudioConfig(audioConfig);
419 }
420
421 if (((bluetooth::audio::HalVersionManager::GetHalVersion() ==
422 bluetooth::audio::BluetoothAudioHalVersion::VERSION_2_1) &&
423 (mTestSinkTransport->GetSessionType_2_1() != SessionType_2_1::UNKNOWN)) ||
424 (mTestSinkTransport->GetSessionType() != SessionType::UNKNOWN)) {
425 mClientIfSink->RenewAudioProviderAndSession();
426 }
427
428 mClientIfSink->StreamStarted(mFdp->PickValueInArray(kBluetoothAudioCtrlAcks));
429 mClientIfSink->StreamSuspended(mFdp->PickValueInArray(kBluetoothAudioCtrlAcks));
430 mClientIfSink->EndSession();
431 }
432
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)433 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
434 ClientInterfaceFuzzer clientInterfaceFuzzer;
435 clientInterfaceFuzzer.process(data, size);
436 return 0;
437 }
438