Merge "Some clean ups to the updater"
diff --git a/applypatch/imgdiff.cpp b/applypatch/imgdiff.cpp
index cb34d46..6ad4a61 100644
--- a/applypatch/imgdiff.cpp
+++ b/applypatch/imgdiff.cpp
@@ -683,12 +683,11 @@
// Create a list of deflated zip entries, sorted by offset.
std::vector<std::pair<std::string, ZipEntry>> temp_entries;
- ZipString name;
+ std::string name;
ZipEntry entry;
while ((ret = Next(cookie, &entry, &name)) == 0) {
if (entry.method == kCompressDeflated || limit_ > 0) {
- std::string entry_name(name.name, name.name + name.name_length);
- temp_entries.emplace_back(entry_name, entry);
+ temp_entries.emplace_back(name, entry);
}
}
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index 2023349..14f5e4b 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -30,10 +30,10 @@
#include "recovery_ui/ui.h"
static const std::vector<std::pair<std::string, Device::BuiltinAction>> kFastbootMenuActions{
- { "Reboot system now", Device::REBOOT_FROM_FASTBOOT },
+ { "Reboot system now", Device::REBOOT },
{ "Enter recovery", Device::ENTER_RECOVERY },
{ "Reboot to bootloader", Device::REBOOT_BOOTLOADER },
- { "Power off", Device::SHUTDOWN_FROM_FASTBOOT },
+ { "Power off", Device::SHUTDOWN },
};
Device::BuiltinAction StartFastboot(Device* device, const std::vector<std::string>& /* args */) {
diff --git a/install/install.cpp b/install/install.cpp
index 1b51b42..8d46641 100644
--- a/install/install.cpp
+++ b/install/install.cpp
@@ -539,13 +539,13 @@
std::vector<std::string> compatibility_info;
ZipEntry info_entry;
- ZipString info_name;
+ std::string info_name;
while (Next(cookie, &info_entry, &info_name) == 0) {
std::string content(info_entry.uncompressed_length, '\0');
int32_t ret = ExtractToMemory(zip_handle, &info_entry, reinterpret_cast<uint8_t*>(&content[0]),
info_entry.uncompressed_length);
if (ret != 0) {
- LOG(ERROR) << "Failed to read " << info_name.name << ": " << ErrorCodeString(ret);
+ LOG(ERROR) << "Failed to read " << info_name << ": " << ErrorCodeString(ret);
CloseArchive(zip_handle);
return false;
}
diff --git a/install/verifier.cpp b/install/verifier.cpp
index 3de58e4..02759cd 100644
--- a/install/verifier.cpp
+++ b/install/verifier.cpp
@@ -320,22 +320,21 @@
std::vector<Certificate> result;
- ZipString name;
+ std::string name;
ZipEntry entry;
while ((iter_status = Next(cookie, &entry, &name)) == 0) {
std::vector<uint8_t> pem_content(entry.uncompressed_length);
if (int32_t extract_status =
ExtractToMemory(handle, &entry, pem_content.data(), pem_content.size());
extract_status != 0) {
- LOG(ERROR) << "Failed to extract " << std::string(name.name, name.name + name.name_length);
+ LOG(ERROR) << "Failed to extract " << name;
return {};
}
Certificate cert(0, Certificate::KEY_TYPE_RSA, nullptr, nullptr);
// Aborts the parsing if we fail to load one of the key file.
if (!LoadCertificateFromBuffer(pem_content, &cert)) {
- LOG(ERROR) << "Failed to load keys from "
- << std::string(name.name, name.name + name.name_length);
+ LOG(ERROR) << "Failed to load keys from " << name;
return {};
}
diff --git a/otautil/include/otautil/sysutil.h b/otautil/include/otautil/sysutil.h
index 326db86..48e9011 100644
--- a/otautil/include/otautil/sysutil.h
+++ b/otautil/include/otautil/sysutil.h
@@ -102,11 +102,11 @@
};
// Reboots the device into the specified target, by additionally handling quiescent reboot mode.
-// All unknown targets reboot into Android.
+// 'target' can be an empty string, which indicates booting into Android.
bool Reboot(std::string_view target);
// Triggers a shutdown.
-bool Shutdown(std::string_view target);
+bool Shutdown();
// Returns a null-terminated char* array, where the elements point to the C-strings in the given
// vector, plus an additional nullptr at the end. This is a helper function that facilitates
diff --git a/otautil/sysutil.cpp b/otautil/sysutil.cpp
index a882985..420db4c 100644
--- a/otautil/sysutil.cpp
+++ b/otautil/sysutil.cpp
@@ -229,9 +229,9 @@
return android::base::SetProperty(ANDROID_RB_PROPERTY, cmd);
}
-bool Shutdown(std::string_view target) {
- std::string cmd = "shutdown," + std::string(target);
- return android::base::SetProperty(ANDROID_RB_PROPERTY, cmd);
+bool Shutdown() {
+ // "shutdown" doesn't need a "reason" arg nor a comma.
+ return android::base::SetProperty(ANDROID_RB_PROPERTY, "shutdown");
}
std::vector<char*> StringVectorToNullTerminatedArray(const std::vector<std::string>& args) {
diff --git a/recovery.cpp b/recovery.cpp
index eb0c2b2..20e5a1b 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -356,8 +356,6 @@
: device->InvokeMenuItem(chosen_item);
switch (chosen_action) {
- case Device::REBOOT_FROM_FASTBOOT: // Can not happen
- case Device::SHUTDOWN_FROM_FASTBOOT: // Can not happen
case Device::NO_ACTION:
break;
diff --git a/recovery_main.cpp b/recovery_main.cpp
index f78c1c7..aba9c5d 100644
--- a/recovery_main.cpp
+++ b/recovery_main.cpp
@@ -471,12 +471,7 @@
switch (ret) {
case Device::SHUTDOWN:
ui->Print("Shutting down...\n");
- Shutdown("recovery");
- break;
-
- case Device::SHUTDOWN_FROM_FASTBOOT:
- ui->Print("Shutting down...\n");
- Shutdown("fastboot");
+ Shutdown();
break;
case Device::REBOOT_BOOTLOADER:
@@ -525,19 +520,9 @@
fastboot = false;
break;
- case Device::REBOOT:
- ui->Print("Rebooting...\n");
- Reboot("recovery_menu");
- break;
-
- case Device::REBOOT_FROM_FASTBOOT:
- ui->Print("Rebooting...\n");
- Reboot("fastboot_menu");
- break;
-
default:
ui->Print("Rebooting...\n");
- Reboot("unknown" + std::to_string(ret));
+ Reboot("");
break;
}
}
diff --git a/recovery_ui/include/recovery_ui/device.h b/recovery_ui/include/recovery_ui/device.h
index 9a4edf2..7c76cdb 100644
--- a/recovery_ui/include/recovery_ui/device.h
+++ b/recovery_ui/include/recovery_ui/device.h
@@ -58,8 +58,6 @@
REBOOT_FASTBOOT = 17,
REBOOT_RECOVERY = 18,
REBOOT_RESCUE = 19,
- REBOOT_FROM_FASTBOOT = 20,
- SHUTDOWN_FROM_FASTBOOT = 21,
};
explicit Device(RecoveryUI* ui);
diff --git a/recovery_ui/ui.cpp b/recovery_ui/ui.cpp
index fc51775..7ea9307 100644
--- a/recovery_ui/ui.cpp
+++ b/recovery_ui/ui.cpp
@@ -375,7 +375,7 @@
case RecoveryUI::REBOOT:
if (reboot_enabled) {
- Reboot("recovery_ui");
+ Reboot("");
while (true) {
pause();
}