diff --git a/libhidlcache/Android.bp b/libhidlcache/Android.bp
deleted file mode 100644
index d28a4f1..0000000
--- a/libhidlcache/Android.bp
+++ /dev/null
@@ -1,71 +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 {
-    name: "libhidlcache",
-    vendor_available: true,
-    vndk: {
-        enabled: true,
-    },
-    defaults: ["libhidl-defaults"],
-    shared_libs: [
-        "libbase",
-        "liblog",
-        "libutils",
-        "libcutils",
-        "libhidlbase",
-        "libhidlmemory",
-        "libhwbinder",
-        "libhidltransport",
-        "android.hidl.memory@1.0",
-        "android.hidl.memory.block@1.0",
-        "android.hidl.memory.token@1.0",
-    ],
-    export_include_dirs: ["include"],
-
-    export_shared_lib_headers: [
-        "android.hidl.memory@1.0",
-        "android.hidl.memory.block@1.0",
-        "android.hidl.memory.token@1.0",
-        "libhidlbase",
-    ],
-    srcs: [
-        "HidlMemoryCache.cpp",
-        "MemoryDealer.cpp",
-        "mapping.cpp",
-    ],
-}
-
-cc_test {
-    name: "libhidlcache_test",
-    defaults: ["hidl-gen-defaults"],
-
-    shared_libs: [
-        "android.hidl.allocator@1.0",
-        "android.hidl.memory@1.0",
-        "android.hidl.memory.block@1.0",
-        "android.hidl.memory.token@1.0",
-        "libbase",
-        "libcutils",
-        "libhidlbase",
-        "libhidlmemory",
-        "libhidlcache",
-        "libhidltransport",
-        "libhwbinder",
-        "liblog",
-        "libutils",
-    ],
-
-    srcs: ["libhidlcache_test.cpp"],
-}
diff --git a/libhidlcache/HidlCache.h b/libhidlcache/HidlCache.h
deleted file mode 100644
index 39a7b3a..0000000
--- a/libhidlcache/HidlCache.h
+++ /dev/null
@@ -1,143 +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.
- */
-#ifndef ANDROID_HARDWARE_HIDL_CACHE_H
-#define ANDROID_HARDWARE_HIDL_CACHE_H
-
-#include <utils/Log.h>
-
-namespace android {
-namespace hardware {
-
-// A generic cache to map Key to sp<Value>. The cache records are kept with
-// wp<Value>, so that it does not block the Value to be garbage collected
-// when there's no other sp<> externally.
-template <class Key, class Value, class Compare = std::less<Key>>
-class HidlCache : public virtual RefBase {
-    using Mutex = std::mutex;
-    using Lock = std::lock_guard<Mutex>;
-
-   public:
-    //  A RAII class to manage lock/unlock HidlCache.
-    class HidlCacheLock : public virtual RefBase {
-       public:
-        HidlCacheLock(sp<HidlCache> cache, const Key& key) : mCache(cache), mKey(key) {
-            mCache->lock(mKey);
-        }
-        ~HidlCacheLock() { mCache->unlock(mKey); }
-
-       private:
-        sp<HidlCache> mCache;
-        const Key mKey;
-    };
-    // lock the IMemory refered by key and keep it alive even if there's no
-    // other memory block refers to.
-    virtual bool lock(const Key& key);
-    virtual sp<Value> unlock(const Key& key);
-    virtual bool flush(const Key& key);
-    // fetch the sp<Value> with key from cache,
-    // make a new instance with fill() if it does not present currently.
-    virtual sp<Value> fetch(const Key& key);
-    virtual sp<HidlCacheLock> lockGuard(const Key& key) { return new HidlCacheLock(this, key); }
-
-    virtual ~HidlCache() {}
-
-   protected:
-    friend void HidlCacheWhiteBoxTest();
-    // This method shall be called with a lock held
-    virtual sp<Value> fillLocked(const Key& key) = 0;
-
-    // @return nullptr if it does not present currently.
-    // @note This method shall be called with a lock held
-    virtual sp<Value> getCachedLocked(const Key& key);
-    bool cached(Key key) const { return mCached.count(key) > 0; }
-    bool locked(Key key) const { return mLocked.count(key) > 0; }
-    Mutex mMutex;
-
-    std::map<Key, wp<Value>, Compare> mCached;
-    std::map<Key, sp<Value>, Compare> mLocked;
-};
-
-template <class Key, class Value, class Compare>
-bool HidlCache<Key, Value, Compare>::lock(const Key& key) {
-    {
-        Lock lock(mMutex);
-        if (cached(key)) {
-            sp<Value> im = mCached[key].promote();
-            if (im != nullptr) {
-                mLocked[key] = im;
-                return true;
-            } else {
-                mCached.erase(key);
-            }
-        }
-    }
-    sp<Value> value = fetch(key);
-    if (value == nullptr) {
-        return false;
-    } else {
-        Lock lock(mMutex);
-        mLocked[key] = value;
-        return true;
-    }
-}
-
-template <class Key, class Value, class Compare>
-sp<Value> HidlCache<Key, Value, Compare>::unlock(const Key& key) {
-    Lock lock(mMutex);
-    if (locked(key)) {
-        sp<Value> v = mLocked[key];
-        mLocked.erase(key);
-        return v;
-    }
-    return nullptr;
-}
-
-template <class Key, class Value, class Compare>
-bool HidlCache<Key, Value, Compare>::flush(const Key& key) {
-    Lock lock(mMutex);
-    bool contain = cached(key);
-    mCached.erase(key);
-    return contain;
-}
-
-template <class Key, class Value, class Compare>
-sp<Value> HidlCache<Key, Value, Compare>::getCachedLocked(const Key& key) {
-    if (cached(key)) {
-        wp<Value> cache = mCached[key];
-        sp<Value> mem = cache.promote();
-        if (mem != nullptr) {
-            return mem;
-        } else {
-            mCached.erase(key);
-        }
-    }
-    return nullptr;
-}
-
-template <class Key, class Value, class Compare>
-sp<Value> HidlCache<Key, Value, Compare>::fetch(const Key& key) {
-    Lock lock(mMutex);
-    sp<Value> value = getCachedLocked(key);
-
-    if (value == nullptr) {
-        value = fillLocked(key);
-    }
-    return value;
-}
-
-}  // namespace hardware
-}  // namespace android
-#endif
diff --git a/libhidlcache/HidlMemoryCache.cpp b/libhidlcache/HidlMemoryCache.cpp
deleted file mode 100644
index a23c388..0000000
--- a/libhidlcache/HidlMemoryCache.cpp
+++ /dev/null
@@ -1,127 +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 "HidlMemoryCache"
-#include "HidlMemoryCache.h"
-#include <android/hidl/memory/1.0/IMemory.h>
-#include <android/hidl/memory/token/1.0/IMemoryToken.h>
-#include <hidlmemory/mapping.h>
-#include <sys/mman.h>
-#include <utils/Log.h>
-
-namespace android {
-namespace hardware {
-
-using IMemoryToken = ::android::hidl::memory::token::V1_0::IMemoryToken;
-using IMemory = ::android::hidl::memory::V1_0::IMemory;
-
-class MemoryDecorator : public virtual IMemory {
-   public:
-    MemoryDecorator(const sp<IMemory>& heap) : mHeap(heap) {}
-    virtual ~MemoryDecorator() {}
-    Return<void> update() override { return mHeap->update(); }
-    Return<void> read() override { return mHeap->read(); }
-    Return<void> updateRange(uint64_t start, uint64_t length) override {
-        return mHeap->updateRange(start, length);
-    }
-    Return<void> readRange(uint64_t start, uint64_t length) override {
-        return mHeap->readRange(start, length);
-    }
-    Return<void> commit() override { return mHeap->commit(); }
-
-    Return<void*> getPointer() override { return mHeap->getPointer(); }
-    Return<uint64_t> getSize() override { return mHeap->getSize(); }
-
-   protected:
-    sp<IMemory> mHeap;
-};
-
-class MemoryCacheable : public virtual MemoryDecorator {
-   public:
-    MemoryCacheable(const sp<IMemory>& heap, sp<IMemoryToken> key)
-        : MemoryDecorator(heap), mKey(key) {}
-    virtual ~MemoryCacheable() { HidlMemoryCache::getInstance()->flush(mKey); }
-
-   protected:
-    sp<IMemoryToken> mKey;
-};
-
-class MemoryBlockImpl : public virtual IMemory {
-   public:
-    MemoryBlockImpl(const sp<IMemory>& heap, uint64_t size, uint64_t offset)
-        : mHeap(heap), mSize(size), mOffset(offset), mHeapSize(heap->getSize()) {}
-    bool validRange(uint64_t start, uint64_t length) {
-        return (start + length <= mSize) && (start + length >= start) &&
-               (mOffset + mSize <= mHeapSize);
-    }
-    Return<void> readRange(uint64_t start, uint64_t length) override {
-        if (!validRange(start, length)) {
-            ALOGE("IMemoryBlock::readRange: out of range");
-            return Void();
-        }
-        return mHeap->readRange(mOffset + start, length);
-    }
-    Return<void> updateRange(uint64_t start, uint64_t length) override {
-        if (!validRange(start, length)) {
-            ALOGE("IMemoryBlock::updateRange: out of range");
-            return Void();
-        }
-        return mHeap->updateRange(mOffset + start, length);
-    }
-    Return<void> read() override { return this->readRange(0, mSize); }
-    Return<void> update() override { return this->updateRange(0, mSize); }
-    Return<void> commit() override { return mHeap->commit(); }
-    Return<uint64_t> getSize() override { return mSize; }
-    Return<void*> getPointer() override {
-        void* p = mHeap->getPointer();
-        return (static_cast<char*>(p) + mOffset);
-    }
-
-   protected:
-    sp<IMemory> mHeap;
-    uint64_t mSize;
-    uint64_t mOffset;
-    uint64_t mHeapSize;
-};
-
-sp<HidlMemoryCache> HidlMemoryCache::getInstance() {
-    static sp<HidlMemoryCache> instance = new HidlMemoryCache();
-    return instance;
-}
-
-sp<IMemory> HidlMemoryCache::fillLocked(const sp<IMemoryToken>& key) {
-    sp<IMemory> memory = nullptr;
-    Return<void> ret = key->get(
-        [&](const hidl_memory& mem) { memory = new MemoryCacheable(mapMemory(mem), key); });
-    if (!ret.isOk()) {
-        ALOGE("HidlMemoryCache::fill: cannot IMemoryToken::get.");
-        return nullptr;
-    }
-    mCached[key] = memory;
-    return memory;
-}
-
-sp<IMemory> HidlMemoryCache::map(const MemoryBlock& memblk) {
-    sp<IMemoryToken> token = memblk.token;
-    sp<IMemory> heap = fetch(token);
-    if (heap == nullptr) {
-        return nullptr;
-    }
-    return new MemoryBlockImpl(heap, memblk.size, memblk.offset);
-}
-
-}  // namespace hardware
-}  // namespace android
diff --git a/libhidlcache/HidlMemoryCache.h b/libhidlcache/HidlMemoryCache.h
deleted file mode 100644
index c9a533b..0000000
--- a/libhidlcache/HidlMemoryCache.h
+++ /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.
- */
-#ifndef ANDROID_HARDWARD_HIDLMEMORY_CACHE_H
-#define ANDROID_HARDWARD_HIDLMEMORY_CACHE_H
-
-#include <android/hidl/memory/block/1.0/types.h>
-#include <android/hidl/memory/token/1.0/IMemoryToken.h>
-#include <hidl/HidlBinderSupport.h>
-#include <hwbinder/IBinder.h>
-#include <utils/RefBase.h>
-#include "HidlCache.h"
-
-namespace android {
-namespace hardware {
-
-struct IMemoryTokenCompare {
-    using IMemoryToken = ::android::hidl::memory::token::V1_0::IMemoryToken;
-    bool operator()(const sp<IMemoryToken>& lhs, const sp<IMemoryToken>& rhs) const {
-        sp<IBinder> lb = toBinder<IMemoryToken>(lhs);
-        sp<IBinder> rb = toBinder<IMemoryToken>(rhs);
-        return lb < rb;
-    }
-};
-
-// The HidlMemoryCache is a singleton class to provides cache for
-// IMemoryToken => ::android::hidl::memory::V1_0::IMemory
-// It's an abstraction layer on top of the IMapper and supports, but is
-// not limited to, the Ashmem type HidlMemory.
-class HidlMemoryCache
-    : public virtual HidlCache<sp<::android::hidl::memory::token::V1_0::IMemoryToken>,
-                               ::android::hidl::memory::V1_0::IMemory, IMemoryTokenCompare> {
-    using IMemoryToken = ::android::hidl::memory::token::V1_0::IMemoryToken;
-    using IMemory = ::android::hidl::memory::V1_0::IMemory;
-    using MemoryBlock = ::android::hidl::memory::block::V1_0::MemoryBlock;
-
-   public:
-    virtual sp<IMemory> map(const MemoryBlock& block);
-    // get the singleton
-    static sp<HidlMemoryCache> getInstance();
-
-   protected:
-    HidlMemoryCache() {}
-    virtual sp<IMemory> fillLocked(const sp<IMemoryToken>& key) override;
-};
-
-}  // namespace hardware
-}  // namespace android
-
-#endif
diff --git a/libhidlcache/MemoryDealer.cpp b/libhidlcache/MemoryDealer.cpp
deleted file mode 100644
index e5686a7..0000000
--- a/libhidlcache/MemoryDealer.cpp
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Copyright (C) 2007 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 "MemoryDealer"
-
-#include <hidlcache/MemoryDealer.h>
-#include <hidlmemory/HidlMemoryToken.h>
-#include <hidlmemory/mapping.h>
-
-#include <list>
-
-#include <log/log.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <sys/file.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-using std::string;
-
-namespace android {
-namespace hardware {
-
-class SimpleBestFitAllocator {
-    enum { PAGE_ALIGNED = 0x00000001 };
-
-   public:
-    explicit SimpleBestFitAllocator(size_t size);
-    ~SimpleBestFitAllocator();
-
-    size_t allocate(size_t size, uint32_t flags = 0);
-    status_t deallocate(size_t offset);
-    size_t size() const;
-    void dump(const char* tag) const;
-    void dump(string& res, const char* tag) const;
-
-    static size_t getAllocationAlignment() { return kMemoryAlign; }
-
-   private:
-    struct chunk_t {
-        chunk_t(size_t start, size_t size) : start(start), size(size), free(1) {}
-        size_t start;
-        size_t size : 28;
-        int free : 4;
-    };
-    using List = std::list<chunk_t*>;
-    using Iterator = std::list<chunk_t*>::iterator;
-    using IteratorConst = std::list<chunk_t*>::const_iterator;
-    using Mutex = std::mutex;
-    using Lock = std::lock_guard<Mutex>;
-
-    ssize_t alloc(size_t size, uint32_t flags);
-    chunk_t* dealloc(size_t start);
-    void dump_l(const char* tag) const;
-    void dump_l(string& res, const char* tag) const;
-
-    static const int kMemoryAlign;
-    mutable Mutex mLock;
-    List mList;
-    size_t mHeapSize;
-};
-
-MemoryDealer::MemoryDealer(size_t size) : mAllocator(new SimpleBestFitAllocator(size)) {}
-
-MemoryDealer::~MemoryDealer() {
-    delete mAllocator;
-}
-
-ssize_t MemoryDealer::allocateOffset(size_t size) {
-    return mAllocator->allocate(size);
-}
-
-void MemoryDealer::deallocate(size_t offset) {
-    mAllocator->deallocate(offset);
-}
-
-void MemoryDealer::dump(const char* tag) const {
-    mAllocator->dump(tag);
-}
-
-size_t MemoryDealer::getAllocationAlignment() {
-    return SimpleBestFitAllocator::getAllocationAlignment();
-}
-
-// align all the memory blocks on a cache-line boundary
-const int SimpleBestFitAllocator::kMemoryAlign = 32;
-
-SimpleBestFitAllocator::SimpleBestFitAllocator(size_t size) {
-    size_t pagesize = getpagesize();
-    mHeapSize = ((size + pagesize - 1) & ~(pagesize - 1));
-
-    chunk_t* node = new chunk_t(0, mHeapSize / kMemoryAlign);
-    mList.push_front(node);
-}
-
-SimpleBestFitAllocator::~SimpleBestFitAllocator() {
-    while (mList.size() != 0) {
-        chunk_t* removed = mList.front();
-        mList.pop_front();
-#ifdef __clang_analyzer__
-        // Clang static analyzer gets confused in this loop
-        // and generates a false positive warning about accessing
-        // memory that is already freed.
-        // Add an "assert" to avoid the confusion.
-        LOG_ALWAYS_FATAL_IF(mList.front() == removed);
-#endif
-        delete removed;
-    }
-}
-
-size_t SimpleBestFitAllocator::size() const {
-    return mHeapSize;
-}
-
-size_t SimpleBestFitAllocator::allocate(size_t size, uint32_t flags) {
-    Lock lock(mLock);
-    ssize_t offset = alloc(size, flags);
-    return offset;
-}
-
-status_t SimpleBestFitAllocator::deallocate(size_t offset) {
-    Lock lock(mLock);
-    chunk_t const* const freed = dealloc(offset);
-    if (freed) {
-        return NO_ERROR;
-    }
-    return NAME_NOT_FOUND;
-}
-
-ssize_t SimpleBestFitAllocator::alloc(size_t size, uint32_t flags) {
-    if (size == 0) {
-        return 0;
-    }
-    size = (size + kMemoryAlign - 1) / kMemoryAlign;
-    size_t pagesize = getpagesize();
-
-    Iterator free_chunk_p = mList.end();
-    for (Iterator p = mList.begin(); p != mList.end(); p++) {
-        chunk_t* cur = *p;
-        int extra = 0;
-        if (flags & PAGE_ALIGNED) extra = (-cur->start & ((pagesize / kMemoryAlign) - 1));
-
-        // best fit
-        if (cur->free && (cur->size >= (size + extra))) {
-            if ((free_chunk_p == mList.end()) || (cur->size < (*free_chunk_p)->size)) {
-                free_chunk_p = p;
-            }
-            if (cur->size == size) {
-                break;
-            }
-        }
-    }
-    if (free_chunk_p != mList.end()) {
-        chunk_t* free_chunk = *free_chunk_p;
-        const size_t free_size = free_chunk->size;
-        free_chunk->free = 0;
-        free_chunk->size = size;
-        if (free_size > size) {
-            int extra = 0;
-            if (flags & PAGE_ALIGNED)
-                extra = (-free_chunk->start & ((pagesize / kMemoryAlign) - 1));
-            if (extra) {
-                chunk_t* split = new chunk_t(free_chunk->start, extra);
-                free_chunk->start += extra;
-                mList.insert(free_chunk_p, split);
-            }
-
-            ALOGE_IF(
-                (flags & PAGE_ALIGNED) && ((free_chunk->start * kMemoryAlign) & (pagesize - 1)),
-                "PAGE_ALIGNED requested, but page is not aligned!!!");
-
-            const ssize_t tail_free = free_size - (size + extra);
-            if (tail_free > 0) {
-                chunk_t* split = new chunk_t(free_chunk->start + free_chunk->size, tail_free);
-                mList.insert(++free_chunk_p, split);
-            }
-        }
-        return (free_chunk->start) * kMemoryAlign;
-    }
-    return NO_MEMORY;
-}
-
-SimpleBestFitAllocator::chunk_t* SimpleBestFitAllocator::dealloc(size_t start) {
-    start = start / kMemoryAlign;
-
-    for (Iterator pos = mList.begin(); pos != mList.end(); pos++) {
-        chunk_t* cur = *pos;
-        if (cur->start == start) {
-            LOG_FATAL_IF(cur->free, "block at offset 0x%08lX of size 0x%08lX already freed",
-                         cur->start * kMemoryAlign, cur->size * kMemoryAlign);
-
-            // merge freed blocks together
-            chunk_t* freed = cur;
-            cur->free = 1;
-            do {
-                if (pos != mList.begin()) {
-                    pos--;
-                    chunk_t* const p = *pos;
-                    pos++;
-                    if (p->free || !cur->size) {
-                        freed = p;
-                        p->size += cur->size;
-                        pos = mList.erase(pos);
-                        delete cur;
-                        if (pos == mList.end()) break;
-                    }
-                }
-                if (++pos == mList.end()) break;
-                cur = *pos;
-            } while (cur && cur->free);
-
-#ifndef NDEBUG
-            if (!freed->free) {
-                dump_l("dealloc (!freed->free)");
-            }
-#endif
-            LOG_FATAL_IF(!freed->free, "freed block at offset 0x%08lX of size 0x%08lX is not free!",
-                         freed->start * kMemoryAlign, freed->size * kMemoryAlign);
-
-            return freed;
-        }
-    }
-    return nullptr;
-}
-
-void SimpleBestFitAllocator::dump(const char* tag) const {
-    Lock lock(mLock);
-    dump_l(tag);
-}
-
-void SimpleBestFitAllocator::dump_l(const char* tag) const {
-    string result;
-    dump_l(result, tag);
-    ALOGD("%s", result.c_str());
-}
-
-void SimpleBestFitAllocator::dump(string& result, const char* tag) const {
-    Lock lock(mLock);
-    dump_l(result, tag);
-}
-
-void SimpleBestFitAllocator::dump_l(string& result, const char* tag) const {
-    size_t size = 0;
-    int32_t i = 0;
-    const size_t SIZE = 256;
-    char buffer[SIZE];
-    snprintf(buffer, SIZE, "  %s (%p, size=%u)\n", tag, this, (unsigned int)mHeapSize);
-
-    result.append(buffer);
-
-    for (IteratorConst pos = mList.begin(); pos != mList.end(); pos++) {
-        chunk_t const* cur = *pos;
-
-        if (!cur->free) size += cur->size * kMemoryAlign;
-
-        i++;
-    }
-    snprintf(buffer, SIZE, "  size allocated: %u (%u KB)\n", int(size), int(size / 1024));
-    result.append(buffer);
-}
-
-bool HidlMemoryDealer::isOk(const MemoryBlock& memblk) {
-    return memblk.token != nullptr;
-}
-
-sp<::android::hidl::memory::V1_0::IMemory> HidlMemoryDealer::heap() {
-    return mHeap;
-}
-
-// The required heap size alignment is 4096 bytes
-static const uint64_t kHeapSizeAlignment = (0x1ULL << 12);
-
-sp<HidlMemoryDealer> HidlMemoryDealer::getInstance(const hidl_memory& mem) {
-    uint64_t msk = (kHeapSizeAlignment - 1);
-    if (mem.size() & msk || !(mem.size() & ~msk)) {
-        ALOGE("size is not aligned to %x", static_cast<uint32_t>(kHeapSizeAlignment));
-        return nullptr;
-    }
-    sp<IMemory> heap = mapMemory(mem);
-    if (heap == nullptr) {
-        ALOGE("fail to mapMemory");
-        return nullptr;
-    }
-    return new HidlMemoryDealer(heap, mem);
-}
-
-HidlMemoryDealer::HidlMemoryDealer(sp<IMemory> heap, const hidl_memory& mem)
-    : MemoryDealer(heap->getSize()),
-      mHeap(heap),
-      mToken(new HidlMemoryToken(HidlMemory::getInstance(mem))) {}
-
-::android::hidl::memory::block::V1_0::MemoryBlock HidlMemoryDealer::allocate(size_t size) {
-    MemoryBlock memblk = {nullptr, 0xFFFFFFFFULL, 0xFFFFFFFFULL};
-    ssize_t offset = allocateOffset(size);
-    if (offset >= 0) {
-        memblk.token = mToken;
-        memblk.size = size;
-        memblk.offset = offset;
-    }
-    return memblk;
-}
-
-};  // namespace hardware
-};  // namespace android
diff --git a/libhidlcache/include/hidlcache/MemoryDealer.h b/libhidlcache/include/hidlcache/MemoryDealer.h
deleted file mode 100644
index fceed83..0000000
--- a/libhidlcache/include/hidlcache/MemoryDealer.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2007 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_HIDL_MEMORY_DEALER_H
-#define ANDROID_HIDL_MEMORY_DEALER_H
-
-#include <android/hidl/memory/1.0/IMemory.h>
-#include <android/hidl/memory/block/1.0/types.h>
-#include <stdint.h>
-#include <sys/types.h>
-namespace android {
-namespace hardware {
-
-class SimpleBestFitAllocator;
-
-// MemoryDealer allocates/deallocates blocks from a continuous memory region.
-// It operates on size and offset and does not depend on any specific data types.
-class MemoryDealer : public RefBase {
-   public:
-    /// Allocate a block with size. The allocated block is identified with an
-    /// offset. For example:
-    /// ssize_t K = dealer->allocateOffset(size);
-    /// On success, K is positive and points to a subregion K ~ (K+size-1) in the heap.
-    /// It's negative if the allocation fails.
-    virtual ssize_t allocateOffset(size_t size);
-    /// @param offset It points to the block that allocated with allocateOffset previously.
-    virtual void deallocate(size_t offset);
-    /// @param tag a string tag used to mark the dump message
-    virtual void dump(const char* tag) const;
-
-    // allocations are aligned to some value. return that value so clients can account for it.
-    static size_t getAllocationAlignment();
-
-    MemoryDealer(size_t size);
-    virtual ~MemoryDealer();
-
-   protected:
-    SimpleBestFitAllocator* mAllocator;
-};
-
-// It extends the generic MemoryDealer and uses
-//  - sp<IMemory> to represent the main memory region.
-//  - MemoryBlock to represent the the block to allocate/deallocate
-class HidlMemoryDealer : public MemoryDealer {
-    using IMemory = ::android::hidl::memory::V1_0::IMemory;
-    using IMemoryToken = ::android::hidl::memory::token::V1_0::IMemoryToken;
-    using MemoryBlock = ::android::hidl::memory::block::V1_0::MemoryBlock;
-
-   public:
-    static bool isOk(const MemoryBlock& memblk);
-    /// @param memory The memory size must align to 4096 bytes
-    static sp<HidlMemoryDealer> getInstance(const hidl_memory& memory);
-    virtual MemoryBlock allocate(size_t size);
-    virtual sp<IMemory> heap();
-
-   protected:
-    /// @param heap It must be acquired with mapMemory(memory) with its
-    /// argument corresponds to the 2nd argument passed to HidlMemoryDealer.
-    HidlMemoryDealer(sp<IMemory> heap, const hidl_memory& memory);
-    sp<IMemory> mHeap;
-    sp<IMemoryToken> mToken;
-};
-
-};  // namespace hardware
-};  // namespace android
-
-#endif  // ANDROID_HIDL_MEMORY_DEALER_H
diff --git a/libhidlcache/include/hidlcache/mapping.h b/libhidlcache/include/hidlcache/mapping.h
deleted file mode 100644
index 972b7b5..0000000
--- a/libhidlcache/include/hidlcache/mapping.h
+++ /dev/null
@@ -1,54 +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.
- */
-#ifndef ANDROID_HARDWARE_CACHE_MAPPING_H
-#define ANDROID_HARDWARE_CACHE_MAPPING_H
-
-#include <android/hidl/memory/1.0/IMemory.h>
-#include <android/hidl/memory/block/1.0/types.h>
-#include <android/hidl/memory/token/1.0/IMemoryToken.h>
-
-namespace android {
-namespace hardware {
-
-/**
- * Returns the IMemory instance corresponding to a MemoryBlock. The heap that
- * a MemoryBlock belongs to is stored in an internal cache to reduce the number
- * of invocations to the mapMemory(hidl_memory)
- *
- * Note, a cache entry is maintained by reference count and may be flushed when
- * the count decrease to zero. Performance critical part that does not want its
- * caches to be flushed can use HidlMemoryCacheLock.
- */
-sp<::android::hidl::memory::V1_0::IMemory> mapMemory(
-    const ::android::hidl::memory::block::V1_0::MemoryBlock& block);
-
-/**
- * Internally, there's a cache pool to keep IMemory instances for heap regions
- * that are referred by the MemoryBlock. During development, this
- * lockMemoryCache(...) method helps to diagnosis whether the cache is effective
- * for a specific key. It returns a RAII object used to lock an IMemory instance
- * referred by the key and keep it alive even if the instance is not referred by
- * any MemoryBlock. If the cache in interest is already effective. It won't differ
- * much in performance w/ wo/ the lockMemoryCache()
- *
- * @note An IMemory instance that is returned from the mapMemory() is
- *       initialized in an unlocked state.
- */
-sp<RefBase> lockMemoryCache(const sp<::android::hidl::memory::token::V1_0::IMemoryToken> key);
-
-}  // namespace hardware
-}  // namespace android
-#endif
diff --git a/libhidlcache/libhidlcache_test.cpp b/libhidlcache/libhidlcache_test.cpp
deleted file mode 100644
index e514460..0000000
--- a/libhidlcache/libhidlcache_test.cpp
+++ /dev/null
@@ -1,159 +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 "hidl-cache-test"
-
-#include <android/hidl/allocator/1.0/IAllocator.h>
-#include <android/hidl/memory/1.0/IMemory.h>
-#include <android/hidl/memory/token/1.0/IMemoryToken.h>
-#include <gtest/gtest.h>
-#include <hidlcache/MemoryDealer.h>
-#include <hidlcache/mapping.h>
-#include <hidlmemory/HidlMemoryToken.h>
-#include <hidlmemory/mapping.h>
-#include "HidlMemoryCache.h"
-
-#define EXPECT_OK(__ret__) EXPECT_TRUE(isOk(__ret__))
-
-template <typename T>
-static inline ::testing::AssertionResult isOk(const ::android::hardware::Return<T>& ret) {
-    return ret.isOk() ? (::testing::AssertionSuccess() << ret.description())
-                      : (::testing::AssertionFailure() << ret.description());
-}
-
-namespace android {
-
-namespace hardware {
-void HidlCacheWhiteBoxTest() {
-    using ::android::hardware::HidlMemoryCache;
-    using ::android::hardware::HidlMemoryToken;
-    using ::android::hidl::allocator::V1_0::IAllocator;
-    using ::android::hidl::memory::V1_0::IMemory;
-    using ::android::hidl::memory::token::V1_0::IMemoryToken;
-    using ::android::hidl::memory::block::V1_0::MemoryBlock;
-
-    sp<IAllocator> ashmemAllocator;
-
-    ashmemAllocator = IAllocator::getService("ashmem");
-    ASSERT_NE(nullptr, ashmemAllocator.get());
-    ASSERT_TRUE(ashmemAllocator->isRemote());  // allocator is always remote
-
-    sp<HidlMemory> mem;
-    EXPECT_OK(ashmemAllocator->allocate(1024, [&](bool success, const hidl_memory& _mem) {
-        ASSERT_TRUE(success);
-        mem = HidlMemory::getInstance(_mem);
-    }));
-
-    sp<IMemoryToken> token = new HidlMemoryToken(mem);
-
-    MemoryBlock blk = {token, 0x200 /* size */, 0x100 /* offset */};
-    sp<IMemoryToken> mtoken = blk.token;
-    mtoken->get([&](const hidl_memory& mem) { sp<IMemory> memory = mapMemory(mem); });
-
-    sp<HidlMemoryCache> cache = HidlMemoryCache::getInstance();
-    EXPECT_FALSE(cache->cached(token));
-
-    MemoryBlock blk2 = {token, 0x200 /* size */, 0x300 /* offset */};
-
-    EXPECT_FALSE(cache->cached(token));
-
-    {
-        sp<IMemory> mem1 = cache->fetch(token);
-        EXPECT_TRUE(cache->cached(token));
-        EXPECT_NE(nullptr, cache->getCachedLocked(token).get());
-        sp<IMemory> mem2 = cache->fetch(token);
-        EXPECT_TRUE(cache->cached(token));
-        EXPECT_NE(nullptr, cache->getCachedLocked(token).get());
-    }
-    EXPECT_FALSE(cache->cached(token));
-    {
-        sp<IMemory> mem1 = mapMemory(blk);
-        EXPECT_TRUE(cache->cached(token));
-        EXPECT_NE(nullptr, cache->getCachedLocked(token).get());
-        uint8_t* data = static_cast<uint8_t*>(static_cast<void*>(mem1->getPointer()));
-        EXPECT_NE(nullptr, data);
-    }
-    {
-        sp<IMemory> mem2 = mapMemory(blk);
-        EXPECT_TRUE(cache->cached(token));
-        EXPECT_NE(nullptr, cache->getCachedLocked(token).get());
-    }
-    EXPECT_FALSE(cache->cached(token));
-    EXPECT_TRUE(cache->lock(token));
-    EXPECT_TRUE(cache->cached(token));
-    EXPECT_NE(nullptr, cache->getCachedLocked(token).get());
-    EXPECT_TRUE(cache->unlock(token));
-    EXPECT_FALSE(cache->cached(token));
-}
-}  // namespace hardware
-
-class HidlCacheTest : public ::testing::Test {};
-
-TEST_F(HidlCacheTest, TestAll) {
-    hardware::HidlCacheWhiteBoxTest();
-}
-
-TEST_F(HidlCacheTest, MemoryDealer) {
-    using ::android::hardware::HidlMemory;
-    using ::android::hardware::hidl_memory;
-    using ::android::hardware::HidlMemoryDealer;
-    using ::android::hidl::allocator::V1_0::IAllocator;
-    using ::android::hidl::memory::block::V1_0::MemoryBlock;
-
-    sp<IAllocator> ashmemAllocator;
-
-    ashmemAllocator = IAllocator::getService("ashmem");
-    sp<HidlMemory> m1;
-    sp<HidlMemory> m2;
-    // test MemoryDealer
-    EXPECT_OK(ashmemAllocator->allocate(2048, [&m1](bool success, const hidl_memory& mem) {
-        ASSERT_TRUE(success);
-        m1 = HidlMemory::getInstance(mem);
-    }));
-
-    EXPECT_OK(ashmemAllocator->allocate(4096, [&m2](bool success, const hidl_memory& mem) {
-        ASSERT_TRUE(success);
-        m2 = HidlMemory::getInstance(mem);
-    }));
-
-    sp<HidlMemoryDealer> dealer;
-
-    // m1 does not statisfy the alignment requirement and should fail.
-    dealer = HidlMemoryDealer::getInstance(*m1);
-    EXPECT_EQ(nullptr, dealer.get());
-
-    dealer = HidlMemoryDealer::getInstance(*m2);
-    EXPECT_NE(nullptr, dealer.get());
-
-    EXPECT_EQ(dealer->heap()->getSize(), 4096ULL);
-    MemoryBlock blk = dealer->allocate(1024);
-    EXPECT_TRUE(HidlMemoryDealer::isOk(blk));
-    MemoryBlock blk2 = dealer->allocate(2048);
-    EXPECT_TRUE(HidlMemoryDealer::isOk(blk2));
-
-    MemoryBlock blk3 = dealer->allocate(2048);
-    EXPECT_FALSE(HidlMemoryDealer::isOk(blk3));
-    dealer->deallocate(blk2.offset);
-    blk3 = dealer->allocate(2048);
-    EXPECT_TRUE(HidlMemoryDealer::isOk(blk3));
-}
-
-int main(int argc, char** argv) {
-    ::testing::InitGoogleTest(&argc, argv);
-    return RUN_ALL_TESTS();
-}
-
-}  // namespace android
\ No newline at end of file
diff --git a/libhidlcache/mapping.cpp b/libhidlcache/mapping.cpp
deleted file mode 100644
index 2a23e6f..0000000
--- a/libhidlcache/mapping.cpp
+++ /dev/null
@@ -1,47 +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 "libhidlmemory"
-
-#include <map>
-#include <mutex>
-#include <string>
-
-#include <hidlmemory/mapping.h>
-
-#include <android-base/logging.h>
-#include <hidl/HidlSupport.h>
-#include "HidlMemoryCache.h"
-
-using android::hardware::HidlMemoryCache;
-using android::hidl::memory::block::V1_0::MemoryBlock;
-using android::hidl::memory::token::V1_0::IMemoryToken;
-using android::hidl::memory::V1_0::IMemory;
-
-namespace android {
-namespace hardware {
-
-sp<IMemory> mapMemory(const ::android::hidl::memory::block::V1_0::MemoryBlock& block) {
-    sp<HidlMemoryCache> c = HidlMemoryCache::getInstance();
-    return c->map(block);
-}
-
-sp<RefBase> lockMemoryCache(const sp<::android::hidl::memory::token::V1_0::IMemoryToken> key) {
-    sp<HidlMemoryCache> c = HidlMemoryCache::getInstance();
-    return c->lockGuard(key);
-}
-
-}  // namespace hardware
-}  // namespace android
