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

Commit 20a0c405 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

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

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/av/+/11832445

Change-Id: Ia5e3775d66a522dba27f09e2308e68a9ee5e75cd
parents 737f907d de38ff80
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -121,6 +121,7 @@ cc_library_shared {
        "AudioAnalytics.cpp",
        "AudioAnalytics.cpp",
        "AudioPowerUsage.cpp",
        "AudioPowerUsage.cpp",
        "AudioTypes.cpp",
        "AudioTypes.cpp",
        "cleaner.cpp",
        "iface_statsd.cpp",
        "iface_statsd.cpp",
        "MediaMetricsService.cpp",
        "MediaMetricsService.cpp",
        "statsd_audiopolicy.cpp",
        "statsd_audiopolicy.cpp",
+49 −0
Original line number Original line 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 Original line 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 Original line Diff line number Diff line
@@ -31,6 +31,7 @@


#include <statslog.h>
#include <statslog.h>


#include "cleaner.h"
#include "MediaMetricsService.h"
#include "MediaMetricsService.h"
#include "frameworks/base/core/proto/android/stats/mediametrics/mediametrics.pb.h"
#include "frameworks/base/core/proto/android/stats/mediametrics/mediametrics.pb.h"
#include "iface_statsd.h"
#include "iface_statsd.h"
@@ -168,11 +169,6 @@ bool statsd_codec(const mediametrics::Item *item)
    }
    }
    // android.media.mediacodec.latency.hist    NOT EMITTED
    // 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
    // android.media.mediacodec.bitrate_mode string
    std::string bitrate_mode;
    std::string bitrate_mode;
    if (item->getString("android.media.mediacodec.bitrate_mode", &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
    // android.media.mediacodec.lifetimeMs int64
    int64_t lifetimeMs = -1;
    int64_t lifetimeMs = -1;
    if ( item->getInt64("android.media.mediacodec.lifetimeMs", &lifetimeMs)) {
    if ( item->getInt64("android.media.mediacodec.lifetimeMs", &lifetimeMs)) {
        lifetimeMs = mediametrics::bucket_time_minutes(lifetimeMs);
        metrics_proto.set_lifetime_millis(lifetimeMs);
        metrics_proto.set_lifetime_millis(lifetimeMs);
    }
    }
#endif


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