Update aaudio metrics.
1) Remove caller name as it is not required.
2) Use 0 as the first value for unknown value, which is the default
value.
3) Add content type and sample rate.
Bug: 183154959
Test: adb shell dumpsys media.metrics
Change-Id: I710101ed0b68fc8f635346e6b480a4d72d83be55
diff --git a/services/mediametrics/AudioAnalytics.cpp b/services/mediametrics/AudioAnalytics.cpp
index 4ef87e4..ca918a9 100644
--- a/services/mediametrics/AudioAnalytics.cpp
+++ b/services/mediametrics/AudioAnalytics.cpp
@@ -140,7 +140,6 @@
static constexpr const char * const AAudioStreamFields[] {
"mediametrics_aaudiostream_reported",
- "caller_name",
"path",
"direction",
"frames_per_burst",
@@ -156,6 +155,8 @@
"format_app",
"format_device",
"log_session_id",
+ "sample_rate",
+ "content_type",
};
/**
@@ -932,12 +933,6 @@
const std::shared_ptr<const android::mediametrics::Item> &item, CallerPath path) const {
const std::string& key = item->getKey();
- std::string callerNameStr;
- mAudioAnalytics.mAnalyticsState->timeMachine().get(
- key, AMEDIAMETRICS_PROP_CALLERNAME, &callerNameStr);
-
- const auto callerName = types::lookup<types::CALLER_NAME, int32_t>(callerNameStr);
-
std::string directionStr;
mAudioAnalytics.mAnalyticsState->timeMachine().get(
key, AMEDIAMETRICS_PROP_DIRECTION, &directionStr);
@@ -994,8 +989,16 @@
std::string logSessionId;
// TODO: log logSessionId
+ int32_t sampleRate = 0;
+ mAudioAnalytics.mAnalyticsState->timeMachine().get(
+ key, AMEDIAMETRICS_PROP_SAMPLERATE, &sampleRate);
+
+ std::string contentTypeStr;
+ mAudioAnalytics.mAnalyticsState->timeMachine().get(
+ key, AMEDIAMETRICS_PROP_CONTENTTYPE, &contentTypeStr);
+ const auto contentType = types::lookup<types::CONTENT_TYPE, int32_t>(contentTypeStr);
+
LOG(LOG_LEVEL) << "key:" << key
- << " caller_name:" << callerName << "(" << callerNameStr << ")"
<< " path:" << path
<< " direction:" << direction << "(" << directionStr << ")"
<< " frames_per_burst:" << framesPerBurst
@@ -1010,14 +1013,15 @@
<< " device_type:" << serializedDeviceTypes
<< " format_app:" << formatApp
<< " format_device: " << formatDevice << "(" << formatDeviceStr << ")"
- << " log_session_id: " << logSessionId;
+ << " log_session_id: " << logSessionId
+ << " sample_rate: " << sampleRate
+ << " content_type: " << contentType << "(" << contentTypeStr << ")";
if (mAudioAnalytics.mDeliverStatistics) {
android::util::BytesField bf_serialized(
serializedDeviceTypes.c_str(), serializedDeviceTypes.size());
const auto result = sendToStatsd(
CONDITION(android::util::MEDIAMETRICS_AAUDIOSTREAM_REPORTED)
- , callerName
, path
, direction
, framesPerBurst
@@ -1033,12 +1037,13 @@
, formatApp
, formatDevice
, logSessionId.c_str()
+ , sampleRate
+ , contentType
);
std::stringstream ss;
ss << "result:" << result;
const auto fieldsStr = printFields(AAudioStreamFields,
CONDITION(android::util::MEDIAMETRICS_AAUDIOSTREAM_REPORTED)
- , callerName
, path
, direction
, framesPerBurst
@@ -1054,6 +1059,8 @@
, formatApp
, formatDevice
, logSessionId.c_str()
+ , sampleRate
+ , contentType
);
ss << " " << fieldsStr;
std::string str = ss.str();
diff --git a/services/mediametrics/AudioTypes.cpp b/services/mediametrics/AudioTypes.cpp
index 44e96ec..1756c98 100644
--- a/services/mediametrics/AudioTypes.cpp
+++ b/services/mediametrics/AudioTypes.cpp
@@ -158,9 +158,9 @@
// DO NOT MODIFY VALUES(OK to add new ones).
// This may be found in frameworks/av/media/libaaudio/include/aaudio/AAudio.h
static std::unordered_map<std::string, int32_t> map {
- // UNKNOWN is -1
- {"AAUDIO_DIRECTION_OUTPUT", 0},
- {"AAUDIO_DIRECTION_INPUT", 1},
+ // UNKNOWN is 0
+ {"AAUDIO_DIRECTION_OUTPUT", 1 /* AAUDIO_DIRECTION_OUTPUT + 1 */},
+ {"AAUDIO_DIRECTION_INPUT", 2 /* AAUDIO_DIRECTION_INPUT + 1*/},
};
return map;
}
@@ -169,7 +169,7 @@
// DO NOT MODIFY VALUES(OK to add new ones).
// This may be found in frameworks/av/media/libaaudio/include/aaudio/AAudio.h
static std::unordered_map<std::string, int32_t> map {
- // UNKNOWN is -1
+ // UNKNOWN is 0
{"AAUDIO_PERFORMANCE_MODE_NONE", 10},
{"AAUDIO_PERFORMANCE_MODE_POWER_SAVING", 11},
{"AAUDIO_PERFORMANCE_MODE_LOW_LATENCY", 12},
@@ -181,9 +181,9 @@
// DO NOT MODIFY VALUES(OK to add new ones).
// This may be found in frameworks/av/media/libaaudio/include/aaudio/AAudio.h
static std::unordered_map<std::string, int32_t> map {
- // UNKNOWN is -1
- {"AAUDIO_SHARING_MODE_EXCLUSIVE", 0},
- {"AAUDIO_SHARING_MODE_SHARED", 1},
+ // UNKNOWN is 0
+ {"AAUDIO_SHARING_MODE_EXCLUSIVE", 1 /* AAUDIO_SHARING_MODE_EXCLUSIVE + 1 */},
+ {"AAUDIO_SHARING_MODE_SHARED", 2 /* AAUDIO_SHARING_MODE_SHARED + 1 */},
};
return map;
}
@@ -484,7 +484,7 @@
auto& map = getAAudioDirection();
auto it = map.find(direction);
if (it == map.end()) {
- return -1; // return unknown
+ return 0; // return unknown
}
return it->second;
}
@@ -506,7 +506,7 @@
auto& map = getAAudioPerformanceMode();
auto it = map.find(performanceMode);
if (it == map.end()) {
- return -1; // return unknown
+ return 0; // return unknown
}
return it->second;
}
@@ -528,7 +528,7 @@
auto& map = getAAudioSharingMode();
auto it = map.find(sharingMode);
if (it == map.end()) {
- return -1; // return unknown
+ return 0; // return unknown
}
return it->second;
}