1 /*
2 * Copyright (C) 2017 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 // TODO(b/129481165): remove the #pragma below and fix conversion issues
18 #pragma clang diagnostic push
19 #pragma clang diagnostic ignored "-Wconversion"
20
21 #define LOG_NDEBUG 0
22 #undef LOG_TAG
23 #define LOG_TAG "FakeHwcService"
24 #include <log/log.h>
25
26 #include "FakeComposerService.h"
27
28 using namespace android::hardware;
29 using namespace android::hardware::graphics::composer;
30
31 namespace sftest {
32
FakeComposerService_2_1(android::sp<ComposerClient> & client)33 FakeComposerService_2_1::FakeComposerService_2_1(android::sp<ComposerClient>& client)
34 : mClient(client) {}
35
~FakeComposerService_2_1()36 FakeComposerService_2_1::~FakeComposerService_2_1() {
37 ALOGI("Maybe killing client %p", mClient.get());
38 // Rely on sp to kill the client.
39 }
40
getCapabilities(getCapabilities_cb hidl_cb)41 Return<void> FakeComposerService_2_1::getCapabilities(getCapabilities_cb hidl_cb) {
42 ALOGI("FakeComposerService::getCapabilities");
43 hidl_cb(hidl_vec<Capability>());
44 return Void();
45 }
46
dumpDebugInfo(dumpDebugInfo_cb hidl_cb)47 Return<void> FakeComposerService_2_1::dumpDebugInfo(dumpDebugInfo_cb hidl_cb) {
48 ALOGI("FakeComposerService::dumpDebugInfo");
49 hidl_cb(hidl_string());
50 return Void();
51 }
52
createClient(createClient_cb hidl_cb)53 Return<void> FakeComposerService_2_1::createClient(createClient_cb hidl_cb) {
54 ALOGI("FakeComposerService::createClient %p", mClient.get());
55 if (!mClient->init()) {
56 LOG_ALWAYS_FATAL("failed to initialize ComposerClient");
57 }
58 hidl_cb(V2_1::Error::NONE, mClient);
59 return Void();
60 }
61
FakeComposerService_2_2(android::sp<ComposerClient> & client)62 FakeComposerService_2_2::FakeComposerService_2_2(android::sp<ComposerClient>& client)
63 : mClient(client) {}
64
~FakeComposerService_2_2()65 FakeComposerService_2_2::~FakeComposerService_2_2() {
66 ALOGI("Maybe killing client %p", mClient.get());
67 // Rely on sp to kill the client.
68 }
69
getCapabilities(getCapabilities_cb hidl_cb)70 Return<void> FakeComposerService_2_2::getCapabilities(getCapabilities_cb hidl_cb) {
71 ALOGI("FakeComposerService::getCapabilities");
72 hidl_cb(hidl_vec<Capability>());
73 return Void();
74 }
75
dumpDebugInfo(dumpDebugInfo_cb hidl_cb)76 Return<void> FakeComposerService_2_2::dumpDebugInfo(dumpDebugInfo_cb hidl_cb) {
77 ALOGI("FakeComposerService::dumpDebugInfo");
78 hidl_cb(hidl_string());
79 return Void();
80 }
81
createClient(createClient_cb hidl_cb)82 Return<void> FakeComposerService_2_2::createClient(createClient_cb hidl_cb) {
83 ALOGI("FakeComposerService::createClient %p", mClient.get());
84 if (!mClient->init()) {
85 LOG_ALWAYS_FATAL("failed to initialize ComposerClient");
86 }
87 hidl_cb(V2_1::Error::NONE, mClient);
88 return Void();
89 }
90
FakeComposerService_2_3(android::sp<ComposerClient> & client)91 FakeComposerService_2_3::FakeComposerService_2_3(android::sp<ComposerClient>& client)
92 : mClient(client) {}
93
~FakeComposerService_2_3()94 FakeComposerService_2_3::~FakeComposerService_2_3() {
95 ALOGI("Maybe killing client %p", mClient.get());
96 // Rely on sp to kill the client.
97 }
98
getCapabilities(getCapabilities_cb hidl_cb)99 Return<void> FakeComposerService_2_3::getCapabilities(getCapabilities_cb hidl_cb) {
100 ALOGI("FakeComposerService::getCapabilities");
101 hidl_cb(hidl_vec<Capability>());
102 return Void();
103 }
104
dumpDebugInfo(dumpDebugInfo_cb hidl_cb)105 Return<void> FakeComposerService_2_3::dumpDebugInfo(dumpDebugInfo_cb hidl_cb) {
106 ALOGI("FakeComposerService::dumpDebugInfo");
107 hidl_cb(hidl_string());
108 return Void();
109 }
110
createClient(createClient_cb hidl_cb)111 Return<void> FakeComposerService_2_3::createClient(createClient_cb hidl_cb) {
112 LOG_ALWAYS_FATAL("createClient called on FakeComposerService_2_3");
113 if (!mClient->init()) {
114 LOG_ALWAYS_FATAL("failed to initialize ComposerClient");
115 }
116 hidl_cb(V2_1::Error::UNSUPPORTED, nullptr);
117 return Void();
118 }
119
createClient_2_3(createClient_2_3_cb hidl_cb)120 Return<void> FakeComposerService_2_3::createClient_2_3(createClient_2_3_cb hidl_cb) {
121 ALOGI("FakeComposerService_2_3::createClient_2_3 %p", mClient.get());
122 if (!mClient->init()) {
123 LOG_ALWAYS_FATAL("failed to initialize ComposerClient");
124 }
125 hidl_cb(V2_1::Error::NONE, mClient);
126 return Void();
127 }
128
FakeComposerService_2_4(android::sp<ComposerClient> & client)129 FakeComposerService_2_4::FakeComposerService_2_4(android::sp<ComposerClient>& client)
130 : mClient(client) {}
131
~FakeComposerService_2_4()132 FakeComposerService_2_4::~FakeComposerService_2_4() {
133 ALOGI("Maybe killing client %p", mClient.get());
134 // Rely on sp to kill the client.
135 }
136
getCapabilities(getCapabilities_cb hidl_cb)137 Return<void> FakeComposerService_2_4::getCapabilities(getCapabilities_cb hidl_cb) {
138 ALOGI("FakeComposerService::getCapabilities");
139 hidl_cb(hidl_vec<Capability>());
140 return Void();
141 }
142
dumpDebugInfo(dumpDebugInfo_cb hidl_cb)143 Return<void> FakeComposerService_2_4::dumpDebugInfo(dumpDebugInfo_cb hidl_cb) {
144 ALOGI("FakeComposerService::dumpDebugInfo");
145 hidl_cb(hidl_string());
146 return Void();
147 }
148
createClient(createClient_cb hidl_cb)149 Return<void> FakeComposerService_2_4::createClient(createClient_cb hidl_cb) {
150 LOG_ALWAYS_FATAL("createClient called on FakeComposerService_2_4");
151 if (!mClient->init()) {
152 LOG_ALWAYS_FATAL("failed to initialize ComposerClient");
153 }
154 hidl_cb(V2_1::Error::UNSUPPORTED, nullptr);
155 return Void();
156 }
157
createClient_2_3(createClient_2_3_cb hidl_cb)158 Return<void> FakeComposerService_2_4::createClient_2_3(createClient_2_3_cb hidl_cb) {
159 LOG_ALWAYS_FATAL("createClient_2_3 called on FakeComposerService_2_4");
160 if (!mClient->init()) {
161 LOG_ALWAYS_FATAL("failed to initialize ComposerClient");
162 }
163 hidl_cb(V2_1::Error::UNSUPPORTED, nullptr);
164 return Void();
165 }
166
createClient_2_4(createClient_2_4_cb hidl_cb)167 Return<void> FakeComposerService_2_4::createClient_2_4(createClient_2_4_cb hidl_cb) {
168 ALOGI("FakeComposerService_2_4::createClient_2_4 %p", mClient.get());
169 if (!mClient->init()) {
170 LOG_ALWAYS_FATAL("failed to initialize ComposerClient");
171 }
172 hidl_cb(V2_4::Error::NONE, mClient);
173 return Void();
174 }
175
176 } // namespace sftest
177
178 // TODO(b/129481165): remove the #pragma below and fix conversion issues
179 #pragma clang diagnostic pop // ignored "-Wconversion"
180