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

Commit 255f72e7 authored by yro's avatar yro
Browse files

Return when invalid config ID was provided through adb command and

change the separator of config_uid and config_id to underscore from dash
to disambiguate negative config ids

Bug: 73896814
Test: statsd_test
Change-Id: Ib0604e9f4c104560d570a64208a9e94d7526f8d6
parent 4e056c8b
Loading
Loading
Loading
Loading
+8 −1
Original line number Original line Diff line number Diff line
@@ -423,6 +423,13 @@ status_t StatsService::cmd_config(FILE* in, FILE* out, FILE* err, Vector<String8
            }
            }


            if (args[1] == "update") {
            if (args[1] == "update") {
                char* endp;
                int64_t configID = strtoll(name.c_str(), &endp, 10);
                if (endp == name.c_str() || *endp != '\0') {
                    fprintf(err, "Error parsing config ID.\n");
                    return UNKNOWN_ERROR;
                }

                // Read stream into buffer.
                // Read stream into buffer.
                string buffer;
                string buffer;
                if (!android::base::ReadFdToString(fileno(in), &buffer)) {
                if (!android::base::ReadFdToString(fileno(in), &buffer)) {
@@ -438,7 +445,7 @@ status_t StatsService::cmd_config(FILE* in, FILE* out, FILE* err, Vector<String8
                }
                }


                // Add / update the config.
                // Add / update the config.
                mConfigManager->UpdateConfig(ConfigKey(uid, StrToInt64(name)), config);
                mConfigManager->UpdateConfig(ConfigKey(uid, configID), config);
            } else {
            } else {
                if (argCount == 2) {
                if (argCount == 2) {
                    cmd_remove_all_configs(out);
                    cmd_remove_all_configs(out);
+2 −2
Original line number Original line Diff line number Diff line
@@ -367,7 +367,7 @@ void StatsdStats::dumpStats(FILE* out) const {
    fprintf(out, "%lu Config in icebox: \n", (unsigned long)mIceBox.size());
    fprintf(out, "%lu Config in icebox: \n", (unsigned long)mIceBox.size());
    for (const auto& configStats : mIceBox) {
    for (const auto& configStats : mIceBox) {
        fprintf(out,
        fprintf(out,
                "Config {%d-%lld}: creation=%d, deletion=%d, #metric=%d, #condition=%d, "
                "Config {%d_%lld}: creation=%d, deletion=%d, #metric=%d, #condition=%d, "
                "#matcher=%d, #alert=%d,  valid=%d\n",
                "#matcher=%d, #alert=%d,  valid=%d\n",
                configStats.uid(), (long long)configStats.id(), configStats.creation_time_sec(),
                configStats.uid(), (long long)configStats.id(), configStats.creation_time_sec(),
                configStats.deletion_time_sec(), configStats.metric_count(),
                configStats.deletion_time_sec(), configStats.metric_count(),