Rebrand the term "rollback" to "revert" in apexd

In staged install flow, "rollback" usually means installation of a
version downgrade by RollbackManager. In apexd, the term means
bringing back the active sessions in /data/apex/active to the way it
was before the device was rebooted.

Using different terms for the two concepts in staged install flow
makes things easier to understand.

Bug: 144831762
Test: Builds without error
Change-Id: Ia648a82f09cd50aba5b0ab4d9e902120a612514e
diff --git a/apexd/aidl/android/apex/ApexSessionInfo.aidl b/apexd/aidl/android/apex/ApexSessionInfo.aidl
index a6dc7fd..d8be1b5 100644
--- a/apexd/aidl/android/apex/ApexSessionInfo.aidl
+++ b/apexd/aidl/android/apex/ApexSessionInfo.aidl
@@ -23,9 +23,9 @@
     boolean isVerified;
     boolean isStaged;
     boolean isActivated;
-    boolean isRollbackInProgress;
+    boolean isRevertInProgress;
     boolean isActivationFailed;
     boolean isSuccess;
-    boolean isRolledBack;
-    boolean isRollbackFailed;
+    boolean isReverted;
+    boolean isRevertFailed;
 }
diff --git a/apexd/aidl/android/apex/IApexService.aidl b/apexd/aidl/android/apex/IApexService.aidl
index 00e69a5..87c1f6b 100644
--- a/apexd/aidl/android/apex/IApexService.aidl
+++ b/apexd/aidl/android/apex/IApexService.aidl
@@ -69,10 +69,10 @@
     * Not meant for use outside of testing. The call will not be
     * functional on user builds.
     */
-   void rollbackActiveSession();
+   void revertActiveSession();
    /**
     * Not meant for use outside of testing. The call will not be
     * functional on user builds.
     */
-   void resumeRollbackIfNeeded();
+   void resumeRevertIfNeeded();
 }
diff --git a/apexd/apexd.cpp b/apexd/apexd.cpp
index 8c2d762..c7cb928 100644
--- a/apexd/apexd.cpp
+++ b/apexd/apexd.cpp
@@ -854,17 +854,17 @@
   return {};
 }
 
-Result<void> DoRollback(ApexSession& session) {
+Result<void> DoRevert(ApexSession& session) {
   if (gInFsCheckpointMode) {
-    // We will roll back automatically when we reboot
+    // We will revert automatically when we reboot
     return {};
   }
   auto scope_guard = android::base::make_scope_guard([&]() {
-    auto st = session.UpdateStateAndCommit(SessionState::ROLLBACK_FAILED);
-    LOG(DEBUG) << "Marking " << session << " as failed to rollback";
+    auto st = session.UpdateStateAndCommit(SessionState::REVERT_FAILED);
+    LOG(DEBUG) << "Marking " << session << " as failed to revert";
     if (!st) {
       LOG(WARNING) << "Failed to mark session " << session
-                   << " as failed to rollback : " << st.error();
+                   << " as failed to revert : " << st.error();
     }
   });
 
@@ -903,81 +903,80 @@
                         << kActiveApexPackagesDataDir;
   }
 
-  scope_guard.Disable();  // Rollback succeeded. Accept state.
+  scope_guard.Disable();  // Revert succeeded. Accept state.
   return {};
 }
 
