summaryrefslogtreecommitdiff
path: root/aosp/update_attempter_android.cc
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-05-14 01:09:55 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-05-14 01:09:55 +0000
commita6c543c64b135f521cae645c2f882d78bf7307e8 (patch)
tree3e0ef8551a610e593102d8ff0f0a2d8c9b682581 /aosp/update_attempter_android.cc
parent3d4e6e0d7ed2b609e0fe2b4d0fcb250808f97476 (diff)
parent422e893875d4d1c8cf73db5d39a0eac19bce3065 (diff)
Snap for 7360053 from 422e893875d4d1c8cf73db5d39a0eac19bce3065 to sc-release
Change-Id: I9d292ff0b5cbdc3e0ab778bcb3f9eca70d8a0277
Diffstat (limited to 'aosp/update_attempter_android.cc')
-rw-r--r--aosp/update_attempter_android.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc
index ba61f255..2ffa0da3 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -884,20 +884,25 @@ void UpdateAttempterAndroid::UpdatePrefsAndReportUpdateMetricsOnReboot() {
string current_version =
android::base::GetProperty("ro.build.version.incremental", "");
TEST_AND_RETURN(!current_version.empty());
+ const auto current_slot = boot_control_->GetCurrentSlot();
// If there's no record of previous version (e.g. due to a data wipe), we
// save the info of current boot and skip the metrics report.
if (!prefs_->Exists(kPrefsPreviousVersion)) {
prefs_->SetString(kPrefsBootId, current_boot_id);
prefs_->SetString(kPrefsPreviousVersion, current_version);
+ prefs_->SetInt64(std::string{kPrefsPreviousSlot},
+ boot_control_->GetCurrentSlot());
ClearMetricsPrefs();
return;
}
+ int64_t previous_slot = -1;
+ prefs_->GetInt64(kPrefsPreviousSlot, &previous_slot);
string previous_version;
- // update_engine restarted under the same build.
+ // update_engine restarted under the same build and same slot.
// TODO(xunchang) identify and report rollback by checking UpdateMarker.
if (prefs_->GetString(kPrefsPreviousVersion, &previous_version) &&
- previous_version == current_version) {
+ previous_version == current_version && previous_slot == current_slot) {
string last_boot_id;
bool is_reboot = prefs_->Exists(kPrefsBootId) &&
(prefs_->GetString(kPrefsBootId, &last_boot_id) &&
@@ -917,6 +922,8 @@ void UpdateAttempterAndroid::UpdatePrefsAndReportUpdateMetricsOnReboot() {
// TODO(xunchang) check the build version is larger than the previous one.
prefs_->SetString(kPrefsBootId, current_boot_id);
prefs_->SetString(kPrefsPreviousVersion, current_version);
+ prefs_->SetInt64(std::string{kPrefsPreviousSlot},
+ boot_control_->GetCurrentSlot());
bool previous_attempt_exists = prefs_->Exists(kPrefsPayloadAttemptNumber);
// |kPrefsPayloadAttemptNumber| should be cleared upon successful update.