diff options
| author | 2016-11-22 09:43:23 +0000 | |
|---|---|---|
| committer | 2016-11-22 09:43:23 +0000 | |
| commit | 1aea108920d43c774d227bf40dc2bc930b10cd47 (patch) | |
| tree | 8a13e7dc2bd4103e0429a74b0f11e339448f2d46 | |
| parent | 3749a60b42f756f93e19830b03d3cd2bde3fc8d2 (diff) | |
| parent | ee9b97e85d153309cd6d076c54eefef991ac846d (diff) | |
Merge "atrace: support HAL services as well."
| -rw-r--r-- | cmds/atrace/Android.bp | 4 | ||||
| -rw-r--r-- | cmds/atrace/atrace.cpp | 33 |
2 files changed, 37 insertions, 0 deletions
diff --git a/cmds/atrace/Android.bp b/cmds/atrace/Android.bp index 194a5650c9..69ed416388 100644 --- a/cmds/atrace/Android.bp +++ b/cmds/atrace/Android.bp @@ -6,6 +6,10 @@ cc_binary { shared_libs: [ "libbinder", + "libhwbinder", + "android.hidl.manager@1.0", + "libhidlbase", + "libhidltransport", "liblog", "libcutils", "libutils", diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp index 290d7a85a6..f6f337ca58 100644 --- a/cmds/atrace/atrace.cpp +++ b/cmds/atrace/atrace.cpp @@ -37,6 +37,8 @@ #include <binder/IServiceManager.h> #include <binder/Parcel.h> +#include <android/hidl/manager/1.0/IServiceManager.h> +#include <hidl/ServiceManagement.h> #include <cutils/properties.h> #include <utils/String8.h> @@ -47,6 +49,7 @@ using namespace android; +using std::string; #define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0]))) #define MAX_SYS_FILES 10 @@ -505,6 +508,35 @@ static bool pokeBinderServices() return true; } +// Poke all the HAL processes in the system to get them to re-read +// their system properties. +static void pokeHalServices() +{ + using ::android::hidl::manager::V1_0::IServiceManager; + using ::android::hardware::IBinder; + using ::android::hardware::hidl_string; + using ::android::hardware::Parcel; + + Parcel data; + + sp<IServiceManager> sm = ::android::hardware::defaultServiceManager(); + sm->list([&](const auto &interfaces) { + for (size_t i = 0; i < interfaces.size(); i++) { + string fqInstanceName = interfaces[i]; + string::size_type n = fqInstanceName.find("/"); + if (n == std::string::npos || interfaces[i].size() == n+1) + continue; + hidl_string fqInterfaceName = fqInstanceName.substr(0, n); + hidl_string instanceName = fqInstanceName.substr(n+1, std::string::npos); + sm->get(fqInterfaceName, instanceName, [&](const auto &interface) { + // TODO(b/32756130) + // Once IServiceManager returns IBase, use interface->notifySyspropsChanged() here + interface->transact(IBinder::SYSPROPS_TRANSACTION, data, nullptr, 0, nullptr); + }); + } + }); +} + // Set the trace tags that userland tracing uses, and poke the running // processes to pick up the new value. static bool setTagsProperty(uint64_t tags) @@ -747,6 +779,7 @@ static bool setUpTrace() } ok &= setAppCmdlineProperty(&packageList[0]); ok &= pokeBinderServices(); + pokeHalServices(); // Disable all the sysfs enables. This is done as a separate loop from // the enables to allow the same enable to exist in multiple categories. |