GpuStats: refactor single stats pieces into a uniform way
This change makes it easy for adding single stats pieces into GpuService without
adding or modifying the binder interface each time.
Bug: 135210726
Test: adb shell dumpsys gpu
Change-Id: I2907065a55d03a6c1494737e6f0a77f6e94272eb
diff --git a/services/gpuservice/gpustats/GpuStats.cpp b/services/gpuservice/gpustats/GpuStats.cpp
index 576c72c..423c89f 100644
--- a/services/gpuservice/gpustats/GpuStats.cpp
+++ b/services/gpuservice/gpustats/GpuStats.cpp
@@ -126,14 +126,25 @@
addLoadingTime(driver, driverLoadingTime, &mAppStats[appStatsKey]);
}
-void GpuStats::setCpuVulkanInUse(const std::string& appPackageName,
- const uint64_t driverVersionCode) {
+void GpuStats::insertTargetStats(const std::string& appPackageName,
+ const uint64_t driverVersionCode, const GpuStatsInfo::Stats stats,
+ const uint64_t /*value*/) {
+ ATRACE_CALL();
+
const std::string appStatsKey = appPackageName + std::to_string(driverVersionCode);
+
+ std::lock_guard<std::mutex> lock(mLock);
if (!mAppStats.count(appStatsKey)) {
return;
}
- mAppStats[appStatsKey].cpuVulkanInUse = true;
+ switch (stats) {
+ case GpuStatsInfo::Stats::CPU_VULKAN_IN_USE:
+ mAppStats[appStatsKey].cpuVulkanInUse = true;
+ break;
+ default:
+ break;
+ }
}
void GpuStats::interceptSystemDriverStatsLocked() {