blob: 908195026e1dd6e13548b5b2308e48d5b6de3ef1 [file] [log] [blame]
Venkatarama Avadhani90373fe2022-11-11 16:54:53 +05301/*
2 * Copyright (C) 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#include <aidl/android/hardware/tv/earc/BnEArc.h>
18#include <aidl/android/hardware/tv/earc/Result.h>
19#include <algorithm>
20#include <vector>
21
22using namespace std;
23
24namespace android {
25namespace hardware {
26namespace tv {
27namespace earc {
28namespace implementation {
29
30using ::aidl::android::hardware::tv::earc::BnEArc;
31using ::aidl::android::hardware::tv::earc::IEArc;
32using ::aidl::android::hardware::tv::earc::IEArcCallback;
33using ::aidl::android::hardware::tv::earc::IEArcStatus;
34using ::aidl::android::hardware::tv::earc::Result;
35
36struct EArcMock : public BnEArc {
37 EArcMock();
38
39 ::ndk::ScopedAStatus setEArcEnabled(bool in_enabled) override;
40 ::ndk::ScopedAStatus isEArcEnabled(bool* _aidl_return) override;
41 ::ndk::ScopedAStatus setCallback(const std::shared_ptr<IEArcCallback>& in_callback) override;
42 ::ndk::ScopedAStatus getState(int32_t in_portId, IEArcStatus* _aidl_return) override;
43 ::ndk::ScopedAStatus getLastReportedAudioCapabilities(
44 int32_t in_portId, std::vector<uint8_t>* _aidl_return) override;
45 ::ndk::ScopedAStatus reportCapabilities(const std::vector<uint8_t> capabilities,
46 int32_t portId);
47 ::ndk::ScopedAStatus changeState(const IEArcStatus status, int32_t portId);
48
49 private:
50 static void* __threadLoop(void* data);
51 void threadLoop();
52
53 private:
54 static void serviceDied(void* cookie);
55 std::shared_ptr<IEArcCallback> mCallback;
56
57 // Variables for the virtual EARC hal impl
58 std::vector<std::vector<uint8_t>> mCapabilities;
59 std::vector<IEArcStatus> mPortStatus;
60 bool mEArcEnabled = true;
61
62 // Port configuration
63 int mTotalPorts = 1;
64
65 // Testing variables
66 pthread_t mThreadId = 0;
67
68 ::ndk::ScopedAIBinder_DeathRecipient mDeathRecipient;
69};
70} // namespace implementation
71} // namespace earc
72} // Namespace tv
73} // namespace hardware
74} // namespace android