Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion install/include/install/snapshot_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "recovery_ui/device.h"

bool FinishPendingSnapshotMerges(Device* device);
bool FinishPendingSnapshotMerges(Device* device, bool called_from_wipe);

/*
* This function tries to create the snapshotted devices in the case a Virtual
Expand Down
44 changes: 43 additions & 1 deletion install/snapshot_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
using android::snapshot::CreateResult;
using android::snapshot::SnapshotManager;

bool FinishPendingSnapshotMerges(Device* device) {
bool FinishPendingSnapshotMerges(Device* device, bool called_from_wipe) {
if (!android::base::GetBoolProperty("ro.virtual_ab.enabled", false)) {
return true;
}
Expand All @@ -38,6 +38,45 @@ bool FinishPendingSnapshotMerges(Device* device) {
return false;
}

if (!called_from_wipe) {
using namespace android::snapshot;

double progress;
UpdateState update_state = sm->GetUpdateState(&progress);

ui->Print("State of pending update: ");

switch (update_state) {
case UpdateState::None:
ui->Print("Pending update not found\n");
// HandleImminentDataWipe() is not a no-op even in this case, do not return
break;
case UpdateState::Initiated:
ui->Print("Initiated\n");
break;
case UpdateState::Unverified:
ui->Print("Unverified\n");
break;
case UpdateState::Merging:
ui->Print("Merging, progress: %.2ff\n", progress);
break;
case UpdateState::MergeNeedsReboot:
ui->Print("MergeNeedsReboot\n");
break;
case UpdateState::MergeCompleted:
ui->Print("MergeCompleted\n");
break;
case UpdateState::MergeFailed:
ui->Print("MergeFailed\n");
break;
case UpdateState::Cancelled:
ui->Print("Cancelled\n");
break;
default:
ui->Print("unknown (%i)\n", (int) update_state);
}
}

auto callback = [&]() -> void {
double progress;
sm->GetUpdateState(&progress);
Expand All @@ -47,6 +86,9 @@ bool FinishPendingSnapshotMerges(Device* device) {
ui->Print("Unable to check merge status and/or complete update merge.\n");
return false;
}
if (!called_from_wipe) {
ui->Print("Operation completed successfully\n");
}
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion install/wipe_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ bool WipeData(Device* device) {
ui->SetBackground(RecoveryUI::ERASING);
ui->SetProgressType(RecoveryUI::INDETERMINATE);

if (!FinishPendingSnapshotMerges(device)) {
if (!FinishPendingSnapshotMerges(device, /* called_from_wipe */ true)) {
ui->Print("Unable to check update status or complete merge, cannot wipe partitions.\n");
return false;
}
Expand Down
5 changes: 5 additions & 0 deletions recovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,11 @@ static Device::BuiltinAction PromptAndWait(Device* device, InstallResult status)
}
break;

case Device::DISCARD_PENDING_UPDATE: {
FinishPendingSnapshotMerges(device, /* called_from_wipe */ false);
break;
}

case Device::WIPE_DATA:
save_current_log = true;
if (ui->IsTextVisible()) {
Expand Down
1 change: 1 addition & 0 deletions recovery_ui/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

static std::vector<std::pair<std::string, Device::BuiltinAction>> g_menu_actions{
{ "Reboot system now", Device::REBOOT },
{ "Discard pending OS update", Device::DISCARD_PENDING_UPDATE },
{ "Reboot to bootloader", Device::REBOOT_BOOTLOADER },
{ "Enter fastboot", Device::ENTER_FASTBOOT },
{ "Apply update from ADB", Device::APPLY_ADB_SIDELOAD },
Expand Down
1 change: 1 addition & 0 deletions recovery_ui/include/recovery_ui/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class Device {
REBOOT_RESCUE = 19,
REBOOT_FROM_FASTBOOT = 20,
SHUTDOWN_FROM_FASTBOOT = 21,
DISCARD_PENDING_UPDATE = 100,
};

explicit Device(RecoveryUI* ui);
Expand Down