• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #define LOG_TAG "gralloc-V1-service"
2 
3 #include <android/binder_ibinder_platform.h>
4 #include <android/binder_manager.h>
5 #include <android/binder_process.h>
6 #include <android/binder_status.h>
7 #include <log/log.h>
8 
9 #include "aidl/GrallocAllocator.h"
10 
11 using namespace android;
12 
13 using pixel::allocator::GrallocAllocator;
14 
main()15 int main() {
16     auto service = ndk::SharedRefBase::make<GrallocAllocator>();
17     auto binder = service->asBinder();
18 
19     AIBinder_setMinSchedulerPolicy(binder.get(), SCHED_NORMAL, -20);
20 
21     const auto instance = std::string() + GrallocAllocator::descriptor + "/default";
22     auto status = AServiceManager_addService(binder.get(), instance.c_str());
23     if (status != STATUS_OK) {
24         ALOGE("Failed to start AIDL gralloc allocator service");
25         return -EINVAL;
26     }
27 
28     ABinderProcess_setThreadPoolMaxThreadCount(4);
29     ABinderProcess_startThreadPool();
30     ABinderProcess_joinThreadPool();
31 
32     return EXIT_FAILURE; // Unreachable
33 }
34