1 /*
2 * Copyright 2022 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 #pragma once
18
19 #include <bluetooth/log.h>
20
21 #include "audio_aidl_interfaces.h"
22
23 namespace bluetooth {
24 namespace audio {
25 namespace aidl {
26
27 using ::aidl::android::hardware::bluetooth::audio::BluetoothAudioStatus;
28
29 enum class BluetoothAudioCtrlAck : uint8_t {
30 SUCCESS_FINISHED = 0,
31 SUCCESS_RECONFIGURATION,
32 PENDING,
33 FAILURE_UNSUPPORTED,
34 FAILURE_BUSY,
35 FAILURE_DISCONNECTING,
36 FAILURE
37 };
38
39 std::ostream& operator<<(std::ostream& os, const BluetoothAudioCtrlAck& ack);
40
BluetoothAudioCtrlAckToHalStatus(const BluetoothAudioCtrlAck & ack)41 inline BluetoothAudioStatus BluetoothAudioCtrlAckToHalStatus(
42 const BluetoothAudioCtrlAck& ack) {
43 switch (ack) {
44 case BluetoothAudioCtrlAck::SUCCESS_FINISHED:
45 return BluetoothAudioStatus::SUCCESS;
46 case BluetoothAudioCtrlAck::FAILURE_UNSUPPORTED:
47 return BluetoothAudioStatus::UNSUPPORTED_CODEC_CONFIGURATION;
48 case BluetoothAudioCtrlAck::PENDING:
49 return BluetoothAudioStatus::FAILURE;
50 case BluetoothAudioCtrlAck::FAILURE_BUSY:
51 return BluetoothAudioStatus::FAILURE;
52 case BluetoothAudioCtrlAck::FAILURE_DISCONNECTING:
53 return BluetoothAudioStatus::FAILURE;
54 case BluetoothAudioCtrlAck::SUCCESS_RECONFIGURATION:
55 return BluetoothAudioStatus::RECONFIGURATION;
56 default:
57 return BluetoothAudioStatus::FAILURE;
58 }
59 }
60
61 } // namespace aidl
62 } // namespace audio
63 } // namespace bluetooth
64
65 namespace fmt {
66 template <>
67 struct formatter<bluetooth::audio::aidl::BluetoothAudioCtrlAck>
68 : ostream_formatter {};
69 } // namespace fmt
70