Add dumpsys support for apexd.
Include active apex packages in the dump.
Bug: 119843077
Bug: 120222424
Test: (build and flash to device) adb shell dumpsys apexservice
Change-Id: I6de62b7367a2be4c7f198988c605731f60e7c46f
diff --git a/apexd/apexservice.cpp b/apexd/apexservice.cpp
index 5e9676a..4ea5c4a 100644
--- a/apexd/apexservice.cpp
+++ b/apexd/apexservice.cpp
@@ -64,6 +64,7 @@
BinderStatus getActivePackages(std::vector<ApexInfo>* aidl_return) override;
BinderStatus getActivePackage(const std::string& packageName,
ApexInfo* aidl_return) override;
+ status_t dump(int fd, const Vector<String16>& args) override;
// Override onTransact so we can handle shellCommand.
status_t onTransact(uint32_t _aidl_code, const Parcel& _aidl_data,
@@ -276,6 +277,25 @@
return BnApexService::onTransact(_aidl_code, _aidl_data, _aidl_reply,
_aidl_flags);
}
+status_t ApexService::dump(int fd, const Vector<String16>& args) {
+ // TODO: Extend to add session info
+ std::vector<ApexInfo> list;
+ BinderStatus status = getActivePackages(&list);
+ if (status.isOk()) {
+ for (const auto& item : list) {
+ std::string msg = StringLog()
+ << "Package: " << item.packageName
+ << " Version: " << item.versionCode
+ << " Path: " << item.packagePath << std::endl;
+ dprintf(fd, "%s", msg.c_str());
+ }
+ return OK;
+ }
+ std::string msg = StringLog() << "Failed to retrieve packages: "
+ << status.toString8().string() << std::endl;
+ dprintf(fd, "%s", msg.c_str());
+ return BAD_VALUE;
+}
status_t ApexService::shellCommand(int in, int out, int err,
const Vector<String16>& args) {