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

Commit 9ee1333f authored by Andy Hung's avatar Andy Hung Committed by Automerger Merge Worker
Browse files

MediaMetrics: Suppress device names am: 74daafd4 am: f2bc0459

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

Change-Id: I5003ed6447301ac1319bd6401a6b6cc5b3bbc4c1
parents e9c17a7e f2bc0459
Loading
Loading
Loading
Loading
+7 −2
Original line number Original line Diff line number Diff line
@@ -43,7 +43,7 @@ namespace android::mediametrics {
#endif
#endif


// Maximum length of a device name.
// Maximum length of a device name.
static constexpr size_t STATSD_DEVICE_NAME_MAX_LENGTH = 32;
// static constexpr size_t STATSD_DEVICE_NAME_MAX_LENGTH = 32; // unused since we suppress


// Transmit Enums to statsd in integer or strings  (this must match the atoms.proto)
// Transmit Enums to statsd in integer or strings  (this must match the atoms.proto)
static constexpr bool STATSD_USE_INT_FOR_ENUM = false;
static constexpr bool STATSD_USE_INT_FOR_ENUM = false;
@@ -66,6 +66,8 @@ static constexpr const auto LOG_LEVEL = android::base::VERBOSE;


static constexpr int PREVIOUS_STATE_EXPIRE_SEC = 60 * 60; // 1 hour.
static constexpr int PREVIOUS_STATE_EXPIRE_SEC = 60 * 60; // 1 hour.


static constexpr const char * SUPPRESSED = "SUPPRESSED";

/*
/*
 * For logging purposes, we list all of the MediaMetrics atom fields,
 * For logging purposes, we list all of the MediaMetrics atom fields,
 * which can then be associated with consecutive arguments to the statsd write.
 * which can then be associated with consecutive arguments to the statsd write.
@@ -448,6 +450,8 @@ void AudioAnalytics::DeviceUse::endAudioIntervalGroup(
    std::string outputDeviceNames;
    std::string outputDeviceNames;
    if (outputDevices.find("AUDIO_DEVICE_OUT_BLUETOOTH") != std::string::npos) {
    if (outputDevices.find("AUDIO_DEVICE_OUT_BLUETOOTH") != std::string::npos) {
        isBluetooth = true;
        isBluetooth = true;
        outputDeviceNames = SUPPRESSED;
#if 0   // TODO(b/161554630) sanitize name
        mAudioAnalytics.mAnalyticsState->timeMachine().get(
        mAudioAnalytics.mAnalyticsState->timeMachine().get(
            "audio.device.bt_a2dp", AMEDIAMETRICS_PROP_NAME, &outputDeviceNames);
            "audio.device.bt_a2dp", AMEDIAMETRICS_PROP_NAME, &outputDeviceNames);
        // Remove | if present
        // Remove | if present
@@ -455,6 +459,7 @@ void AudioAnalytics::DeviceUse::endAudioIntervalGroup(
        if (outputDeviceNames.size() > STATSD_DEVICE_NAME_MAX_LENGTH) {
        if (outputDeviceNames.size() > STATSD_DEVICE_NAME_MAX_LENGTH) {
            outputDeviceNames.resize(STATSD_DEVICE_NAME_MAX_LENGTH); // truncate
            outputDeviceNames.resize(STATSD_DEVICE_NAME_MAX_LENGTH); // truncate
        }
        }
#endif
    }
    }


    switch (itemType) {
    switch (itemType) {
@@ -775,7 +780,7 @@ void AudioAnalytics::DeviceConnection::postBluetoothA2dpDeviceConnectionStateSup
        std::lock_guard l(mLock);
        std::lock_guard l(mLock);
        mA2dpConnectionRequestNs = atNs;
        mA2dpConnectionRequestNs = atNs;
        ++mA2dpConnectionRequests;
        ++mA2dpConnectionRequests;
        mA2dpDeviceName = name;
        mA2dpDeviceName = SUPPRESSED; // TODO(b/161554630) sanitize name
    }
    }
    ALOGD("(key=%s) a2dp connection name:%s request atNs:%lld",
    ALOGD("(key=%s) a2dp connection name:%s request atNs:%lld",
            key.c_str(), name.c_str(), (long long)atNs);
            key.c_str(), name.c_str(), (long long)atNs);