split android.hidl.memory
Split android.hidl.memory into android.hidl.memory and
android.hidl.allocator. This must be done because IAllocator is served
over hwbinder transport and IMapper/IMemory are always going to be
passthrough hals.
Test: hidl_test, device boots with allocator
Bug: 35327976
Merged-In: Ib135b5e101fadadbbf16126a98f90181f76a253b
Change-Id: Ib135b5e101fadadbbf16126a98f90181f76a253b
diff --git a/transport/memory/1.0/Android.bp b/transport/memory/1.0/Android.bp
index 0a7b88f..4ec0191 100644
--- a/transport/memory/1.0/Android.bp
+++ b/transport/memory/1.0/Android.bp
@@ -3,7 +3,6 @@
filegroup {
name: "android.hidl.memory@1.0_hal",
srcs: [
- "IAllocator.hal",
"IMapper.hal",
"IMemory.hal",
],
@@ -14,12 +13,9 @@
tools: ["hidl-gen"],
cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hidl:system/libhidl/transport android.hidl.memory@1.0",
srcs: [
- "IAllocator.hal",
- "IMapper.hal",
- "IMemory.hal",
+ ":android.hidl.memory@1.0_hal",
],
out: [
- "android/hidl/memory/1.0/AllocatorAll.cpp",
"android/hidl/memory/1.0/MapperAll.cpp",
"android/hidl/memory/1.0/MemoryAll.cpp",
],
@@ -30,16 +26,9 @@
tools: ["hidl-gen"],
cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hidl:system/libhidl/transport android.hidl.memory@1.0",
srcs: [
- "IAllocator.hal",
- "IMapper.hal",
- "IMemory.hal",
+ ":android.hidl.memory@1.0_hal",
],
out: [
- "android/hidl/memory/1.0/IAllocator.h",
- "android/hidl/memory/1.0/IHwAllocator.h",
- "android/hidl/memory/1.0/BnHwAllocator.h",
- "android/hidl/memory/1.0/BpHwAllocator.h",
- "android/hidl/memory/1.0/BsAllocator.h",
"android/hidl/memory/1.0/IMapper.h",
"android/hidl/memory/1.0/IHwMapper.h",
"android/hidl/memory/1.0/BnHwMapper.h",
diff --git a/transport/memory/1.0/IAllocator.hal b/transport/memory/1.0/IAllocator.hal
deleted file mode 100644
index 7f540aa..0000000
--- a/transport/memory/1.0/IAllocator.hal
+++ /dev/null
@@ -1,32 +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.hidl.memory@1.0;
-
-/**
- * Interface which allocates the required memory.
- */
-interface IAllocator {
-
- /**
- * Return memory must have instance name corresponding to this type of memory.
- *
- * @param size Size of memory to allocate in bytes.
- * @return success Whether allocation succeeded.
- * @return memory Unmapped memory object.
- */
- allocate(uint64_t size) generates (bool success, memory mem);
-};
\ No newline at end of file
diff --git a/transport/memory/1.0/default/Android.bp b/transport/memory/1.0/default/Android.bp
index 62fb556..e3a05c3 100644
--- a/transport/memory/1.0/default/Android.bp
+++ b/transport/memory/1.0/default/Android.bp
@@ -35,25 +35,3 @@
"android.hidl.memory@1.0",
],
}
-
-cc_binary {
- name: "android.hidl.memory@1.0-service",
- relative_install_path: "hw",
- srcs: [
- "AshmemAllocator.cpp",
- "service.cpp"
- ],
- init_rc: ["android.hidl.memory@1.0-service.rc"],
-
- shared_libs: [
- "android.hidl.base@1.0",
- "android.hidl.memory@1.0",
- "libhidlbase",
- "libhidltransport",
- "libhwbinder",
- "libbase",
- "liblog",
- "libutils",
- "libcutils",
- ],
-}
diff --git a/transport/memory/1.0/default/AshmemAllocator.cpp b/transport/memory/1.0/default/AshmemAllocator.cpp
deleted file mode 100644
index 667c46e..0000000
--- a/transport/memory/1.0/default/AshmemAllocator.cpp
+++ /dev/null
@@ -1,49 +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.
- */
-
-#include "AshmemAllocator.h"
-
-#include <cutils/ashmem.h>
-
-namespace android {
-namespace hidl {
-namespace memory {
-namespace V1_0 {
-namespace implementation {
-
-// Methods from ::android::hidl::memory::V1_0::IAllocator follow.
-Return<void> AshmemAllocator::allocate(uint64_t size, allocate_cb _hidl_cb) {
- int fd = ashmem_create_region("AshmemAllocator_hidl", size);
- if (fd < 0) {
- _hidl_cb(false /* success */, hidl_memory());
- return Void();
- }
-
- native_handle_t* handle = native_handle_create(1, 0);
- handle->data[0] = fd;
- hidl_memory memory("ashmem", handle, size);
-
- _hidl_cb(true /* success */, memory);
- native_handle_close(handle);
- native_handle_delete(handle);
- return Void();
-}
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace memory
-} // namespace hidl
-} // namespace android
diff --git a/transport/memory/1.0/default/AshmemAllocator.h b/transport/memory/1.0/default/AshmemAllocator.h
deleted file mode 100644
index 35ad420..0000000
--- a/transport/memory/1.0/default/AshmemAllocator.h
+++ /dev/null
@@ -1,51 +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_HIDL_ASHMEM_MEMORY_V1_0_ALLOCATOR_H
-#define ANDROID_HIDL_ASHMEM_MEMORY_V1_0_ALLOCATOR_H
-
-#include <android/hidl/memory/1.0/IAllocator.h>
-#include <hidl/MQDescriptor.h>
-#include <hidl/Status.h>
-
-namespace android {
-namespace hidl {
-namespace memory {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hidl::memory::V1_0::IAllocator;
-using ::android::hardware::hidl_array;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::sp;
-
-struct AshmemAllocator : public IAllocator {
- // Methods from ::android::hidl::memory::V1_0::IAllocator follow.
- Return<void> allocate(uint64_t size, allocate_cb _hidl_cb) override;
-
-};
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace memory
-} // namespace hidl
-} // namespace android
-
-#endif // ANDROID_HIDL_ASHMEM_MEMORY_V1_0_ALLOCATOR_H
diff --git a/transport/memory/1.0/default/HidlFetch.cpp b/transport/memory/1.0/default/HidlFetch.cpp
index adb55d3..d47cf97 100644
--- a/transport/memory/1.0/default/HidlFetch.cpp
+++ b/transport/memory/1.0/default/HidlFetch.cpp
@@ -16,7 +16,6 @@
#include "HidlFetch.h"
-#include "AshmemAllocator.h"
#include "AshmemMapper.h"
static std::string kAshmemMemoryName = "ashmem";
diff --git a/transport/memory/1.0/default/HidlFetch.h b/transport/memory/1.0/default/HidlFetch.h
index 389ca30..b220be4 100644
--- a/transport/memory/1.0/default/HidlFetch.h
+++ b/transport/memory/1.0/default/HidlFetch.h
@@ -17,7 +17,6 @@
#ifndef HIDL_FETCH_H
#define HIDL_FETCH_H
-#include <android/hidl/memory/1.0/IAllocator.h>
#include <android/hidl/memory/1.0/IMapper.h>
namespace android {
@@ -34,4 +33,4 @@
} // namespace hidl
} // namespace android
-#endif // HIDL_FETCH_H
\ No newline at end of file
+#endif // HIDL_FETCH_H
diff --git a/transport/memory/1.0/default/android.hidl.memory@1.0-service.rc b/transport/memory/1.0/default/android.hidl.memory@1.0-service.rc
deleted file mode 100644
index 1caaae9..0000000
--- a/transport/memory/1.0/default/android.hidl.memory@1.0-service.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-service hidl_memory /system/bin/hw/android.hidl.memory@1.0-service
- class hal
- user system
- group system
diff --git a/transport/memory/1.0/default/service.cpp b/transport/memory/1.0/default/service.cpp
deleted file mode 100644
index 0302e51..0000000
--- a/transport/memory/1.0/default/service.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#define LOG_TAG "android.hidl.memory@1.0-service"
-
-#include "AshmemAllocator.h"
-
-#include <android-base/logging.h>
-#include <android/hidl/memory/1.0/IAllocator.h>
-#include <hidl/HidlTransportSupport.h>
-
-using android::hardware::configureRpcThreadpool;
-using android::hardware::joinRpcThreadpool;
-using android::hidl::memory::V1_0::IAllocator;
-using android::hidl::memory::V1_0::implementation::AshmemAllocator;
-using android::sp;
-using android::status_t;
-
-int main() {
- configureRpcThreadpool(1, true /* callerWillJoin */);
-
- sp<IAllocator> allocator = new AshmemAllocator();
-
- status_t status = allocator->registerAsService("ashmem");
-
- if (android::OK != status) {
- LOG(FATAL) << "Unable to register allocator service: " << status;
- }
-
- joinRpcThreadpool();
-
- return -1;
-}