summaryrefslogtreecommitdiff
path: root/transport/memory
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2016-12-15 12:56:07 -0800
committerSteven Moreland <smoreland@google.com>2016-12-22 13:10:45 -0800
commit9f77329af70be049edf26ce294be2c39876dd085 (patch)
tree13da0f6755ee86ce87c5cf6599ef9a3640c9971b /transport/memory
parent2ef31d85e0e91c28f05d6288505f57d5d7c43eed (diff)
downloadlibhidl-9f77329af70be049edf26ce294be2c39876dd085.tar.gz
memory: IAllocator is always binderized.
Benefits: - single process allocates all of the shared memory (allows us to get statitistics). - prevents us from having to open up the allocator in passthrough mode forever. - prevents us from having to include/require android.hidl.memory@1.0-impl elsewhere Bug: 32185232 Test: hidl_test Change-Id: I37be6a4afb14a79df457e166aa4b99de416b8f40
Diffstat (limited to 'transport/memory')
-rw-r--r--transport/memory/1.0/default/Android.bp8
-rw-r--r--transport/memory/1.0/default/HidlFetch.cpp8
-rw-r--r--transport/memory/1.0/default/HidlFetch.h3
-rw-r--r--transport/memory/1.0/default/service.cpp27
4 files changed, 29 insertions, 17 deletions
diff --git a/transport/memory/1.0/default/Android.bp b/transport/memory/1.0/default/Android.bp
index 4bc24a2..2b89f07 100644
--- a/transport/memory/1.0/default/Android.bp
+++ b/transport/memory/1.0/default/Android.bp
@@ -16,7 +16,6 @@ cc_library_shared {
name: "android.hidl.memory@1.0-impl",
relative_install_path: "hw",
srcs: [
- "AshmemAllocator.cpp",
"AshmemMapper.cpp",
"AshmemMemory.cpp",
"HidlFetch.cpp"
@@ -39,7 +38,10 @@ cc_library_shared {
cc_binary {
name: "android.hidl.memory@1.0-service",
relative_install_path: "hw",
- srcs: ["service.cpp"],
+ srcs: [
+ "AshmemAllocator.cpp",
+ "service.cpp"
+ ],
init_rc: ["android.hidl.memory@1.0-service.rc"],
shared_libs: [
@@ -48,8 +50,10 @@ cc_binary {
"libhidlbase",
"libhidltransport",
"libhwbinder",
+ "libbase",
"liblog",
"libutils",
+ "libcutils",
],
required: [
diff --git a/transport/memory/1.0/default/HidlFetch.cpp b/transport/memory/1.0/default/HidlFetch.cpp
index 8236055..adb55d3 100644
--- a/transport/memory/1.0/default/HidlFetch.cpp
+++ b/transport/memory/1.0/default/HidlFetch.cpp
@@ -27,14 +27,6 @@ namespace memory {
namespace V1_0 {
namespace implementation {
-IAllocator* HIDL_FETCH_IAllocator(const char* name) {
- if (name == kAshmemMemoryName) {
- return new AshmemAllocator;
- }
-
- return nullptr;
-}
-
IMapper* HIDL_FETCH_IMapper(const char* name) {
if (name == kAshmemMemoryName) {
return new AshmemMapper;
diff --git a/transport/memory/1.0/default/HidlFetch.h b/transport/memory/1.0/default/HidlFetch.h
index a9d366f..389ca30 100644
--- a/transport/memory/1.0/default/HidlFetch.h
+++ b/transport/memory/1.0/default/HidlFetch.h
@@ -26,9 +26,6 @@ namespace memory {
namespace V1_0 {
namespace implementation {
-// TODO: disable passthrough allocator. It's much better if it's in a centralized location
-extern "C" IAllocator* HIDL_FETCH_IAllocator(const char* name);
-
extern "C" IMapper* HIDL_FETCH_IMapper(const char* name);
} // namespace implementation
diff --git a/transport/memory/1.0/default/service.cpp b/transport/memory/1.0/default/service.cpp
index ff3a8e8..8ea8b8a 100644
--- a/transport/memory/1.0/default/service.cpp
+++ b/transport/memory/1.0/default/service.cpp
@@ -1,12 +1,31 @@
#define LOG_TAG "android.hidl.memory@1.0-service"
-#include <android/hidl/memory/1.0/IAllocator.h>
+#include "AshmemAllocator.h"
-#include <hidl/LegacySupport.h>
+#include <android-base/logging.h>
+#include <android/hidl/memory/1.0/IAllocator.h>
+#include <hwbinder/IPCThreadState.h>
+#include <hwbinder/ProcessState.h>
+using android::hardware::IPCThreadState;
+using android::hardware::ProcessState;
using android::hidl::memory::V1_0::IAllocator;
-using android::hardware::defaultPassthroughServiceImplementation;
+using android::hidl::memory::V1_0::implementation::AshmemAllocator;
+using android::sp;
+using android::status_t;
int main() {
- return defaultPassthroughServiceImplementation<IAllocator>("ashmem");
+ sp<IAllocator> allocator = new AshmemAllocator();
+
+ status_t status = allocator->registerAsService("ashmem");
+
+ if (android::OK != status) {
+ LOG(FATAL) << "Unable to register allocator service: " << status;
+ }
+
+ ProcessState::self()->setThreadPoolMaxThreadCount(0);
+ ProcessState::self()->startThreadPool();
+ IPCThreadState::self()->joinThreadPool();
+
+ return -1;
}