GpuStats: Track ANGLE usage info

Bug: 132285967
Test: atest GpuStatsPuller_test
Change-Id: I1763624fe705b6d3a3ccc3bdbddfa573362ddc27
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index baa8402..dbc1e5c 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -5975,6 +5975,12 @@
 
     // Api version of the system GLES driver.
     optional int32 gles_version = 11;
+
+    // Total count of the angle driver gets loaded.
+    optional int64 angle_loading_count = 12;
+
+    // Total count of the angle driver fails to be loaded.
+    optional int64 angle_loading_failure_count = 13;
 }
 
 /**
@@ -6007,6 +6013,10 @@
     // Vulkan driver loading time info.
     optional GpuDriverLoadingTime vk_driver_loading_time = 4
             [(android.os.statsd.log_mode) = MODE_BYTES];
+
+    // Angle driver loading time info.
+    optional GpuDriverLoadingTime angle_driver_loading_time = 5
+            [(android.os.statsd.log_mode) = MODE_BYTES];
 }
 
 /*
diff --git a/cmds/statsd/src/external/GpuStatsPuller.cpp b/cmds/statsd/src/external/GpuStatsPuller.cpp
index 876383c..f727d6d 100644
--- a/cmds/statsd/src/external/GpuStatsPuller.cpp
+++ b/cmds/statsd/src/external/GpuStatsPuller.cpp
@@ -68,6 +68,8 @@
         if (!event->write(info.vulkanVersion)) return false;
         if (!event->write(info.cpuVulkanVersion)) return false;
         if (!event->write(info.glesVersion)) return false;
+        if (!event->write((int64_t)info.angleLoadingCount)) return false;
+        if (!event->write((int64_t)info.angleLoadingFailureCount)) return false;
         event->init();
         data->emplace_back(event);
     }
@@ -92,6 +94,7 @@
         if (!event->write((int64_t)info.driverVersionCode)) return false;
         if (!event->write(int64VectorToProtoByteString(info.glDriverLoadingTime))) return false;
         if (!event->write(int64VectorToProtoByteString(info.vkDriverLoadingTime))) return false;
+        if (!event->write(int64VectorToProtoByteString(info.angleDriverLoadingTime))) return false;
         event->init();
         data->emplace_back(event);
     }
diff --git a/cmds/statsd/tests/external/GpuStatsPuller_test.cpp b/cmds/statsd/tests/external/GpuStatsPuller_test.cpp
index 2acfb83..63fb4ed 100644
--- a/cmds/statsd/tests/external/GpuStatsPuller_test.cpp
+++ b/cmds/statsd/tests/external/GpuStatsPuller_test.cpp
@@ -32,27 +32,31 @@
 namespace statsd {
 
 // clang-format off
-static const std::string DRIVER_PACKAGE_NAME    = "TEST_DRIVER";
-static const std::string DRIVER_VERSION_NAME    = "TEST_DRIVER_VERSION";
-static const std::string APP_PACKAGE_NAME       = "TEST_APP";
-static const int64_t TIMESTAMP_WALLCLOCK        = 111;
-static const int64_t TIMESTAMP_ELAPSED          = 222;
-static const int64_t DRIVER_VERSION_CODE        = 333;
-static const int64_t DRIVER_BUILD_TIME          = 444;
-static const int64_t GL_LOADING_COUNT           = 3;
-static const int64_t GL_LOADING_FAILURE_COUNT   = 1;
-static const int64_t VK_LOADING_COUNT           = 4;
-static const int64_t VK_LOADING_FAILURE_COUNT   = 0;
-static const int64_t GL_DRIVER_LOADING_TIME_0   = 555;
-static const int64_t GL_DRIVER_LOADING_TIME_1   = 666;
-static const int64_t VK_DRIVER_LOADING_TIME_0   = 777;
-static const int64_t VK_DRIVER_LOADING_TIME_1   = 888;
-static const int64_t VK_DRIVER_LOADING_TIME_2   = 999;
-static const int32_t VULKAN_VERSION             = 1;
-static const int32_t CPU_VULKAN_VERSION         = 2;
-static const int32_t GLES_VERSION               = 3;
-static const size_t NUMBER_OF_VALUES_GLOBAL     = 11;
-static const size_t NUMBER_OF_VALUES_APP        = 4;
+static const std::string DRIVER_PACKAGE_NAME      = "TEST_DRIVER";
+static const std::string DRIVER_VERSION_NAME      = "TEST_DRIVER_VERSION";
+static const std::string APP_PACKAGE_NAME         = "TEST_APP";
+static const int64_t TIMESTAMP_WALLCLOCK          = 111;
+static const int64_t TIMESTAMP_ELAPSED            = 222;
+static const int64_t DRIVER_VERSION_CODE          = 333;
+static const int64_t DRIVER_BUILD_TIME            = 444;
+static const int64_t GL_LOADING_COUNT             = 3;
+static const int64_t GL_LOADING_FAILURE_COUNT     = 1;
+static const int64_t VK_LOADING_COUNT             = 4;
+static const int64_t VK_LOADING_FAILURE_COUNT     = 0;
+static const int64_t ANGLE_LOADING_COUNT          = 2;
+static const int64_t ANGLE_LOADING_FAILURE_COUNT  = 1;
+static const int64_t GL_DRIVER_LOADING_TIME_0     = 555;
+static const int64_t GL_DRIVER_LOADING_TIME_1     = 666;
+static const int64_t VK_DRIVER_LOADING_TIME_0     = 777;
+static const int64_t VK_DRIVER_LOADING_TIME_1     = 888;
+static const int64_t VK_DRIVER_LOADING_TIME_2     = 999;
+static const int64_t ANGLE_DRIVER_LOADING_TIME_0  = 1010;
+static const int64_t ANGLE_DRIVER_LOADING_TIME_1  = 1111;
+static const int32_t VULKAN_VERSION               = 1;
+static const int32_t CPU_VULKAN_VERSION           = 2;
+static const int32_t GLES_VERSION                 = 3;
+static const size_t NUMBER_OF_VALUES_GLOBAL       = 13;
+static const size_t NUMBER_OF_VALUES_APP          = 5;
 // clang-format on
 
 class MockGpuStatsPuller : public GpuStatsPuller {
@@ -99,6 +103,8 @@
     EXPECT_TRUE(event->write(VULKAN_VERSION));
     EXPECT_TRUE(event->write(CPU_VULKAN_VERSION));
     EXPECT_TRUE(event->write(GLES_VERSION));
+    EXPECT_TRUE(event->write(ANGLE_LOADING_COUNT));
+    EXPECT_TRUE(event->write(ANGLE_LOADING_FAILURE_COUNT));
     event->init();
     inData.emplace_back(event);
     MockGpuStatsPuller mockPuller(android::util::GPU_STATS_GLOBAL_INFO, &inData);
@@ -119,6 +125,8 @@
     EXPECT_EQ(VULKAN_VERSION, outData[0]->getValues()[8].mValue.int_value);
     EXPECT_EQ(CPU_VULKAN_VERSION, outData[0]->getValues()[9].mValue.int_value);
     EXPECT_EQ(GLES_VERSION, outData[0]->getValues()[10].mValue.int_value);
+    EXPECT_EQ(ANGLE_LOADING_COUNT, outData[0]->getValues()[11].mValue.long_value);
+    EXPECT_EQ(ANGLE_LOADING_FAILURE_COUNT, outData[0]->getValues()[12].mValue.long_value);
 }
 
 TEST_F(GpuStatsPuller_test, PullGpuStatsAppInfo) {
@@ -134,8 +142,12 @@
     vkDriverLoadingTime.emplace_back(VK_DRIVER_LOADING_TIME_0);
     vkDriverLoadingTime.emplace_back(VK_DRIVER_LOADING_TIME_1);
     vkDriverLoadingTime.emplace_back(VK_DRIVER_LOADING_TIME_2);
+    std::vector<int64_t> angleDriverLoadingTime;
+    angleDriverLoadingTime.emplace_back(ANGLE_DRIVER_LOADING_TIME_0);
+    angleDriverLoadingTime.emplace_back(ANGLE_DRIVER_LOADING_TIME_1);
     EXPECT_TRUE(event->write(int64VectorToProtoByteString(glDriverLoadingTime)));
     EXPECT_TRUE(event->write(int64VectorToProtoByteString(vkDriverLoadingTime)));
+    EXPECT_TRUE(event->write(int64VectorToProtoByteString(angleDriverLoadingTime)));
     event->init();
     inData.emplace_back(event);
     MockGpuStatsPuller mockPuller(android::util::GPU_STATS_APP_INFO, &inData);
@@ -151,6 +163,8 @@
               outData[0]->getValues()[2].mValue.str_value);
     EXPECT_EQ(int64VectorToProtoByteString(vkDriverLoadingTime),
               outData[0]->getValues()[3].mValue.str_value);
+    EXPECT_EQ(int64VectorToProtoByteString(angleDriverLoadingTime),
+              outData[0]->getValues()[4].mValue.str_value);
 }
 
 }  // namespace statsd