summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alex Buynytskyy <alexbuy@google.com> 2021-03-24 05:57:24 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-03-24 05:57:24 +0000
commit779c7e1cf8538ed03efac4f7cbedb32f6ea7f084 (patch)
tree2e33588e528458299a746bfd7fdf7af98d9b35a5
parentdc2a0a63f908e263af28a03749cdb40e03f094ef (diff)
parentbcb2fe0cbb6b93e16f34d113c1da1bfd14c6180c (diff)
Merge "Add properties to test readlogs timeout." into sc-dev
-rw-r--r--services/incremental/IncrementalService.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp
index bd3f99a5efb8..60d9ea20d06a 100644
--- a/services/incremental/IncrementalService.cpp
+++ b/services/incremental/IncrementalService.cpp
@@ -100,6 +100,21 @@ static bool isPageAligned(IncFsSize s) {
return (s & (Constants::blockSize - 1)) == 0;
}
+static bool getEnforceReadLogsMaxIntervalForSystemDataLoaders() {
+ return android::base::GetBoolProperty("debug.incremental.enforce_readlogs_max_interval_for_"
+ "system_dataloaders",
+ false);
+}
+
+static Seconds getReadLogsMaxInterval() {
+ constexpr int limit = duration_cast<Seconds>(Constants::readLogsMaxInterval).count();
+ int readlogs_max_interval_secs =
+ std::min(limit,
+ android::base::GetIntProperty<
+ int>("debug.incremental.readlogs_max_interval_sec", limit));
+ return Seconds{readlogs_max_interval_secs};
+}
+
template <base::LogSeverity level = base::ERROR>
bool mkdirOrLog(std::string_view name, int mode = 0770, bool allowExisting = true) {
auto cstr = path::c_str(name);
@@ -711,7 +726,8 @@ bool IncrementalService::startLoading(StorageId storageId,
dataLoaderStub = ifs->dataLoaderStub;
}
- if (dataLoaderStub->isSystemDataLoader()) {
+ if (dataLoaderStub->isSystemDataLoader() &&
+ !getEnforceReadLogsMaxIntervalForSystemDataLoaders()) {
// Readlogs from system dataloader (adb) can always be collected.
ifs->startLoadingTs = TimePoint::max();
} else {
@@ -719,7 +735,7 @@ bool IncrementalService::startLoading(StorageId storageId,
const auto startLoadingTs = mClock->now();
ifs->startLoadingTs = startLoadingTs;
// Setup a callback to disable the readlogs after max interval.
- addTimedJob(*mTimedQueue, storageId, Constants::readLogsMaxInterval,
+ addTimedJob(*mTimedQueue, storageId, getReadLogsMaxInterval(),
[this, storageId, startLoadingTs]() {
const auto ifs = getIfs(storageId);
if (!ifs) {
@@ -807,7 +823,7 @@ int IncrementalService::setStorageParams(StorageId storageId, bool enableReadLog
// Check installation time.
const auto now = mClock->now();
const auto startLoadingTs = ifs->startLoadingTs;
- if (startLoadingTs <= now && now - startLoadingTs > Constants::readLogsMaxInterval) {
+ if (startLoadingTs <= now && now - startLoadingTs > getReadLogsMaxInterval()) {
LOG(ERROR) << "enableReadLogs failed, readlogs can't be enabled at this time, storageId: "
<< storageId;
return -EPERM;