Recognize AIDL calls in TimeCheck
Bug: 309542478
Test: simulate timeout of HAL implementation
Test: dumpsys media.audio_flinger
Change-Id: I5de2c3d280acb1970af2a68f6bdd8270e1d41eb3
diff --git a/media/utils/MethodStatistics.cpp b/media/utils/MethodStatistics.cpp
index 086757b..80f0fc4 100644
--- a/media/utils/MethodStatistics.cpp
+++ b/media/utils/MethodStatistics.cpp
@@ -20,6 +20,8 @@
// Repository for MethodStatistics Objects
+// It's important to have the HAL class name defined with suffix "Hidl/Aidl" because
+// TimerThread::isRequestFromHal use this string to match binder call to/from hal.
std::shared_ptr<std::vector<std::string>>
getStatisticsClassesForModule(std::string_view moduleName) {
static const std::map<std::string, std::shared_ptr<std::vector<std::string>>,
@@ -34,6 +36,15 @@
"StreamOutHalHidl",
})
},
+ {
+ METHOD_STATISTICS_MODULE_NAME_AUDIO_AIDL,
+ std::shared_ptr<std::vector<std::string>>(
+ new std::vector<std::string>{
+ "DeviceHalAidl",
+ "EffectHalAidl",
+ "StreamHalAidl",
+ })
+ },
};
auto it = m.find(moduleName);
if (it == m.end()) return {};
@@ -61,6 +72,9 @@
addClassesToMap(
getStatisticsClassesForModule(METHOD_STATISTICS_MODULE_NAME_AUDIO_HIDL),
m);
+ addClassesToMap(
+ getStatisticsClassesForModule(METHOD_STATISTICS_MODULE_NAME_AUDIO_AIDL),
+ m);
return m;
}();
diff --git a/media/utils/TimerThread.cpp b/media/utils/TimerThread.cpp
index 3966103..25852e4 100644
--- a/media/utils/TimerThread.cpp
+++ b/media/utils/TimerThread.cpp
@@ -104,11 +104,16 @@
//
/* static */
bool TimerThread::isRequestFromHal(const std::shared_ptr<const Request>& request) {
- const size_t hidlPos = request->tag.asStringView().find("Hidl");
- if (hidlPos == std::string::npos) return false;
- // should be a separator afterwards Hidl which indicates the string was in the class.
- const size_t separatorPos = request->tag.asStringView().find("::", hidlPos);
- return separatorPos != std::string::npos;
+ for (const auto& s : {"Hidl", "Aidl"}) {
+ const auto& tagSV = request->tag.asStringView();
+ const size_t halStrPos = tagSV.find(s);
+ // should be a separator afterwards Hidl/Aidl which indicates the string was in the class.
+ if (halStrPos != std::string::npos && tagSV.find("::", halStrPos) != std::string::npos) {
+ return true;
+ }
+ }
+
+ return false;
}
struct TimerThread::SnapshotAnalysis TimerThread::getSnapshotAnalysis(size_t retiredCount) const {
diff --git a/media/utils/include/mediautils/MethodStatistics.h b/media/utils/include/mediautils/MethodStatistics.h
index c8b36d8..2543dfa 100644
--- a/media/utils/include/mediautils/MethodStatistics.h
+++ b/media/utils/include/mediautils/MethodStatistics.h
@@ -124,6 +124,7 @@
// Managed Statistics support.
// Supported Modules
#define METHOD_STATISTICS_MODULE_NAME_AUDIO_HIDL "AudioHidl"
+#define METHOD_STATISTICS_MODULE_NAME_AUDIO_AIDL "AudioAidl"
// Returns a vector of class names for the module, or a nullptr if module not found.
std::shared_ptr<std::vector<std::string>>
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 98b6c27..1479df2 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -859,12 +859,15 @@
dprintf(fd, "\nIEffect binder call profile:\n");
write(fd, timeCheckStats.c_str(), timeCheckStats.size());
- // Automatically fetch HIDL statistics.
- std::shared_ptr<std::vector<std::string>> hidlClassNames =
- mediautils::getStatisticsClassesForModule(
- METHOD_STATISTICS_MODULE_NAME_AUDIO_HIDL);
- if (hidlClassNames) {
- for (const auto& className : *hidlClassNames) {
+ // Automatically fetch HIDL or AIDL statistics.
+ const std::string_view halType = (mDevicesFactoryHal->getHalVersion().getType() ==
+ AudioHalVersionInfo::Type::HIDL)
+ ? METHOD_STATISTICS_MODULE_NAME_AUDIO_HIDL
+ : METHOD_STATISTICS_MODULE_NAME_AUDIO_AIDL;
+ const std::shared_ptr<std::vector<std::string>> halClassNames =
+ mediautils::getStatisticsClassesForModule(halType);
+ if (halClassNames) {
+ for (const auto& className : *halClassNames) {
auto stats = mediautils::getStatisticsForClass(className);
if (stats) {
timeCheckStats = stats->dump();