Make atrace not depend on /dev/hwbinder.
Bug: 31262344
Test: compiles
Change-Id: I2b4fa6815723507dd04afda19e99e5a15053dc66
diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp
index f4c6be2..5a34755 100644
--- a/cmds/atrace/atrace.cpp
+++ b/cmds/atrace/atrace.cpp
@@ -517,6 +517,12 @@
using ::android::hardware::hidl_string;
sp<IServiceManager> sm = ::android::hardware::defaultServiceManager();
+
+ if (sm == nullptr) {
+ fprintf(stderr, "failed to get IServiceManager to poke hal services\n");
+ return;
+ }
+
auto listRet = sm->list([&](const auto &interfaces) {
for (size_t i = 0; i < interfaces.size(); i++) {
string fqInstanceName = interfaces[i];