summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2017-05-22 18:04:09 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-05-22 18:04:09 +0000
commit114080588744a7a30e52b90ab77ba2df122bbb4c (patch)
treea4736731632ccb20907ace5a511fab58ba274094
parenta8d813df69681c21cbf3370f05f260f0df01de7d (diff)
parent0d0bd78eea5189a08698480f93c240fd0658b82e (diff)
downloadlibhidl-114080588744a7a30e52b90ab77ba2df122bbb4c.tar.gz
Merge "Allow clients of mapMemory to recover." am: 079afdf499 am: 636495c14d am: 771654961d
am: 0d0bd78eea Change-Id: I7f6cd0df7fd332713ed1f9d4d2e9a99c0e7acbd3
-rw-r--r--libhidlmemory/include/hidlmemory/mapping.h6
-rw-r--r--libhidlmemory/mapping.cpp9
2 files changed, 11 insertions, 4 deletions
diff --git a/libhidlmemory/include/hidlmemory/mapping.h b/libhidlmemory/include/hidlmemory/mapping.h
index 8ed0d54..5e1dab3 100644
--- a/libhidlmemory/include/hidlmemory/mapping.h
+++ b/libhidlmemory/include/hidlmemory/mapping.h
@@ -19,7 +19,11 @@
namespace android {
namespace hardware {
+/**
+ * Returns the IMemory instance corresponding to a hidl_memory object.
+ * If the shared memory cannot be fetched, this returns nullptr.
+ */
sp<android::hidl::memory::V1_0::IMemory> mapMemory(const hidl_memory &memory);
} // namespace hardware
-} // namespace android \ No newline at end of file
+} // namespace android
diff --git a/libhidlmemory/mapping.cpp b/libhidlmemory/mapping.cpp
index 3761f99..f4bb21e 100644
--- a/libhidlmemory/mapping.cpp
+++ b/libhidlmemory/mapping.cpp
@@ -33,17 +33,20 @@ sp<IMemory> mapMemory(const hidl_memory &memory) {
sp<IMapper> mapper = IMapper::getService(memory.name(), true /* getStub */);
if (mapper == nullptr) {
- LOG(FATAL) << "Could not fetch mapper for " << memory.name() << " shared memory";
+ LOG(ERROR) << "Could not fetch mapper for " << memory.name() << " shared memory";
+ return nullptr;
}
if (mapper->isRemote()) {
- LOG(FATAL) << "IMapper must be a passthrough service.";
+ LOG(ERROR) << "IMapper must be a passthrough service.";
+ return nullptr;
}
Return<sp<IMemory>> ret = mapper->mapMemory(memory);
if (!ret.isOk()) {
- LOG(FATAL) << "hidl_memory map returned transport error.";
+ LOG(ERROR) << "hidl_memory map returned transport error.";
+ return nullptr;
}
return ret;