| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 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 |  | 
| Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 17 | // TODO(b/129481165): remove the #pragma below and fix conversion issues | 
 | 18 | #pragma clang diagnostic push | 
 | 19 | #pragma clang diagnostic ignored "-Wconversion" | 
 | 20 |  | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 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; | 
| Ady Abraham | e0f9edb | 2019-11-19 14:25:04 -0800 | [diff] [blame] | 29 | using namespace android::hardware::graphics::composer; | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 30 |  | 
 | 31 | namespace sftest { | 
 | 32 |  | 
| Ady Abraham | e0f9edb | 2019-11-19 14:25:04 -0800 | [diff] [blame] | 33 | FakeComposerService_2_1::FakeComposerService_2_1(android::sp<ComposerClient>& client) | 
 | 34 |       : mClient(client) {} | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 35 |  | 
| Ady Abraham | e0f9edb | 2019-11-19 14:25:04 -0800 | [diff] [blame] | 36 | FakeComposerService_2_1::~FakeComposerService_2_1() { | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 37 |     ALOGI("Maybe killing client %p", mClient.get()); | 
 | 38 |     // Rely on sp to kill the client. | 
 | 39 | } | 
 | 40 |  | 
| Ady Abraham | e0f9edb | 2019-11-19 14:25:04 -0800 | [diff] [blame] | 41 | Return<void> FakeComposerService_2_1::getCapabilities(getCapabilities_cb hidl_cb) { | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 42 |     ALOGI("FakeComposerService::getCapabilities"); | 
 | 43 |     hidl_cb(hidl_vec<Capability>()); | 
 | 44 |     return Void(); | 
 | 45 | } | 
 | 46 |  | 
| Ady Abraham | e0f9edb | 2019-11-19 14:25:04 -0800 | [diff] [blame] | 47 | Return<void> FakeComposerService_2_1::dumpDebugInfo(dumpDebugInfo_cb hidl_cb) { | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 48 |     ALOGI("FakeComposerService::dumpDebugInfo"); | 
 | 49 |     hidl_cb(hidl_string()); | 
 | 50 |     return Void(); | 
 | 51 | } | 
 | 52 |  | 
| Ady Abraham | e0f9edb | 2019-11-19 14:25:04 -0800 | [diff] [blame] | 53 | Return<void> FakeComposerService_2_1::createClient(createClient_cb hidl_cb) { | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 54 |     ALOGI("FakeComposerService::createClient %p", mClient.get()); | 
| Chia-I Wu | 29e146b | 2018-01-30 12:17:56 -0800 | [diff] [blame] | 55 |     if (!mClient->init()) { | 
 | 56 |         LOG_ALWAYS_FATAL("failed to initialize ComposerClient"); | 
 | 57 |     } | 
| Ady Abraham | e0f9edb | 2019-11-19 14:25:04 -0800 | [diff] [blame] | 58 |     hidl_cb(V2_1::Error::NONE, mClient); | 
 | 59 |     return Void(); | 
 | 60 | } | 
 | 61 |  | 
 | 62 | FakeComposerService_2_2::FakeComposerService_2_2(android::sp<ComposerClient>& client) | 
 | 63 |       : mClient(client) {} | 
 | 64 |  | 
 | 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 |  | 
 | 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 |  | 
 | 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 |  | 
 | 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 |  | 
 | 91 | FakeComposerService_2_3::FakeComposerService_2_3(android::sp<ComposerClient>& client) | 
 | 92 |       : mClient(client) {} | 
 | 93 |  | 
 | 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 |  | 
 | 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 |  | 
 | 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 |  | 
 | 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 |  | 
 | 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 |  | 
 | 129 | FakeComposerService_2_4::FakeComposerService_2_4(android::sp<ComposerClient>& client) | 
 | 130 |       : mClient(client) {} | 
 | 131 |  | 
 | 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 |  | 
 | 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 |  | 
 | 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 |  | 
 | 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 |  | 
 | 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 |  | 
 | 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); | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 173 |     return Void(); | 
 | 174 | } | 
 | 175 |  | 
 | 176 | } // namespace sftest | 
| Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 177 |  | 
 | 178 | // TODO(b/129481165): remove the #pragma below and fix conversion issues | 
 | 179 | #pragma clang diagnostic pop // ignored "-Wconversion" |