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_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);