-Result<void> RollbackStagedSession(ApexSession& session) {
+Result<void> RevertStagedSession(ApexSession& session) {
   // If the session is staged, it hasn't been activated yet, and we just need
   // to update its state to prevent it from being activated later.
-  return session.UpdateStateAndCommit(SessionState::ROLLED_BACK);
+  return session.UpdateStateAndCommit(SessionState::REVERTED);
 }
 
-Result<void> RollbackActivatedSession(ApexSession& session) {
+Result<void> RevertActivatedSession(ApexSession& session) {
   if (gInFsCheckpointMode) {
     LOG(DEBUG) << "Checkpoint mode is enabled";
     // On checkpointing devices, our modifications on /data will be
-    // automatically rolled back when we abort changes. Updating the session
-    // state is pointless here, as it will be rolled back as well.
+    // automatically reverted when we abort changes. Updating the session
+    // state is pointless here, as it will be reverted as well.
     return {};
   }
 
-  auto status =
-      session.UpdateStateAndCommit(SessionState::ROLLBACK_IN_PROGRESS);
+  auto status = session.UpdateStateAndCommit(SessionState::REVERT_IN_PROGRESS);
   if (!status) {
-    // TODO: should we continue with a rollback?
-    return Error() << "Rollback of session " << session
+    // TODO: should we continue with a revert?
+    return Error() << "Revert of session " << session
                    << " failed : " << status.error();
   }
 
-  status = DoRollback(session);
+  status = DoRevert(session);
   if (!status) {
-    return Error() << "Rollback of session " << session
+    return Error() << "Revert of session " << session
                    << " failed : " << status.error();
   }
 
-  status = session.UpdateStateAndCommit(SessionState::ROLLED_BACK);
+  status = session.UpdateStateAndCommit(SessionState::REVERTED);
   if (!status) {
     LOG(WARNING) << "Failed to mark session " << session
-                 << " as rolled back : " << status.error();
+                 << " as reverted : " << status.error();
   }
 
   return {};
 }
 
-Result<void> RollbackSession(ApexSession& session) {
-  LOG(DEBUG) << "Initializing rollback of " << session;
+Result<void> RevertSession(ApexSession& session) {
+  LOG(DEBUG) << "Initializing revert of " << session;
 
   switch (session.GetState()) {
-    case SessionState::ROLLBACK_IN_PROGRESS:
+    case SessionState::REVERT_IN_PROGRESS:
       [[clang::fallthrough]];
-    case SessionState::ROLLED_BACK:
+    case SessionState::REVERTED:
       return {};
     case SessionState::STAGED:
-      return RollbackStagedSession(session);
+      return RevertStagedSession(session);
     case SessionState::ACTIVATED:
-      return RollbackActivatedSession(session);
+      return RevertActivatedSession(session);
     default:
       return Error() << "Can't restore session " << session
                      << " : session is in a wrong state";
   }
 }
 
-Result<void> ResumeRollback(ApexSession& session) {
+Result<void> ResumeRevert(ApexSession& session) {
   auto backup_exists = PathExists(std::string(kApexBackupDir));
   if (!backup_exists) {
     return backup_exists.error();
   }
   if (*backup_exists) {
-    auto rollback_status = DoRollback(session);
-    if (!rollback_status) {
-      return rollback_status;
+    auto revert_status = DoRevert(session);
+    if (!revert_status) {
+      return revert_status;
     }
   }
-  auto status = session.UpdateStateAndCommit(SessionState::ROLLED_BACK);
+  auto status = session.UpdateStateAndCommit(SessionState::REVERTED);
   if (!status) {
     LOG(WARNING) << "Failed to mark session " << session
-                 << " as rolled back : " << status.error();
+                 << " as reverted : " << status.error();
   }
   return {};
 }
@@ -1074,7 +1073,7 @@
 
 }  // namespace apexd_private
 
-Result<void> resumeRollbackIfNeeded() {
+Result<void> resumeRevertIfNeeded() {
   auto session = ApexSession::GetActiveSession();
   if (!session) {
     return session.error();
@@ -1082,9 +1081,9 @@
   if (!session->has_value()) {
     return {};
   }
-  if ((**session).GetState() == SessionState::ROLLBACK_IN_PROGRESS) {
-    // This means that phone was rebooted during the rollback. Resuming it.
-    return ResumeRollback(**session);
+  if ((**session).GetState() == SessionState::REVERT_IN_PROGRESS) {
+    // This means that phone was rebooted during the revert. Resuming it.
+    return ResumeRevert(**session);
   }
   return {};
 }
@@ -1258,7 +1257,7 @@
       case SessionState::STAGED:
         return session.DeleteSession();
       case SessionState::ACTIVATED:
-        return RollbackActivatedSession(session);
+        return RevertActivatedSession(session);
       default:
         return Error() << "Session " << session << " can't be aborted";
     }
@@ -1530,40 +1529,40 @@
   return {};
 }
 
-Result<void> rollbackStagedSessionIfAny() {
+Result<void> revertStagedSessionIfAny() {
   auto session = ApexSession::GetActiveSession();
   if (!session) {
     return session.error();
   }
   if (!session->has_value()) {
-    LOG(WARNING) << "No session to rollback";
+    LOG(WARNING) << "No session to revert";
     return {};
   }
   if ((*session)->GetState() == SessionState::STAGED) {
-    LOG(INFO) << "Rolling back session " << **session;
-    return RollbackStagedSession(**session);
+    LOG(INFO) << "Reverting back session " << **session;
+    return RevertStagedSession(**session);
   }
-  return Error() << "Can't rollback " << **session
+  return Error() << "Can't revert " << **session
                  << " because it is not in STAGED state";
 }
 
-Result<void> rollbackActiveSession() {
+Result<void> revertActiveSession() {
   auto session = ApexSession::GetActiveSession();
   if (!session) {
     return Error() << "Failed to get active session : " << session.error();
   } else if (!session->has_value()) {
-    return Error() << "Rollback requested, when there are no active sessions.";
+    return Error() << "Revert requested, when there are no active sessions.";
   } else {
-    return RollbackSession(*(*session));
+    return RevertSession(*(*session));
   }
 }
 
-Result<void> rollbackActiveSessionAndReboot() {
-  auto status = rollbackActiveSession();
+Result<void> revertActiveSessionAndReboot() {
+  auto status = revertActiveSession();
   if (!status) {
     return status;
   }
-  LOG(ERROR) << "Successfully rolled back. Time to reboot device.";
+  LOG(ERROR) << "Successfully reverted. Time to reboot device.";
   if (gInFsCheckpointMode) {
     Result<void> res = gVoldService->AbortChanges(
         "apexd_initiated" /* message */, false /* retry */);
@@ -1689,23 +1688,22 @@
     }
   }
 
-  // Ask whether we should roll back any staged sessions; this can happen if
+  // Ask whether we should revert any staged sessions; this can happen if
   // we've exceeded the retry count on a device that supports filesystem
   // checkpointing.
   if (gSupportsFsCheckpoints) {
-    Result<bool> needs_rollback = gVoldService->NeedsRollback();
-    if (!needs_rollback) {
-      LOG(ERROR) << "Failed to check if we need a rollback: "
-                 << needs_rollback.error();
-    } else if (*needs_rollback) {
+    Result<bool> needs_revert = gVoldService->NeedsRollback();
+    if (!needs_revert) {
+      LOG(ERROR) << "Failed to check if we need a revert: "
+                 << needs_revert.error();
+    } else if (*needs_revert) {
       LOG(INFO) << "Exceeded number of session retries ("
                 << kNumRetriesWhenCheckpointingEnabled
-                << "). Starting a rollback";
-      Result<void> status = rollbackStagedSessionIfAny();
+                << "). Starting a revert";
+      Result<void> status = revertStagedSessionIfAny();
       if (!status) {
-        LOG(ERROR)
-            << "Failed to roll back (as requested by fs checkpointing) : "
-            << status.error();
+        LOG(ERROR) << "Failed to revert (as requested by fs checkpointing) : "
+                   << status.error();
       }
     }
   }
@@ -1721,24 +1719,24 @@
   // Activate APEXes from /data/apex. If one in the directory is newer than the
   // system one, the new one will eclipse the old one.
   scanStagedSessionsDirAndStage();
-  status = resumeRollbackIfNeeded();
+  status = resumeRevertIfNeeded();
   if (!status) {
-    LOG(ERROR) << "Failed to resume rollback : " << status.error();
+    LOG(ERROR) << "Failed to resume revert : " << status.error();
   }
 
   status = scanPackagesDirAndActivate(kActiveApexPackagesDataDir);
   if (!status) {
     LOG(ERROR) << "Failed to activate packages from "
                << kActiveApexPackagesDataDir << " : " << status.error();
-    Result<void> rollback_status = rollbackActiveSessionAndReboot();
-    if (!rollback_status) {
+    Result<void> revert_status = revertActiveSessionAndReboot();
+    if (!revert_status) {
       // TODO: should we kill apexd in this case?
-      LOG(ERROR) << "Failed to rollback : " << rollback_status.error();
+      LOG(ERROR) << "Failed to revert : " << revert_status.error();
     }
   }
 
   for (const auto& dir : kApexPackageBuiltinDirs) {
-    // TODO(b/123622800): if activation failed, rollback and reboot.
+    // TODO(b/123622800): if activation failed, revert and reboot.
     status = scanPackagesDirAndActivate(dir.c_str());
     if (!status) {
       // This should never happen. Like **really** never.
diff --git a/apexd/apexd.h b/apexd/apexd.h
index 841b8c5..3e8b241 100644
--- a/apexd/apexd.h
+++ b/apexd/apexd.h
@@ -31,7 +31,7 @@
 
 class CheckpointInterface;
 
-android::base::Result<void> resumeRollbackIfNeeded();
+android::base::Result<void> resumeRevertIfNeeded();
 
 android::base::Result<void> scanPackagesDirAndActivate(
     const char* apex_package_dir);
@@ -54,8 +54,8 @@
     WARN_UNUSED;
 android::base::Result<void> markStagedSessionSuccessful(const int session_id)
     WARN_UNUSED;
-android::base::Result<void> rollbackActiveSession();
-android::base::Result<void> rollbackActiveSessionAndReboot();
+android::base::Result<void> revertActiveSession();
+android::base::Result<void> revertActiveSessionAndReboot();
 
 android::base::Result<void> activatePackage(const std::string& full_path)
     WARN_UNUSED;
diff --git a/apexd/apexd_main.cpp b/apexd/apexd_main.cpp
index 7b42925..db842c8 100644
--- a/apexd/apexd_main.cpp
+++ b/apexd/apexd_main.cpp
@@ -98,9 +98,8 @@
   // it.
   android::apex::onAllPackagesReady();
 
-  android::apex::waitForBootStatus(
-      android::apex::rollbackActiveSessionAndReboot,
-      android::apex::unmountDanglingMounts);
+  android::apex::waitForBootStatus(android::apex::revertActiveSessionAndReboot,
+                                   android::apex::unmountDanglingMounts);
 
   android::apex::binder::JoinThreadPool();
   return 1;
diff --git a/apexd/apexd_session.cpp b/apexd/apexd_session.cpp
index 0e244c7..4652b84 100644
--- a/apexd/apexd_session.cpp
+++ b/apexd/apexd_session.cpp
@@ -178,9 +178,9 @@
       [[fallthrough]];
     case SessionState::ACTIVATION_FAILED:
       [[fallthrough]];
-    case SessionState::ROLLED_BACK:
+    case SessionState::REVERTED:
       [[fallthrough]];
-    case SessionState::ROLLBACK_FAILED:
+    case SessionState::REVERT_FAILED:
       return true;
     default:
       return false;
diff --git a/apexd/apexd_test_utils.h b/apexd/apexd_test_utils.h
index 1a5ff6e..940cc3d 100644
--- a/apexd/apexd_test_utils.h
+++ b/apexd/apexd_test_utils.h
@@ -61,15 +61,15 @@
           Field("isStaged", &ApexSessionInfo::isStaged, Eq(other.isStaged)),
           Field("isActivated", &ApexSessionInfo::isActivated,
                 Eq(other.isActivated)),
-          Field("isRollbackInProgress", &ApexSessionInfo::isRollbackInProgress,
-                Eq(other.isRollbackInProgress)),
+          Field("isRevertInProgress", &ApexSessionInfo::isRevertInProgress,
+                Eq(other.isRevertInProgress)),
           Field("isActivationFailed", &ApexSessionInfo::isActivationFailed,
                 Eq(other.isActivationFailed)),
           Field("isSuccess", &ApexSessionInfo::isSuccess, Eq(other.isSuccess)),
-          Field("isRolledBack", &ApexSessionInfo::isRolledBack,
-                Eq(other.isRolledBack)),
-          Field("isRollbackFailed", &ApexSessionInfo::isRollbackFailed,
-                Eq(other.isRollbackFailed))),
+          Field("isReverted", &ApexSessionInfo::isReverted,
+                Eq(other.isReverted)),
+          Field("isRevertFailed", &ApexSessionInfo::isRevertFailed,
+                Eq(other.isRevertFailed))),
       arg, result_listener);
 }
 
@@ -92,11 +92,11 @@
   info.isVerified = false;
   info.isStaged = false;
   info.isActivated = false;
-  info.isRollbackInProgress = false;
+  info.isRevertInProgress = false;
   info.isActivationFailed = false;
   info.isSuccess = false;
-  info.isRolledBack = false;
-  info.isRollbackFailed = false;
+  info.isReverted = false;
+  info.isRevertFailed = false;
   return info;
 }
 
@@ -112,8 +112,8 @@
   *os << "  isActivated : " << session.isActivated << "\n";
   *os << "  isActivationFailed : " << session.isActivationFailed << "\n";
   *os << "  isSuccess : " << session.isSuccess << "\n";
-  *os << "  isRolledBack : " << session.isRolledBack << "\n";
-  *os << "  isRollbackFailed : " << session.isRollbackFailed << "\n";
+  *os << "  isReverted : " << session.isReverted << "\n";
+  *os << "  isRevertFailed : " << session.isRevertFailed << "\n";
   *os << "}";
 }
 
diff --git a/apexd/apexservice.cpp b/apexd/apexservice.cpp
index 1407c60..53d03b6 100644
--- a/apexd/apexservice.cpp
+++ b/apexd/apexservice.cpp
@@ -78,8 +78,8 @@
   BinderStatus postinstallPackages(
       const std::vector<std::string>& paths) override;
   BinderStatus abortActiveSession() override;
-  BinderStatus rollbackActiveSession() override;
-  BinderStatus resumeRollbackIfNeeded() override;
+  BinderStatus revertActiveSession() override;
+  BinderStatus resumeRevertIfNeeded() override;
 
   status_t dump(int fd, const Vector<String16>& args) override;
 
@@ -198,11 +198,11 @@
   session_info->isVerified = false;
   session_info->isStaged = false;
   session_info->isActivated = false;
-  session_info->isRollbackInProgress = false;
+  session_info->isRevertInProgress = false;
   session_info->isActivationFailed = false;
   session_info->isSuccess = false;
-  session_info->isRolledBack = false;
-  session_info->isRollbackFailed = false;
+  session_info->isReverted = false;
+  session_info->isRevertFailed = false;
 }
 
 void convertToApexSessionInfo(const ApexSession& session,
@@ -228,14 +228,14 @@
     case SessionState::SUCCESS:
       session_info->isSuccess = true;
       break;
-    case SessionState::ROLLBACK_IN_PROGRESS:
-      session_info->isRollbackInProgress = true;
+    case SessionState::REVERT_IN_PROGRESS:
+      session_info->isRevertInProgress = true;
       break;
-    case SessionState::ROLLED_BACK:
-      session_info->isRolledBack = true;
+    case SessionState::REVERTED:
+      session_info->isReverted = true;
       break;
-    case SessionState::ROLLBACK_FAILED:
-      session_info->isRollbackFailed = true;
+    case SessionState::REVERT_FAILED:
+      session_info->isRevertFailed = true;
       break;
     case SessionState::UNKNOWN:
     default:
@@ -437,14 +437,14 @@
   return BinderStatus::ok();
 }
 
-BinderStatus ApexService::rollbackActiveSession() {
-  BinderStatus debugCheck = CheckDebuggable("rollbackActiveSession");
+BinderStatus ApexService::revertActiveSession() {
+  BinderStatus debugCheck = CheckDebuggable("revertActiveSession");
   if (!debugCheck.isOk()) {
     return debugCheck;
   }
 
-  LOG(DEBUG) << "rollbackActiveSession() received by ApexService.";
-  Result<void> res = ::android::apex::rollbackActiveSession();
+  LOG(DEBUG) << "revertActiveSession() received by ApexService.";
+  Result<void> res = ::android::apex::revertActiveSession();
   if (!res) {
     return BinderStatus::fromExceptionCode(
         BinderStatus::EX_ILLEGAL_ARGUMENT,
@@ -453,14 +453,14 @@
   return BinderStatus::ok();
 }
 
-BinderStatus ApexService::resumeRollbackIfNeeded() {
-  BinderStatus debugCheck = CheckDebuggable("resumeRollbackIfNeeded");
+BinderStatus ApexService::resumeRevertIfNeeded() {
+  BinderStatus debugCheck = CheckDebuggable("resumeRevertIfNeeded");
   if (!debugCheck.isOk()) {
     return debugCheck;
   }
 
-  LOG(DEBUG) << "resumeRollbackIfNeeded() received by ApexService.";
-  Result<void> res = ::android::apex::resumeRollbackIfNeeded();
+  LOG(DEBUG) << "resumeRevertIfNeeded() received by ApexService.";
+  Result<void> res = ::android::apex::resumeRevertIfNeeded();
   if (!res) {
     return BinderStatus::fromExceptionCode(
         BinderStatus::EX_ILLEGAL_ARGUMENT,
diff --git a/apexd/apexservice_test.cpp b/apexd/apexservice_test.cpp
index 92424b4..9e0a84e 100644
--- a/apexd/apexservice_test.cpp
+++ b/apexd/apexservice_test.cpp
@@ -613,7 +613,7 @@
   };
   install_fn(installer1);
   install_fn(installer2);
-  // Simulating a rollback. After this call test_v2_apex_path should be removed.
+  // Simulating a revert. After this call test_v2_apex_path should be removed.
   install_fn(installer3);
 
   EXPECT_FALSE(RegularFileExists(installer1.test_installed_file));
@@ -1594,7 +1594,7 @@
               UnorderedElementsAre(installer1.test_installed_file));
 }
 
-class ApexServiceRollbackTest : public ApexServiceTest {
+class ApexServiceRevertTest : public ApexServiceTest {
  protected:
   void SetUp() override { ApexServiceTest::SetUp(); }
 
@@ -1614,8 +1614,7 @@
     }
   }
 
-  void CheckRollbackWasPerformed(
-      const std::vector<std::string>& expected_pkgs) {
+  void CheckRevertWasPerformed(const std::vector<std::string>& expected_pkgs) {
     // First check that /data/apex/active exists and has correct permissions.
     struct stat sd;
     ASSERT_EQ(0, stat(kActiveApexPackagesDataDir, &sd));
@@ -1628,7 +1627,7 @@
   }
 };
 
-TEST_F(ApexServiceRollbackTest, AbortActiveSessionSuccessfulRollback) {
+TEST_F(ApexServiceRevertTest, AbortActiveSessionSuccessfulRevert) {
   if (supports_fs_checkpointing_) {
     GTEST_SKIP() << "Can't run if filesystem checkpointing is enabled";
   }
@@ -1654,15 +1653,15 @@
   auto pkg2 = StringPrintf("%s/com.android.apex.test_package_2@1.apex",
                            kActiveApexPackagesDataDir);
   SCOPED_TRACE("");
-  CheckRollbackWasPerformed({pkg1, pkg2});
+  CheckRevertWasPerformed({pkg1, pkg2});
   std::vector<ApexSessionInfo> sessions;
   ASSERT_TRUE(IsOk(service_->getSessions(&sessions)));
   ApexSessionInfo expected = CreateSessionInfo(239);
-  expected.isRolledBack = true;
+  expected.isReverted = true;
   ASSERT_THAT(sessions, UnorderedElementsAre(SessionInfoEq(expected)));
 }
 
-TEST_F(ApexServiceRollbackTest, RollbackLastSessionCalledSuccessfulRollback) {
+TEST_F(ApexServiceRevertTest, RevertLastSessionCalledSuccessfulRevert) {
   if (supports_fs_checkpointing_) {
     GTEST_SKIP() << "Can't run if filesystem checkpointing is enabled";
   }
@@ -1681,15 +1680,15 @@
 
   PrepareBackup({GetTestFile("apex.apexd_test.apex")});
 
-  ASSERT_TRUE(IsOk(service_->rollbackActiveSession()));
+  ASSERT_TRUE(IsOk(service_->revertActiveSession()));
 
   auto pkg = StringPrintf("%s/com.android.apex.test_package@1.apex",
                           kActiveApexPackagesDataDir);
   SCOPED_TRACE("");
-  CheckRollbackWasPerformed({pkg});
+  CheckRevertWasPerformed({pkg});
 }
 
-TEST_F(ApexServiceRollbackTest, RollbackLastSessionCalledNoActiveSession) {
+TEST_F(ApexServiceRevertTest, RevertLastSessionCalledNoActiveSession) {
   // This test simulates a situation that should never happen on user builds:
   // abortLastSession was called, but there are no active sessions.
   PrepareTestApexForInstall installer(GetTestFile("apex.apexd_test_v2.apex"));
@@ -1702,21 +1701,21 @@
 
   PrepareBackup({GetTestFile("apex.apexd_test.apex")});
 
-  // Even though backup is there, no sessions are active, hence rollback request
+  // Even though backup is there, no sessions are active, hence revert request
   // should fail.
-  ASSERT_FALSE(IsOk(service_->rollbackActiveSession()));
+  ASSERT_FALSE(IsOk(service_->revertActiveSession()));
 }
 
-TEST_F(ApexServiceRollbackTest, RollbackFailsNoBackupFolder) {
-  ASSERT_FALSE(IsOk(service_->rollbackActiveSession()));
+TEST_F(ApexServiceRevertTest, RevertFailsNoBackupFolder) {
+  ASSERT_FALSE(IsOk(service_->revertActiveSession()));
 }
 
-TEST_F(ApexServiceRollbackTest, RollbackFailsNoActivePackagesFolder) {
+TEST_F(ApexServiceRevertTest, RevertFailsNoActivePackagesFolder) {
   PrepareTestApexForInstall installer(GetTestFile("apex.apexd_test.apex"));
-  ASSERT_FALSE(IsOk(service_->rollbackActiveSession()));
+  ASSERT_FALSE(IsOk(service_->revertActiveSession()));
 }
 
-TEST_F(ApexServiceRollbackTest, MarkStagedSessionSuccessfulCleanupBackup) {
+TEST_F(ApexServiceRevertTest, MarkStagedSessionSuccessfulCleanupBackup) {
   PrepareBackup({GetTestFile("apex.apexd_test.apex"),
                  GetTestFile("apex.apexd_test_different_app.apex")});
 
@@ -1729,7 +1728,7 @@
   ASSERT_TRUE(fs::is_empty(fs::path(kApexBackupDir)));
 }
 
-TEST_F(ApexServiceRollbackTest, ResumesRollback) {
+TEST_F(ApexServiceRevertTest, ResumesRevert) {
   if (supports_fs_checkpointing_) {
     GTEST_SKIP() << "Can't run if filesystem checkpointing is enabled";
   }
@@ -1747,25 +1746,25 @@
   auto session = ApexSession::CreateSession(17239);
   ASSERT_TRUE(IsOk(session));
   ASSERT_TRUE(
-      IsOk(session->UpdateStateAndCommit(SessionState::ROLLBACK_IN_PROGRESS)));
+      IsOk(session->UpdateStateAndCommit(SessionState::REVERT_IN_PROGRESS)));
 
-  ASSERT_TRUE(IsOk(service_->resumeRollbackIfNeeded()));
+  ASSERT_TRUE(IsOk(service_->resumeRevertIfNeeded()));
 
   auto pkg1 = StringPrintf("%s/com.android.apex.test_package@1.apex",
                            kActiveApexPackagesDataDir);
   auto pkg2 = StringPrintf("%s/com.android.apex.test_package_2@1.apex",
                            kActiveApexPackagesDataDir);
   SCOPED_TRACE("");
-  CheckRollbackWasPerformed({pkg1, pkg2});
+  CheckRevertWasPerformed({pkg1, pkg2});
 
   std::vector<ApexSessionInfo> sessions;
   ASSERT_TRUE(IsOk(service_->getSessions(&sessions)));
   ApexSessionInfo expected = CreateSessionInfo(17239);
-  expected.isRolledBack = true;
+  expected.isReverted = true;
   ASSERT_THAT(sessions, UnorderedElementsAre(SessionInfoEq(expected)));
 }
 
-TEST_F(ApexServiceRollbackTest, DoesNotResumeRollback) {
+TEST_F(ApexServiceRevertTest, DoesNotResumeRevert) {
   if (supports_fs_checkpointing_) {
     GTEST_SKIP() << "Can't run if filesystem checkpointing is enabled";
   }
@@ -1781,9 +1780,9 @@
   ASSERT_TRUE(IsOk(session));
   ASSERT_TRUE(IsOk(session->UpdateStateAndCommit(SessionState::SUCCESS)));
 
-  ASSERT_TRUE(IsOk(service_->resumeRollbackIfNeeded()));
+  ASSERT_TRUE(IsOk(service_->resumeRevertIfNeeded()));
 
-  // Check that rollback wasn't resumed.
+  // Check that revert wasn't resumed.
   auto active_pkgs = ReadEntireDir(kActiveApexPackagesDataDir);
   ASSERT_TRUE(IsOk(active_pkgs));
   ASSERT_THAT(*active_pkgs,
@@ -1796,7 +1795,7 @@
   ASSERT_THAT(sessions, UnorderedElementsAre(SessionInfoEq(expected)));
 }
 
-TEST_F(ApexServiceRollbackTest, FailsRollback) {
+TEST_F(ApexServiceRevertTest, FailsRevert) {
   if (supports_fs_checkpointing_) {
     GTEST_SKIP() << "Can't run if filesystem checkpointing is enabled";
   }
@@ -1805,29 +1804,28 @@
   ASSERT_TRUE(IsOk(session));
   ASSERT_TRUE(IsOk(session->UpdateStateAndCommit(SessionState::ACTIVATED)));
 
-  ASSERT_FALSE(IsOk(service_->rollbackActiveSession()));
+  ASSERT_FALSE(IsOk(service_->revertActiveSession()));
   ApexSessionInfo session_info;
   ASSERT_TRUE(IsOk(service_->getStagedSessionInfo(53, &session_info)));
   ApexSessionInfo expected = CreateSessionInfo(53);
-  expected.isRollbackFailed = true;
+  expected.isRevertFailed = true;
   ASSERT_THAT(session_info, SessionInfoEq(expected));
 }
 
-TEST_F(ApexServiceRollbackTest, RollbackFailedStateRollbackAttemptFails) {
+TEST_F(ApexServiceRevertTest, RevertFailedStateRevertAttemptFails) {
   if (supports_fs_checkpointing_) {
     GTEST_SKIP() << "Can't run if filesystem checkpointing is enabled";
   }
 
   auto session = ApexSession::CreateSession(17239);
   ASSERT_TRUE(IsOk(session));
-  ASSERT_TRUE(
-      IsOk(session->UpdateStateAndCommit(SessionState::ROLLBACK_FAILED)));
+  ASSERT_TRUE(IsOk(session->UpdateStateAndCommit(SessionState::REVERT_FAILED)));
 
-  ASSERT_FALSE(IsOk(service_->rollbackActiveSession()));
+  ASSERT_FALSE(IsOk(service_->revertActiveSession()));
   ApexSessionInfo session_info;
   ASSERT_TRUE(IsOk(service_->getStagedSessionInfo(17239, &session_info)));
   ApexSessionInfo expected = CreateSessionInfo(17239);
-  expected.isRollbackFailed = true;
+  expected.isRevertFailed = true;
   ASSERT_THAT(session_info, SessionInfoEq(expected));
 }
 
diff --git a/proto/session_state.proto b/proto/session_state.proto
index f023353..af1513d 100644
--- a/proto/session_state.proto
+++ b/proto/session_state.proto
@@ -27,9 +27,9 @@
     ACTIVATED = 3;
     ACTIVATION_FAILED = 4;
     SUCCESS = 5;
-    ROLLBACK_IN_PROGRESS = 6;
-    ROLLED_BACK = 7;
-    ROLLBACK_FAILED = 8;
+    REVERT_IN_PROGRESS = 6;
+    REVERTED = 7;
+    REVERT_FAILED = 8;
   }
 
   int32 id = 1;