Filter lshal-reported HALs using CL arguments
Currently, lshal reports all available HALs (under 3 labels: binderized
services, passthrough clients, and passthrough libraries). This change
allows users to restrict the command's output to one or more of these
associations.
Bug: 68653063
Test: Manually tested lshal with/without the --types flag, and with
various permutations of the HAL types. Ensured that --debug and --neat
are still functional.
Change-Id: Idcd22746f8ec3f0d4d5d981a84400f2683a1272a
diff --git a/cmds/lshal/ListCommand.h b/cmds/lshal/ListCommand.h
index 88faac1..c35561d 100644
--- a/cmds/lshal/ListCommand.h
+++ b/cmds/lshal/ListCommand.h
@@ -46,6 +46,12 @@
uint32_t threadCount; // number of threads total
};
+enum class HalType {
+ BINDERIZED_SERVICES = 0,
+ PASSTHROUGH_CLIENTS,
+ PASSTHROUGH_LIBRARIES
+};
+
class ListCommand : public Command {
public:
ListCommand(Lshal &lshal) : Command(lshal) {}
@@ -128,6 +134,9 @@
bool addEntryWithInstance(const TableEntry &entry, vintf::HalManifest *manifest) const;
bool addEntryWithoutInstance(const TableEntry &entry, const vintf::HalManifest *manifest) const;
+ // Helper function. Whether to list entries corresponding to a given HAL type.
+ bool shouldReportHalType(const HalType &type) const;
+
Table mServicesTable{};
Table mPassthroughRefTable{};
Table mImplementationsTable{};
@@ -144,6 +153,10 @@
// If true, explanatory text are not emitted.
bool mNeat = false;
+ // Type(s) of HAL associations to list. By default, report all.
+ std::vector<HalType> mListTypes{HalType::BINDERIZED_SERVICES, HalType::PASSTHROUGH_CLIENTS,
+ HalType::PASSTHROUGH_LIBRARIES};
+
// If an entry does not exist, need to ask /proc/{pid}/cmdline to get it.
// If an entry exist but is an empty string, process might have died.
// If an entry exist and not empty, it contains the cached content of /proc/{pid}/cmdline.