[incremental/metrics] report uid of last read error am: 0d68016aea

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14751573

Change-Id: Ib3a72e2f3beb9d595c27c4a28af315d1e66bf8cb
This commit is contained in:
Songchun Fan
2021-05-28 05:16:53 +00:00
committed by Automerger Merge Worker
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