diff --git a/graphics/allocator/2.0/Android.bp b/graphics/allocator/2.0/Android.bp
index 271f2ce..f707468 100644
--- a/graphics/allocator/2.0/Android.bp
+++ b/graphics/allocator/2.0/Android.bp
@@ -3,9 +3,7 @@
 filegroup {
     name: "android.hardware.graphics.allocator@2.0_hal",
     srcs: [
-        "types.hal",
         "IAllocator.hal",
-        "IAllocatorClient.hal",
     ],
 }
 
@@ -17,9 +15,7 @@
         ":android.hardware.graphics.allocator@2.0_hal",
     ],
     out: [
-        "android/hardware/graphics/allocator/2.0/types.cpp",
         "android/hardware/graphics/allocator/2.0/AllocatorAll.cpp",
-        "android/hardware/graphics/allocator/2.0/AllocatorClientAll.cpp",
     ],
 }
 
@@ -31,18 +27,11 @@
         ":android.hardware.graphics.allocator@2.0_hal",
     ],
     out: [
-        "android/hardware/graphics/allocator/2.0/types.h",
-        "android/hardware/graphics/allocator/2.0/hwtypes.h",
         "android/hardware/graphics/allocator/2.0/IAllocator.h",
         "android/hardware/graphics/allocator/2.0/IHwAllocator.h",
         "android/hardware/graphics/allocator/2.0/BnHwAllocator.h",
         "android/hardware/graphics/allocator/2.0/BpHwAllocator.h",
         "android/hardware/graphics/allocator/2.0/BsAllocator.h",
-        "android/hardware/graphics/allocator/2.0/IAllocatorClient.h",
-        "android/hardware/graphics/allocator/2.0/IHwAllocatorClient.h",
-        "android/hardware/graphics/allocator/2.0/BnHwAllocatorClient.h",
-        "android/hardware/graphics/allocator/2.0/BpHwAllocatorClient.h",
-        "android/hardware/graphics/allocator/2.0/BsAllocatorClient.h",
     ],
 }
 
@@ -59,6 +48,7 @@
         "libutils",
         "libcutils",
         "android.hardware.graphics.common@1.0",
+        "android.hardware.graphics.mapper@2.0",
         "android.hidl.base@1.0",
     ],
     export_shared_lib_headers: [
@@ -67,6 +57,7 @@
         "libhwbinder",
         "libutils",
         "android.hardware.graphics.common@1.0",
+        "android.hardware.graphics.mapper@2.0",
         "android.hidl.base@1.0",
     ],
 }
diff --git a/graphics/allocator/2.0/IAllocator.hal b/graphics/allocator/2.0/IAllocator.hal
index bf0e141..43a3916 100644
--- a/graphics/allocator/2.0/IAllocator.hal
+++ b/graphics/allocator/2.0/IAllocator.hal
@@ -16,38 +16,9 @@
 
 package android.hardware.graphics.allocator@2.0;
 
-import IAllocatorClient;
+import android.hardware.graphics.mapper@2.0;
 
 interface IAllocator {
-    enum Capability : int32_t {
-        /** reserved */
-        INVALID = 0,
-
-        /**
-         * IAllocatorClient::testAllocate must always return UNDEFINED unless
-         * this capability is supported.
-         */
-        TEST_ALLOCATE = 1,
-
-        /**
-         * IAllocatorClient::BufferDescriptorInfo::layerCount must be 1 unless
-         * this capability is supported.
-         */
-        LAYERED_BUFFERS = 2,
-    };
-
-    /**
-     * Provides a list of supported capabilities (as described in the
-     * definition of Capability above). This list must not change after
-     * initialization.
-     *
-     * @return capabilities is a list of supported capabilities.
-     */
-    @entry
-    @exit
-    @callflow(next="*")
-    getCapabilities() generates (vec<Capability> capabilities);
-
     /**
      * Retrieves implementation-defined debug information, which will be
      * displayed during, for example, `dumpsys SurfaceFlinger`.
@@ -60,15 +31,27 @@
     dumpDebugInfo() generates (string debugInfo);
 
     /**
-     * Creates a client of the allocator. All resources created by the client
-     * are owned by the client and are only visible to the client, unless they
-     * are exported by exportHandle.
+     * Allocates buffers with the properties specified by the descriptor.
      *
+     * @param descriptor specifies the properties of the buffers to allocate.
+     * @param count is the number of buffers to allocate.
      * @return error is NONE upon success. Otherwise,
-     *         NO_RESOURCES when no more client can currently be created.
-     * @return client is the newly created client.
+     *         BAD_DESCRIPTOR when the descriptor is invalid.
+     *         NO_RESOURCES when the allocation cannot be fulfilled at this
+     *                      time.
+     *         UNSUPPORTED when any of the property encoded in the descriptor
+     *                     is not supported.
+     * @return stride is the number of pixels between two consecutive rows of
+     *         the buffers, when the concept of consecutive rows is defined.
+     *         Otherwise, it has no meaning.
+     * @return buffers is an array of raw handles to the newly allocated
+     *         buffers.
      */
     @entry
+    @exit
     @callflow(next="*")
-    createClient() generates (Error error, IAllocatorClient client);
+    allocate(BufferDescriptor descriptor, uint32_t count)
+        generates (Error error,
+                   uint32_t stride,
+                   vec<handle> buffers);
 };
diff --git a/graphics/allocator/2.0/IAllocatorClient.hal b/graphics/allocator/2.0/IAllocatorClient.hal
deleted file mode 100644
index 8ca568f..0000000
--- a/graphics/allocator/2.0/IAllocatorClient.hal
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.hardware.graphics.allocator@2.0;
-
-import android.hardware.graphics.common@1.0::PixelFormat;
-
-interface IAllocatorClient {
-    struct BufferDescriptorInfo {
-        /**
-         * The width specifies how many columns of pixels must be in the
-         * allocated buffer, but does not necessarily represent the offset in
-         * columns between the same column in adjacent rows. The rows may be
-         * padded.
-         */
-        uint32_t width;
-
-       /**
-        * The height specifies how many rows of pixels must be in the
-        * allocated buffer.
-        */
-        uint32_t height;
-
-       /**
-        * The number of image layers that must be in the allocated buffer.
-        */
-        uint32_t layerCount;
-
-        /** Buffer pixel format. */
-        PixelFormat format;
-
-        /**
-         * Buffer producer usage mask; valid flags can be found in the
-         * definition of ProducerUsage.
-         */
-        uint64_t producerUsageMask;
-
-        /**
-         * Buffer consumer usage mask; valid flags can be found in the
-         * definition of ConsumerUsage.
-         */
-        uint64_t consumerUsageMask;
-    };
-
-    /**
-     * Creates a new, opaque buffer descriptor.
-     *
-     * @param descriptorInfo specifies the attributes of the buffer
-     *        descriptor.
-     * @return error is NONE upon success. Otherwise,
-     *         BAD_VALUE when any attribute in descriptorInfo is invalid.
-     *         NO_RESOURCES when no more descriptors can currently be created.
-     * @return descriptor is the newly created buffer descriptor.
-     */
-    @entry
-    @callflow(next="*")
-    createDescriptor(BufferDescriptorInfo descriptorInfo)
-          generates (Error error,
-                     BufferDescriptor descriptor);
-
-    /**
-     * Destroys an existing buffer descriptor.
-     *
-     * @param descriptor is the descriptor to destroy.
-     * @return error is either NONE or BAD_DESCRIPTOR.
-     */
-    @exit
-    @callflow(next="*")
-    destroyDescriptor(BufferDescriptor descriptor) generates (Error error);
-
-    /**
-     * Tests whether a buffer allocation can succeed, ignoring potential
-     * resource contention which might lead to a NO_RESOURCES error.
-     *
-     * @param descriptors is a list of buffer descriptors.
-     * @return error is NONE or NOT_SHARED upon success;
-     *         NONE when buffers can be created and share a backing store.
-     *         NOT_SHARED when buffers can be created but require more than a
-     *                    backing store.
-     *         Otherwise,
-     *         BAD_DESCRIPTOR when any of the descriptors is invalid.
-     *         UNSUPPORTED when any of the descriptors can never be satisfied.
-     *         UNDEFINED when TEST_ALLOCATE is not listed in getCapabilities.
-     */
-    @callflow(next="allocate")
-    testAllocate(vec<BufferDescriptor> descriptors) generates (Error error);
-
-    /**
-     * Attempts to allocate a list of buffers sharing a backing store.
-     *
-     * Each buffer must correspond to one of the descriptors passed into the
-     * function and must hold a reference to its backing store. If the device
-     * is unable to share the backing store between the buffers, it must
-     * attempt to allocate the buffers with different backing stores and
-     * return NOT_SHARED if it is successful.
-     *
-     * @param descriptors is the buffer descriptors to attempt to allocate.
-     * @return error is NONE or NOT_SHARED upon success;
-     *         NONE when buffers can be created and share a backing store.
-     *         NOT_SHARED when buffers can be created but require more than a
-     *                    backing store.
-     *         Otherwise,
-     *         BAD_DESCRIPTOR when any of the descriptors is invalid.
-     *         UNSUPPORTED when any of the descriptors can never be satisfied.
-     *         NO_RESOURCES when any of the buffers cannot be created at this
-     *                      time.
-     * @return buffers is the allocated buffers.
-     */
-    @callflow(next="exportHandle")
-    allocate(vec<BufferDescriptor> descriptors)
-        generates (Error error,
-                   vec<Buffer> buffers);
-
-    /**
-     * Frees a buffer.
-     *
-     * @param buffer is the buffer to be freed.
-     * @return error is NONE upon success. Otherwise,
-     *         BAD_BUFFER when the buffer is invalid.
-     */
-    @exit
-    @callflow(next="*")
-    free(Buffer buffer) generates (Error error);
-
-    /**
-     * Exports a buffer for use in other client libraries or for cross-process
-     * sharing.
-     *
-     * The exported handle is a handle to the backing store of the buffer, not
-     * to the buffer itself. It however may not hold any reference to the
-     * backing store and may be considered invalid by client libraries. To use
-     * it and, in most cases, to save it for later use, a client must make a
-     * clone of the handle and have the cloned handle hold a reference to the
-     * backing store. Such a cloned handle will stay valid even after the
-     * original buffer is freed. Refer to native_handle_clone and IMapper for
-     * how a handle is cloned and how a reference is added.
-     *
-     * @param descriptor is the descriptor used to allocate the buffer.
-     * @param buffer is the buffer to be exported.
-     * @return error is NONE upon success. Otherwise,
-     *         BAD_DESCRIPTOR when the descriptor is invalid.
-     *         BAD_BUFFER when the buffer is invalid.
-     *         BAD_VALUE when descriptor and buffer do not match.
-     *         NO_RESOURCES when the buffer cannot be exported at this time.
-     * @return bufferHandle is the exported handle.
-     */
-    @callflow(next="free")
-    exportHandle(BufferDescriptor descriptor,
-                 Buffer buffer)
-      generates (Error error,
-                 handle bufferHandle);
-};
diff --git a/graphics/allocator/2.0/default/Android.bp b/graphics/allocator/2.0/default/Android.bp
index 0baef89..6adfa71 100644
--- a/graphics/allocator/2.0/default/Android.bp
+++ b/graphics/allocator/2.0/default/Android.bp
@@ -3,7 +3,7 @@
     defaults: ["hidl_defaults"],
     proprietary: true,
     relative_install_path: "hw",
