Snap for 5567188 from 7af550d73d418b76a2537e5ceced6958d5fd1097 to qt-release
Change-Id: I26546c528acabd680f17e3537e1b5544ed24fce5
diff --git a/apexd/apexd.cpp b/apexd/apexd.cpp
index 046b8aa..355934d 100644
--- a/apexd/apexd.cpp
+++ b/apexd/apexd.cpp
@@ -119,6 +119,8 @@
"com.android.tzdata",
};
+static constexpr const int kNumRetriesWhenCheckpointingEnabled = 1;
+
bool isBootstrapApex(const ApexFile& apex) {
return std::find(kBootstrapApexes.begin(), kBootstrapApexes.end(),
apex.GetManifest().name()) != kBootstrapApexes.end();
@@ -1605,12 +1607,19 @@
Status rollbackStagedSessionIfAny() {
auto session = ApexSession::GetActiveSession();
- if (session.Ok() && session->has_value() &&
- (*session)->GetState() == SessionState::STAGED) {
- return RollbackStagedSession(*(*session));
+ if (!session.Ok()) {
+ return session.ErrorStatus();
}
-
- return Status::Success();
+ if (!session->has_value()) {
+ LOG(WARNING) << "No session to rollback";
+ return Status::Success();
+ }
+ if ((*session)->GetState() == SessionState::STAGED) {
+ LOG(INFO) << "Rolling back session " << **session;
+ return RollbackStagedSession(**session);
+ }
+ return Status::Fail(StringLog() << "Can't rollback " << **session
+ << " because it is not in STAGED state");
}
Status rollbackActiveSession() {
@@ -1701,6 +1710,9 @@
LOG(ERROR) << "Failed to check if we need a rollback: "
<< needs_rollback.ErrorMessage();
} else if (*needs_rollback) {
+ LOG(INFO) << "Exceeded number of session retries ("
+ << kNumRetriesWhenCheckpointingEnabled
+ << "). Starting a rollback";
Status status = rollbackStagedSessionIfAny();
if (!status.Ok()) {
LOG(ERROR)
@@ -1772,7 +1784,7 @@
if (gSupportsFsCheckpoints) {
Status checkpoint_status =
- gVoldService->StartCheckpoint(1 /* numRetries */);
+ gVoldService->StartCheckpoint(kNumRetriesWhenCheckpointingEnabled);
if (!checkpoint_status.Ok()) {
// The device supports checkpointing, but we could not start it;
// log a warning, but do continue, since we can live without it.