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

Commit e898b05e authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Push new codec values to statsd" into rvc-dev am: de38ff80 am:...

Merge "Merge "Push new codec values to statsd" into rvc-dev am: de38ff80 am: 20a0c405 am: 858b7747" into rvc-qpr-dev-plus-aosp
parents 6db2406d a304200f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ cc_library_shared {
        "AudioAnalytics.cpp",
        "AudioPowerUsage.cpp",
        "AudioTypes.cpp",
        "cleaner.cpp",
        "iface_statsd.cpp",
        "MediaMetricsService.cpp",
        "statsd_audiopolicy.cpp",
+49 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

//#define LOG_NDEBUG 0
#define LOG_TAG "MetricsCleaner"
#include <utils/Log.h>

#include "cleaner.h"

namespace android::mediametrics {

// place time into buckets at 0,1,2,4,8,16,32 seconds and then at minute boundaries.
// time is rounded up to the next boundary.
//
int64_t bucket_time_minutes(int64_t in_millis) {

    const int64_t SEC_TO_MS = 1000;
    const int64_t MIN_TO_MS = (60 * SEC_TO_MS);

    if (in_millis <= 0) {
        return 0;
    }
    if (in_millis <= 32 * SEC_TO_MS) {
        for (int sec = 1; sec <= 32; sec *= 2) {
            if (in_millis <= sec * SEC_TO_MS) {
                return sec * SEC_TO_MS;
            }
        }
    }
    /* up to next 1 minute boundary */
    int64_t minutes = (in_millis + MIN_TO_MS - 1) / MIN_TO_MS;
    in_millis = minutes * MIN_TO_MS;
    return in_millis;
}

} // namespace android::mediametrics
+29 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef MEDIAMETRICS_CLEANER_H
#define MEDIAMETRICS_CLEANER_H

namespace android::mediametrics {

// break time into buckets at 1,2,4,8,16,32 seconds
// and then at minute boundaries
//
extern int64_t bucket_time_minutes(int64_t incomingMs);

} // namespace android::mediametrics

#endif  // MEDIAMETRICS_CLEANER_H
+2 −6
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@

#include <statslog.h>

#include "cleaner.h"
#include "MediaMetricsService.h"
#include "frameworks/base/core/proto/android/stats/mediametrics/mediametrics.pb.h"
#include "iface_statsd.h"
@@ -168,11 +169,6 @@ bool statsd_codec(const mediametrics::Item *item)
    }
    // android.media.mediacodec.latency.hist    NOT EMITTED

#if 0
    // TODO(b/139143194)
    // can't send them to statsd until statsd proto updates merge
    // but in the meantime, they can appear in local 'dumpsys media.metrics' output
    //
    // android.media.mediacodec.bitrate_mode string
    std::string bitrate_mode;
    if (item->getString("android.media.mediacodec.bitrate_mode", &bitrate_mode)) {
@@ -186,9 +182,9 @@ bool statsd_codec(const mediametrics::Item *item)
    // android.media.mediacodec.lifetimeMs int64
    int64_t lifetimeMs = -1;
    if ( item->getInt64("android.media.mediacodec.lifetimeMs", &lifetimeMs)) {
        lifetimeMs = mediametrics::bucket_time_minutes(lifetimeMs);
        metrics_proto.set_lifetime_millis(lifetimeMs);
    }
#endif

    std::string serialized;
    if (!metrics_proto.SerializeToString(&serialized)) {