|
26 | 26 | #include <android/binder_manager.h> |
27 | 27 | #include <common/FlagManager.h> |
28 | 28 | #include <common/trace.h> |
| 29 | +#include <fmt/core.h> |
29 | 30 | #include <log/log.h> |
30 | 31 |
|
31 | 32 | #include <aidl/android/hardware/graphics/composer3/BnComposerCallback.h> |
32 | 33 |
|
33 | 34 | #include <algorithm> |
34 | 35 | #include <cinttypes> |
| 36 | +#include <string> |
| 37 | +#include <string_view> |
35 | 38 |
|
36 | 39 | #include "HWC2.h" |
37 | 40 |
|
@@ -229,25 +232,32 @@ class AidlIComposerCallbackWrapper : public BnComposerCallback { |
229 | 232 | HWC2::ComposerCallback& mCallback; |
230 | 233 | }; |
231 | 234 |
|
232 | | -std::string AidlComposer::instance(const std::string& serviceName) { |
233 | | - return std::string(AidlIComposer::descriptor) + "/" + serviceName; |
| 235 | +std::string AidlComposer::ensureFullyQualifiedName(std::string_view serviceName) { |
| 236 | + if (!serviceName.starts_with(AidlIComposer::descriptor)) { |
| 237 | + return fmt::format("{}/{}", AidlIComposer::descriptor, serviceName); |
| 238 | + } else { |
| 239 | + return std::string{serviceName}; |
| 240 | + } |
234 | 241 | } |
235 | 242 |
|
236 | | -bool AidlComposer::isDeclared(const std::string& serviceName) { |
237 | | - return AServiceManager_isDeclared(instance(serviceName).c_str()); |
| 243 | +bool AidlComposer::namesAnAidlComposerService(std::string_view serviceName) { |
| 244 | + if (!serviceName.starts_with(AidlIComposer::descriptor)) { |
| 245 | + return AServiceManager_isDeclared(ensureFullyQualifiedName(serviceName).c_str()); |
| 246 | + } |
| 247 | + return true; |
238 | 248 | } |
239 | 249 |
|
240 | 250 | AidlComposer::AidlComposer(const std::string& serviceName) { |
241 | 251 | // This only waits if the service is actually declared |
242 | | - mAidlComposer = AidlIComposer::fromBinder( |
243 | | - ndk::SpAIBinder(AServiceManager_waitForService(instance(serviceName).c_str()))); |
| 252 | + mAidlComposer = AidlIComposer::fromBinder(ndk::SpAIBinder( |
| 253 | + AServiceManager_waitForService(ensureFullyQualifiedName(serviceName).c_str()))); |
244 | 254 | if (!mAidlComposer) { |
245 | 255 | LOG_ALWAYS_FATAL("Failed to get AIDL composer service"); |
246 | 256 | return; |
247 | 257 | } |
248 | 258 |
|
249 | 259 | if (!mAidlComposer->createClient(&mAidlComposerClient).isOk()) { |
250 | | - LOG_ALWAYS_FATAL("Can't create AidlComposerClient, fallback to HIDL"); |
| 260 | + LOG_ALWAYS_FATAL("Can't create AidlComposerClient"); |
251 | 261 | return; |
252 | 262 | } |
253 | 263 |
|
|
0 commit comments