Move global buffer ops to VR display service.
The original home for these ops was the VR display manager service,
which is a protected singleton service that may only have one client.
Since more than one service needs to create global buffers, move these
ops to the display service. They are already protected by permission
checks.
Bug: 62424911
Test: dvr_api-test passes
Change-Id: Ia2f57fdf8a5258b52a652935d160e90db0f1cf9e
diff --git a/libs/vr/libdisplay/display_client.cpp b/libs/vr/libdisplay/display_client.cpp
index 40c158a..442c82d 100644
--- a/libs/vr/libdisplay/display_client.cpp
+++ b/libs/vr/libdisplay/display_client.cpp
@@ -104,10 +104,8 @@
return {};
}
-Status<std::unique_ptr<ProducerQueue>> Surface::CreateQueue(uint32_t width,
- uint32_t height,
- uint32_t format,
- size_t metadata_size) {
+Status<std::unique_ptr<ProducerQueue>> Surface::CreateQueue(
+ uint32_t width, uint32_t height, uint32_t format, size_t metadata_size) {
ALOGD_IF(TRACE, "Surface::CreateQueue: Creating empty queue.");
auto status = InvokeRemoteMethod<DisplayProtocol::CreateQueue>(
ProducerQueueConfigBuilder()
@@ -190,6 +188,42 @@
return ErrorStatus(error);
}
+pdx::Status<std::unique_ptr<IonBuffer>> DisplayClient::SetupGlobalBuffer(
+ DvrGlobalBufferKey key, size_t size, uint64_t usage) {
+ auto status =
+ InvokeRemoteMethod<DisplayProtocol::SetupGlobalBuffer>(key, size, usage);
+ if (!status) {
+ ALOGE(
+ "DisplayClient::SetupGlobalBuffer: Failed to create the global buffer "
+ "%s",
+ status.GetErrorMessage().c_str());
+ return status.error_status();
+ }
+
+ auto ion_buffer = std::make_unique<IonBuffer>();
+ auto native_buffer_handle = status.take();
+ const int ret = native_buffer_handle.Import(ion_buffer.get());
+ if (ret < 0) {
+ ALOGE(
+ "DisplayClient::GetGlobalBuffer: Failed to import global buffer: "
+ "key=%d; error=%s",
+ key, strerror(-ret));
+ return ErrorStatus(-ret);
+ }
+
+ return {std::move(ion_buffer)};
+}
+
+pdx::Status<void> DisplayClient::DeleteGlobalBuffer(DvrGlobalBufferKey key) {
+ auto status = InvokeRemoteMethod<DisplayProtocol::DeleteGlobalBuffer>(key);
+ if (!status) {
+ ALOGE("DisplayClient::DeleteGlobalBuffer Failed: %s",
+ status.GetErrorMessage().c_str());
+ }
+
+ return status;
+}
+
Status<std::unique_ptr<IonBuffer>> DisplayClient::GetGlobalBuffer(
DvrGlobalBufferKey key) {
auto status = InvokeRemoteMethod<DisplayProtocol::GetGlobalBuffer>(key);