Delete vestigial Status parcel read.
am: 7fd5fbec0c
Change-Id: I8db582a21a9f5fea0690eb56568cdd2296f21f54
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..9b3f9d9
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+
+BasedOnStyle: Google
+CommentPragmas: NOLINT:.*
+DerivePointerAlignment: false
+AllowShortFunctionsOnASingleLine: Inline
+ColumnLimit: 100
+TabWidth: 4
+UseTab: Never
+IndentWidth: 4
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 0000000..3631423
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1,5 @@
+smoreland@google.com
+elsk@google.com
+maco@google.com
+hridya@google.com
+malchev@google.com
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
new file mode 100644
index 0000000..213c93a
--- /dev/null
+++ b/PREUPLOAD.cfg
@@ -0,0 +1,5 @@
+[Options]
+ignore_merged_commits = true
+
+[Builtin Hooks]
+clang_format = true
diff --git a/base/Android.bp b/base/Android.bp
index 5ba464a..e4cf6cb 100644
--- a/base/Android.bp
+++ b/base/Android.bp
@@ -23,7 +23,6 @@
"libutils",
],
export_shared_lib_headers: [
- "libbase",
"libutils",
"libcutils", // for native_handle.h
],
diff --git a/base/HidlSupport.cpp b/base/HidlSupport.cpp
index f9a23e8..c0888f6 100644
--- a/base/HidlSupport.cpp
+++ b/base/HidlSupport.cpp
@@ -71,7 +71,7 @@
if (other.mHandle != nullptr) {
mHandle = native_handle_clone(other.mHandle);
if (mHandle == nullptr) {
- LOG(FATAL) << "Failed to clone native_handle in hidl_handle.";
+ PLOG(FATAL) << "Failed to clone native_handle in hidl_handle";
}
mOwnsHandle = true;
} else {
@@ -220,7 +220,7 @@
// assume my resources are freed.
if (size > UINT32_MAX) {
- LOG(FATAL) << "string size can't exceed 2^32 bytes.";
+ LOG(FATAL) << "string size can't exceed 2^32 bytes: " << size;
}
char *buf = (char *)malloc(size + 1);
memcpy(buf, data, size);
@@ -254,7 +254,7 @@
void hidl_string::setToExternal(const char *data, size_t size) {
if (size > UINT32_MAX) {
- LOG(FATAL) << "string size can't exceed 2^32 bytes.";
+ LOG(FATAL) << "string size can't exceed 2^32 bytes: " << size;
}
clear();
diff --git a/base/TaskRunner.cpp b/base/TaskRunner.cpp
index 33117e7..782b40b 100644
--- a/base/TaskRunner.cpp
+++ b/base/TaskRunner.cpp
@@ -43,6 +43,10 @@
}
}
+bool TaskRunner::push(const Task &t) {
+ return (mQueue != nullptr) && (!!t) && this->mQueue->push(t);
+}
+
} // namespace details
} // namespace hardware
} // namespace android
diff --git a/base/include/hidl/MQDescriptor.h b/base/include/hidl/MQDescriptor.h
index abab212..23be971 100644
--- a/base/include/hidl/MQDescriptor.h
+++ b/base/include/hidl/MQDescriptor.h
@@ -17,7 +17,8 @@
#ifndef _FMSGQ_DESCRIPTOR_H
#define _FMSGQ_DESCRIPTOR_H
-#include <android-base/macros.h>
+#include <unistd.h>
+
#include <cutils/native_handle.h>
#include <hidl/HidlInternal.h>
#include <hidl/HidlSupport.h>
diff --git a/base/include/hidl/Status.h b/base/include/hidl/Status.h
index a04cf77..7c716c7 100644
--- a/base/include/hidl/Status.h
+++ b/base/include/hidl/Status.h
@@ -20,7 +20,6 @@
#include <cstdint>
#include <sstream>
-#include <android-base/macros.h>
#include <hidl/HidlInternal.h>
#include <utils/Errors.h>
#include <utils/StrongPointer.h>
@@ -195,6 +194,9 @@
return mVal;
}
+ T withDefault(T t) {
+ return isOk() ? mVal : t;
+ }
};
template<typename T> class Return<sp<T>> : public details::return_status {
@@ -220,6 +222,10 @@
assertOk();
return mVal;
}
+
+ sp<T> withDefault(sp<T> t) {
+ return isOk() ? mVal : t;
+ }
};
diff --git a/base/include/hidl/TaskRunner.h b/base/include/hidl/TaskRunner.h
index 8ecceca..28ea01c 100644
--- a/base/include/hidl/TaskRunner.h
+++ b/base/include/hidl/TaskRunner.h
@@ -52,9 +52,7 @@
* Add a task. Return true if successful, false if
* the queue's size exceeds limit or t doesn't contain a callable target.
*/
- inline bool push(const Task &t) {
- return (mQueue != nullptr) && (!!t) && this->mQueue->push(t);
- }
+ bool push(const Task &t);
private:
std::shared_ptr<SynchronizedQueue<Task>> mQueue;
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 35e9d33..8f0bcf4 100644
--- a/libhidlmemory/mapping.cpp
+++ b/libhidlmemory/mapping.cpp
@@ -55,11 +55,13 @@
sp<IMapper> mapper = getMapperService(memory.name());
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;
}
// hidl_memory's size is stored in uint64_t, but mapMemory's mmap will map
@@ -74,7 +76,8 @@
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;
diff --git a/manifest.xml b/manifest.xml
index 799b660..eb64dab 100644
--- a/manifest.xml
+++ b/manifest.xml
@@ -62,6 +62,15 @@
<instance>default</instance>
</interface>
</hal>
+ <hal format="hidl">
+ <name>android.system.net.netd</name>
+ <transport>hwbinder</transport>
+ <version>1.0</version>
+ <interface>
+ <name>INetd</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
<hal>
<name>android.system.wifi.keystore</name>
<transport>hwbinder</transport>
diff --git a/test_main.cpp b/test_main.cpp
index 4be2eb9..bce9294 100644
--- a/test_main.cpp
+++ b/test_main.cpp
@@ -363,6 +363,29 @@
ret.isOk();
}
+TEST_F(LibHidlTest, ReturnTest) {
+ using ::android::DEAD_OBJECT;
+ using ::android::hardware::Return;
+ using ::android::hardware::Status;
+ using ::android::hardware::hidl_string;
+
+ EXPECT_FALSE(Return<void>(Status::fromStatusT(DEAD_OBJECT)).isOk());
+ EXPECT_TRUE(Return<void>(Status::ok()).isOk());
+
+ hidl_string one = "1";
+ hidl_string two = "2";
+ Return<hidl_string> ret = Return<hidl_string>(Status::fromStatusT(DEAD_OBJECT));
+
+ EXPECT_EQ(one, Return<hidl_string>(one).withDefault(two));
+ EXPECT_EQ(two, ret.withDefault(two));
+
+ hidl_string&& moved = ret.withDefault(std::move(two));
+ EXPECT_EQ("2", moved);
+
+ const hidl_string three = "3";
+ EXPECT_EQ(three, ret.withDefault(three));
+}
+
std::string toString(const ::android::hardware::Status &s) {
using ::android::hardware::operator<<;
std::ostringstream oss;
diff --git a/transport/Android.bp b/transport/Android.bp
index 47a4de3..73eee3a 100644
--- a/transport/Android.bp
+++ b/transport/Android.bp
@@ -26,6 +26,7 @@
cc_library_shared {
name: "libhidltransport",
vendor_available: true,
+ defaults: ["hidl-module-defaults"],
cflags: libhidl_flags,
shared_libs: [
"libbase",
@@ -34,6 +35,7 @@
"libhidlbase",
"libhwbinder",
"libcutils",
+ "libvndksupport",
],
export_shared_lib_headers: [
"libbase",
@@ -59,6 +61,7 @@
srcs: [
"HidlBinderSupport.cpp",
"HidlTransportSupport.cpp",
+ "HidlTransportUtils.cpp",
"ServiceManagement.cpp",
"Static.cpp"
],
diff --git a/transport/HidlBinderSupport.cpp b/transport/HidlBinderSupport.cpp
index 3fb5a0f..1217de1 100644
--- a/transport/HidlBinderSupport.cpp
+++ b/transport/HidlBinderSupport.cpp
@@ -29,6 +29,23 @@
namespace android {
namespace hardware {
+hidl_binder_death_recipient::hidl_binder_death_recipient(const sp<hidl_death_recipient> &recipient,
+ uint64_t cookie, const sp<::android::hidl::base::V1_0::IBase> &base) :
+ mRecipient(recipient), mCookie(cookie), mBase(base) {
+}
+
+void hidl_binder_death_recipient::binderDied(const wp<IBinder>& /*who*/) {
+ sp<hidl_death_recipient> recipient = mRecipient.promote();
+ if (recipient != nullptr && mBase != nullptr) {
+ recipient->serviceDied(mCookie, mBase);
+ }
+ mBase = nullptr;
+}
+
+wp<hidl_death_recipient> hidl_binder_death_recipient::getRecipient() {
+ return mRecipient;
+}
+
const size_t hidl_memory::kOffsetOfHandle = offsetof(hidl_memory, mHandle);
const size_t hidl_memory::kOffsetOfName = offsetof(hidl_memory, mName);
static_assert(hidl_memory::kOffsetOfHandle == 0, "wrong offset");
@@ -79,7 +96,6 @@
return _hidl_err;
}
-// static
const size_t hidl_string::kOffsetOfBuffer = offsetof(hidl_string, mBuffer);
static_assert(hidl_string::kOffsetOfBuffer == 0, "wrong offset");
diff --git a/transport/HidlTransportUtils.cpp b/transport/HidlTransportUtils.cpp
new file mode 100644
index 0000000..4e952eb
--- /dev/null
+++ b/transport/HidlTransportUtils.cpp
@@ -0,0 +1,69 @@
+/*
+ * 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 <hidl/HidlTransportUtils.h>
+
+#include <android/hidl/base/1.0/IBase.h>
+
+namespace android {
+namespace hardware {
+namespace details {
+
+using ::android::hidl::base::V1_0::IBase;
+
+Return<bool> canCastInterface(IBase* interface, const char* castTo, bool emitError) {
+ if (interface == nullptr) {
+ return false;
+ }
+
+ // b/68217907
+ // Every HIDL interface is a base interface.
+ if (std::string(IBase::descriptor) == castTo) {
+ return true;
+ }
+
+ bool canCast = false;
+ auto chainRet = interface->interfaceChain([&](const hidl_vec<hidl_string> &types) {
+ for (size_t i = 0; i < types.size(); i++) {
+ if (types[i] == castTo) {
+ canCast = true;
+ break;
+ }
+ }
+ });
+
+ if (!chainRet.isOk()) {
+ // call fails, propagate the error if emitError
+ return emitError
+ ? details::StatusOf<void, bool>(chainRet)
+ : Return<bool>(false);
+ }
+
+ return canCast;
+}
+
+std::string getDescriptor(IBase* interface) {
+ std::string myDescriptor{};
+ auto ret = interface->interfaceDescriptor([&](const hidl_string &types) {
+ myDescriptor = types.c_str();
+ });
+ ret.isOk(); // ignored, return empty string if not isOk()
+ return myDescriptor;
+}
+
+} // namespace details
+} // namespace hardware
+} // namespace android
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp
index 617a858..5e2d1a5 100644
--- a/transport/ServiceManagement.cpp
+++ b/transport/ServiceManagement.cpp
@@ -26,6 +26,7 @@
#include <mutex>
#include <regex>
+#include <set>
#include <hidl/HidlBinderSupport.h>
#include <hidl/ServiceManagement.h>
@@ -35,6 +36,7 @@
#include <android-base/properties.h>
#include <hwbinder/IPCThreadState.h>
#include <hwbinder/Parcel.h>
+#include <vndksupport/linker.h>
#include <android/hidl/manager/1.0/IServiceManager.h>
#include <android/hidl/manager/1.0/BpHwServiceManager.h>
@@ -44,10 +46,6 @@
#define RE_PATH RE_COMPONENT "(?:[.]" RE_COMPONENT ")*"
static const std::regex gLibraryFileNamePattern("(" RE_PATH "@[0-9]+[.][0-9]+)-impl(.*?).so");
-extern "C" {
- android_namespace_t* android_get_exported_namespace(const char*);
-}
-
using android::base::WaitForProperty;
using android::hidl::manager::V1_0::IServiceManager;
@@ -184,10 +182,11 @@
return results;
}
-bool matchPackageName(const std::string &lib, std::string *matchedName) {
+bool matchPackageName(const std::string& lib, std::string* matchedName, std::string* implName) {
std::smatch match;
if (std::regex_match(lib, match, gLibraryFileNamePattern)) {
*matchedName = match.str(1) + "::I*";
+ *implName = match.str(2);
return true;
}
return false;
@@ -212,63 +211,91 @@
<< interfaceName << "/" << instanceName;
}
-struct PassthroughServiceManager : IServiceManager {
- Return<sp<IBase>> get(const hidl_string& fqName,
- const hidl_string& name) override {
- std::string stdFqName(fqName.c_str());
+using InstanceDebugInfo = hidl::manager::V1_0::IServiceManager::InstanceDebugInfo;
+static inline void fetchPidsForPassthroughLibraries(
+ std::map<std::string, InstanceDebugInfo>* infos) {
+ static const std::string proc = "/proc/";
+ std::map<std::string, std::set<pid_t>> pids;
+ std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(proc.c_str()), closedir);
+ if (!dir) return;
+ dirent* dp;
+ while ((dp = readdir(dir.get())) != nullptr) {
+ pid_t pid = strtoll(dp->d_name, NULL, 0);
+ if (pid == 0) continue;
+ std::string mapsPath = proc + dp->d_name + "/maps";
+ std::ifstream ifs{mapsPath};
+ if (!ifs.is_open()) continue;
+
+ for (std::string line; std::getline(ifs, line);) {
+ // The last token of line should look like
+ // vendor/lib64/hw/android.hardware.foo@1.0-impl-extra.so
+ // Use some simple filters to ignore bad lines before extracting libFileName
+ // and checking the key in info to make parsing faster.
+ if (line.back() != 'o') continue;
+ if (line.rfind('@') == std::string::npos) continue;
+
+ auto spacePos = line.rfind(' ');
+ if (spacePos == std::string::npos) continue;
+ auto libFileName = line.substr(spacePos + 1);
+ auto it = infos->find(libFileName);
+ if (it == infos->end()) continue;
+ pids[libFileName].insert(pid);
+ }
+ }
+ for (auto& pair : *infos) {
+ pair.second.clientPids =
+ std::vector<pid_t>{pids[pair.first].begin(), pids[pair.first].end()};
+ }
+}
+
+struct PassthroughServiceManager : IServiceManager {
+ static void openLibs(const std::string& fqName,
+ std::function<bool /* continue */(void* /* handle */,
+ const std::string& /* lib */, const std::string& /* sym */)> eachLib) {
//fqName looks like android.hardware.foo@1.0::IFoo
- size_t idx = stdFqName.find("::");
+ size_t idx = fqName.find("::");
if (idx == std::string::npos ||
- idx + strlen("::") + 1 >= stdFqName.size()) {
+ idx + strlen("::") + 1 >= fqName.size()) {
LOG(ERROR) << "Invalid interface name passthrough lookup: " << fqName;
- return nullptr;
+ return;
}
- std::string packageAndVersion = stdFqName.substr(0, idx);
- std::string ifaceName = stdFqName.substr(idx + strlen("::"));
+ std::string packageAndVersion = fqName.substr(0, idx);
+ std::string ifaceName = fqName.substr(idx + strlen("::"));
const std::string prefix = packageAndVersion + "-impl";
const std::string sym = "HIDL_FETCH_" + ifaceName;
- const android_namespace_t* sphal_namespace = android_get_exported_namespace("sphal");
const int dlMode = RTLD_LAZY;
void *handle = nullptr;
- // TODO: lookup in VINTF instead
- // TODO(b/34135607): Remove HAL_LIBRARY_PATH_SYSTEM
-
dlerror(); // clear
- for (const std::string &path : {
- HAL_LIBRARY_PATH_ODM, HAL_LIBRARY_PATH_VENDOR, HAL_LIBRARY_PATH_SYSTEM
- }) {
+ std::vector<std::string> paths = {HAL_LIBRARY_PATH_ODM, HAL_LIBRARY_PATH_VENDOR,
+ HAL_LIBRARY_PATH_SYSTEM};
+#ifdef LIBHIDL_TARGET_DEBUGGABLE
+ const char* env = std::getenv("TREBLE_TESTING_OVERRIDE");
+ const bool trebleTestingOverride = env && !strcmp(env, "true");
+ if (trebleTestingOverride) {
+ const char* vtsRootPath = std::getenv("VTS_ROOT_PATH");
+ if (vtsRootPath && strlen(vtsRootPath) > 0) {
+ const std::string halLibraryPathVtsOverride =
+ std::string(vtsRootPath) + HAL_LIBRARY_PATH_SYSTEM;
+ paths.push_back(halLibraryPathVtsOverride);
+ }
+ }
+#endif
+ for (const std::string& path : paths) {
std::vector<std::string> libs = search(path, prefix, ".so");
for (const std::string &lib : libs) {
const std::string fullPath = path + lib;
- // If sphal namespace is available, try to load from the
- // namespace first. If it fails, fall back to the original
- // dlopen, which loads from the current namespace.
- if (sphal_namespace != nullptr && path != HAL_LIBRARY_PATH_SYSTEM) {
- const android_dlextinfo dlextinfo = {
- .flags = ANDROID_DLEXT_USE_NAMESPACE,
- // const_cast is dirty but required because
- // library_namespace field is non-const.
- .library_namespace = const_cast<android_namespace_t*>(sphal_namespace),
- };
- handle = android_dlopen_ext(fullPath.c_str(), dlMode, &dlextinfo);
- if (handle == nullptr) {
- const char* error = dlerror();
- LOG(WARNING) << "Failed to dlopen " << lib << " from sphal namespace:"
- << (error == nullptr ? "unknown error" : error);
- } else {
- LOG(DEBUG) << lib << " loaded from sphal namespace.";
- }
- }
- if (handle == nullptr) {
+ if (path != HAL_LIBRARY_PATH_SYSTEM) {
+ handle = android_load_sphal_library(fullPath.c_str(), dlMode);
+ } else {
handle = dlopen(fullPath.c_str(), dlMode);
}
@@ -279,31 +306,41 @@
continue;
}
- IBase* (*generator)(const char* name);
- *(void **)(&generator) = dlsym(handle, sym.c_str());
- if(!generator) {
- const char* error = dlerror();
- LOG(ERROR) << "Passthrough lookup opened " << lib
- << " but could not find symbol " << sym << ": "
- << (error == nullptr ? "unknown error" : error);
- dlclose(handle);
- continue;
+ if (!eachLib(handle, lib, sym)) {
+ return;
}
-
- IBase *interface = (*generator)(name.c_str());
-
- if (interface == nullptr) {
- dlclose(handle);
- continue; // this module doesn't provide this instance name
- }
-
- registerReference(fqName, name);
-
- return interface;
}
}
+ }
- return nullptr;
+ Return<sp<IBase>> get(const hidl_string& fqName,
+ const hidl_string& name) override {
+ sp<IBase> ret = nullptr;
+
+ openLibs(fqName, [&](void* handle, const std::string &lib, const std::string &sym) {
+ IBase* (*generator)(const char* name);
+ *(void **)(&generator) = dlsym(handle, sym.c_str());
+ if(!generator) {
+ const char* error = dlerror();
+ LOG(ERROR) << "Passthrough lookup opened " << lib
+ << " but could not find symbol " << sym << ": "
+ << (error == nullptr ? "unknown error" : error);
+ dlclose(handle);
+ return true;
+ }
+
+ ret = (*generator)(name.c_str());
+
+ if (ret == nullptr) {
+ dlclose(handle);
+ return true; // this module doesn't provide this instance name
+ }
+
+ registerReference(fqName, name);
+ return false;
+ });
+
+ return ret;
}
Return<bool> add(const hidl_string& /* name */,
@@ -339,6 +376,7 @@
Return<void> debugDump(debugDump_cb _hidl_cb) override {
using Arch = ::android::hidl::base::V1_0::DebugInfo::Architecture;
+ using std::literals::string_literals::operator""s;
static std::vector<std::pair<Arch, std::vector<const char *>>> sAllPaths{
{Arch::IS_64BIT, {HAL_LIBRARY_PATH_ODM_64BIT,
HAL_LIBRARY_PATH_VENDOR_64BIT,
@@ -347,24 +385,32 @@
HAL_LIBRARY_PATH_VENDOR_32BIT,
HAL_LIBRARY_PATH_SYSTEM_32BIT}}
};
- std::vector<InstanceDebugInfo> vec;
+ std::map<std::string, InstanceDebugInfo> map;
for (const auto &pair : sAllPaths) {
Arch arch = pair.first;
for (const auto &path : pair.second) {
std::vector<std::string> libs = search(path, "", ".so");
for (const std::string &lib : libs) {
std::string matchedName;
- if (matchPackageName(lib, &matchedName)) {
- vec.push_back({
- .interfaceName = matchedName,
- .instanceName = "*",
- .clientPids = {},
- .arch = arch
- });
+ std::string implName;
+ if (matchPackageName(lib, &matchedName, &implName)) {
+ std::string instanceName{"* ("s + path + ")"s};
+ if (!implName.empty()) instanceName += " ("s + implName + ")"s;
+ map.emplace(path + lib, InstanceDebugInfo{.interfaceName = matchedName,
+ .instanceName = instanceName,
+ .clientPids = {},
+ .arch = arch});
}
}
}
}
+ fetchPidsForPassthroughLibraries(&map);
+ hidl_vec<InstanceDebugInfo> vec;
+ vec.resize(map.size());
+ size_t idx = 0;
+ for (auto&& pair : map) {
+ vec[idx++] = std::move(pair.second);
+ }
_hidl_cb(vec);
return Void();
}
@@ -385,6 +431,14 @@
namespace details {
+void preloadPassthroughService(const std::string &descriptor) {
+ PassthroughServiceManager::openLibs(descriptor,
+ [&](void* /* handle */, const std::string& /* lib */, const std::string& /* sym */) {
+ // do nothing
+ return true; // open all libs
+ });
+}
+
struct Waiter : IServiceNotification {
Return<void> onRegistration(const hidl_string& /* fqName */,
const hidl_string& /* name */,
diff --git a/transport/allocator/1.0/Android.bp b/transport/allocator/1.0/Android.bp
index f127316..b836d26 100644
--- a/transport/allocator/1.0/Android.bp
+++ b/transport/allocator/1.0/Android.bp
@@ -49,13 +49,11 @@
"liblog",
"libutils",
"libcutils",
- "android.hidl.base@1.0",
],
export_shared_lib_headers: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"libutils",
- "android.hidl.base@1.0",
],
}
diff --git a/transport/allocator/1.0/default/Android.bp b/transport/allocator/1.0/default/Android.bp
index d15d7c2..7d5fd8b 100644
--- a/transport/allocator/1.0/default/Android.bp
+++ b/transport/allocator/1.0/default/Android.bp
@@ -23,7 +23,6 @@
init_rc: ["android.hidl.allocator@1.0-service.rc"],
shared_libs: [
- "android.hidl.base@1.0",
"android.hidl.allocator@1.0",
"libhidlbase",
"libhidltransport",
diff --git a/transport/base/1.0/Android.bp b/transport/base/1.0/Android.bp
index a137f78..8382824 100644
--- a/transport/base/1.0/Android.bp
+++ b/transport/base/1.0/Android.bp
@@ -39,24 +39,4 @@
],
}
-cc_library_shared {
- name: "android.hidl.base@1.0",
- generated_sources: ["android.hidl.base@1.0_genc++"],
- generated_headers: ["android.hidl.base@1.0_genc++_headers"],
- export_generated_headers: ["android.hidl.base@1.0_genc++_headers"],
- vendor_available: true,
- shared_libs: [
- "libhidlbase",
- "libhidltransport",
- "libhwbinder",
- "liblog",
- "libutils",
- "libcutils",
- ],
- export_shared_lib_headers: [
- "libhidlbase",
- "libhidltransport",
- "libhwbinder",
- "libutils",
- ],
-}
+// android.hidl.base@1.0 is exported from libhidltransport
diff --git a/transport/include/hidl/HidlBinderSupport.h b/transport/include/hidl/HidlBinderSupport.h
index a82f977..6f82dbc 100644
--- a/transport/include/hidl/HidlBinderSupport.h
+++ b/transport/include/hidl/HidlBinderSupport.h
@@ -40,18 +40,9 @@
// DeathRecipient interface.
struct hidl_binder_death_recipient : IBinder::DeathRecipient {
hidl_binder_death_recipient(const sp<hidl_death_recipient> &recipient,
- uint64_t cookie, const sp<::android::hidl::base::V1_0::IBase> &base) :
- mRecipient(recipient), mCookie(cookie), mBase(base) {
- }
- virtual void binderDied(const wp<IBinder>& /*who*/) {
- sp<hidl_death_recipient> recipient = mRecipient.promote();
- if (recipient != nullptr) {
- recipient->serviceDied(mCookie, mBase);
- }
- }
- wp<hidl_death_recipient> getRecipient() {
- return mRecipient;
- }
+ uint64_t cookie, const sp<::android::hidl::base::V1_0::IBase> &base);
+ virtual void binderDied(const wp<IBinder>& /*who*/);
+ wp<hidl_death_recipient> getRecipient();
private:
wp<hidl_death_recipient> mRecipient;
uint64_t mCookie;
diff --git a/transport/include/hidl/HidlTransportUtils.h b/transport/include/hidl/HidlTransportUtils.h
index a69c123..5afb9a6 100644
--- a/transport/include/hidl/HidlTransportUtils.h
+++ b/transport/include/hidl/HidlTransportUtils.h
@@ -28,46 +28,10 @@
* @param emitError if emitError is false, return Return<bool>{false} on error; if emitError
* is true, the Return<bool> object contains the actual error.
*/
-inline Return<bool> canCastInterface(::android::hidl::base::V1_0::IBase* interface,
- const char* castTo, bool emitError = false) {
- if (interface == nullptr) {
- return false;
- }
+Return<bool> canCastInterface(::android::hidl::base::V1_0::IBase* interface,
+ const char* castTo, bool emitError = false);
- // b/68217907
- // Every HIDL interface is a base interface.
- if (std::string(::android::hidl::base::V1_0::IBase::descriptor) == castTo) {
- return true;
- }
-
- bool canCast = false;
- auto chainRet = interface->interfaceChain([&](const hidl_vec<hidl_string> &types) {
- for (size_t i = 0; i < types.size(); i++) {
- if (types[i] == castTo) {
- canCast = true;
- break;
- }
- }
- });
-
- if (!chainRet.isOk()) {
- // call fails, propagate the error if emitError
- return emitError
- ? details::StatusOf<void, bool>(chainRet)
- : Return<bool>(false);
- }
-
- return canCast;
-}
-
-inline std::string getDescriptor(::android::hidl::base::V1_0::IBase* interface) {
- std::string myDescriptor{};
- auto ret = interface->interfaceDescriptor([&](const hidl_string &types) {
- myDescriptor = types.c_str();
- });
- ret.isOk(); // ignored, return empty string if not isOk()
- return myDescriptor;
-}
+std::string getDescriptor(::android::hidl::base::V1_0::IBase* interface);
} // namespace details
} // namespace hardware
diff --git a/transport/include/hidl/ServiceManagement.h b/transport/include/hidl/ServiceManagement.h
index 2b2266b..324a584 100644
--- a/transport/include/hidl/ServiceManagement.h
+++ b/transport/include/hidl/ServiceManagement.h
@@ -32,12 +32,6 @@
namespace hardware {
-// These functions are for internal use by hidl. If you want to get ahold
-// of an interface, the best way to do this is by calling IFoo::getService()
-
-sp<::android::hidl::manager::V1_0::IServiceManager> defaultServiceManager();
-sp<::android::hidl::manager::V1_0::IServiceManager> getPassthroughServiceManager();
-
namespace details {
// e.x.: android.hardware.foo@1.0, IFoo, default
void onRegistration(const std::string &packageName,
@@ -46,8 +40,26 @@
// e.x.: android.hardware.foo@1.0::IFoo, default
void waitForHwService(const std::string &interface, const std::string &instanceName);
+
+void preloadPassthroughService(const std::string &descriptor);
};
+// These functions are for internal use by hidl. If you want to get ahold
+// of an interface, the best way to do this is by calling IFoo::getService()
+sp<::android::hidl::manager::V1_0::IServiceManager> defaultServiceManager();
+sp<::android::hidl::manager::V1_0::IServiceManager> getPassthroughServiceManager();
+
+/**
+ * Given a service that is in passthrough mode, this function will go ahead and load the
+ * required passthrough module library (but not call HIDL_FETCH_I* functions to instantiate it).
+ *
+ * E.x.: preloadPassthroughService<IFoo>();
+ */
+template<typename I>
+static inline void preloadPassthroughService() {
+ details::preloadPassthroughService(I::descriptor);
+}
+
}; // namespace hardware
}; // namespace android
diff --git a/transport/manager/1.0/Android.bp b/transport/manager/1.0/Android.bp
index bb712e1..8bdbfa5 100644
--- a/transport/manager/1.0/Android.bp
+++ b/transport/manager/1.0/Android.bp
@@ -42,26 +42,4 @@
],
}
-cc_library_shared {
- name: "android.hidl.manager@1.0",
- generated_sources: ["android.hidl.manager@1.0_genc++"],
- generated_headers: ["android.hidl.manager@1.0_genc++_headers"],
- export_generated_headers: ["android.hidl.manager@1.0_genc++_headers"],
- vendor_available: true,
- shared_libs: [
- "libhidlbase",
- "libhidltransport",
- "libhwbinder",
- "liblog",
- "libutils",
- "libcutils",
- "android.hidl.base@1.0",
- ],
- export_shared_lib_headers: [
- "libhidlbase",
- "libhidltransport",
- "libhwbinder",
- "libutils",
- "android.hidl.base@1.0",
- ],
-}
+// android.hidl.manager@1.0 is exported from libhidltransport
diff --git a/transport/memory/1.0/Android.bp b/transport/memory/1.0/Android.bp
index bcd2321..ec9d0eb 100644
--- a/transport/memory/1.0/Android.bp
+++ b/transport/memory/1.0/Android.bp
@@ -56,13 +56,11 @@
"liblog",
"libutils",
"libcutils",
- "android.hidl.base@1.0",
],
export_shared_lib_headers: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"libutils",
- "android.hidl.base@1.0",
],
}
diff --git a/transport/memory/1.0/default/Android.bp b/transport/memory/1.0/default/Android.bp
index 3b1b7da..b0c601a 100644
--- a/transport/memory/1.0/default/Android.bp
+++ b/transport/memory/1.0/default/Android.bp
@@ -32,7 +32,6 @@
"libutils",
"libhidlbase",
"libhidltransport",
- "android.hidl.base@1.0",
"android.hidl.memory@1.0",
],
}
diff --git a/transport/token/1.0/Android.bp b/transport/token/1.0/Android.bp
index 75ff679..d5825c2 100644
--- a/transport/token/1.0/Android.bp
+++ b/transport/token/1.0/Android.bp
@@ -49,13 +49,11 @@
"liblog",
"libutils",
"libcutils",
- "android.hidl.base@1.0",
],
export_shared_lib_headers: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"libutils",
- "android.hidl.base@1.0",
],
}
diff --git a/transport/token/1.0/utils/Android.bp b/transport/token/1.0/utils/Android.bp
index 0360d99..ab77a2a 100644
--- a/transport/token/1.0/utils/Android.bp
+++ b/transport/token/1.0/utils/Android.bp
@@ -14,6 +14,7 @@
cc_library {
name: "android.hidl.token@1.0-utils",
+ vendor_available: true,
srcs: [
"HybridInterface.cpp",
diff --git a/update-makefiles.sh b/update-makefiles.sh
index 7f43031..e82d24c 100755
--- a/update-makefiles.sh
+++ b/update-makefiles.sh
@@ -1,11 +1,5 @@
#!/bin/bash
-# TODO(b/33276472)
-if [ ! -d system/libhidl/transport ] ; then
- echo "Where is system/libhidl/transport?";
- exit 1;
-fi
-
packages=(
android.hidl.allocator@1.0
android.hidl.base@1.0