Update for providing architecture info
to IBase::getDebugInfo() and IServiceManager::debugDump().
Moved PassthroughServiceManager::list to debugDump() because
it need to provide 32-bit libraries as well, which doesn't
meet the contract of list().
Bug: 35803184
Test: lshal -itrpc
Change-Id: I18374188ae6a33ba498ece5cddd92b48526f5f44
diff --git a/base/include/hidl/HidlInternal.h b/base/include/hidl/HidlInternal.h
index 80543c0..c0250fb 100644
--- a/base/include/hidl/HidlInternal.h
+++ b/base/include/hidl/HidlInternal.h
@@ -97,14 +97,21 @@
};
};
+#define HAL_LIBRARY_PATH_SYSTEM_64BIT "/system/lib64/hw/"
+#define HAL_LIBRARY_PATH_VENDOR_64BIT "/vendor/lib64/hw/"
+#define HAL_LIBRARY_PATH_ODM_64BIT "/odm/lib64/hw/"
+#define HAL_LIBRARY_PATH_SYSTEM_32BIT "/system/lib/hw/"
+#define HAL_LIBRARY_PATH_VENDOR_32BIT "/vendor/lib/hw/"
+#define HAL_LIBRARY_PATH_ODM_32BIT "/odm/lib/hw/"
+
#if defined(__LP64__)
-#define HAL_LIBRARY_PATH_SYSTEM "/system/lib64/hw/"
-#define HAL_LIBRARY_PATH_VENDOR "/vendor/lib64/hw/"
-#define HAL_LIBRARY_PATH_ODM "/odm/lib64/hw/"
+#define HAL_LIBRARY_PATH_SYSTEM HAL_LIBRARY_PATH_SYSTEM_64BIT
+#define HAL_LIBRARY_PATH_VENDOR HAL_LIBRARY_PATH_VENDOR_64BIT
+#define HAL_LIBRARY_PATH_ODM HAL_LIBRARY_PATH_ODM_64BIT
#else
-#define HAL_LIBRARY_PATH_SYSTEM "/system/lib/hw/"
-#define HAL_LIBRARY_PATH_VENDOR "/vendor/lib/hw/"
-#define HAL_LIBRARY_PATH_ODM "/odm/lib/hw/"
+#define HAL_LIBRARY_PATH_SYSTEM HAL_LIBRARY_PATH_SYSTEM_32BIT
+#define HAL_LIBRARY_PATH_VENDOR HAL_LIBRARY_PATH_VENDOR_32BIT
+#define HAL_LIBRARY_PATH_ODM HAL_LIBRARY_PATH_ODM_32BIT
#endif
// ----------------------------------------------------------------------
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp
index 387b161..a1e570f 100644
--- a/transport/ServiceManagement.cpp
+++ b/transport/ServiceManagement.cpp
@@ -193,20 +193,8 @@
return false;
}
- Return<void> list(list_cb _hidl_cb) override {
- std::vector<hidl_string> vec;
- for (const std::string &path : {
- HAL_LIBRARY_PATH_ODM, HAL_LIBRARY_PATH_VENDOR, HAL_LIBRARY_PATH_SYSTEM
- }) {
- std::vector<std::string> libs = search(path, "", ".so");
- for (const std::string &lib : libs) {
- std::string matchedName;
- if (matchPackageName(lib, &matchedName)) {
- vec.push_back(matchedName + "/*");
- }
- }
- }
- _hidl_cb(vec);
+ Return<void> list(list_cb /* _hidl_cb */) override {
+ LOG(FATAL) << "Cannot list services with passthrough service manager.";
return Void();
}
Return<void> listByInterface(const hidl_string& /* fqInstanceName */,
@@ -224,10 +212,35 @@
return false;
}
- Return<void> debugDump(debugDump_cb) override {
- // This makes no sense.
- LOG(FATAL) << "Cannot call debugDump on passthrough service manager."
- << "Call it on defaultServiceManager() instead.";
+ Return<void> debugDump(debugDump_cb _hidl_cb) override {
+ using Arch = ::android::hidl::base::V1_0::DebugInfo::Architecture;
+ static std::vector<std::pair<Arch, std::vector<const char *>>> sAllPaths{
+ {Arch::IS_64BIT, {HAL_LIBRARY_PATH_ODM_64BIT,
+ HAL_LIBRARY_PATH_VENDOR_64BIT,
+ HAL_LIBRARY_PATH_SYSTEM_64BIT}},
+ {Arch::IS_32BIT, {HAL_LIBRARY_PATH_ODM_32BIT,
+ HAL_LIBRARY_PATH_VENDOR_32BIT,
+ HAL_LIBRARY_PATH_SYSTEM_32BIT}}
+ };
+ std::vector<InstanceDebugInfo> vec;
+ 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
+ });
+ }
+ }
+ }
+ }
+ _hidl_cb(vec);
return Void();
}
diff --git a/transport/base/1.0/types.hal b/transport/base/1.0/types.hal
index 0f225d2..727c65a 100644
--- a/transport/base/1.0/types.hal
+++ b/transport/base/1.0/types.hal
@@ -19,8 +19,18 @@
/*
* The returned object for getDebugInfo.
* pid: pid of current process. -1 if not available.
+ * ptr: address of this object
+ * arch: 64bit or 32bit
*/
struct DebugInfo {
+
+ enum Architecture : int32_t {
+ UNKNOWN = 0,
+ IS_64BIT,
+ IS_32BIT,
+ };
+
int32_t pid;
uint64_t ptr;
+ Architecture arch;
};
diff --git a/transport/manager/1.0/IServiceManager.hal b/transport/manager/1.0/IServiceManager.hal
index 3b292a4..2bbbe22 100644
--- a/transport/manager/1.0/IServiceManager.hal
+++ b/transport/manager/1.0/IServiceManager.hal
@@ -17,6 +17,7 @@
package android.hidl.manager@1.0;
import IServiceNotification;
+import android.hidl.base@1.0::DebugInfo.Architecture;
/**
* Manages all the hidl hals on a device.
@@ -108,20 +109,24 @@
IServiceNotification callback)
generates (bool success);
+ /**
+ * Returned object for debugDump().
+ */
struct InstanceDebugInfo {
string interfaceName;
string instanceName;
vec<int32_t> clientPids;
+ Architecture arch;
};
- /*
+ /**
* Similar to list, but contains more information for each instance.
* @return info a vector where each item contains debug information for each
* instance.
*/
debugDump() generates (vec<InstanceDebugInfo> info);
- /*
+ /**
* When the passthrough service manager returns a service via
* get(string, string), it must dispatch a registerPassthroughClient call
* to the binderized service manager to indicate which process has called