From a4208b5f90baf1326d372fd97ca39f06911d7165 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Mon, 14 Feb 2022 18:38:06 -0800 Subject: Perform data wipe in recovery if ota package has powerwash set Normally, if an ota package has --wipe_user_data flag, we set bootloader parameter --wipe_data, so that next boot into bootloader will wipe userdata. But this doesn't work in recovery, likely because after recovery we don't reboot to bootloader, but directly boot into android. Therefore perform data reset in recovery if the OTA package has POWERWASH flag. Bug: 203507329 Test: apply an OTA pkg with --wipe_user_data, verify that data wipe happened Change-Id: Icca4a5f74246bde44a5fd589395404c9f57867ee --- install/fuse_install.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'install/fuse_install.cpp') diff --git a/install/fuse_install.cpp b/install/fuse_install.cpp index 143b5d3fb..197e1debb 100644 --- a/install/fuse_install.cpp +++ b/install/fuse_install.cpp @@ -146,10 +146,11 @@ static bool StartInstallPackageFuse(std::string_view path) { return run_fuse_sideload(std::move(fuse_data_provider)) == 0; } -InstallResult InstallWithFuseFromPath(std::string_view path, RecoveryUI* ui) { +InstallResult InstallWithFuseFromPath(std::string_view path, Device* device) { // We used to use fuse in a thread as opposed to a process. Since accessing // through fuse involves going from kernel to userspace to kernel, it leads // to deadlock when a page fault occurs. (Bug: 26313124) + auto ui = device->GetUI(); pid_t child; if ((child = fork()) == 0) { bool status = StartInstallPackageFuse(path); @@ -183,8 +184,8 @@ InstallResult InstallWithFuseFromPath(std::string_view path, RecoveryUI* ui) { auto package = Package::CreateFilePackage(FUSE_SIDELOAD_HOST_PATHNAME, std::bind(&RecoveryUI::SetProgress, ui, std::placeholders::_1)); - result = - InstallPackage(package.get(), FUSE_SIDELOAD_HOST_PATHNAME, false, 0 /* retry_count */, ui); + result = InstallPackage(package.get(), FUSE_SIDELOAD_HOST_PATHNAME, false, 0 /* retry_count */, + device); break; } @@ -226,7 +227,7 @@ InstallResult ApplyFromSdcard(Device* device) { ui->Print("\n-- Install %s ...\n", path.c_str()); SetSdcardUpdateBootloaderMessage(); - auto result = InstallWithFuseFromPath(path, ui); + auto result = InstallWithFuseFromPath(path, device); ensure_path_unmounted(SDCARD_ROOT); return result; } -- cgit v1.2.3