Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 380d6781 authored by Android Build Merger (Role)'s avatar Android Build Merger (Role) Committed by Android (Google) Code Review
Browse files

Merge "Merge "statsd: Pass alert and config id to Perfetto" into pi-dev am:...

Merge "Merge "statsd: Pass alert and config id to Perfetto" into pi-dev am: 66cb4e28" into pi-dev-plus-aosp
parents 0bb7fbe7 b6456c21
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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:
+14 −2
Original line number Diff line number Diff line
@@ -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
@@ -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>
@@ -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()) {
@@ -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)) {
@@ -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.
+4 −1
Original line number Diff line number Diff line
@@ -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