Fix client creation failure in vr_hwc
There's some code in vr_hwc to prevent multiple clients, but it was
slightly broken in that only the first attempt to create a client would
work. If you destroyed the client and then tried to create another one,
it would incorrectly fail.
This results in a "failed to create composer client" assertion crash in
surface flinger the second time a user runs a vr app that uses vr
flinger.
Bug: 74985350
Test: Enable vr flinger render path, enter vr, exit vr, enter vr,
confirmed no crash.
Change-Id: Id5de0063c1e4e0be5a06d0a59b59ae3b669480f8
diff --git a/services/vr/hardware_composer/impl/vr_hwc.cpp b/services/vr/hardware_composer/impl/vr_hwc.cpp
index 313c022..11ffc3f 100644
--- a/services/vr/hardware_composer/impl/vr_hwc.cpp
+++ b/services/vr/hardware_composer/impl/vr_hwc.cpp
@@ -868,7 +868,7 @@
Error status = Error::NONE;
sp<VrComposerClient> client;
- if (client_ == nullptr) {
+ if (!client_.promote().get()) {
client = new VrComposerClient(*this);
} else {
ALOGE("Already have a client");