[incremental/metrics] report uid of last read error

BUG: 187354818
Test: atest service.incremental_test
Change-Id: I632b747440ed4faef31266a3a7b18b7a382ff2cf
diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp
index 8b816d0..47d59b2 100644
--- a/services/incremental/IncrementalService.cpp
+++ b/services/incremental/IncrementalService.cpp
@@ -2495,6 +2495,9 @@
         const auto& kMetricsLastReadErrorNo =
                 os::incremental::BnIncrementalService::METRICS_LAST_READ_ERROR_NUMBER();
         result->putInt(String16(kMetricsLastReadErrorNo.c_str()), lastReadError->errorNo);
+        const auto& kMetricsLastReadUid =
+                os::incremental::BnIncrementalService::METRICS_LAST_READ_ERROR_UID();
+        result->putInt(String16(kMetricsLastReadUid.c_str()), lastReadError->uid);
     }
     std::unique_lock l(ifs->lock);
     if (!ifs->dataLoaderStub) {
diff --git a/services/incremental/test/IncrementalServiceTest.cpp b/services/incremental/test/IncrementalServiceTest.cpp
index fae654e..094c5fb 100644
--- a/services/incremental/test/IncrementalServiceTest.cpp
+++ b/services/incremental/test/IncrementalServiceTest.cpp
@@ -2260,6 +2260,11 @@
             result.getInt(String16(BnIncrementalService::METRICS_LAST_READ_ERROR_NUMBER().c_str()),
                           &lastReadErrorNumber));
     ASSERT_EQ(expectedLastReadErrorNumber, lastReadErrorNumber);
+    int expectedLastReadUid = -1, lastReadErrorUid = -1;
+    ASSERT_FALSE(
+            result.getInt(String16(BnIncrementalService::METRICS_LAST_READ_ERROR_UID().c_str()),
+                          &lastReadErrorUid));
+    ASSERT_EQ(expectedLastReadUid, lastReadErrorUid);
 }
 
 TEST_F(IncrementalServiceTest, testMetricsWithLastReadError) {
@@ -2272,7 +2277,8 @@
                                                         duration_cast<std::chrono::microseconds>(
                                                                 now.time_since_epoch())
                                                                 .count()),
-                                                .errorNo = static_cast<uint32_t>(-ETIME)}));
+                                                .errorNo = static_cast<uint32_t>(-ETIME),
+                                                .uid = 20000}));
     TemporaryDir tempDir;
     int storageId =
             mIncrementalService->createStorage(tempDir.path, mDataLoaderParcel,
@@ -2283,7 +2289,7 @@
     mClock->advanceMs(10);
     android::os::PersistableBundle result{};
     mIncrementalService->getMetrics(storageId, &result);
-    ASSERT_EQ(11, (int)result.size());
+    ASSERT_EQ(12, (int)result.size());
     int64_t expectedMillisSinceLastReadError = 10, millisSinceLastReadError = -1;
     ASSERT_TRUE(result.getLong(String16(BnIncrementalService::METRICS_MILLIS_SINCE_LAST_READ_ERROR()
                                                 .c_str()),
@@ -2294,6 +2300,10 @@
             result.getInt(String16(BnIncrementalService::METRICS_LAST_READ_ERROR_NUMBER().c_str()),
                           &lastReadErrorNumber));
     ASSERT_EQ(expectedLastReadErrorNumber, lastReadErrorNumber);
+    int expectedLastReadUid = 20000, lastReadErrorUid = -1;
+    ASSERT_TRUE(result.getInt(String16(BnIncrementalService::METRICS_LAST_READ_ERROR_UID().c_str()),
+                              &lastReadErrorUid));
+    ASSERT_EQ(expectedLastReadUid, lastReadErrorUid);
 }
 
 } // namespace android::os::incremental