summaryrefslogtreecommitdiff
path: root/transport/allocator/1.0/default/service.cpp
blob: 63babd35c4f14c07bd1c4f64264e1f93f93ece08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#define LOG_TAG "android.hidl.allocator@1.0-service"

#include "AshmemAllocator.h"

#include <android-base/logging.h>
#include <android/hidl/allocator/1.0/IAllocator.h>
#include <hidl/HidlTransportSupport.h>

using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using android::hidl::allocator::V1_0::IAllocator;
using android::hidl::allocator::V1_0::implementation::AshmemAllocator;
using android::sp;
using android::status_t;

int main() {
    configureRpcThreadpool(1, true /* callerWillJoin */);

    sp<IAllocator> allocator = new AshmemAllocator();

    status_t status = allocator->registerAsService("ashmem");

    if (android::OK != status) {
        LOG(FATAL) << "Unable to register allocator service: " << status;
    }

    joinRpcThreadpool();

    return -1;
}