service.cpp revision 346cf518ea29fd63e0ca0e366254d84e34f9286b
1#define LOG_TAG "android.hidl.allocator@1.0-service" 2 3#include "AshmemAllocator.h" 4 5#include <android-base/logging.h> 6#include <android/hidl/allocator/1.0/IAllocator.h> 7#include <hidl/HidlTransportSupport.h> 8 9using android::hardware::configureRpcThreadpool; 10using android::hardware::joinRpcThreadpool; 11using android::hidl::allocator::V1_0::IAllocator; 12using android::hidl::allocator::V1_0::implementation::AshmemAllocator; 13using android::sp; 14using android::status_t; 15 16int main() { 17 configureRpcThreadpool(1, true /* callerWillJoin */); 18 19 sp<IAllocator> allocator = new AshmemAllocator(); 20 21 status_t status = allocator->registerAsService("ashmem"); 22 23 if (android::OK != status) { 24 LOG(FATAL) << "Unable to register allocator service: " << status; 25 } 26 27 joinRpcThreadpool(); 28 29 return -1; 30} 31