Loading cmds/atrace/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ cc_binary { "libz", "libbase", ], static_libs: [ "libpdx_default_transport", ], init_rc: ["atrace.rc"], Loading cmds/atrace/atrace.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ #include <hidl/ServiceManagement.h> #include <cutils/properties.h> #include <pdx/default_transport/service_utility.h> #include <utils/String8.h> #include <utils/Timers.h> #include <utils/Tokenizer.h> Loading @@ -48,6 +49,7 @@ #include <android-base/file.h> using namespace android; using pdx::default_transport::ServiceUtility; using std::string; #define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0]))) Loading Loading @@ -814,6 +816,7 @@ static bool setUpTrace() ok &= setAppCmdlineProperty(&packageList[0]); ok &= pokeBinderServices(); pokeHalServices(); ok &= ServiceUtility::PokeServices(); // 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. Loading Loading @@ -851,6 +854,7 @@ static void cleanUpTrace() setTagsProperty(0); clearAppProperties(); pokeBinderServices(); ServiceUtility::PokeServices(); // Set the options back to their defaults. setTraceOverwriteEnable(true); Loading libs/vr/libpdx_default_transport/private/pdx/default_transport/service_utility.h +47 −1 Original line number Diff line number Diff line #ifndef ANDROID_PDX_DEFAULT_TRANSPORT_SERVICE_UTILITY_H_ #define ANDROID_PDX_DEFAULT_TRANSPORT_SERVICE_UTILITY_H_ #include <ftw.h> #include <pdx/client.h> #include <pdx/default_transport/client_channel_factory.h> #include <pdx/service.h> Loading @@ -25,15 +27,59 @@ class ServiceUtility : public ClientBase<ServiceUtility> { return ClientChannelFactory::GetEndpointPath(endpoint_path); } // Traverses the PDX service path space and sends a message to reload system // properties to each service endpoint it finds along the way. // NOTE: This method is used by atrace to poke PDX services. Please avoid // unnecessary changes to this mechanism to minimize impact on atrace. static bool PokeServices() { const int kMaxDepth = 16; const int result = nftw(GetRootEndpointPath().c_str(), PokeService, kMaxDepth, FTW_PHYS); return result == 0 ? true : false; } private: friend BASE; ServiceUtility(const std::string& endpoint_path, int* error = nullptr) : BASE(ClientChannelFactory::Create(endpoint_path)) { : BASE(ClientChannelFactory::Create(endpoint_path), 0) { if (error) *error = Client::error(); } // Sends the sysprop_change message to the service at fpath, so it re-reads // its system properties. Returns 0 on success or a negated errno code on // failure. // NOTE: This method is used by atrace to poke PDX services. Please avoid // unnecessary changes to this mechanism to minimize impact on atrace. static int PokeService(const char* fpath, const struct stat* /*sb*/, int typeflag, struct FTW* /*ftwbuf*/) { const bool kIgnoreErrors = true; if (typeflag == FTW_F) { int error; auto utility = ServiceUtility::Create(fpath, &error); if (!utility) { if (error != -ECONNREFUSED) { ALOGE("ServiceUtility::PokeService: Failed to open %s: %s.", fpath, strerror(-error)); } return kIgnoreErrors ? 0 : error; } auto status = utility->ReloadSystemProperties(); if (!status) { ALOGE( "ServiceUtility::PokeService: Failed to send sysprop change to %s: " "%s", fpath, status.GetErrorMessage().c_str()); return kIgnoreErrors ? 0 : -status.error(); } } return 0; } ServiceUtility(const ServiceUtility&) = delete; void operator=(const ServiceUtility&) = delete; }; Loading Loading
cmds/atrace/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ cc_binary { "libz", "libbase", ], static_libs: [ "libpdx_default_transport", ], init_rc: ["atrace.rc"], Loading
cmds/atrace/atrace.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ #include <hidl/ServiceManagement.h> #include <cutils/properties.h> #include <pdx/default_transport/service_utility.h> #include <utils/String8.h> #include <utils/Timers.h> #include <utils/Tokenizer.h> Loading @@ -48,6 +49,7 @@ #include <android-base/file.h> using namespace android; using pdx::default_transport::ServiceUtility; using std::string; #define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0]))) Loading Loading @@ -814,6 +816,7 @@ static bool setUpTrace() ok &= setAppCmdlineProperty(&packageList[0]); ok &= pokeBinderServices(); pokeHalServices(); ok &= ServiceUtility::PokeServices(); // 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. Loading Loading @@ -851,6 +854,7 @@ static void cleanUpTrace() setTagsProperty(0); clearAppProperties(); pokeBinderServices(); ServiceUtility::PokeServices(); // Set the options back to their defaults. setTraceOverwriteEnable(true); Loading
libs/vr/libpdx_default_transport/private/pdx/default_transport/service_utility.h +47 −1 Original line number Diff line number Diff line #ifndef ANDROID_PDX_DEFAULT_TRANSPORT_SERVICE_UTILITY_H_ #define ANDROID_PDX_DEFAULT_TRANSPORT_SERVICE_UTILITY_H_ #include <ftw.h> #include <pdx/client.h> #include <pdx/default_transport/client_channel_factory.h> #include <pdx/service.h> Loading @@ -25,15 +27,59 @@ class ServiceUtility : public ClientBase<ServiceUtility> { return ClientChannelFactory::GetEndpointPath(endpoint_path); } // Traverses the PDX service path space and sends a message to reload system // properties to each service endpoint it finds along the way. // NOTE: This method is used by atrace to poke PDX services. Please avoid // unnecessary changes to this mechanism to minimize impact on atrace. static bool PokeServices() { const int kMaxDepth = 16; const int result = nftw(GetRootEndpointPath().c_str(), PokeService, kMaxDepth, FTW_PHYS); return result == 0 ? true : false; } private: friend BASE; ServiceUtility(const std::string& endpoint_path, int* error = nullptr) : BASE(ClientChannelFactory::Create(endpoint_path)) { : BASE(ClientChannelFactory::Create(endpoint_path), 0) { if (error) *error = Client::error(); } // Sends the sysprop_change message to the service at fpath, so it re-reads // its system properties. Returns 0 on success or a negated errno code on // failure. // NOTE: This method is used by atrace to poke PDX services. Please avoid // unnecessary changes to this mechanism to minimize impact on atrace. static int PokeService(const char* fpath, const struct stat* /*sb*/, int typeflag, struct FTW* /*ftwbuf*/) { const bool kIgnoreErrors = true; if (typeflag == FTW_F) { int error; auto utility = ServiceUtility::Create(fpath, &error); if (!utility) { if (error != -ECONNREFUSED) { ALOGE("ServiceUtility::PokeService: Failed to open %s: %s.", fpath, strerror(-error)); } return kIgnoreErrors ? 0 : error; } auto status = utility->ReloadSystemProperties(); if (!status) { ALOGE( "ServiceUtility::PokeService: Failed to send sysprop change to %s: " "%s", fpath, status.GetErrorMessage().c_str()); return kIgnoreErrors ? 0 : -status.error(); } } return 0; } ServiceUtility(const ServiceUtility&) = delete; void operator=(const ServiceUtility&) = delete; }; Loading