From 1310f1584ca557245d0677efd0db4dc1f1ed7c57 Mon Sep 17 00:00:00 2001 From: Charles Chen Date: Mon, 13 Feb 2023 18:02:10 +0000 Subject: Enable isolated process to use graphics allocator Add an LLNDK API for isolated process usage. Bug: 268016157 Bug: 269675258 Test: Manual - Service can be added with allowIsolated set to true. Change-Id: I9d3c39e313978ccd6b01574b5533530d4f959904 Merged-In: I9d3c39e313978ccd6b01574b5533530d4f959904 --- libs/ui/Gralloc4.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'libs/ui/Gralloc4.cpp') diff --git a/libs/ui/Gralloc4.cpp b/libs/ui/Gralloc4.cpp index f6ab7b2a5e..53372c9866 100644 --- a/libs/ui/Gralloc4.cpp +++ b/libs/ui/Gralloc4.cpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include #include @@ -1195,8 +1197,15 @@ Gralloc4Allocator::Gralloc4Allocator(const Gralloc4Mapper& mapper) : mMapper(map mAllocator = IAllocator::getService(); if (__builtin_available(android 31, *)) { if (hasIAllocatorAidl()) { - mAidlAllocator = AidlIAllocator::fromBinder(ndk::SpAIBinder( - AServiceManager_waitForService(kAidlAllocatorServiceName.c_str()))); + // TODO(b/269517338): Perform the isolated checking for this in service manager instead. + uid_t aid = multiuser_get_app_id(getuid()); + if (aid >= AID_ISOLATED_START && aid <= AID_ISOLATED_END) { + mAidlAllocator = AidlIAllocator::fromBinder(ndk::SpAIBinder( + AServiceManager_getService(kAidlAllocatorServiceName.c_str()))); + } else { + mAidlAllocator = AidlIAllocator::fromBinder(ndk::SpAIBinder( + AServiceManager_waitForService(kAidlAllocatorServiceName.c_str()))); + } ALOGE_IF(!mAidlAllocator, "AIDL IAllocator declared but failed to get service"); } } -- cgit v1.2.3-59-g8ed1b