Loading cmds/statsd/src/anomaly/subscriber_util.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -55,8 +55,9 @@ void triggerSubscribers(const int64_t rule_id, } break; case Subscription::SubscriberInformationCase::kPerfettoDetails: if (!CollectPerfettoTraceAndUploadToDropbox(subscription.perfetto_details())) { ALOGW("Failed to generate prefetto traces."); if (!CollectPerfettoTraceAndUploadToDropbox(subscription.perfetto_details(), rule_id, configKey)) { ALOGW("Failed to generate perfetto traces."); } break; case Subscription::SubscriberInformationCase::kBroadcastSubscriberDetails: Loading cmds/statsd/src/external/Perfetto.cpp +14 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #define DEBUG false // STOPSHIP if true #include "config/ConfigKey.h" #include "Log.h" #include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" // Alert Loading @@ -22,6 +23,7 @@ #include <android-base/unique_fd.h> #include <errno.h> #include <fcntl.h> #include <inttypes.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> Loading @@ -36,7 +38,9 @@ namespace android { namespace os { namespace statsd { bool CollectPerfettoTraceAndUploadToDropbox(const PerfettoDetails& config) { bool CollectPerfettoTraceAndUploadToDropbox(const PerfettoDetails& config, int64_t alert_id, const ConfigKey& configKey) { VLOG("Starting trace collection through perfetto"); if (!config.has_trace_config()) { Loading @@ -44,6 +48,13 @@ bool CollectPerfettoTraceAndUploadToDropbox(const PerfettoDetails& config) { return false; } char alertId[20]; char configId[20]; char configUid[20]; snprintf(alertId, sizeof(alertId), "%" PRId64, alert_id); snprintf(configId, sizeof(configId), "%" PRId64, configKey.GetId()); snprintf(configUid, sizeof(configUid), "%d", configKey.GetUid()); android::base::unique_fd readPipe; android::base::unique_fd writePipe; if (!android::base::Pipe(&readPipe, &writePipe)) { Loading Loading @@ -82,7 +93,8 @@ bool CollectPerfettoTraceAndUploadToDropbox(const PerfettoDetails& config) { } execl("/system/bin/perfetto", "perfetto", "--background", "--config", "-", "--dropbox", kDropboxTag, nullptr); kDropboxTag, "--alert-id", alertId, "--config-id", configId, "--config-uid", configUid, nullptr); // execl() doesn't return in case of success, if we get here something // failed. Loading cmds/statsd/src/external/Perfetto.h +4 −1 Original line number Diff line number Diff line Loading @@ -24,13 +24,16 @@ namespace android { namespace os { namespace statsd { class ConfigKey; class PerfettoDetails; // Declared in statsd_config.pb.h // Starts the collection of a Perfetto trace with the given |config|. // The trace is uploaded to Dropbox by the perfetto cmdline util once done. // This method returns immediately after passing the config and does NOT wait // for the full duration of the trace. bool CollectPerfettoTraceAndUploadToDropbox(const PerfettoDetails& config); bool CollectPerfettoTraceAndUploadToDropbox(const PerfettoDetails& config, int64_t alert_id, const ConfigKey& configKey); } // namespace statsd } // namespace os Loading Loading
cmds/statsd/src/anomaly/subscriber_util.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -55,8 +55,9 @@ void triggerSubscribers(const int64_t rule_id, } break; case Subscription::SubscriberInformationCase::kPerfettoDetails: if (!CollectPerfettoTraceAndUploadToDropbox(subscription.perfetto_details())) { ALOGW("Failed to generate prefetto traces."); if (!CollectPerfettoTraceAndUploadToDropbox(subscription.perfetto_details(), rule_id, configKey)) { ALOGW("Failed to generate perfetto traces."); } break; case Subscription::SubscriberInformationCase::kBroadcastSubscriberDetails: Loading
cmds/statsd/src/external/Perfetto.cpp +14 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #define DEBUG false // STOPSHIP if true #include "config/ConfigKey.h" #include "Log.h" #include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" // Alert Loading @@ -22,6 +23,7 @@ #include <android-base/unique_fd.h> #include <errno.h> #include <fcntl.h> #include <inttypes.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> Loading @@ -36,7 +38,9 @@ namespace android { namespace os { namespace statsd { bool CollectPerfettoTraceAndUploadToDropbox(const PerfettoDetails& config) { bool CollectPerfettoTraceAndUploadToDropbox(const PerfettoDetails& config, int64_t alert_id, const ConfigKey& configKey) { VLOG("Starting trace collection through perfetto"); if (!config.has_trace_config()) { Loading @@ -44,6 +48,13 @@ bool CollectPerfettoTraceAndUploadToDropbox(const PerfettoDetails& config) { return false; } char alertId[20]; char configId[20]; char configUid[20]; snprintf(alertId, sizeof(alertId), "%" PRId64, alert_id); snprintf(configId, sizeof(configId), "%" PRId64, configKey.GetId()); snprintf(configUid, sizeof(configUid), "%d", configKey.GetUid()); android::base::unique_fd readPipe; android::base::unique_fd writePipe; if (!android::base::Pipe(&readPipe, &writePipe)) { Loading Loading @@ -82,7 +93,8 @@ bool CollectPerfettoTraceAndUploadToDropbox(const PerfettoDetails& config) { } execl("/system/bin/perfetto", "perfetto", "--background", "--config", "-", "--dropbox", kDropboxTag, nullptr); kDropboxTag, "--alert-id", alertId, "--config-id", configId, "--config-uid", configUid, nullptr); // execl() doesn't return in case of success, if we get here something // failed. Loading
cmds/statsd/src/external/Perfetto.h +4 −1 Original line number Diff line number Diff line Loading @@ -24,13 +24,16 @@ namespace android { namespace os { namespace statsd { class ConfigKey; class PerfettoDetails; // Declared in statsd_config.pb.h // Starts the collection of a Perfetto trace with the given |config|. // The trace is uploaded to Dropbox by the perfetto cmdline util once done. // This method returns immediately after passing the config and does NOT wait // for the full duration of the trace. bool CollectPerfettoTraceAndUploadToDropbox(const PerfettoDetails& config); bool CollectPerfettoTraceAndUploadToDropbox(const PerfettoDetails& config, int64_t alert_id, const ConfigKey& configKey); } // namespace statsd } // namespace os Loading