@@ -716,7 +716,7 @@ bool SnapshotManager::InitiateMerge() {
716
716
}
717
717
}
718
718
719
- SnapshotUpdateStatus initial_status;
719
+ SnapshotUpdateStatus initial_status = ReadSnapshotUpdateStatus (lock. get ()) ;
720
720
initial_status.set_state (UpdateState::Merging);
721
721
initial_status.set_sectors_allocated (initial_target_values.sectors_allocated );
722
722
initial_status.set_total_sectors (initial_target_values.total_sectors );
@@ -2515,15 +2515,25 @@ bool SnapshotManager::WriteUpdateState(LockedFile* lock, UpdateState state,
2515
2515
SnapshotUpdateStatus status;
2516
2516
status.set_state (state);
2517
2517
2518
- if (state == UpdateState::MergeFailed) {
2519
- status.set_merge_failure_code (failure_code);
2518
+ switch (state) {
2519
+ case UpdateState::MergeFailed:
2520
+ status.set_merge_failure_code (failure_code);
2521
+ break ;
2522
+ case UpdateState::Initiated:
2523
+ status.set_source_build_fingerprint (
2524
+ android::base::GetProperty (" ro.build.fingerprint" , " " ));
2525
+ break ;
2526
+ default :
2527
+ break ;
2520
2528
}
2521
2529
2522
2530
// If we're transitioning between two valid states (eg, we're not beginning
2523
- // or ending an OTA), then make sure to propagate the compression bit.
2531
+ // or ending an OTA), then make sure to propagate the compression bit and
2532
+ // build fingerprint.
2524
2533
if (!(state == UpdateState::Initiated || state == UpdateState::None)) {
2525
2534
SnapshotUpdateStatus old_status = ReadSnapshotUpdateStatus (lock);
2526
2535
status.set_compression_enabled (old_status.compression_enabled ());
2536
+ status.set_source_build_fingerprint (old_status.source_build_fingerprint ());
2527
2537
}
2528
2538
return WriteSnapshotUpdateStatus (lock, status);
2529
2539
}
@@ -2838,7 +2848,7 @@ Return SnapshotManager::CreateUpdateSnapshots(const DeltaArchiveManifest& manife
2838
2848
}
2839
2849
}
2840
2850
2841
- SnapshotUpdateStatus status = {} ;
2851
+ SnapshotUpdateStatus status = ReadSnapshotUpdateStatus (lock. get ()) ;
2842
2852
status.set_state (update_state);
2843
2853
status.set_compression_enabled (cow_creator.compression_enabled );
2844
2854
if (!WriteSnapshotUpdateStatus (lock.get (), status)) {
@@ -3264,9 +3274,10 @@ bool SnapshotManager::Dump(std::ostream& os) {
3264
3274
3265
3275
std::stringstream ss;
3266
3276
3277
+ auto update_status = ReadSnapshotUpdateStatus (file.get ());
3278
+
3267
3279
ss << " Update state: " << ReadUpdateState (file.get ()) << std::endl;
3268
- ss << " Compression: " << ReadSnapshotUpdateStatus (file.get ()).compression_enabled ()
3269
- << std::endl;
3280
+ ss << " Compression: " << update_status.compression_enabled () << std::endl;
3270
3281
ss << " Current slot: " << device_->GetSlotSuffix () << std::endl;
3271
3282
ss << " Boot indicator: booting from " << GetCurrentSlot () << " slot" << std::endl;
3272
3283
ss << " Rollback indicator: "
@@ -3275,6 +3286,7 @@ bool SnapshotManager::Dump(std::ostream& os) {
3275
3286
ss << " Forward merge indicator: "
3276
3287
<< (access (GetForwardMergeIndicatorPath ().c_str (), F_OK) == 0 ? " exists" : strerror (errno))
3277
3288
<< std::endl;
3289
+ ss << " Source build fingerprint: " << update_status.source_build_fingerprint () << std::endl;
3278
3290
3279
3291
bool ok = true ;
3280
3292
std::vector<std::string> snapshots;
@@ -3792,5 +3804,13 @@ MergeFailureCode SnapshotManager::ReadMergeFailureCode() {
3792
3804
return status.merge_failure_code ();
3793
3805
}
3794
3806
3807
+ std::string SnapshotManager::ReadSourceBuildFingerprint () {
3808
+ auto lock = LockExclusive ();
3809
+ if (!lock) return {};
3810
+
3811
+ SnapshotUpdateStatus status = ReadSnapshotUpdateStatus (lock.get ());
3812
+ return status.source_build_fingerprint ();
3813
+ }
3814
+
3795
3815
} // namespace snapshot
3796
3816
} // namespace android
0 commit comments