[incremental/metrics] report uid of last read error

BUG: 187354818
Test: atest service.incremental_test
Change-Id: I632b747440ed4faef31266a3a7b18b7a382ff2cf
This commit is contained in:
Songchun Fan
2021-05-27 19:15:48 -07:00
parent 27008c1123
commit 0d68016aea
2 changed files with 15 additions and 2 deletions

View File

@@ -2495,6 +2495,9 @@ void IncrementalService::getMetrics(StorageId storageId, android::os::Persistabl
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) {

View File

@@ -2260,6 +2260,11 @@ TEST_F(IncrementalServiceTest, testMetricsWithNoLastReadError) {
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 @@ TEST_F(IncrementalServiceTest, testMetricsWithLastReadError) {
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 @@ TEST_F(IncrementalServiceTest, testMetricsWithLastReadError) {
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 @@ TEST_F(IncrementalServiceTest, testMetricsWithLastReadError) {
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