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/libvrflinger/display_manager_service.cpp b/libs/vr/libvrflinger/display_manager_service.cpp
index 0e9a6ab..40396b9 100644
--- a/libs/vr/libvrflinger/display_manager_service.cpp
+++ b/libs/vr/libvrflinger/display_manager_service.cpp
@@ -78,16 +78,6 @@
*this, &DisplayManagerService::OnGetSurfaceQueue, message);
return {};
- case DisplayManagerProtocol::SetupGlobalBuffer::Opcode:
- DispatchRemoteMethod<DisplayManagerProtocol::SetupGlobalBuffer>(
- *this, &DisplayManagerService::OnSetupGlobalBuffer, message);
- return {};
-
- case DisplayManagerProtocol::DeleteGlobalBuffer::Opcode:
- DispatchRemoteMethod<DisplayManagerProtocol::DeleteGlobalBuffer>(
- *this, &DisplayManagerService::OnDeleteGlobalBuffer, message);
- return {};
-
default:
return Service::DefaultHandleMessage(message);
}
@@ -134,36 +124,6 @@
return status;
}
-pdx::Status<BorrowedNativeBufferHandle>
-DisplayManagerService::OnSetupGlobalBuffer(pdx::Message& message,
- DvrGlobalBufferKey key, size_t size,
- uint64_t usage) {
- const int user_id = message.GetEffectiveUserId();
- const bool trusted = user_id == AID_ROOT || IsTrustedUid(user_id);
-
- if (!trusted) {
- ALOGE(
- "DisplayService::SetupGlobalBuffer: Global buffers may only be created "
- "by trusted UIDs: user_id=%d",
- user_id);
- return ErrorStatus(EPERM);
- }
- return display_service_->SetupGlobalBuffer(key, size, usage);
-}
-
-pdx::Status<void> DisplayManagerService::OnDeleteGlobalBuffer(
- pdx::Message& message, DvrGlobalBufferKey key) {
- const int user_id = message.GetEffectiveUserId();
- const bool trusted = (user_id == AID_ROOT) || IsTrustedUid(user_id);
-
- if (!trusted) {
- ALOGE("DisplayService::DeleteGlobalBuffer: Untrusted user_id (%d)",
- user_id);
- return ErrorStatus(EPERM);
- }
- return display_service_->DeleteGlobalBuffer(key);
-}
-
void DisplayManagerService::OnDisplaySurfaceChange() {
if (display_manager_)
display_manager_->SetNotificationsPending(true);
diff --git a/libs/vr/libvrflinger/display_manager_service.h b/libs/vr/libvrflinger/display_manager_service.h
index c869ceb..3133fe1 100644
--- a/libs/vr/libvrflinger/display_manager_service.h
+++ b/libs/vr/libvrflinger/display_manager_service.h
@@ -56,11 +56,6 @@
pdx::Status<pdx::LocalChannelHandle> OnGetSurfaceQueue(pdx::Message& message,
int surface_id,
int queue_id);
- pdx::Status<BorrowedNativeBufferHandle> OnSetupGlobalBuffer(
- pdx::Message& message, DvrGlobalBufferKey key, size_t size,
- uint64_t usage);
- pdx::Status<void> OnDeleteGlobalBuffer(pdx::Message& message,
- DvrGlobalBufferKey key);
// Called by the display service to indicate changes to display surfaces that
// the display manager should evaluate.
diff --git a/libs/vr/libvrflinger/display_service.cpp b/libs/vr/libvrflinger/display_service.cpp
index 2f54f71..733edc6 100644
--- a/libs/vr/libvrflinger/display_service.cpp
+++ b/libs/vr/libvrflinger/display_service.cpp
@@ -12,8 +12,10 @@
#include <dvr/dvr_display_types.h>
#include <pdx/default_transport/service_endpoint.h>
#include <pdx/rpc/remote_method.h>
+#include <private/android_filesystem_config.h>
#include <private/dvr/display_protocol.h>
#include <private/dvr/numeric.h>
+#include <private/dvr/trusted_uids.h>
#include <private/dvr/types.h>
using android::dvr::display::DisplayProtocol;
@@ -140,6 +142,16 @@
*this, &DisplayService::OnCreateSurface, message);
return {};
+ case DisplayProtocol::SetupGlobalBuffer::Opcode:
+ DispatchRemoteMethod<DisplayProtocol::SetupGlobalBuffer>(
+ *this, &DisplayService::OnSetupGlobalBuffer, message);
+ return {};
+
+ case DisplayProtocol::DeleteGlobalBuffer::Opcode:
+ DispatchRemoteMethod<DisplayProtocol::DeleteGlobalBuffer>(
+ *this, &DisplayService::OnDeleteGlobalBuffer, message);
+ return {};
+
case DisplayProtocol::GetGlobalBuffer::Opcode:
DispatchRemoteMethod<DisplayProtocol::GetGlobalBuffer>(
*this, &DisplayService::OnGetGlobalBuffer, message);
@@ -259,6 +271,36 @@
}
}
+pdx::Status<BorrowedNativeBufferHandle> DisplayService::OnSetupGlobalBuffer(
+ pdx::Message& message, DvrGlobalBufferKey key, size_t size,
+ uint64_t usage) {
+ const int user_id = message.GetEffectiveUserId();
+ const bool trusted = user_id == AID_ROOT || IsTrustedUid(user_id);
+
+ if (!trusted) {
+ ALOGE(
+ "DisplayService::OnSetupGlobalBuffer: Permission denied for user_id=%d",
+ user_id);
+ return ErrorStatus(EPERM);
+ }
+ return SetupGlobalBuffer(key, size, usage);
+}
+
+pdx::Status<void> DisplayService::OnDeleteGlobalBuffer(pdx::Message& message,
+ DvrGlobalBufferKey key) {
+ const int user_id = message.GetEffectiveUserId();
+ const bool trusted = (user_id == AID_ROOT) || IsTrustedUid(user_id);
+
+ if (!trusted) {
+ ALOGE(
+ "DisplayService::OnDeleteGlobalBuffer: Permission denied for "
+ "user_id=%d",
+ user_id);
+ return ErrorStatus(EPERM);
+ }
+ return DeleteGlobalBuffer(key);
+}
+
pdx::Status<BorrowedNativeBufferHandle> DisplayService::OnGetGlobalBuffer(
pdx::Message& /* message */, DvrGlobalBufferKey key) {
ALOGD_IF(TRACE, "DisplayService::OnGetGlobalBuffer: key=%d", key);
diff --git a/libs/vr/libvrflinger/display_service.h b/libs/vr/libvrflinger/display_service.h
index cb21e9f..6efe264 100644
--- a/libs/vr/libvrflinger/display_service.h
+++ b/libs/vr/libvrflinger/display_service.h
@@ -92,6 +92,11 @@
pdx::Message& message, display::ConfigFileType config_type);
pdx::Status<display::SurfaceInfo> OnCreateSurface(
pdx::Message& message, const display::SurfaceAttributes& attributes);
+ pdx::Status<BorrowedNativeBufferHandle> OnSetupGlobalBuffer(
+ pdx::Message& message, DvrGlobalBufferKey key, size_t size,
+ uint64_t usage);
+ pdx::Status<void> OnDeleteGlobalBuffer(pdx::Message& message,
+ DvrGlobalBufferKey key);
// Temporary query for current VR status. Will be removed later.
pdx::Status<bool> IsVrAppRunning(pdx::Message& message);