-    srcs: ["Gralloc.cpp"],
+    srcs: ["Gralloc.cpp", "Gralloc0Allocator.cpp", "Gralloc1Allocator.cpp"],
     cppflags: ["-Wall", "-Wextra"],
     shared_libs: [
         "android.hardware.graphics.allocator@2.0",
@@ -15,6 +15,7 @@
         "liblog",
         "libutils",
     ],
+    static_libs: ["libgrallocmapperincludes"],
 }
 
 cc_binary {
diff --git a/graphics/allocator/2.0/default/Gralloc.cpp b/graphics/allocator/2.0/default/Gralloc.cpp
index 0b9e863..273d3f5 100644
--- a/graphics/allocator/2.0/default/Gralloc.cpp
+++ b/graphics/allocator/2.0/default/Gralloc.cpp
@@ -16,17 +16,11 @@
 
 #define LOG_TAG "GrallocPassthrough"
 
-#include <mutex>
-#include <type_traits>
-#include <unordered_set>
-#include <vector>
-
-#include <string.h>
-
-#include <hardware/gralloc1.h>
-#include <log/log.h>
-
 #include "Gralloc.h"
+#include "Gralloc0Allocator.h"
+#include "Gralloc1Allocator.h"
+
+#include <log/log.h>
 
 namespace android {
 namespace hardware {
@@ -35,417 +29,6 @@
 namespace V2_0 {
 namespace implementation {
 
-class GrallocHal : public IAllocator {
-public:
-    GrallocHal(const hw_module_t* module);
-    virtual ~GrallocHal();
-
-    // IAllocator interface
-    Return<void> getCapabilities(getCapabilities_cb hidl_cb) override;
-    Return<void> dumpDebugInfo(dumpDebugInfo_cb hidl_cb) override;
-    Return<void> createClient(createClient_cb hidl_cb) override;
-
-    Error createDescriptor(
-            const IAllocatorClient::BufferDescriptorInfo& descriptorInfo,
-            BufferDescriptor* outDescriptor);
-    Error destroyDescriptor(BufferDescriptor descriptor);
-
-    Error testAllocate(const hidl_vec<BufferDescriptor>& descriptors);
-    Error allocate(const hidl_vec<BufferDescriptor>& descriptors,
-            hidl_vec<Buffer>* outBuffers);
-    Error free(Buffer buffer);
-
-    Error exportHandle(Buffer buffer, const native_handle_t** outHandle);
-
-private:
-    void initCapabilities();
-
-    template<typename T>
-    void initDispatch(gralloc1_function_descriptor_t desc, T* outPfn);
-    void initDispatch();
-
-    bool hasCapability(Capability capability) const;
-
-    gralloc1_device_t* mDevice;
-
-    std::unordered_set<Capability> mCapabilities;
-
-    struct {
-        GRALLOC1_PFN_DUMP dump;
-        GRALLOC1_PFN_CREATE_DESCRIPTOR createDescriptor;
-        GRALLOC1_PFN_DESTROY_DESCRIPTOR destroyDescriptor;
-        GRALLOC1_PFN_SET_DIMENSIONS setDimensions;
-        GRALLOC1_PFN_SET_FORMAT setFormat;
-        GRALLOC1_PFN_SET_LAYER_COUNT setLayerCount;
-        GRALLOC1_PFN_SET_CONSUMER_USAGE setConsumerUsage;
-        GRALLOC1_PFN_SET_PRODUCER_USAGE setProducerUsage;
-        GRALLOC1_PFN_ALLOCATE allocate;
-        GRALLOC1_PFN_RELEASE release;
-    } mDispatch;
-};
-
-class GrallocClient : public IAllocatorClient {
-public:
-    GrallocClient(GrallocHal& hal);
-    virtual ~GrallocClient();
-
-    // IAllocatorClient interface
-    Return<void> createDescriptor(const BufferDescriptorInfo& descriptorInfo,
-            createDescriptor_cb hidl_cb) override;
-    Return<Error> destroyDescriptor(BufferDescriptor descriptor) override;
-
-    Return<Error> testAllocate(
-            const hidl_vec<BufferDescriptor>& descriptors) override;
-    Return<void> allocate(const hidl_vec<BufferDescriptor>& descriptors,
-            allocate_cb hidl_cb) override;
-    Return<Error> free(Buffer buffer) override;
-
-    Return<void> exportHandle(BufferDescriptor descriptor,
-            Buffer buffer, exportHandle_cb hidl_cb) override;
-
-private:
-    GrallocHal& mHal;
-
-    std::mutex mMutex;
-    std::unordered_set<BufferDescriptor> mDescriptors;
-    std::unordered_set<Buffer> mBuffers;
-};
-
-GrallocHal::GrallocHal(const hw_module_t* module)
-    : mDevice(nullptr), mDispatch()
-{
-    int status = gralloc1_open(module, &mDevice);
-    if (status) {
-        LOG_ALWAYS_FATAL("failed to open gralloc1 device: %s",
-                strerror(-status));
-    }
-
-    initCapabilities();
-    initDispatch();
-}
-
-GrallocHal::~GrallocHal()
-{
-    gralloc1_close(mDevice);
-}
-
-void GrallocHal::initCapabilities()
-{
-    uint32_t count = 0;
-    mDevice->getCapabilities(mDevice, &count, nullptr);
-
-    std::vector<Capability> caps(count);
-    mDevice->getCapabilities(mDevice, &count, reinterpret_cast<
-              std::underlying_type<Capability>::type*>(caps.data()));
-    caps.resize(count);
-
-    mCapabilities.insert(caps.cbegin(), caps.cend());
-}
-
-template<typename T>
-void GrallocHal::initDispatch(gralloc1_function_descriptor_t desc, T* outPfn)
-{
-    auto pfn = mDevice->getFunction(mDevice, desc);
-    if (!pfn) {
-        LOG_ALWAYS_FATAL("failed to get gralloc1 function %d", desc);
-    }
-
-    *outPfn = reinterpret_cast<T>(pfn);
-}
-
-void GrallocHal::initDispatch()
-{
-    initDispatch(GRALLOC1_FUNCTION_DUMP, &mDispatch.dump);
-    initDispatch(GRALLOC1_FUNCTION_CREATE_DESCRIPTOR,
-            &mDispatch.createDescriptor);
-    initDispatch(GRALLOC1_FUNCTION_DESTROY_DESCRIPTOR,
-            &mDispatch.destroyDescriptor);
-    initDispatch(GRALLOC1_FUNCTION_SET_DIMENSIONS, &mDispatch.setDimensions);
-    initDispatch(GRALLOC1_FUNCTION_SET_FORMAT, &mDispatch.setFormat);
-    if (hasCapability(Capability::LAYERED_BUFFERS)) {
-        initDispatch(GRALLOC1_FUNCTION_SET_LAYER_COUNT,
-                &mDispatch.setLayerCount);
-    }
-    initDispatch(GRALLOC1_FUNCTION_SET_CONSUMER_USAGE,
-            &mDispatch.setConsumerUsage);
-    initDispatch(GRALLOC1_FUNCTION_SET_PRODUCER_USAGE,
-            &mDispatch.setProducerUsage);
-    initDispatch(GRALLOC1_FUNCTION_ALLOCATE, &mDispatch.allocate);
-    initDispatch(GRALLOC1_FUNCTION_RELEASE, &mDispatch.release);
-}
-
-bool GrallocHal::hasCapability(Capability capability) const
-{
-    return (mCapabilities.count(capability) > 0);
-}
-
-Return<void> GrallocHal::getCapabilities(getCapabilities_cb hidl_cb)
-{
-    std::vector<Capability> caps(
-            mCapabilities.cbegin(), mCapabilities.cend());
-
-    hidl_vec<Capability> reply;
-    reply.setToExternal(caps.data(), caps.size());
-    hidl_cb(reply);
-
-    return Void();
-}
-
-Return<void> GrallocHal::dumpDebugInfo(dumpDebugInfo_cb hidl_cb)
-{
-    uint32_t len = 0;
-    mDispatch.dump(mDevice, &len, nullptr);
-
-    std::vector<char> buf(len + 1);
-    mDispatch.dump(mDevice, &len, buf.data());
-    buf.resize(len + 1);
-    buf[len] = '\0';
-
-    hidl_string reply;
-    reply.setToExternal(buf.data(), len);
-    hidl_cb(reply);
-
-    return Void();
-}
-
-Return<void> GrallocHal::createClient(createClient_cb hidl_cb)
-{
-    sp<IAllocatorClient> client = new GrallocClient(*this);
-    hidl_cb(Error::NONE, client);
-
-    return Void();
-}
-
-Error GrallocHal::createDescriptor(
-        const IAllocatorClient::BufferDescriptorInfo& descriptorInfo,
-        BufferDescriptor* outDescriptor)
-{
-    gralloc1_buffer_descriptor_t descriptor;
-    int32_t err = mDispatch.createDescriptor(mDevice, &descriptor);
-    if (err != GRALLOC1_ERROR_NONE) {
-        return static_cast<Error>(err);
-    }
-
-    err = mDispatch.setDimensions(mDevice, descriptor,
-            descriptorInfo.width, descriptorInfo.height);
-    if (err == GRALLOC1_ERROR_NONE) {
-        err = mDispatch.setFormat(mDevice, descriptor,
-                static_cast<int32_t>(descriptorInfo.format));
-    }
-    if (err == GRALLOC1_ERROR_NONE) {
-        if (hasCapability(Capability::LAYERED_BUFFERS)) {
-            err = mDispatch.setLayerCount(mDevice, descriptor,
-                    descriptorInfo.layerCount);
-        } else if (descriptorInfo.layerCount != 1) {
-            err = GRALLOC1_ERROR_BAD_VALUE;
-        }
-    }
-    if (err == GRALLOC1_ERROR_NONE) {
-        uint64_t producerUsageMask = descriptorInfo.producerUsageMask;
-        if (producerUsageMask & GRALLOC1_PRODUCER_USAGE_CPU_READ_OFTEN) {
-            producerUsageMask |= GRALLOC1_PRODUCER_USAGE_CPU_READ;
-        }
-        if (producerUsageMask & GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN) {
-            producerUsageMask |= GRALLOC1_PRODUCER_USAGE_CPU_WRITE;
-        }
-        err = mDispatch.setProducerUsage(mDevice, descriptor,
-                descriptorInfo.producerUsageMask);
-    }
-    if (err == GRALLOC1_ERROR_NONE) {
-        uint64_t consumerUsageMask = descriptorInfo.consumerUsageMask;
-        if (consumerUsageMask & GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN) {
-            consumerUsageMask |= GRALLOC1_CONSUMER_USAGE_CPU_READ;
-        }
-        err = mDispatch.setConsumerUsage(mDevice, descriptor,
-                consumerUsageMask);
-    }
-
-    if (err == GRALLOC1_ERROR_NONE) {
-        *outDescriptor = descriptor;
-    } else {
-        mDispatch.destroyDescriptor(mDevice, descriptor);
-    }
-
-    return static_cast<Error>(err);
-}
-
-Error GrallocHal::destroyDescriptor(BufferDescriptor descriptor)
-{
-    int32_t err = mDispatch.destroyDescriptor(mDevice, descriptor);
-    return static_cast<Error>(err);
-}
-
-Error GrallocHal::testAllocate(const hidl_vec<BufferDescriptor>& descriptors)
-{
-    if (!hasCapability(Capability::TEST_ALLOCATE)) {
-        return Error::UNDEFINED;
-    }
-
-    int32_t err = mDispatch.allocate(mDevice, descriptors.size(),
-            descriptors.data(), nullptr);
-    return static_cast<Error>(err);
-}
-
-Error GrallocHal::allocate(const hidl_vec<BufferDescriptor>& descriptors,
-        hidl_vec<Buffer>* outBuffers)
-{
-    std::vector<buffer_handle_t> buffers(descriptors.size());
-    int32_t err = mDispatch.allocate(mDevice, descriptors.size(),
-            descriptors.data(), buffers.data());
-    if (err == GRALLOC1_ERROR_NONE || err == GRALLOC1_ERROR_NOT_SHARED) {
-        outBuffers->resize(buffers.size());
-        for (size_t i = 0; i < outBuffers->size(); i++) {
-            (*outBuffers)[i] = static_cast<Buffer>(
-                    reinterpret_cast<uintptr_t>(buffers[i]));
-        }
-    }
-
-    return static_cast<Error>(err);
-}
-
-Error GrallocHal::free(Buffer buffer)
-{
-    buffer_handle_t handle = reinterpret_cast<buffer_handle_t>(
-            static_cast<uintptr_t>(buffer));
-
-    int32_t err = mDispatch.release(mDevice, handle);
-    return static_cast<Error>(err);
-}
-
-Error GrallocHal::exportHandle(Buffer buffer,
-        const native_handle_t** outHandle)
-{
-    // we rely on the caller to validate buffer here
-    *outHandle = reinterpret_cast<buffer_handle_t>(
-            static_cast<uintptr_t>(buffer));
-    return Error::NONE;
-}
-
-GrallocClient::GrallocClient(GrallocHal& hal)
-    : mHal(hal)
-{
-}
-
-GrallocClient::~GrallocClient()
-{
-    if (!mBuffers.empty()) {
-        ALOGW("client destroyed with valid buffers");
-        for (auto buf : mBuffers) {
-            mHal.free(buf);
-        }
-    }
-
-    if (!mDescriptors.empty()) {
-        ALOGW("client destroyed with valid buffer descriptors");
-        for (auto desc : mDescriptors) {
-            mHal.destroyDescriptor(desc);
-        }
-    }
-}
-
-Return<void> GrallocClient::createDescriptor(
-        const BufferDescriptorInfo& descriptorInfo,
-        createDescriptor_cb hidl_cb)
-{
-    BufferDescriptor descriptor = 0;
-    Error err = mHal.createDescriptor(descriptorInfo, &descriptor);
-
-    if (err == Error::NONE) {
-        std::lock_guard<std::mutex> lock(mMutex);
-
-        auto result = mDescriptors.insert(descriptor);
-        if (!result.second) {
-            ALOGW("duplicated buffer descriptor id returned");
-            mHal.destroyDescriptor(descriptor);
-            err = Error::NO_RESOURCES;
-        }
-    }
-
-    hidl_cb(err, descriptor);
-    return Void();
-}
-
-Return<Error> GrallocClient::destroyDescriptor(BufferDescriptor descriptor)
-{
-    {
-        std::lock_guard<std::mutex> lock(mMutex);
-        if (!mDescriptors.erase(descriptor)) {
-            return Error::BAD_DESCRIPTOR;
-        }
-    }
-
-    return mHal.destroyDescriptor(descriptor);
-}
-
-Return<Error> GrallocClient::testAllocate(
-        const hidl_vec<BufferDescriptor>& descriptors)
-{
-    return mHal.testAllocate(descriptors);
-}
-
-Return<void> GrallocClient::allocate(
-        const hidl_vec<BufferDescriptor>& descriptors,
-        allocate_cb hidl_cb) {
-    hidl_vec<Buffer> buffers;
-    Error err = mHal.allocate(descriptors, &buffers);
-
-    if (err == Error::NONE || err == Error::NOT_SHARED) {
-        std::lock_guard<std::mutex> lock(mMutex);
-
-        for (size_t i = 0; i < buffers.size(); i++) {
-            auto result = mBuffers.insert(buffers[i]);
-            if (!result.second) {
-                ALOGW("duplicated buffer id returned");
-
-                for (size_t j = 0; j < buffers.size(); j++) {
-                    if (j < i) {
-                        mBuffers.erase(buffers[i]);
-                    }
-                    mHal.free(buffers[i]);
-                }
-
-                buffers = hidl_vec<Buffer>();
-                err = Error::NO_RESOURCES;
-                break;
-            }
-        }
-    }
-
-    hidl_cb(err, buffers);
-    return Void();
-}
-
-Return<Error> GrallocClient::free(Buffer buffer)
-{
-    {
-        std::lock_guard<std::mutex> lock(mMutex);
-        if (!mBuffers.erase(buffer)) {
-            return Error::BAD_BUFFER;
-        }
-    }
-
-    return mHal.free(buffer);
-}
-
-Return<void> GrallocClient::exportHandle(BufferDescriptor /*descriptor*/,
-        Buffer buffer, exportHandle_cb hidl_cb)
-{
-    const native_handle_t* handle = nullptr;
-
-    {
-        std::lock_guard<std::mutex> lock(mMutex);
-        if (mBuffers.count(buffer) == 0) {
-            hidl_cb(Error::BAD_BUFFER, handle);
-            return Void();
-        }
-    }
-
-    Error err = mHal.exportHandle(buffer, &handle);
-
-    hidl_cb(err, handle);
-    return Void();
-}
-
 IAllocator* HIDL_FETCH_IAllocator(const char* /* name */) {
     const hw_module_t* module = nullptr;
     int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
@@ -455,12 +38,15 @@
     }
 
     uint8_t major = (module->module_api_version >> 8) & 0xff;
-    if (major != 1) {
-        ALOGE("unknown gralloc module major version %d", major);
-        return nullptr;
+    switch (major) {
+        case 1:
+            return new Gralloc1Allocator(module);
+        case 0:
+            return new Gralloc0Allocator(module);
+        default:
+            ALOGE("unknown gralloc module major version %d", major);
+            return nullptr;
     }
-
-    return new GrallocHal(module);
 }
 
 } // namespace implementation
diff --git a/graphics/allocator/2.0/default/Gralloc0Allocator.cpp b/graphics/allocator/2.0/default/Gralloc0Allocator.cpp
new file mode 100644
index 0000000..3b62bb3
--- /dev/null
+++ b/graphics/allocator/2.0/default/Gralloc0Allocator.cpp
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "Gralloc0Allocator"
+
+#include "Gralloc0Allocator.h"
+#include "GrallocBufferDescriptor.h"
+
+#include <vector>
+
+#include <string.h>
+
+#include <log/log.h>
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace allocator {
+namespace V2_0 {
+namespace implementation {
+
+using android::hardware::graphics::mapper::V2_0::implementation::
+    grallocDecodeBufferDescriptor;
+
+Gralloc0Allocator::Gralloc0Allocator(const hw_module_t* module) {
+    int result = gralloc_open(module, &mDevice);
+    if (result) {
+        LOG_ALWAYS_FATAL("failed to open gralloc0 device: %s",
+                         strerror(-result));
+    }
+}
+
+Gralloc0Allocator::~Gralloc0Allocator() {
+    gralloc_close(mDevice);
+}
+
+Return<void> Gralloc0Allocator::dumpDebugInfo(dumpDebugInfo_cb hidl_cb) {
+    char buf[4096] = {};
+    if (mDevice->dump) {
+        mDevice->dump(mDevice, buf, sizeof(buf));
+        buf[sizeof(buf) - 1] = '\0';
+    }
+
+    hidl_cb(hidl_string(buf));
+
+    return Void();
+}
+
+Return<void> Gralloc0Allocator::allocate(const BufferDescriptor& descriptor,
+                                         uint32_t count, allocate_cb hidl_cb) {
+    IMapper::BufferDescriptorInfo descriptorInfo;
+    if (!grallocDecodeBufferDescriptor(descriptor, &descriptorInfo)) {
+        hidl_cb(Error::BAD_DESCRIPTOR, 0, hidl_vec<hidl_handle>());
+        return Void();
+    }
+
+    Error error = Error::NONE;
+    uint32_t stride = 0;
+    std::vector<hidl_handle> buffers;
+    buffers.reserve(count);
+
+    // allocate the buffers
+    for (uint32_t i = 0; i < count; i++) {
+        buffer_handle_t tmpBuffer;
+        uint32_t tmpStride;
+        error = allocateOne(descriptorInfo, &tmpBuffer, &tmpStride);
+        if (error != Error::NONE) {
+            break;
+        }
+
+        if (stride == 0) {
+            stride = tmpStride;
+        } else if (stride != tmpStride) {
+            // non-uniform strides
+            mDevice->free(mDevice, tmpBuffer);
+            stride = 0;
+            error = Error::UNSUPPORTED;
+            break;
+        }
+
+        buffers.emplace_back(hidl_handle(tmpBuffer));
+    }
+
+    // return the buffers
+    hidl_vec<hidl_handle> hidl_buffers;
+    if (error == Error::NONE) {
+        hidl_buffers.setToExternal(buffers.data(), buffers.size());
+    }
+    hidl_cb(error, stride, hidl_buffers);
+
+    // free the buffers
+    for (const auto& buffer : buffers) {
+        mDevice->free(mDevice, buffer.getNativeHandle());
+    }
+
+    return Void();
+}
+
+Error Gralloc0Allocator::allocateOne(const IMapper::BufferDescriptorInfo& info,
+                                     buffer_handle_t* outBuffer,
+                                     uint32_t* outStride) {
+    if (info.layerCount > 1 || (info.usage >> 32) != 0) {
+        return Error::BAD_VALUE;
+    }
+
+    buffer_handle_t buffer = nullptr;
+    int stride = 0;
+    int result = mDevice->alloc(mDevice, info.width, info.height,
+                                static_cast<int>(info.format), info.usage,
+                                &buffer, &stride);
+    if (result) {
+        switch (result) {
+            case -EINVAL:
+                return Error::BAD_VALUE;
+            default:
+                return Error::NO_RESOURCES;
+        }
+    }
+
+    *outBuffer = buffer;
+    *outStride = stride;
+
+    return Error::NONE;
+}
+
+}  // namespace implementation
+}  // namespace V2_0
+}  // namespace allocator
+}  // namespace graphics
+}  // namespace hardware
+}  // namespace android
diff --git a/graphics/allocator/2.0/default/Gralloc0Allocator.h b/graphics/allocator/2.0/default/Gralloc0Allocator.h
new file mode 100644
index 0000000..0e90527
--- /dev/null
+++ b/graphics/allocator/2.0/default/Gralloc0Allocator.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_HARDWARE_GRAPHICS_ALLOCATOR_V2_0_GRALLOC0ALLOCATOR_H
+#define ANDROID_HARDWARE_GRAPHICS_ALLOCATOR_V2_0_GRALLOC0ALLOCATOR_H
+
+#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
+#include <android/hardware/graphics/mapper/2.0/IMapper.h>
+#include <hardware/gralloc.h>
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace allocator {
+namespace V2_0 {
+namespace implementation {
+
+using android::hardware::graphics::mapper::V2_0::IMapper;
+using android::hardware::graphics::mapper::V2_0::BufferDescriptor;
+using android::hardware::graphics::mapper::V2_0::Error;
+
+class Gralloc0Allocator : public IAllocator {
+   public:
+    Gralloc0Allocator(const hw_module_t* module);
+    virtual ~Gralloc0Allocator();
+
+    // IAllocator interface
+    Return<void> dumpDebugInfo(dumpDebugInfo_cb hidl_cb) override;
+    Return<void> allocate(const BufferDescriptor& descriptor, uint32_t count,
+                          allocate_cb hidl_cb) override;
+
+   private:
+    Error allocateOne(const IMapper::BufferDescriptorInfo& info,
+                      buffer_handle_t* outBuffer, uint32_t* outStride);
+
+    alloc_device_t* mDevice;
+};
+
+}  // namespace implementation
+}  // namespace V2_0
+}  // namespace allocator
+}  // namespace graphics
+}  // namespace hardware
+}  // namespace android
+
+#endif  // ANDROID_HARDWARE_GRAPHICS_ALLOCATOR_V2_0_GRALLOC0ALLOCATOR_H
diff --git a/graphics/allocator/2.0/default/Gralloc1Allocator.cpp b/graphics/allocator/2.0/default/Gralloc1Allocator.cpp
new file mode 100644
index 0000000..c0a5e1e
--- /dev/null
+++ b/graphics/allocator/2.0/default/Gralloc1Allocator.cpp
@@ -0,0 +1,321 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "Gralloc1Allocator"
+
+#include "Gralloc1Allocator.h"
+#include "GrallocBufferDescriptor.h"
+
+#include <vector>
+
+#include <string.h>
+
+#include <log/log.h>
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace allocator {
+namespace V2_0 {
+namespace implementation {
+
+using android::hardware::graphics::common::V1_0::BufferUsage;
+using android::hardware::graphics::mapper::V2_0::implementation::
+    grallocDecodeBufferDescriptor;
+
+Gralloc1Allocator::Gralloc1Allocator(const hw_module_t* module)
+    : mDevice(nullptr), mCapabilities(), mDispatch() {
+    int result = gralloc1_open(module, &mDevice);
+    if (result) {
+        LOG_ALWAYS_FATAL("failed to open gralloc1 device: %s",
+                         strerror(-result));
+    }
+
+    initCapabilities();
+    initDispatch();
+}
+
+Gralloc1Allocator::~Gralloc1Allocator() {
+    gralloc1_close(mDevice);
+}
+
+void Gralloc1Allocator::initCapabilities() {
+    uint32_t count = 0;
+    mDevice->getCapabilities(mDevice, &count, nullptr);
+
+    std::vector<int32_t> capabilities(count);
+    mDevice->getCapabilities(mDevice, &count, capabilities.data());
+    capabilities.resize(count);
+
+    for (auto capability : capabilities) {
+        if (capability == GRALLOC1_CAPABILITY_LAYERED_BUFFERS) {
+            mCapabilities.layeredBuffers = true;
+            break;
+        }
+    }
+}
+
+template <typename T>
+void Gralloc1Allocator::initDispatch(gralloc1_function_descriptor_t desc,
+                                     T* outPfn) {
+    auto pfn = mDevice->getFunction(mDevice, desc);
+    if (!pfn) {
+        LOG_ALWAYS_FATAL("failed to get gralloc1 function %d", desc);
+    }
+
+    *outPfn = reinterpret_cast<T>(pfn);
+}
+
+void Gralloc1Allocator::initDispatch() {
+    initDispatch(GRALLOC1_FUNCTION_DUMP, &mDispatch.dump);
+    initDispatch(GRALLOC1_FUNCTION_CREATE_DESCRIPTOR,
+                 &mDispatch.createDescriptor);
+    initDispatch(GRALLOC1_FUNCTION_DESTROY_DESCRIPTOR,
+                 &mDispatch.destroyDescriptor);
+    initDispatch(GRALLOC1_FUNCTION_SET_DIMENSIONS, &mDispatch.setDimensions);
+    initDispatch(GRALLOC1_FUNCTION_SET_FORMAT, &mDispatch.setFormat);
+    if (mCapabilities.layeredBuffers) {
+        initDispatch(GRALLOC1_FUNCTION_SET_LAYER_COUNT,
+                     &mDispatch.setLayerCount);
+    }
+    initDispatch(GRALLOC1_FUNCTION_SET_CONSUMER_USAGE,
+                 &mDispatch.setConsumerUsage);
+    initDispatch(GRALLOC1_FUNCTION_SET_PRODUCER_USAGE,
+                 &mDispatch.setProducerUsage);
+    initDispatch(GRALLOC1_FUNCTION_GET_STRIDE, &mDispatch.getStride);
+    initDispatch(GRALLOC1_FUNCTION_ALLOCATE, &mDispatch.allocate);
+    initDispatch(GRALLOC1_FUNCTION_RELEASE, &mDispatch.release);
+}
+
+Return<void> Gralloc1Allocator::dumpDebugInfo(dumpDebugInfo_cb hidl_cb) {
+    uint32_t len = 0;
+    mDispatch.dump(mDevice, &len, nullptr);
+
+    std::vector<char> buf(len + 1);
+    mDispatch.dump(mDevice, &len, buf.data());
+    buf.resize(len + 1);
+    buf[len] = '\0';
+
+    hidl_string reply;
+    reply.setToExternal(buf.data(), len);
+    hidl_cb(reply);
+
+    return Void();
+}
+
+Return<void> Gralloc1Allocator::allocate(const BufferDescriptor& descriptor,
+                                         uint32_t count, allocate_cb hidl_cb) {
+    IMapper::BufferDescriptorInfo descriptorInfo;
+    if (!grallocDecodeBufferDescriptor(descriptor, &descriptorInfo)) {
+        hidl_cb(Error::BAD_DESCRIPTOR, 0, hidl_vec<hidl_handle>());
+        return Void();
+    }
+
+    gralloc1_buffer_descriptor_t desc;
+    Error error = createDescriptor(descriptorInfo, &desc);
+    if (error != Error::NONE) {
+        hidl_cb(error, 0, hidl_vec<hidl_handle>());
+        return Void();
+    }
+
+    uint32_t stride = 0;
+    std::vector<hidl_handle> buffers;
+    buffers.reserve(count);
+
+    // allocate the buffers
+    for (uint32_t i = 0; i < count; i++) {
+        buffer_handle_t tmpBuffer;
+        uint32_t tmpStride;
+        error = allocateOne(desc, &tmpBuffer, &tmpStride);
+        if (error != Error::NONE) {
+            break;
+        }
+
+        if (stride == 0) {
+            stride = tmpStride;
+        } else if (stride != tmpStride) {
+            // non-uniform strides
+            mDispatch.release(mDevice, tmpBuffer);
+            stride = 0;
+            error = Error::UNSUPPORTED;
+            break;
+        }
+
+        buffers.emplace_back(hidl_handle(tmpBuffer));
+    }
+
+    mDispatch.destroyDescriptor(mDevice, desc);
+
+    // return the buffers
+    hidl_vec<hidl_handle> hidl_buffers;
+    if (error == Error::NONE) {
+        hidl_buffers.setToExternal(buffers.data(), buffers.size());
+    }
+    hidl_cb(error, stride, hidl_buffers);
+
+    // free the buffers
+    for (const auto& buffer : buffers) {
+        mDispatch.release(mDevice, buffer.getNativeHandle());
+    }
+
+    return Void();
+}
+
+Error Gralloc1Allocator::toError(int32_t error) {
+    switch (error) {
+        case GRALLOC1_ERROR_NONE:
+            return Error::NONE;
+        case GRALLOC1_ERROR_BAD_DESCRIPTOR:
+            return Error::BAD_DESCRIPTOR;
+        case GRALLOC1_ERROR_BAD_HANDLE:
+            return Error::BAD_BUFFER;
+        case GRALLOC1_ERROR_BAD_VALUE:
+            return Error::BAD_VALUE;
+        case GRALLOC1_ERROR_NOT_SHARED:
+            return Error::NONE;  // this is fine
+        case GRALLOC1_ERROR_NO_RESOURCES:
+            return Error::NO_RESOURCES;
+        case GRALLOC1_ERROR_UNDEFINED:
+        case GRALLOC1_ERROR_UNSUPPORTED:
+        default:
+            return Error::UNSUPPORTED;
+    }
+}
+
+uint64_t Gralloc1Allocator::toProducerUsage(uint64_t usage) {
+    // this is potentially broken as we have no idea which private flags
+    // should be filtered out
+    uint64_t producerUsage =
+        usage &
+        ~static_cast<uint64_t>(BufferUsage::CPU_READ_MASK |
+                               BufferUsage::CPU_WRITE_MASK);
+
+    switch (usage & BufferUsage::CPU_WRITE_MASK) {
+        case static_cast<uint64_t>(BufferUsage::CPU_WRITE_RARELY):
+            producerUsage |= GRALLOC1_PRODUCER_USAGE_CPU_WRITE;
+            break;
+        case static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN):
+            producerUsage |= GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN;
+            break;
+        default:
+            break;
+    }
+
+    switch (usage & BufferUsage::CPU_READ_MASK) {
+        case static_cast<uint64_t>(BufferUsage::CPU_READ_RARELY):
+            producerUsage |= GRALLOC1_PRODUCER_USAGE_CPU_READ;
+            break;
+        case static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN):
+            producerUsage |= GRALLOC1_PRODUCER_USAGE_CPU_READ_OFTEN;
+            break;
+        default:
+            break;
+    }
+
+    return producerUsage;
+}
+
+uint64_t Gralloc1Allocator::toConsumerUsage(uint64_t usage) {
+    // this is potentially broken as we have no idea which private flags
+    // should be filtered out
+    uint64_t consumerUsage =
+        usage &
+        ~static_cast<uint64_t>(BufferUsage::CPU_READ_MASK |
+                               BufferUsage::CPU_WRITE_MASK);
+
+    switch (usage & BufferUsage::CPU_READ_MASK) {
+        case static_cast<uint64_t>(BufferUsage::CPU_READ_RARELY):
+            consumerUsage |= GRALLOC1_CONSUMER_USAGE_CPU_READ;
+            break;
+        case static_cast<uint64_t>(BufferUsage::CPU_READ_OFTEN):
+            consumerUsage |= GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN;
+            break;
+        default:
+            break;
+    }
+
+    return consumerUsage;
+}
+
+Error Gralloc1Allocator::createDescriptor(
+    const IMapper::BufferDescriptorInfo& info,
+    gralloc1_buffer_descriptor_t* outDescriptor) {
+    gralloc1_buffer_descriptor_t descriptor;
+
+    int32_t error = mDispatch.createDescriptor(mDevice, &descriptor);
+
+    if (error == GRALLOC1_ERROR_NONE) {
+        error = mDispatch.setDimensions(mDevice, descriptor, info.width,
+                                        info.height);
+    }
+    if (error == GRALLOC1_ERROR_NONE) {
+        error = mDispatch.setFormat(mDevice, descriptor,
+                                    static_cast<int32_t>(info.format));
+    }
+    if (error == GRALLOC1_ERROR_NONE) {
+        if (mCapabilities.layeredBuffers) {
+            error =
+                mDispatch.setLayerCount(mDevice, descriptor, info.layerCount);
+        } else if (info.layerCount > 1) {
+            error = GRALLOC1_ERROR_UNSUPPORTED;
+        }
+    }
+    if (error == GRALLOC1_ERROR_NONE) {
+        error = mDispatch.setProducerUsage(mDevice, descriptor,
+                                           toProducerUsage(info.usage));
+    }
+    if (error == GRALLOC1_ERROR_NONE) {
+        error = mDispatch.setConsumerUsage(mDevice, descriptor,
+                                           toConsumerUsage(info.usage));
+    }
+
+    if (error == GRALLOC1_ERROR_NONE) {
+        *outDescriptor = descriptor;
+    } else {
+        mDispatch.destroyDescriptor(mDevice, descriptor);
+    }
+
+    return toError(error);
+}
+
+Error Gralloc1Allocator::allocateOne(gralloc1_buffer_descriptor_t descriptor,
+                                     buffer_handle_t* outBuffer,
+                                     uint32_t* outStride) {
+    buffer_handle_t buffer = nullptr;
+    int32_t error = mDispatch.allocate(mDevice, 1, &descriptor, &buffer);
+    if (error != GRALLOC1_ERROR_NONE && error != GRALLOC1_ERROR_NOT_SHARED) {
+        return toError(error);
+    }
+
+    uint32_t stride = 0;
+    error = mDispatch.getStride(mDevice, buffer, &stride);
+    if (error != GRALLOC1_ERROR_NONE && error != GRALLOC1_ERROR_UNDEFINED) {
+        mDispatch.release(mDevice, buffer);
+        return toError(error);
+    }
+
+    *outBuffer = buffer;
+    *outStride = stride;
+
+    return Error::NONE;
+}
+
+}  // namespace implementation
+}  // namespace V2_0
+}  // namespace allocator
+}  // namespace graphics
+}  // namespace hardware
+}  // namespace android
diff --git a/graphics/allocator/2.0/default/Gralloc1Allocator.h b/graphics/allocator/2.0/default/Gralloc1Allocator.h
new file mode 100644
index 0000000..7b5a966
--- /dev/null
+++ b/graphics/allocator/2.0/default/Gralloc1Allocator.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_HARDWARE_GRAPHICS_ALLOCATOR_V2_0_GRALLOC1ALLOCATOR_H
+#define ANDROID_HARDWARE_GRAPHICS_ALLOCATOR_V2_0_GRALLOC1ALLOCATOR_H
+
+#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
+#include <android/hardware/graphics/mapper/2.0/IMapper.h>
+#include <hardware/gralloc1.h>
+
+namespace android {
+namespace hardware {
+namespace graphics {
+namespace allocator {
+namespace V2_0 {
+namespace implementation {
+
+using android::hardware::graphics::mapper::V2_0::IMapper;
+using android::hardware::graphics::mapper::V2_0::BufferDescriptor;
+using android::hardware::graphics::mapper::V2_0::Error;
+
+class Gralloc1Allocator : public IAllocator {
+   public:
+    Gralloc1Allocator(const hw_module_t* module);
+    virtual ~Gralloc1Allocator();
+
+    // IAllocator interface
+    Return<void> dumpDebugInfo(dumpDebugInfo_cb hidl_cb) override;
+    Return<void> allocate(const BufferDescriptor& descriptor, uint32_t count,
+                          allocate_cb hidl_cb) override;
+
+   private:
+    void initCapabilities();
+
+    template <typename T>
+    void initDispatch(gralloc1_function_descriptor_t desc, T* outPfn);
+    void initDispatch();
+
+    static Error toError(int32_t error);
+    static uint64_t toProducerUsage(uint64_t usage);
+    static uint64_t toConsumerUsage(uint64_t usage);
+
+    Error createDescriptor(const IMapper::BufferDescriptorInfo& info,
+                           gralloc1_buffer_descriptor_t* outDescriptor);
+    Error allocateOne(gralloc1_buffer_descriptor_t descriptor,
+                      buffer_handle_t* outBuffer, uint32_t* outStride);
+
+    gralloc1_device_t* mDevice;
+
+    struct {
+        bool layeredBuffers;
+    } mCapabilities;
+
+    struct {
+        GRALLOC1_PFN_DUMP dump;
+        GRALLOC1_PFN_CREATE_DESCRIPTOR createDescriptor;
+        GRALLOC1_PFN_DESTROY_DESCRIPTOR destroyDescriptor;
+        GRALLOC1_PFN_SET_DIMENSIONS setDimensions;
+        GRALLOC1_PFN_SET_FORMAT setFormat;
+        GRALLOC1_PFN_SET_LAYER_COUNT setLayerCount;
+        GRALLOC1_PFN_SET_CONSUMER_USAGE setConsumerUsage;
+        GRALLOC1_PFN_SET_PRODUCER_USAGE setProducerUsage;
+        GRALLOC1_PFN_GET_STRIDE getStride;
+        GRALLOC1_PFN_ALLOCATE allocate;
+        GRALLOC1_PFN_RELEASE release;
+    } mDispatch;
+};
+
+}  // namespace implementation
+}  // namespace V2_0
+}  // namespace allocator
+}  // namespace graphics
+}  // namespace hardware
+}  // namespace android
+
+#endif  // ANDROID_HARDWARE_GRAPHICS_ALLOCATOR_V2_0_GRALLOC1ALLOCATOR_H
diff --git a/graphics/allocator/2.0/types.hal b/graphics/allocator/2.0/types.hal
deleted file mode 100644
index d9b184b..0000000
--- a/graphics/allocator/2.0/types.hal
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.hardware.graphics.allocator@2.0;
-
-enum Error : int32_t {
-    NONE            = 0, /** no error */
-    BAD_DESCRIPTOR  = 1, /** invalid BufferDescriptor */
-    BAD_BUFFER      = 2, /** invalid Buffer */
-    BAD_VALUE       = 3, /** invalid width, height, etc. */
-    NOT_SHARED      = 4, /** buffers not sharing backing store */
-    NO_RESOURCES    = 5, /** temporary failure due to resource contention */
-    UNDEFINED       = 6, /** an operation has no defined meaning */
-    UNSUPPORTED     = 7, /** permanent failure */
-};
-
-enum ProducerUsage : uint64_t {
-    /** bit 0 is reserved */
-
-    /** buffer is read by CPU occasionally */
-    CPU_READ        = 1ULL << 1,
-    /** buffer is read by CPU frequently */
-    CPU_READ_OFTEN  = 1ULL << 2,
-
-    /** bit 3 is reserved */
-    /** bit 4 is reserved */
-
-    /** buffer is written by CPU occasionally */
-    CPU_WRITE       = 1ULL << 5,
-    /** buffer is written by CPU frequently */
-    CPU_WRITE_OFTEN = 1ULL << 6,
-
-    /** bit 7 is reserved */
-    /** bit 8 is reserved */
-
-    /** buffer is used as a GPU render target */
-    GPU_RENDER_TARGET = 1ULL << 9,
-
-    /** bit 10 is reserved */
-    /** bit 11 is reserved */
-    /** bit 12 is reserved */
-    /** bit 13 is reserved */
-
-    /**
-     * Buffer is allocated with hardware-level protection against copying the
-     * contents (or information derived from the contents) into unprotected
-     * memory.
-     */
-    PROTECTED         = 1ULL << 14,
-
-    /** bit 15 is reserved */
-    /** bit 16 is reserved */
-
-    /** buffer is used as a camera HAL output */
-    CAMERA            = 1ULL << 17,
-
-    /** bit 18 is reserved */
-    /** bit 19 is reserved */
-    /** bit 20 is reserved */
-    /** bit 21 is reserved */
-
-    /** buffer is used as a video decoder output */
-    VIDEO_DECODER     = 1ULL << 22,
-
-    /** buffer is used as a sensor direct report output */
-    SENSOR_DIRECT_DATA = 1ULL << 23,
-
-    /** bits 24-27 are reserved for future versions */
-    /** bits 28-31 are reserved for vendor extensions */
-
-    /** bits 32-47 are reserved for future versions */
-    /** bits 48-63 are reserved for vendor extensions */
-};
-
-enum ConsumerUsage : uint64_t {
-    /** bit 0 is reserved */
-
-    /** buffer is read by CPU occasionally */
-    CPU_READ          = 1ULL << 1,
-    /** buffer is read by CPU frequently */
-    CPU_READ_OFTEN    = 1ULL << 2,
-
-    /** bit 3 is reserved */
-    /** bit 4 is reserved */
-    /** bit 5 is reserved */
-    /** bit 6 is reserved */
-    /** bit 7 is reserved */
-
-    /** buffer is used as a GPU texture */
-    GPU_TEXTURE       = 1ULL << 8,
-
-    /** bit 9 is reserved */
-    /** bit 10 is reserved */
-
-    /** buffer is used by hwcomposer HAL */
-    HWCOMPOSER        = 1ULL << 11,
-    /** buffer is a hwcomposer HAL client target */
-    CLIENT_TARGET     = 1ULL << 12,
-
-    /** bit 13 is reserved */
-    /** bit 14 is reserved */
-
-    /** buffer is used as a hwcomposer HAL cursor */
-    CURSOR            = 1ULL << 15,
-
-    /** buffer is used as a video encoder input */
-    VIDEO_ENCODER     = 1ULL << 16,
-
-    /** bit 17 is reserved */
-
-    /** buffer is used as a camera HAL input */
-    CAMERA            = 1ULL << 18,
-
-    /** bit 19 is reserved */
-
-    /** buffer is used as a renderscript allocation */
-    RENDERSCRIPT      = 1ULL << 20,
-
-    /** bit 21 is reserved */
-    /** bit 22 is reserved */
-
-    /**
-     * buffer is used as as an OpenGL shader storage or uniform
-       buffer object */
-    GPU_DATA_BUFFER    = 1ULL << 23,
-
-    /** bits 24-27 are reserved for future versions */
-    /** bits 28-31 are reserved for vendor extensions */
-
-    /** bits 32-47 are reserved for future versions */
-    /** bits 48-63 are reserved for vendor extensions */
-};
-
-typedef uint64_t BufferDescriptor;
-typedef uint64_t Buffer;
diff --git a/graphics/allocator/2.0/vts/functional/Android.bp b/graphics/allocator/2.0/vts/functional/Android.bp
deleted file mode 100644
index fb77ab3..0000000
--- a/graphics/allocator/2.0/vts/functional/Android.bp
+++ /dev/null
@@ -1,62 +0,0 @@
-//
-// Copyright (C) 2016 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-cc_library_static {
-    name: "libVtsHalGraphicsAllocatorTestUtils",
-    defaults: ["hidl_defaults"],
-    srcs: ["VtsHalGraphicsAllocatorTestUtils.cpp"],
-    shared_libs: [
-        "android.hardware.graphics.allocator@2.0",
-    ],
-    static_libs: [
-        "VtsHalHidlTargetTestBase",
-    ],
-    cflags: [
-        "-Wall",
-        "-Wextra",
-        "-Werror",
-        "-O0",
-        "-g",
-    ],
-    export_include_dirs: ["."],
-}
-
-cc_test {
-    name: "VtsHalGraphicsAllocatorV2_0TargetTest",
-    defaults: ["hidl_defaults"],
-    srcs: ["VtsHalGraphicsAllocatorV2_0TargetTest.cpp"],
-    shared_libs: [
-        "libbase",
-        "liblog",
-        "libcutils",
-        "libhidlbase",
-        "libhidltransport",
-        "libnativehelper",
-        "libutils",
-        "android.hardware.graphics.allocator@2.0",
-    ],
-    static_libs: [
-        "libVtsHalGraphicsAllocatorTestUtils",
-        "VtsHalHidlTargetTestBase",
-    ],
-    cflags: [
-        "-Wall",
-        "-Wextra",
-        "-Werror",
-        "-O0",
-        "-g",
-    ]
-}
diff --git a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.cpp b/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.cpp
deleted file mode 100644
index 0dc43be..0000000
--- a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <VtsHalHidlTargetTestBase.h>
-
-#include "VtsHalGraphicsAllocatorTestUtils.h"
-
-namespace android {
-namespace hardware {
-namespace graphics {
-namespace allocator {
-namespace V2_0 {
-namespace tests {
-
-Allocator::Allocator() { init(); }
-
-void Allocator::init() {
-  mAllocator = ::testing::VtsHalHidlTargetTestBase::getService<IAllocator>();
-  ASSERT_NE(nullptr, mAllocator.get()) << "failed to get allocator service";
-
-  std::vector<IAllocator::Capability> capabilities = getCapabilities();
-  mCapabilities.insert(capabilities.begin(), capabilities.end());
-}
-
-sp<IAllocator> Allocator::getRaw() const { return mAllocator; }
-
-bool Allocator::hasCapability(IAllocator::Capability capability) const {
-  return mCapabilities.count(capability) > 0;
-}
-
-std::vector<IAllocator::Capability> Allocator::getCapabilities() {
-  std::vector<IAllocator::Capability> capabilities;
-  mAllocator->getCapabilities(
-      [&](const auto& tmpCapabilities) { capabilities = tmpCapabilities; });
-
-  return capabilities;
-}
-
-std::string Allocator::dumpDebugInfo() {
-  std::string debugInfo;
-  mAllocator->dumpDebugInfo(
-      [&](const auto& tmpDebugInfo) { debugInfo = tmpDebugInfo.c_str(); });
-
-  return debugInfo;
-}
-
-std::unique_ptr<AllocatorClient> Allocator::createClient() {
-  std::unique_ptr<AllocatorClient> client;
-  mAllocator->createClient([&](const auto& tmpError, const auto& tmpClient) {
-    ASSERT_EQ(Error::NONE, tmpError) << "failed to create client";
-    client = std::make_unique<AllocatorClient>(tmpClient);
-  });
-
-  return client;
-}
-
-AllocatorClient::AllocatorClient(const sp<IAllocatorClient>& client)
-    : mClient(client) {}
-
-AllocatorClient::~AllocatorClient() {
-  for (auto buffer : mBuffers) {
-    EXPECT_EQ(Error::NONE, mClient->free(buffer))
-        << "failed to free buffer " << buffer;
-  }
-  mBuffers.clear();
-
-  for (auto descriptor : mDescriptors) {
-    EXPECT_EQ(Error::NONE, mClient->destroyDescriptor(descriptor))
-        << "failed to destroy descriptor " << descriptor;
-  }
-  mDescriptors.clear();
-}
-
-sp<IAllocatorClient> AllocatorClient::getRaw() const { return mClient; }
-
-BufferDescriptor AllocatorClient::createDescriptor(
-    const IAllocatorClient::BufferDescriptorInfo& info) {
-  BufferDescriptor descriptor = 0;
-  mClient->createDescriptor(
-      info, [&](const auto& tmpError, const auto& tmpDescriptor) {
-        ASSERT_EQ(Error::NONE, tmpError) << "failed to create descriptor";
-        descriptor = tmpDescriptor;
-
-        EXPECT_TRUE(mDescriptors.insert(descriptor).second)
-            << "duplicated descriptor id " << descriptor;
-      });
-
-  return descriptor;
-}
-
-void AllocatorClient::destroyDescriptor(BufferDescriptor descriptor) {
-  ASSERT_EQ(Error::NONE, mClient->destroyDescriptor(descriptor))
-      << "failed to destroy descriptor " << descriptor;
-
-  mDescriptors.erase(descriptor);
-}
-
-Error AllocatorClient::testAllocate(
-    const std::vector<BufferDescriptor>& descriptors) {
-  return mClient->testAllocate(descriptors);
-}
-
-bool AllocatorClient::testAllocate(BufferDescriptor descriptor) {
-  std::vector<BufferDescriptor> descriptors(1, descriptor);
-  Error error = testAllocate(descriptors);
-  return (error == Error::NONE || error == Error::NOT_SHARED);
-}
-
-Error AllocatorClient::allocate(
-    const std::vector<BufferDescriptor>& descriptors,
-    std::vector<Buffer>& buffers) {
-  Error error = Error::NO_RESOURCES;
-  mClient->allocate(descriptors, [&](const auto& tmpError,
-                                     const auto& tmpBuffers) {
-    ASSERT_TRUE(tmpError == Error::NONE || tmpError == Error::NOT_SHARED)
-        << "failed to allocate buffer";
-    ASSERT_EQ(descriptors.size(), tmpBuffers.size()) << "invalid buffer count";
-
-    error = tmpError;
-    buffers = tmpBuffers;
-
-    for (auto buffer : buffers) {
-      EXPECT_TRUE(mBuffers.insert(buffer).second)
-          << "duplicated buffer id " << buffer;
-    }
-  });
-
-  return error;
-}
-
-Buffer AllocatorClient::allocate(BufferDescriptor descriptor) {
-  std::vector<BufferDescriptor> descriptors(1, descriptor);
-  std::vector<Buffer> buffers;
-  allocate(descriptors, buffers);
-  if (::testing::Test::HasFatalFailure()) {
-    return 0;
-  }
-
-  return buffers[0];
-}
-
-void AllocatorClient::free(Buffer buffer) {
-  ASSERT_EQ(Error::NONE, mClient->free(buffer))
-      << "failed to free buffer " << buffer;
-
-  mBuffers.erase(buffer);
-}
-
-native_handle_t* AllocatorClient::exportHandle(BufferDescriptor descriptor,
-                                               Buffer buffer) {
-  native_handle_t* handle;
-  mClient->exportHandle(
-      descriptor, buffer, [&](const auto& tmpError, const auto& tmpHandle) {
-        ASSERT_EQ(Error::NONE, tmpError) << "failed to export buffer handle";
-        ASSERT_NE(nullptr, tmpHandle.getNativeHandle())
-            << "invalid buffer handle";
-
-        handle = native_handle_clone(tmpHandle.getNativeHandle());
-        ASSERT_NE(nullptr, handle) << "failed to clone handle";
-      });
-
-  return handle;
-}
-
-}  // namespace tests
-}  // namespace V2_0
-}  // namespace allocator
-}  // namespace graphics
-}  // namespace hardware
-}  // namespace android
diff --git a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.h b/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.h
deleted file mode 100644
index c9bfe8f..0000000
--- a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorTestUtils.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef VTS_HAL_GRAPHICS_ALLOCATOR_UTILS
-#define VTS_HAL_GRAPHICS_ALLOCATOR_UTILS
-
-#include <memory>
-#include <string>
-#include <unordered_set>
-#include <vector>
-
-#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
-#include <utils/StrongPointer.h>
-
-namespace android {
-namespace hardware {
-namespace graphics {
-namespace allocator {
-namespace V2_0 {
-namespace tests {
-
-class AllocatorClient;
-
-// A wrapper to IAllocator.
-class Allocator {
- public:
-  Allocator();
-
-  sp<IAllocator> getRaw() const;
-
-  // Returns true when the allocator supports the specified capability.
-  bool hasCapability(IAllocator::Capability capability) const;
-
-  std::vector<IAllocator::Capability> getCapabilities();
-  std::string dumpDebugInfo();
-  std::unique_ptr<AllocatorClient> createClient();
-
- private:
-  void init();
-
-  sp<IAllocator> mAllocator;
-  std::unordered_set<IAllocator::Capability> mCapabilities;
-};
-
-// A wrapper to IAllocatorClient.
-class AllocatorClient {
- public:
-  AllocatorClient(const sp<IAllocatorClient>& client);
-  ~AllocatorClient();
-
-  sp<IAllocatorClient> getRaw() const;
-
-  BufferDescriptor createDescriptor(
-      const IAllocatorClient::BufferDescriptorInfo& info);
-  void destroyDescriptor(BufferDescriptor descriptor);
-
-  Error testAllocate(const std::vector<BufferDescriptor>& descriptors);
-  bool testAllocate(BufferDescriptor descriptor);
-
-  Error allocate(const std::vector<BufferDescriptor>& descriptors,
-                 std::vector<Buffer>& buffers);
-  Buffer allocate(BufferDescriptor descriptor);
-  void free(Buffer buffer);
-
-  // Returns a handle to the buffer.  The ownership of the handle is
-  // transferred to the caller.
-  native_handle_t* exportHandle(BufferDescriptor descriptor, Buffer buffer);
-
- private:
-  sp<IAllocatorClient> mClient;
-
-  // Keep track of all descriptors and buffers.  When a test fails with
-  // ASSERT_*, the destructor will clean up the resources for the test.
-  std::unordered_set<BufferDescriptor> mDescriptors;
-  std::unordered_set<Buffer> mBuffers;
-};
-
-}  // namespace tests
-}  // namespace V2_0
-}  // namespace allocator
-}  // namespace graphics
-}  // namespace hardware
-}  // namespace android
-
-#endif  // VTS_HAL_GRAPHICS_ALLOCATOR_UTILS
diff --git a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorV2_0TargetTest.cpp b/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorV2_0TargetTest.cpp
deleted file mode 100644
index b1c764f..0000000
--- a/graphics/allocator/2.0/vts/functional/VtsHalGraphicsAllocatorV2_0TargetTest.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "graphics_allocator_hidl_hal_test"
-
-#include <android-base/logging.h>
-#include <VtsHalHidlTargetTestBase.h>
-
-#include "VtsHalGraphicsAllocatorTestUtils.h"
-
-namespace android {
-namespace hardware {
-namespace graphics {
-namespace allocator {
-namespace V2_0 {
-namespace tests {
-namespace {
-
-using android::hardware::graphics::common::V1_0::PixelFormat;
-
-#define CHECK_FEATURE_OR_SKIP(FEATURE_NAME)                 \
-  do {                                                      \
-    if (!mAllocator->hasCapability(FEATURE_NAME)) {         \
-      std::cout << "[  SKIPPED ] Feature " << #FEATURE_NAME \
-                << " not supported" << std::endl;           \
-      return;                                               \
-    }                                                       \
-  } while (0)
-
-class GraphicsAllocatorHidlTest : public ::testing::VtsHalHidlTargetTestBase {
- protected:
-  void SetUp() override {
-    ASSERT_NO_FATAL_FAILURE(mAllocator = std::make_unique<Allocator>());
-    ASSERT_NO_FATAL_FAILURE(mClient = mAllocator->createClient());
-
-    mDummyDescriptorInfo.width = 64;
-    mDummyDescriptorInfo.height = 64;
-    mDummyDescriptorInfo.layerCount = 1;
-    mDummyDescriptorInfo.format = PixelFormat::RGBA_8888;
-    mDummyDescriptorInfo.producerUsageMask =
-        static_cast<uint64_t>(ProducerUsage::CPU_WRITE);
-    mDummyDescriptorInfo.consumerUsageMask =
-        static_cast<uint64_t>(ConsumerUsage::CPU_READ);
-  }
-
-  void TearDown() override {}
-
-  std::unique_ptr<Allocator> mAllocator;
-  std::unique_ptr<AllocatorClient> mClient;
-  IAllocatorClient::BufferDescriptorInfo mDummyDescriptorInfo{};
-};
-
-TEST_F(GraphicsAllocatorHidlTest, GetCapabilities) {
-  auto capabilities = mAllocator->getCapabilities();
-  for (auto cap : capabilities) {
-    EXPECT_NE(IAllocator::Capability::INVALID, cap);
-  }
-}
-
-TEST_F(GraphicsAllocatorHidlTest, DumpDebugInfo) {
-  mAllocator->dumpDebugInfo();
-}
-
-TEST_F(GraphicsAllocatorHidlTest, CreateDestroyDescriptor) {
-  BufferDescriptor descriptor;
-  ASSERT_NO_FATAL_FAILURE(descriptor =
-                              mClient->createDescriptor(mDummyDescriptorInfo));
-  mClient->destroyDescriptor(descriptor);
-}
-
-/**
- * Test testAllocate with a single buffer descriptor.
- */
-TEST_F(GraphicsAllocatorHidlTest, TestAllocateBasic) {
-  CHECK_FEATURE_OR_SKIP(IAllocator::Capability::TEST_ALLOCATE);
-
-  BufferDescriptor descriptor;
-  ASSERT_NO_FATAL_FAILURE(descriptor =
-                              mClient->createDescriptor(mDummyDescriptorInfo));
-
-  ASSERT_TRUE(mClient->testAllocate(descriptor));
-}
-
-/**
- * Test testAllocate with two buffer descriptors.
- */
-TEST_F(GraphicsAllocatorHidlTest, TestAllocateArray) {
-  CHECK_FEATURE_OR_SKIP(IAllocator::Capability::TEST_ALLOCATE);
-
-  BufferDescriptor descriptor;
-  ASSERT_NO_FATAL_FAILURE(descriptor =
-                              mClient->createDescriptor(mDummyDescriptorInfo));
-
-  hidl_vec<BufferDescriptor> descriptors;
-  descriptors.resize(2);
-  descriptors[0] = descriptor;
-  descriptors[1] = descriptor;
-
-  auto error = mClient->testAllocate(descriptors);
-  ASSERT_TRUE(error == Error::NONE || error == Error::NOT_SHARED);
-}
-
-/**
- * Test allocate/free with a single buffer descriptor.
- */
-TEST_F(GraphicsAllocatorHidlTest, AllocateFreeBasic) {
-  BufferDescriptor descriptor;
-  ASSERT_NO_FATAL_FAILURE(descriptor =
-                              mClient->createDescriptor(mDummyDescriptorInfo));
-
-  Buffer buffer;
-  ASSERT_NO_FATAL_FAILURE(buffer = mClient->allocate(descriptor));
-
-  mClient->free(buffer);
-}
-
-/**
- * Test allocate/free with an array of buffer descriptors.
- */
-TEST_F(GraphicsAllocatorHidlTest, AllocateFreeArray) {
-  BufferDescriptor descriptor1;
-  ASSERT_NO_FATAL_FAILURE(descriptor1 =
-                              mClient->createDescriptor(mDummyDescriptorInfo));
-
-  BufferDescriptor descriptor2;
-  ASSERT_NO_FATAL_FAILURE(descriptor2 =
-                              mClient->createDescriptor(mDummyDescriptorInfo));
-
-  hidl_vec<BufferDescriptor> descriptors;
-  descriptors.resize(3);
-  descriptors[0] = descriptor1;
-  descriptors[1] = descriptor1;
-  descriptors[2] = descriptor2;
-
-  std::vector<Buffer> buffers;
-  ASSERT_NO_FATAL_FAILURE(mClient->allocate(descriptors, buffers));
-
-  for (auto buf : buffers) {
-    mClient->free(buf);
-  }
-}
-
-TEST_F(GraphicsAllocatorHidlTest, ExportHandle) {
-  BufferDescriptor descriptor;
-  ASSERT_NO_FATAL_FAILURE(descriptor =
-                              mClient->createDescriptor(mDummyDescriptorInfo));
-
-  Buffer buffer;
-  ASSERT_NO_FATAL_FAILURE(buffer = mClient->allocate(descriptor));
-
-  native_handle_t* handle;
-  ASSERT_NO_FATAL_FAILURE(handle = mClient->exportHandle(descriptor, buffer));
-
-  native_handle_close(handle);
-  native_handle_delete(handle);
-}
-
-}  // namespace anonymous
-}  // namespace tests
-}  // namespace V2_0
-}  // namespace allocator
-}  // namespace graphics
-}  // namespace hardware
-}  // namespace android
-
-int main(int argc, char** argv) {
-  ::testing::InitGoogleTest(&argc, argv);
-
-  int status = RUN_ALL_TESTS();
-  LOG(INFO) << "Test result = " << status;
-
-  return status;
-}
